web/lib/Zend/Service/LiveDocx/MailMerge.php
changeset 807 877f952ae2bd
parent 207 621fa6caec0c
child 1230 68c69c656a2c
equal deleted inserted replaced
805:5e7a0fedabdf 807:877f952ae2bd
    13  * to license@zend.com so we can send you a copy immediately.
    13  * to license@zend.com so we can send you a copy immediately.
    14  *
    14  *
    15  * @category   Zend
    15  * @category   Zend
    16  * @package    Zend_Service
    16  * @package    Zend_Service
    17  * @subpackage LiveDocx
    17  * @subpackage LiveDocx
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    18  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    20  * @version    $Id: MailMerge.php 23022 2010-10-05 15:30:55Z jonathan_maron $
    20  * @version    $Id: MailMerge.php 24593 2012-01-05 20:35:02Z matthew $
    21  */
    21  */
    22 
    22 
    23 /** Zend_Date **/
    23 /** Zend_Date **/
    24 require_once 'Zend/Date.php';
    24 require_once 'Zend/Date.php';
    25 
    25 
    28 
    28 
    29 /**
    29 /**
    30  * @category   Zend
    30  * @category   Zend
    31  * @package    Zend_Service
    31  * @package    Zend_Service
    32  * @subpackage LiveDocx
    32  * @subpackage LiveDocx
    33  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    33  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    34  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    34  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    35  * @since      LiveDocx 1.0 
    35  * @since      LiveDocx 1.0
    36  */
    36  */
    37 class Zend_Service_LiveDocx_MailMerge extends Zend_Service_LiveDocx
    37 class Zend_Service_LiveDocx_MailMerge extends Zend_Service_LiveDocx
    38 {
    38 {
    39     /**
    39     /**
    40      * URI of LiveDocx.MailMerge WSDL
    40      * URI of LiveDocx.MailMerge WSDL
    41      * @since LiveDocx 1.0 
    41      * @since LiveDocx 1.0
    42      */
    42      */
    43     //const WSDL = 'https://api.livedocx.com/1.2/mailmerge.asmx?WSDL';
    43     //const WSDL = 'https://api.livedocx.com/1.2/mailmerge.asmx?WSDL';
    44     const WSDL = 'https://api.livedocx.com/2.0/mailmerge.asmx?WSDL';
    44     const WSDL = 'https://api.livedocx.com/2.0/mailmerge.asmx?WSDL';
    45 
    45 
    46     /**
    46     /**
    69     public function __construct($options = null)
    69     public function __construct($options = null)
    70     {
    70     {
    71         $this->_wsdl             = self::WSDL;
    71         $this->_wsdl             = self::WSDL;
    72         $this->_fieldValues      = array();
    72         $this->_fieldValues      = array();
    73         $this->_blockFieldValues = array();
    73         $this->_blockFieldValues = array();
    74         
    74 
    75         parent::__construct($options);
    75         parent::__construct($options);
    76     }
    76     }
    77 
    77 
    78     /**
    78     /**
    79      * Set the filename of a LOCAL template
    79      * Set the filename of a LOCAL template
    91                 'Cannot read local template from disk.'
    91                 'Cannot read local template from disk.'
    92             );
    92             );
    93         }
    93         }
    94 
    94 
    95         $this->logIn();
    95         $this->logIn();
    96         
    96 
    97         try {
    97         try {
    98             $this->getSoapClient()->SetLocalTemplate(array(
    98             $this->getSoapClient()->SetLocalTemplate(array(
    99                 'template' => base64_encode(file_get_contents($filename)),
    99                 'template' => base64_encode(file_get_contents($filename)),
   100                 'format'   => self::getFormat($filename),
   100                 'format'   => self::getFormat($filename),
   101             ));
   101             ));
   119      * @since  LiveDocx 1.0
   119      * @since  LiveDocx 1.0
   120      */
   120      */
   121     public function setRemoteTemplate($filename)
   121     public function setRemoteTemplate($filename)
   122     {
   122     {
   123         $this->logIn();
   123         $this->logIn();
   124         
   124 
   125         try {
   125         try {
   126             $this->getSoapClient()->SetRemoteTemplate(array(
   126             $this->getSoapClient()->SetRemoteTemplate(array(
   127                 'filename' => $filename,
   127                 'filename' => $filename,
   128             ));
   128             ));
   129         } catch (Exception $e) {
   129         } catch (Exception $e) {
   145      * @since  LiveDocx 1.0
   145      * @since  LiveDocx 1.0
   146      */
   146      */
   147     public function setFieldValues($values)
   147     public function setFieldValues($values)
   148     {
   148     {
   149         $this->logIn();
   149         $this->logIn();
   150         
   150 
   151         foreach ($values as $value) {
   151         foreach ($values as $value) {
   152             if (is_array($value)) {
   152             if (is_array($value)) {
   153                 $method = 'multiAssocArrayToArrayOfArrayOfString';
   153                 $method = 'multiAssocArrayToArrayOfArrayOfString';
   154             } else {
   154             } else {
   155                 $method = 'assocArrayToArrayOfArrayOfString';
   155                 $method = 'assocArrayToArrayOfArrayOfString';
   156             }
   156             }
   157             break;
   157             break;
   158         }
   158         }
   159         
   159 
   160         try {
   160         try {
   161             $this->getSoapClient()->SetFieldValues(array(
   161             $this->getSoapClient()->SetFieldValues(array(
   162                 'fieldValues' => self::$method($values),
   162                 'fieldValues' => self::$method($values),
   163             ));
   163             ));
   164         } catch (Exception $e) {
   164         } catch (Exception $e) {
   182      * @since  LiveDocx 1.0
   182      * @since  LiveDocx 1.0
   183      */
   183      */
   184     public function setFieldValue($field, $value)
   184     public function setFieldValue($field, $value)
   185     {
   185     {
   186         $this->_fieldValues[$field] = $value;
   186         $this->_fieldValues[$field] = $value;
   187         
   187 
   188         return $this;
   188         return $this;
   189     }
   189     }
   190 
   190 
   191     /**
   191     /**
   192      * Set block field values
   192      * Set block field values
   199      * @since  LiveDocx 1.0
   199      * @since  LiveDocx 1.0
   200      */
   200      */
   201     public function setBlockFieldValues($blockName, $blockFieldValues)
   201     public function setBlockFieldValues($blockName, $blockFieldValues)
   202     {
   202     {
   203         $this->logIn();
   203         $this->logIn();
   204         
   204 
   205         try {
   205         try {
   206             $this->getSoapClient()->SetBlockFieldValues(array(
   206             $this->getSoapClient()->SetBlockFieldValues(array(
   207                 'blockName'        => $blockName,
   207                 'blockName'        => $blockName,
   208                 'blockFieldValues' => self::multiAssocArrayToArrayOfArrayOfString($blockFieldValues)
   208                 'blockFieldValues' => self::multiAssocArrayToArrayOfArrayOfString($blockFieldValues)
   209             ));
   209             ));
   248         return $this;
   248         return $this;
   249     }
   249     }
   250 
   250 
   251     /**
   251     /**
   252      * Set a password to open to document
   252      * Set a password to open to document
   253      * 
   253      *
   254      * This method can only be used for PDF documents
   254      * This method can only be used for PDF documents
   255      * 
   255      *
   256      * @param  string  $password
   256      * @param  string  $password
   257      * @return Zend_Service_LiveDocx_MailMerge
   257      * @return Zend_Service_LiveDocx_MailMerge
   258      * @throws Zend_Service_LiveDocx_Exception
   258      * @throws Zend_Service_LiveDocx_Exception
   259      * @since  LiveDocx 1.2 Premium
   259      * @since  LiveDocx 1.2 Premium
   260      */
   260      */
   261     public function setDocumentPassword($password)
   261     public function setDocumentPassword($password)
   262     {
   262     {
   263         $this->logIn();
   263         $this->logIn();
   264         
   264 
   265         try {
   265         try {
   266             $this->getSoapClient()->SetDocumentPassword(array(
   266             $this->getSoapClient()->SetDocumentPassword(array(
   267                 'password' => $password
   267                 'password' => $password
   268             ));
   268             ));
   269         } catch (Exception $e) {
   269         } catch (Exception $e) {
   270             require_once 'Zend/Service/LiveDocx/Exception.php';
   270             require_once 'Zend/Service/LiveDocx/Exception.php';
   271             throw new Zend_Service_LiveDocx_Exception(
   271             throw new Zend_Service_LiveDocx_Exception(
   272                 'Cannot set document password. This method can be used on PDF files only.', 0, $e
   272                 'Cannot set document password. This method can be used on PDF files only.', 0, $e
   273             );
   273             );
   274         }
   274         }
   275         
   275 
   276         return $this;        
   276         return $this;
   277     }
   277     }
   278     
   278 
   279     /**
   279     /**
   280      * Set a master password for document and determine which security features
   280      * Set a master password for document and determine which security features
   281      * are accessible without using the master password.
   281      * are accessible without using the master password.
   282      * 
   282      *
   283      * As default, nothing is allowed. To allow a security setting,
   283      * As default, nothing is allowed. To allow a security setting,
   284      * explicatively set it using one of he DOCUMENT_ACCESS_PERMISSION_* class
   284      * explicatively set it using one of he DOCUMENT_ACCESS_PERMISSION_* class
   285      * constants. 
   285      * constants.
   286      * 
   286      *
   287      * {code}
   287      * {code}
   288      * $phpLiveDocx->setDocumentAccessPermissions(
   288      * $phpLiveDocx->setDocumentAccessPermissions(
   289      *     array (
   289      *     array (
   290      *         Zend_Service_LiveDocx_MailMerge::DOCUMENT_ACCESS_PERMISSION_ALLOW_PRINTING_HIGH_LEVEL,
   290      *         Zend_Service_LiveDocx_MailMerge::DOCUMENT_ACCESS_PERMISSION_ALLOW_PRINTING_HIGH_LEVEL,
   291      *         Zend_Service_LiveDocx_MailMerge::DOCUMENT_ACCESS_PERMISSION_ALLOW_EXTRACT_CONTENTS
   291      *         Zend_Service_LiveDocx_MailMerge::DOCUMENT_ACCESS_PERMISSION_ALLOW_EXTRACT_CONTENTS
   292      *     ),
   292      *     ),
   293      *     'myDocumentAccessPassword'
   293      *     'myDocumentAccessPassword'
   294      * );
   294      * );
   295      * {code}
   295      * {code}
   296      * 
   296      *
   297      * This method can only be used for PDF documents
   297      * This method can only be used for PDF documents
   298      * 
   298      *
   299      * @param  array  $permissions 
   299      * @param  array  $permissions
   300      * @param  string $password
   300      * @param  string $password
   301      * @return Zend_Service_LiveDocx_MailMerge
   301      * @return Zend_Service_LiveDocx_MailMerge
   302      * @throws Zend_Service_LiveDocx_Exception
   302      * @throws Zend_Service_LiveDocx_Exception
   303      * @since  LiveDocx 1.2 Premium
   303      * @since  LiveDocx 1.2 Premium
   304      */
   304      */
   305     public function setDocumentAccessPermissions($permissions, $password)
   305     public function setDocumentAccessPermissions($permissions, $password)
   306     {
   306     {
   307         $this->logIn();
   307         $this->logIn();
   308         
   308 
   309         try {
   309         try {
   310             $this->getSoapClient()->SetDocumentAccessPermissions(array(
   310             $this->getSoapClient()->SetDocumentAccessPermissions(array(
   311                 'permissions' => $permissions,
   311                 'permissions' => $permissions,
   312                 'password'    => $password
   312                 'password'    => $password
   313             ));
   313             ));
   315             require_once 'Zend/Service/LiveDocx/Exception.php';
   315             require_once 'Zend/Service/LiveDocx/Exception.php';
   316             throw new Zend_Service_LiveDocx_Exception(
   316             throw new Zend_Service_LiveDocx_Exception(
   317                 'Cannot set document access permissions', 0, $e
   317                 'Cannot set document access permissions', 0, $e
   318             );
   318             );
   319         }
   319         }
   320         
   320 
   321         return $this;        
   321         return $this;
   322     }    
   322     }
   323     
   323 
   324     /**
   324     /**
   325      * Merge assigned data with template to generate document
   325      * Merge assigned data with template to generate document
   326      *
   326      *
   327      * @throws Zend_Service_LiveDocx_Excpetion
   327      * @throws Zend_Service_LiveDocx_Excpetion
   328      * @return void
   328      * @return void
   329      * @since  LiveDocx 1.0
   329      * @since  LiveDocx 1.0
   330      */
   330      */
   331     public function createDocument()
   331     public function createDocument()
   332     {
   332     {
   333         $this->logIn();
   333         $this->logIn();
   334         
   334 
   335         if (count($this->_fieldValues) > 0) {
   335         if (count($this->_fieldValues) > 0) {
   336             $this->setFieldValues($this->_fieldValues);
   336             $this->setFieldValues($this->_fieldValues);
   337         }
   337         }
   338 
   338 
   339         $this->_fieldValues      = array();
   339         $this->_fieldValues      = array();
   359      * @since  LiveDocx 1.0
   359      * @since  LiveDocx 1.0
   360      */
   360      */
   361     public function retrieveDocument($format)
   361     public function retrieveDocument($format)
   362     {
   362     {
   363         $this->logIn();
   363         $this->logIn();
   364         
   364 
   365         $format = strtolower($format);
   365         $format = strtolower($format);
   366         
   366 
   367         try {
   367         try {
   368             $result = $this->getSoapClient()->RetrieveDocument(array(
   368             $result = $this->getSoapClient()->RetrieveDocument(array(
   369                 'format' => $format,
   369                 'format' => $format,
   370             ));
   370             ));
   371         } catch (Exception $e) {
   371         } catch (Exception $e) {
   388      * @since  LiveDocx 1.2
   388      * @since  LiveDocx 1.2
   389      */
   389      */
   390     public function getMetafiles($fromPage, $toPage)
   390     public function getMetafiles($fromPage, $toPage)
   391     {
   391     {
   392         $this->logIn();
   392         $this->logIn();
   393         
   393 
   394         $ret    = array();
   394         $ret    = array();
   395         $result = $this->getSoapClient()->GetMetafiles(array(
   395         $result = $this->getSoapClient()->GetMetafiles(array(
   396             'fromPage' => (integer) $fromPage,
   396             'fromPage' => (integer) $fromPage,
   397             'toPage'   => (integer) $toPage,
   397             'toPage'   => (integer) $toPage,
   398         ));
   398         ));
   420      * @since  LiveDocx 1.2
   420      * @since  LiveDocx 1.2
   421      */
   421      */
   422     public function getAllMetafiles()
   422     public function getAllMetafiles()
   423     {
   423     {
   424         $this->logIn();
   424         $this->logIn();
   425         
   425 
   426         $ret    = array();
   426         $ret    = array();
   427         $result = $this->getSoapClient()->GetAllMetafiles();
   427         $result = $this->getSoapClient()->GetAllMetafiles();
   428 
   428 
   429         if (isset($result->GetAllMetafilesResult->string)) {
   429         if (isset($result->GetAllMetafilesResult->string)) {
   430             $pageCounter = 1;
   430             $pageCounter = 1;
   437                $ret[$pageCounter] = base64_decode($result->GetAllMetafilesResult->string);
   437                $ret[$pageCounter] = base64_decode($result->GetAllMetafilesResult->string);
   438             }
   438             }
   439         }
   439         }
   440 
   440 
   441         return $ret;
   441         return $ret;
   442     }    
   442     }
   443     
   443 
   444     /**
   444     /**
   445      * Return graphical bitmap data for specified page range of created document
   445      * Return graphical bitmap data for specified page range of created document
   446      * Return array contains bitmap data (binary) - array key is page number
   446      * Return array contains bitmap data (binary) - array key is page number
   447      *
   447      *
   448      * @param  integer $fromPage
   448      * @param  integer $fromPage
   449      * @param  integer $toPage
   449      * @param  integer $toPage
   450      * @param  integer $zoomFactor
   450      * @param  integer $zoomFactor
   451      * @param  string  $format
   451      * @param  string  $format
   452      * @return array
   452      * @return array
   453      * @since  LiveDocx 1.2
   453      * @since  LiveDocx 1.2
   454      */    
   454      */
   455     public function getBitmaps($fromPage, $toPage, $zoomFactor, $format)
   455     public function getBitmaps($fromPage, $toPage, $zoomFactor, $format)
   456     {
   456     {
   457         $this->logIn();
   457         $this->logIn();
   458         
   458 
   459         $ret = array();
   459         $ret = array();
   460         
   460 
   461         $result = $this->getSoapClient()->GetBitmaps(array(
   461         $result = $this->getSoapClient()->GetBitmaps(array(
   462             'fromPage'   => (integer) $fromPage,
   462             'fromPage'   => (integer) $fromPage,
   463             'toPage'     => (integer) $toPage,
   463             'toPage'     => (integer) $toPage,
   464             'zoomFactor' => (integer) $zoomFactor,
   464             'zoomFactor' => (integer) $zoomFactor,
   465             'format'     => (string)  $format,
   465             'format'     => (string)  $format,
   475             } else {
   475             } else {
   476                $ret[$pageCounter] = base64_decode($result->GetBitmapsResult->string);
   476                $ret[$pageCounter] = base64_decode($result->GetBitmapsResult->string);
   477             }
   477             }
   478         }
   478         }
   479 
   479 
   480         return $ret;        
   480         return $ret;
   481     }
   481     }
   482     
   482 
   483     /**
   483     /**
   484      * Return graphical bitmap data for all pages of created document
   484      * Return graphical bitmap data for all pages of created document
   485      * Return array contains bitmap data (binary) - array key is page number
   485      * Return array contains bitmap data (binary) - array key is page number
   486      *
   486      *
   487      * @param  integer $zoomFactor
   487      * @param  integer $zoomFactor
   488      * @param  string  $format
   488      * @param  string  $format
   489      * @return array
   489      * @return array
   490      * @since  LiveDocx 1.2
   490      * @since  LiveDocx 1.2
   491      */    
   491      */
   492     public function getAllBitmaps($zoomFactor, $format)
   492     public function getAllBitmaps($zoomFactor, $format)
   493     {
   493     {
   494         $this->logIn();
   494         $this->logIn();
   495         
   495 
   496         $ret    = array();
   496         $ret    = array();
   497         $result = $this->getSoapClient()->GetAllBitmaps(array(
   497         $result = $this->getSoapClient()->GetAllBitmaps(array(
   498             'zoomFactor' => (integer) $zoomFactor,
   498             'zoomFactor' => (integer) $zoomFactor,
   499             'format'     => (string)  $format,
   499             'format'     => (string)  $format,
   500         ));
   500         ));
   509             } else {
   509             } else {
   510                $ret[$pageCounter] = base64_decode($result->GetAllBitmapsResult->string);
   510                $ret[$pageCounter] = base64_decode($result->GetAllBitmapsResult->string);
   511             }
   511             }
   512         }
   512         }
   513 
   513 
   514         return $ret;        
   514         return $ret;
   515     }    
   515     }
   516 
   516 
   517     /**
   517     /**
   518      * Return all the fields in the template
   518      * Return all the fields in the template
   519      *
   519      *
   520      * @return array
   520      * @return array
   521      * @since  LiveDocx 1.0
   521      * @since  LiveDocx 1.0
   522      */
   522      */
   523     public function getFieldNames()
   523     public function getFieldNames()
   524     {
   524     {
   525         $this->logIn();
   525         $this->logIn();
   526         
   526 
   527         $ret    = array();
   527         $ret    = array();
   528         $result = $this->getSoapClient()->GetFieldNames();
   528         $result = $this->getSoapClient()->GetFieldNames();
   529 
   529 
   530         if (isset($result->GetFieldNamesResult->string)) {
   530         if (isset($result->GetFieldNamesResult->string)) {
   531             if (is_array($result->GetFieldNamesResult->string)) {
   531             if (is_array($result->GetFieldNamesResult->string)) {
   546      * @since  LiveDocx 1.0
   546      * @since  LiveDocx 1.0
   547      */
   547      */
   548     public function getBlockFieldNames($blockName)
   548     public function getBlockFieldNames($blockName)
   549     {
   549     {
   550         $this->logIn();
   550         $this->logIn();
   551         
   551 
   552         $ret    = array();
   552         $ret    = array();
   553         $result = $this->getSoapClient()->GetBlockFieldNames(array(
   553         $result = $this->getSoapClient()->GetBlockFieldNames(array(
   554             'blockName' => $blockName
   554             'blockName' => $blockName
   555         ));
   555         ));
   556 
   556 
   572      * @since  LiveDocx 1.0
   572      * @since  LiveDocx 1.0
   573      */
   573      */
   574     public function getBlockNames()
   574     public function getBlockNames()
   575     {
   575     {
   576         $this->logIn();
   576         $this->logIn();
   577         
   577 
   578         $ret    = array();
   578         $ret    = array();
   579         $result = $this->getSoapClient()->GetBlockNames();
   579         $result = $this->getSoapClient()->GetBlockNames();
   580 
   580 
   581         if (isset($result->GetBlockNamesResult->string)) {
   581         if (isset($result->GetBlockNamesResult->string)) {
   582             if (is_array($result->GetBlockNamesResult->string)) {
   582             if (is_array($result->GetBlockNamesResult->string)) {
   598      * @since  LiveDocx 1.0
   598      * @since  LiveDocx 1.0
   599      */
   599      */
   600     public function uploadTemplate($filename)
   600     public function uploadTemplate($filename)
   601     {
   601     {
   602         $this->logIn();
   602         $this->logIn();
   603         
   603 
   604         try {
   604         try {
   605             $this->getSoapClient()->UploadTemplate(array(
   605             $this->getSoapClient()->UploadTemplate(array(
   606                 'template' => base64_encode(file_get_contents($filename)),
   606                 'template' => base64_encode(file_get_contents($filename)),
   607                 'filename' => basename($filename),
   607                 'filename' => basename($filename),
   608             ));
   608             ));
   623      * @since  LiveDocx 1.0
   623      * @since  LiveDocx 1.0
   624      */
   624      */
   625     public function downloadTemplate($filename)
   625     public function downloadTemplate($filename)
   626     {
   626     {
   627         $this->logIn();
   627         $this->logIn();
   628         
   628 
   629         try {
   629         try {
   630             $result = $this->getSoapClient()->DownloadTemplate(array(
   630             $result = $this->getSoapClient()->DownloadTemplate(array(
   631                 'filename' => basename($filename),
   631                 'filename' => basename($filename),
   632             ));
   632             ));
   633         } catch (Exception $e) {
   633         } catch (Exception $e) {
   649      * @since  LiveDocx 1.0
   649      * @since  LiveDocx 1.0
   650      */
   650      */
   651     public function deleteTemplate($filename)
   651     public function deleteTemplate($filename)
   652     {
   652     {
   653         $this->logIn();
   653         $this->logIn();
   654         
   654 
   655         $this->getSoapClient()->DeleteTemplate(array(
   655         $this->getSoapClient()->DeleteTemplate(array(
   656             'filename' => basename($filename),
   656             'filename' => basename($filename),
   657         ));
   657         ));
   658     }
   658     }
   659 
   659 
   660     /**
   660     /**
   661      * List all templates stored on LiveDocx service
   661      * List all templates stored on LiveDocx service
   662      *
   662      *
   663      * @return array
   663      * @return array
   664      * @since  LiveDocx 1.0 
   664      * @since  LiveDocx 1.0
   665      */
   665      */
   666     public function listTemplates()
   666     public function listTemplates()
   667     {
   667     {
   668         $this->logIn();
   668         $this->logIn();
   669         
   669 
   670         $ret    = array();
   670         $ret    = array();
   671         $result = $this->getSoapClient()->ListTemplates();
   671         $result = $this->getSoapClient()->ListTemplates();
   672 
   672 
   673         if (isset($result->ListTemplatesResult)) {
   673         if (isset($result->ListTemplatesResult)) {
   674             $ret = $this->_backendListArrayToMultiAssocArray($result->ListTemplatesResult);
   674             $ret = $this->_backendListArrayToMultiAssocArray($result->ListTemplatesResult);
   685      * @since  LiveDocx 1.0
   685      * @since  LiveDocx 1.0
   686      */
   686      */
   687     public function templateExists($filename)
   687     public function templateExists($filename)
   688     {
   688     {
   689         $this->logIn();
   689         $this->logIn();
   690         
   690 
   691         $result = $this->getSoapClient()->TemplateExists(array(
   691         $result = $this->getSoapClient()->TemplateExists(array(
   692             'filename' => basename($filename),
   692             'filename' => basename($filename),
   693         ));
   693         ));
   694 
   694 
   695         return (boolean) $result->TemplateExistsResult;
   695         return (boolean) $result->TemplateExistsResult;
   702      * @since  LiveDocx 1.0
   702      * @since  LiveDocx 1.0
   703      */
   703      */
   704     public function shareDocument()
   704     public function shareDocument()
   705     {
   705     {
   706         $this->logIn();
   706         $this->logIn();
   707         
   707 
   708         $ret    = null;
   708         $ret    = null;
   709         $result = $this->getSoapClient()->ShareDocument();
   709         $result = $this->getSoapClient()->ShareDocument();
   710 
   710 
   711         if (isset($result->ShareDocumentResult)) {
   711         if (isset($result->ShareDocumentResult)) {
   712             $ret = (string) $result->ShareDocumentResult;
   712             $ret = (string) $result->ShareDocumentResult;
   722      * @since  LiveDocx 1.0
   722      * @since  LiveDocx 1.0
   723      */
   723      */
   724     public function listSharedDocuments()
   724     public function listSharedDocuments()
   725     {
   725     {
   726         $this->logIn();
   726         $this->logIn();
   727         
   727 
   728         $ret    = array();
   728         $ret    = array();
   729         $result = $this->getSoapClient()->ListSharedDocuments();
   729         $result = $this->getSoapClient()->ListSharedDocuments();
   730 
   730 
   731         if (isset($result->ListSharedDocumentsResult)) {
   731         if (isset($result->ListSharedDocumentsResult)) {
   732             $ret = $this->_backendListArrayToMultiAssocArray(
   732             $ret = $this->_backendListArrayToMultiAssocArray(
   745      * @since  LiveDocx 1.0
   745      * @since  LiveDocx 1.0
   746      */
   746      */
   747     public function deleteSharedDocument($filename)
   747     public function deleteSharedDocument($filename)
   748     {
   748     {
   749         $this->logIn();
   749         $this->logIn();
   750         
   750 
   751         $this->getSoapClient()->DeleteSharedDocument(array(
   751         $this->getSoapClient()->DeleteSharedDocument(array(
   752             'filename' => basename($filename),
   752             'filename' => basename($filename),
   753         ));
   753         ));
   754     }
   754     }
   755 
   755 
   762      * @since  LiveDocx 1.0
   762      * @since  LiveDocx 1.0
   763      */
   763      */
   764     public function downloadSharedDocument($filename)
   764     public function downloadSharedDocument($filename)
   765     {
   765     {
   766         $this->logIn();
   766         $this->logIn();
   767         
   767 
   768         try {
   768         try {
   769             $result = $this->getSoapClient()->DownloadSharedDocument(array(
   769             $result = $this->getSoapClient()->DownloadSharedDocument(array(
   770                 'filename' => basename($filename),
   770                 'filename' => basename($filename),
   771             ));
   771             ));
   772         } catch (Exception $e) {
   772         } catch (Exception $e) {
   787      * @since  LiveDocx 1.0
   787      * @since  LiveDocx 1.0
   788      */
   788      */
   789     public function sharedDocumentExists($filename)
   789     public function sharedDocumentExists($filename)
   790     {
   790     {
   791         $this->logIn();
   791         $this->logIn();
   792         
   792 
   793         $ret             = false;
   793         $ret             = false;
   794         $sharedDocuments = $this->listSharedDocuments();
   794         $sharedDocuments = $this->listSharedDocuments();
   795         foreach ($sharedDocuments as $shareDocument) {
   795         foreach ($sharedDocuments as $shareDocument) {
   796             if (isset($shareDocument['filename']) 
   796             if (isset($shareDocument['filename'])
   797                 && (basename($filename) === $shareDocument['filename'])
   797                 && (basename($filename) === $shareDocument['filename'])
   798             ) {
   798             ) {
   799                 $ret = true;
   799                 $ret = true;
   800                 break;
   800                 break;
   801             }
   801             }
   811      * @since  LiveDocx 1.0
   811      * @since  LiveDocx 1.0
   812      */
   812      */
   813     public function getTemplateFormats()
   813     public function getTemplateFormats()
   814     {
   814     {
   815         $this->logIn();
   815         $this->logIn();
   816         
   816 
   817         $ret    = array();
   817         $ret    = array();
   818         $result = $this->getSoapClient()->GetTemplateFormats();
   818         $result = $this->getSoapClient()->GetTemplateFormats();
   819 
   819 
   820         if (isset($result->GetTemplateFormatsResult->string)) {
   820         if (isset($result->GetTemplateFormatsResult->string)) {
   821             $ret = $result->GetTemplateFormatsResult->string;
   821             $ret = $result->GetTemplateFormatsResult->string;
   832      * @since  LiveDocx 1.1
   832      * @since  LiveDocx 1.1
   833      */
   833      */
   834     public function getDocumentFormats()
   834     public function getDocumentFormats()
   835     {
   835     {
   836         $this->logIn();
   836         $this->logIn();
   837         
   837 
   838         $ret    = array();
   838         $ret    = array();
   839         $result = $this->getSoapClient()->GetDocumentFormats();
   839         $result = $this->getSoapClient()->GetDocumentFormats();
   840 
   840 
   841         if (isset($result->GetDocumentFormatsResult->string)) {
   841         if (isset($result->GetDocumentFormatsResult->string)) {
   842             $ret = $result->GetDocumentFormatsResult->string;
   842             $ret = $result->GetDocumentFormatsResult->string;
   843             $ret = array_map('strtolower', $ret);
   843             $ret = array_map('strtolower', $ret);
   844         }
   844         }
   845 
   845 
   846         return $ret;
   846         return $ret;
   847     }
   847     }
   848         
   848 
   849     /**
   849     /**
   850      * Return the names of all fonts that are installed on backend server
   850      * Return the names of all fonts that are installed on backend server
   851      *
   851      *
   852      * @return array
   852      * @return array
   853      * @since  LiveDocx 1.2
   853      * @since  LiveDocx 1.2
   854      */
   854      */
   855     public function getFontNames()
   855     public function getFontNames()
   856     {
   856     {
   857         $this->logIn();
   857         $this->logIn();
   858         
   858 
   859         $ret    = array();
   859         $ret    = array();
   860         $result = $this->getSoapClient()->GetFontNames();
   860         $result = $this->getSoapClient()->GetFontNames();
   861 
   861 
   862         if (isset($result->GetFontNamesResult->string)) {
   862         if (isset($result->GetFontNamesResult->string)) {
   863             $ret = $result->GetFontNamesResult->string;
   863             $ret = $result->GetFontNamesResult->string;
   864         }
   864         }
   865 
   865 
   866         return $ret;
   866         return $ret;
   867     }    
   867     }
   868     
   868 
   869     /**
   869     /**
   870      * Return supported document access options
   870      * Return supported document access options
   871      *
   871      *
   872      * @return array
   872      * @return array
   873      * @since  LiveDocx 1.2 Premium
   873      * @since  LiveDocx 1.2 Premium
   874      */
   874      */
   875     public function getDocumentAccessOptions()
   875     public function getDocumentAccessOptions()
   876     {
   876     {
   877         $this->logIn();
   877         $this->logIn();
   878         
   878 
   879         $ret    = array();
   879         $ret    = array();
   880         $result = $this->getSoapClient()->GetDocumentAccessOptions();
   880         $result = $this->getSoapClient()->GetDocumentAccessOptions();
   881 
   881 
   882         if (isset($result->GetDocumentAccessOptionsResult->string)) {
   882         if (isset($result->GetDocumentAccessOptionsResult->string)) {
   883             $ret = $result->GetDocumentAccessOptionsResult->string;
   883             $ret = $result->GetDocumentAccessOptionsResult->string;
   945                       . "It has been replaced by %s::%s() (drop in replacement)",
   945                       . "It has been replaced by %s::%s() (drop in replacement)",
   946                         __CLASS__, __FUNCTION__, __CLASS__, $replacement);
   946                         __CLASS__, __FUNCTION__, __CLASS__, $replacement);
   947 
   947 
   948         trigger_error($errorMessage, E_USER_NOTICE);
   948         trigger_error($errorMessage, E_USER_NOTICE);
   949         */
   949         */
   950         
   950 
   951         return $this->$replacement();
   951         return $this->$replacement();
   952     }
   952     }
   953 
   953 
   954     /**
   954     /**
   955      * Upload an image file to LiveDocx service
   955      * Upload an image file to LiveDocx service
  1060     /**
  1060     /**
  1061      * Convert LiveDocx service return value from list methods to consistent PHP array
  1061      * Convert LiveDocx service return value from list methods to consistent PHP array
  1062      *
  1062      *
  1063      * @param  array $list
  1063      * @param  array $list
  1064      * @return array
  1064      * @return array
  1065      * @since  LiveDocx 1.0 
  1065      * @since  LiveDocx 1.0
  1066      */
  1066      */
  1067     protected function _backendListArrayToMultiAssocArray($list)
  1067     protected function _backendListArrayToMultiAssocArray($list)
  1068     {
  1068     {
  1069         $this->logIn();
  1069         $this->logIn();
  1070         
  1070 
  1071         $ret = array();
  1071         $ret = array();
  1072         if (isset($list->ArrayOfString)) {
  1072         if (isset($list->ArrayOfString)) {
  1073            foreach ($list->ArrayOfString as $a) {
  1073            foreach ($list->ArrayOfString as $a) {
  1074                if (is_array($a)) {      // 1 template only
  1074                if (is_array($a)) {      // 1 template only
  1075                    $o = new stdClass();
  1075                    $o = new stdClass();
  1106      */
  1106      */
  1107     public static function assocArrayToArrayOfArrayOfString($assoc)
  1107     public static function assocArrayToArrayOfArrayOfString($assoc)
  1108     {
  1108     {
  1109         $arrayKeys   = array_keys($assoc);
  1109         $arrayKeys   = array_keys($assoc);
  1110         $arrayValues = array_values($assoc);
  1110         $arrayValues = array_values($assoc);
  1111         
  1111 
  1112         return array($arrayKeys, $arrayValues);
  1112         return array($arrayKeys, $arrayValues);
  1113     }
  1113     }
  1114 
  1114 
  1115     /**
  1115     /**
  1116      * Convert multi assoc array to required SOAP type
  1116      * Convert multi assoc array to required SOAP type