[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Zend Framework 4 * 5 * LICENSE 6 * 7 * This source file is subject to the new BSD license that is bundled 8 * with this package in the file LICENSE.txt. 9 * It is also available through the world-wide-web at this URL: 10 * http://framework.zend.com/license/new-bsd 11 * If you did not receive a copy of the license and are unable to 12 * obtain it through the world-wide-web, please send an email 13 * to [email protected] so we can send you a copy immediately. 14 * 15 * @category Zend 16 * @package Zend_Service 17 * @subpackage LiveDocx 18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) 19 * @license http://framework.zend.com/license/new-bsd New BSD License 20 * @version $Id$ 21 */ 22 23 /** Zend_Date **/ 24 require_once 'Zend/Date.php'; 25 26 /** Zend_Service_LiveDocx **/ 27 require_once 'Zend/Service/LiveDocx.php'; 28 29 /** 30 * @category Zend 31 * @package Zend_Service 32 * @subpackage LiveDocx 33 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) 34 * @license http://framework.zend.com/license/new-bsd New BSD License 35 * @since LiveDocx 1.0 36 */ 37 class Zend_Service_LiveDocx_MailMerge extends Zend_Service_LiveDocx 38 { 39 /** 40 * URI of LiveDocx.MailMerge WSDL 41 * @since LiveDocx 1.0 42 */ 43 const WSDL = 'https://api.livedocx.com/1.2/mailmerge.asmx?WSDL'; 44 45 /** 46 * Field values 47 * 48 * @var array 49 * @since LiveDocx 1.0 50 */ 51 protected $_fieldValues; 52 53 /** 54 * Block field values 55 * 56 * @var array 57 * @since LiveDocx 1.0 58 */ 59 protected $_blockFieldValues; 60 61 /** 62 * Constructor (LiveDocx.MailMerge SOAP Service) 63 * 64 * @return void 65 * @return throws Zend_Service_LiveDocx_Exception 66 * @since LiveDocx 1.0 67 */ 68 public function __construct($options = null) 69 { 70 $this->_wsdl = self::WSDL; 71 $this->_fieldValues = array(); 72 $this->_blockFieldValues = array(); 73 74 parent::__construct($options); 75 } 76 77 /** 78 * Set the filename of a LOCAL template 79 * (i.e. a template stored locally on YOUR server) 80 * 81 * @param string $filename 82 * @return Zend_Service_LiveDocx_MailMerge 83 * @throws Zend_Service_LiveDocx_Exception 84 * @since LiveDocx 1.0 85 */ 86 public function setLocalTemplate($filename) 87 { 88 $this->logIn(); 89 90 try { 91 $this->getSoapClient()->SetLocalTemplate(array( 92 'template' => base64_encode(file_get_contents($filename)), 93 'format' => self::getFormat($filename), 94 )); 95 } catch (Exception $e) { 96 require_once 'Zend/Service/LiveDocx/Exception.php'; 97 throw new Zend_Service_LiveDocx_Exception( 98 'Cannot set local template', 0, $e 99 ); 100 } 101 102 return $this; 103 } 104 105 /** 106 * Set the filename of a REMOTE template 107 * (i.e. a template stored remotely on the LIVEDOCX server) 108 * 109 * @param string $filename 110 * @return Zend_Service_LiveDocx_MailMerge 111 * @throws Zend_Service_LiveDocx_Exception 112 * @since LiveDocx 1.0 113 */ 114 public function setRemoteTemplate($filename) 115 { 116 $this->logIn(); 117 118 try { 119 $this->getSoapClient()->SetRemoteTemplate(array( 120 'filename' => $filename, 121 )); 122 } catch (Exception $e) { 123 require_once 'Zend/Service/LiveDocx/Exception.php'; 124 throw new Zend_Service_LiveDocx_Exception( 125 'Cannot set remote template', 0, $e 126 ); 127 } 128 129 return $this; 130 } 131 132 /** 133 * Set an associative or multi-associative array of keys and values pairs 134 * 135 * @param array $values 136 * @return Zend_Service_LiveDocx_MailMerge 137 * @throws Zend_Service_LiveDocx_Exception 138 * @since LiveDocx 1.0 139 */ 140 public function setFieldValues($values) 141 { 142 $this->logIn(); 143 144 foreach ($values as $value) { 145 if (is_array($value)) { 146 $method = 'multiAssocArrayToArrayOfArrayOfString'; 147 } else { 148 $method = 'assocArrayToArrayOfArrayOfString'; 149 } 150 break; 151 } 152 153 try { 154 $this->getSoapClient()->SetFieldValues(array( 155 'fieldValues' => self::$method($values), 156 )); 157 } catch (Exception $e) { 158 require_once 'Zend/Service/LiveDocx/Exception.php'; 159 throw new Zend_Service_LiveDocx_Exception( 160 'Cannot set field values', 0, $e 161 ); 162 } 163 164 return $this; 165 } 166 167 /** 168 * Set an array of key and value or array of values 169 * 170 * @param string $field 171 * @param array|string $value 172 * 173 * @throws Zend_Service_LiveDocx_Exception 174 * @return Zend_Service_LiveDocx_MailMerge 175 * @since LiveDocx 1.0 176 */ 177 public function setFieldValue($field, $value) 178 { 179 $this->_fieldValues[$field] = $value; 180 181 return $this; 182 } 183 184 /** 185 * Set block field values 186 * 187 * @param string $blockName 188 * @param array $blockFieldValues 189 * 190 * @return Zend_Service_LiveDocx_MailMerge 191 * @throws Zend_Service_LiveDocx_Exception 192 * @since LiveDocx 1.0 193 */ 194 public function setBlockFieldValues($blockName, $blockFieldValues) 195 { 196 $this->logIn(); 197 198 try { 199 $this->getSoapClient()->SetBlockFieldValues(array( 200 'blockName' => $blockName, 201 'blockFieldValues' => self::multiAssocArrayToArrayOfArrayOfString($blockFieldValues) 202 )); 203 } catch (Exception $e) { 204 require_once 'Zend/Service/LiveDocx/Exception.php'; 205 throw new Zend_Service_LiveDocx_Exception( 206 'Cannot set block field values', 0, $e 207 ); 208 } 209 210 return $this; 211 } 212 213 /** 214 * Assign values to template fields 215 * 216 * @param array|string $field 217 * @param array|string $value 218 * @return Zend_Service_LiveDocx_MailMerge 219 * @throws Zend_Service_LiveDocx_Exception 220 * @since LiveDocx 1.0 221 */ 222 public function assign($field, $value = null) 223 { 224 try { 225 if (is_array($field) && (null === $value)) { 226 foreach ($field as $fieldName => $fieldValue) { 227 $this->setFieldValue($fieldName, $fieldValue); 228 } 229 } elseif (is_array($value)) { 230 $this->setBlockFieldValues($field, $value); 231 } else { 232 $this->setFieldValue($field, $value); 233 } 234 } catch (Exception $e) { 235 require_once 'Zend/Service/LiveDocx/Exception.php'; 236 throw new Zend_Service_LiveDocx_Exception( 237 'Cannot assign data to template', 0, $e 238 ); 239 } 240 241 return $this; 242 } 243 244 /** 245 * Set a password to open to document 246 * 247 * This method can only be used for PDF documents 248 * 249 * @param string $password 250 * @return Zend_Service_LiveDocx_MailMerge 251 * @throws Zend_Service_LiveDocx_Exception 252 * @since LiveDocx 1.2 Premium 253 */ 254 public function setDocumentPassword($password) 255 { 256 $this->logIn(); 257 258 try { 259 $this->getSoapClient()->SetDocumentPassword(array( 260 'password' => $password 261 )); 262 } catch (Exception $e) { 263 require_once 'Zend/Service/LiveDocx/Exception.php'; 264 throw new Zend_Service_LiveDocx_Exception( 265 'Cannot set document password. This method can be used on PDF files only.', 0, $e 266 ); 267 } 268 269 return $this; 270 } 271 272 /** 273 * Set a master password for document and determine which security features 274 * are accessible without using the master password. 275 * 276 * As default, nothing is allowed. To allow a security setting, 277 * explicatively set it using one of he DOCUMENT_ACCESS_PERMISSION_* class 278 * constants. 279 * 280 * {code} 281 * $phpLiveDocx->setDocumentAccessPermissions( 282 * array ( 283 * Zend_Service_LiveDocx_MailMerge::DOCUMENT_ACCESS_PERMISSION_ALLOW_PRINTING_HIGH_LEVEL, 284 * Zend_Service_LiveDocx_MailMerge::DOCUMENT_ACCESS_PERMISSION_ALLOW_EXTRACT_CONTENTS 285 * ), 286 * 'myDocumentAccessPassword' 287 * ); 288 * {code} 289 * 290 * This method can only be used for PDF documents 291 * 292 * @param array $permissions 293 * @param string $password 294 * @return Zend_Service_LiveDocx_MailMerge 295 * @throws Zend_Service_LiveDocx_Exception 296 * @since LiveDocx 1.2 Premium 297 */ 298 public function setDocumentAccessPermissions($permissions, $password) 299 { 300 $this->logIn(); 301 302 try { 303 $this->getSoapClient()->SetDocumentAccessPermissions(array( 304 'permissions' => $permissions, 305 'password' => $password 306 )); 307 } catch (Exception $e) { 308 require_once 'Zend/Service/LiveDocx/Exception.php'; 309 throw new Zend_Service_LiveDocx_Exception( 310 'Cannot set document access permissions', 0, $e 311 ); 312 } 313 314 return $this; 315 } 316 317 /** 318 * Merge assigned data with template to generate document 319 * 320 * @throws Zend_Service_LiveDocx_Excpetion 321 * @return void 322 * @since LiveDocx 1.0 323 */ 324 public function createDocument() 325 { 326 $this->logIn(); 327 328 if (count($this->_fieldValues) > 0) { 329 $this->setFieldValues($this->_fieldValues); 330 } 331 332 $this->_fieldValues = array(); 333 $this->_blockFieldValues = array(); 334 335 try { 336 $this->getSoapClient()->CreateDocument(); 337 } catch (Exception $e) { 338 require_once 'Zend/Service/LiveDocx/Exception.php'; 339 throw new Zend_Service_LiveDocx_Exception( 340 'Cannot create document', 0, $e 341 ); 342 } 343 } 344 345 /** 346 * Retrieve document in specified format 347 * 348 * @param string $format 349 * 350 * @throws Zend_Service_LiveDocx_Exception 351 * @return binary 352 * @since LiveDocx 1.0 353 */ 354 public function retrieveDocument($format) 355 { 356 $this->logIn(); 357 358 $format = strtolower($format); 359 360 try { 361 $result = $this->getSoapClient()->RetrieveDocument(array( 362 'format' => $format, 363 )); 364 } catch (Exception $e) { 365 require_once 'Zend/Service/LiveDocx/Exception.php'; 366 throw new Zend_Service_LiveDocx_Exception( 367 'Cannot retrieve document - call setLocalTemplate() or setRemoteTemplate() first', 0, $e 368 ); 369 } 370 371 return base64_decode($result->RetrieveDocumentResult); 372 } 373 374 /** 375 * Return WMF (aka Windows metafile) data for specified page range of created document 376 * Return array contains WMF data (binary) - array key is page number 377 * 378 * @param integer $fromPage 379 * @param integer $toPage 380 * @return array 381 * @since LiveDocx 1.2 382 */ 383 public function getMetafiles($fromPage, $toPage) 384 { 385 $this->logIn(); 386 387 $ret = array(); 388 $result = $this->getSoapClient()->GetMetafiles(array( 389 'fromPage' => (integer) $fromPage, 390 'toPage' => (integer) $toPage, 391 )); 392 393 if (isset($result->GetMetafilesResult->string)) { 394 $pageCounter = (integer) $fromPage; 395 if (is_array($result->GetMetafilesResult->string)) { 396 foreach ($result->GetMetafilesResult->string as $string) { 397 $ret[$pageCounter] = base64_decode($string); 398 $pageCounter++; 399 } 400 } else { 401 $ret[$pageCounter] = base64_decode($result->GetMetafilesResult->string); 402 } 403 } 404 405 return $ret; 406 } 407 408 /** 409 * Return WMF (aka Windows metafile) data for pages of created document 410 * Return array contains WMF data (binary) - array key is page number 411 * 412 * @return array 413 * @since LiveDocx 1.2 414 */ 415 public function getAllMetafiles() 416 { 417 $this->logIn(); 418 419 $ret = array(); 420 $result = $this->getSoapClient()->GetAllMetafiles(); 421 422 if (isset($result->GetAllMetafilesResult->string)) { 423 $pageCounter = 1; 424 if (is_array($result->GetAllMetafilesResult->string)) { 425 foreach ($result->GetAllMetafilesResult->string as $string) { 426 $ret[$pageCounter] = base64_decode($string); 427 $pageCounter++; 428 } 429 } else { 430 $ret[$pageCounter] = base64_decode($result->GetAllMetafilesResult->string); 431 } 432 } 433 434 return $ret; 435 } 436 437 /** 438 * Return graphical bitmap data for specified page range of created document 439 * Return array contains bitmap data (binary) - array key is page number 440 * 441 * @param integer $fromPage 442 * @param integer $toPage 443 * @param integer $zoomFactor 444 * @param string $format 445 * @return array 446 * @since LiveDocx 1.2 447 */ 448 public function getBitmaps($fromPage, $toPage, $zoomFactor, $format) 449 { 450 $this->logIn(); 451 452 $ret = array(); 453 454 $result = $this->getSoapClient()->GetBitmaps(array( 455 'fromPage' => (integer) $fromPage, 456 'toPage' => (integer) $toPage, 457 'zoomFactor' => (integer) $zoomFactor, 458 'format' => (string) $format, 459 )); 460 461 if (isset($result->GetBitmapsResult->string)) { 462 $pageCounter = (integer) $fromPage; 463 if (is_array($result->GetBitmapsResult->string)) { 464 foreach ($result->GetBitmapsResult->string as $string) { 465 $ret[$pageCounter] = base64_decode($string); 466 $pageCounter++; 467 } 468 } else { 469 $ret[$pageCounter] = base64_decode($result->GetBitmapsResult->string); 470 } 471 } 472 473 return $ret; 474 } 475 476 /** 477 * Return graphical bitmap data for all pages of created document 478 * Return array contains bitmap data (binary) - array key is page number 479 * 480 * @param integer $zoomFactor 481 * @param string $format 482 * @return array 483 * @since LiveDocx 1.2 484 */ 485 public function getAllBitmaps($zoomFactor, $format) 486 { 487 $this->logIn(); 488 489 $ret = array(); 490 $result = $this->getSoapClient()->GetAllBitmaps(array( 491 'zoomFactor' => (integer) $zoomFactor, 492 'format' => (string) $format, 493 )); 494 495 if (isset($result->GetAllBitmapsResult->string)) { 496 $pageCounter = 1; 497 if (is_array($result->GetAllBitmapsResult->string)) { 498 foreach ($result->GetAllBitmapsResult->string as $string) { 499 $ret[$pageCounter] = base64_decode($string); 500 $pageCounter++; 501 } 502 } else { 503 $ret[$pageCounter] = base64_decode($result->GetAllBitmapsResult->string); 504 } 505 } 506 507 return $ret; 508 } 509 510 /** 511 * Return all the fields in the template 512 * 513 * @return array 514 * @since LiveDocx 1.0 515 */ 516 public function getFieldNames() 517 { 518 $this->logIn(); 519 520 $ret = array(); 521 $result = $this->getSoapClient()->GetFieldNames(); 522 523 if (isset($result->GetFieldNamesResult->string)) { 524 if (is_array($result->GetFieldNamesResult->string)) { 525 $ret = $result->GetFieldNamesResult->string; 526 } else { 527 $ret[] = $result->GetFieldNamesResult->string; 528 } 529 } 530 531 return $ret; 532 } 533 534 /** 535 * Return all the block fields in the template 536 * 537 * @param string $blockName 538 * @return array 539 * @since LiveDocx 1.0 540 */ 541 public function getBlockFieldNames($blockName) 542 { 543 $this->logIn(); 544 545 $ret = array(); 546 $result = $this->getSoapClient()->GetBlockFieldNames(array( 547 'blockName' => $blockName 548 )); 549 550 if (isset($result->GetBlockFieldNamesResult->string)) { 551 if (is_array($result->GetBlockFieldNamesResult->string)) { 552 $ret = $result->GetBlockFieldNamesResult->string; 553 } else { 554 $ret[] = $result->GetBlockFieldNamesResult->string; 555 } 556 } 557 558 return $ret; 559 } 560 561 /** 562 * Return all the block fields in the template 563 * 564 * @return array 565 * @since LiveDocx 1.0 566 */ 567 public function getBlockNames() 568 { 569 $this->logIn(); 570 571 $ret = array(); 572 $result = $this->getSoapClient()->GetBlockNames(); 573 574 if (isset($result->GetBlockNamesResult->string)) { 575 if (is_array($result->GetBlockNamesResult->string)) { 576 $ret = $result->GetBlockNamesResult->string; 577 } else { 578 $ret[] = $result->GetBlockNamesResult->string; 579 } 580 } 581 582 return $ret; 583 } 584 585 /** 586 * Upload a template file to LiveDocx service 587 * 588 * @param string $filename 589 * @return void 590 * @throws Zend_Service_LiveDocx_Exception 591 * @since LiveDocx 1.0 592 */ 593 public function uploadTemplate($filename) 594 { 595 $this->logIn(); 596 597 try { 598 $this->getSoapClient()->UploadTemplate(array( 599 'template' => base64_encode(file_get_contents($filename)), 600 'filename' => basename($filename), 601 )); 602 } catch (Exception $e) { 603 require_once 'Zend/Service/LiveDocx/Exception.php'; 604 throw new Zend_Service_LiveDocx_Exception( 605 'Cannot upload template', 0, $e 606 ); 607 } 608 } 609 610 /** 611 * Download template file from LiveDocx service 612 * 613 * @param string $filename 614 * @return binary 615 * @throws Zend_Service_LiveDocx_Exception 616 * @since LiveDocx 1.0 617 */ 618 public function downloadTemplate($filename) 619 { 620 $this->logIn(); 621 622 try { 623 $result = $this->getSoapClient()->DownloadTemplate(array( 624 'filename' => basename($filename), 625 )); 626 } catch (Exception $e) { 627 require_once 'Zend/Service/LiveDocx/Exception.php'; 628 throw new Zend_Service_LiveDocx_Exception( 629 'Cannot download template', 0, $e 630 ); 631 } 632 633 return base64_decode($result->DownloadTemplateResult); 634 } 635 636 /** 637 * Delete a template file from LiveDocx service 638 * 639 * @param string $filename 640 * @return void 641 * @throws Zend_Service_LiveDocx_Exception 642 * @since LiveDocx 1.0 643 */ 644 public function deleteTemplate($filename) 645 { 646 $this->logIn(); 647 648 $this->getSoapClient()->DeleteTemplate(array( 649 'filename' => basename($filename), 650 )); 651 } 652 653 /** 654 * List all templates stored on LiveDocx service 655 * 656 * @return array 657 * @since LiveDocx 1.0 658 */ 659 public function listTemplates() 660 { 661 $this->logIn(); 662 663 $ret = array(); 664 $result = $this->getSoapClient()->ListTemplates(); 665 666 if (isset($result->ListTemplatesResult)) { 667 $ret = $this->_backendListArrayToMultiAssocArray($result->ListTemplatesResult); 668 } 669 670 return $ret; 671 } 672 673 /** 674 * Check whether a template file is available on LiveDocx service 675 * 676 * @param string $filename 677 * @return boolean 678 * @since LiveDocx 1.0 679 */ 680 public function templateExists($filename) 681 { 682 $this->logIn(); 683 684 $result = $this->getSoapClient()->TemplateExists(array( 685 'filename' => basename($filename), 686 )); 687 688 return (boolean) $result->TemplateExistsResult; 689 } 690 691 /** 692 * Share a document - i.e. the document is available to all over the Internet 693 * 694 * @return string 695 * @since LiveDocx 1.0 696 */ 697 public function shareDocument() 698 { 699 $this->logIn(); 700 701 $ret = null; 702 $result = $this->getSoapClient()->ShareDocument(); 703 704 if (isset($result->ShareDocumentResult)) { 705 $ret = (string) $result->ShareDocumentResult; 706 } 707 708 return $ret; 709 } 710 711 /** 712 * List all shared documents stored on LiveDocx service 713 * 714 * @return array 715 * @since LiveDocx 1.0 716 */ 717 public function listSharedDocuments() 718 { 719 $this->logIn(); 720 721 $ret = array(); 722 $result = $this->getSoapClient()->ListSharedDocuments(); 723 724 if (isset($result->ListSharedDocumentsResult)) { 725 $ret = $this->_backendListArrayToMultiAssocArray( 726 $result->ListSharedDocumentsResult 727 ); 728 } 729 730 return $ret; 731 } 732 733 /** 734 * Delete a shared document from LiveDocx service 735 * 736 * @param string $filename 737 * @return void 738 * @since LiveDocx 1.0 739 */ 740 public function deleteSharedDocument($filename) 741 { 742 $this->logIn(); 743 744 $this->getSoapClient()->DeleteSharedDocument(array( 745 'filename' => basename($filename), 746 )); 747 } 748 749 /* 750 * Download a shared document from LiveDocx service 751 * 752 * @param string $filename 753 * @return binary 754 * @throws Zend_Service_LiveDocx_Exception 755 * @since LiveDocx 1.0 756 */ 757 public function downloadSharedDocument($filename) 758 { 759 $this->logIn(); 760 761 try { 762 $result = $this->getSoapClient()->DownloadSharedDocument(array( 763 'filename' => basename($filename), 764 )); 765 } catch (Exception $e) { 766 require_once 'Zend/Service/LiveDocx/Exception.php'; 767 throw new Zend_Service_LiveDocx_Exception( 768 'Cannot download shared document', 0, $e 769 ); 770 } 771 772 return base64_decode($result->DownloadSharedDocumentResult); 773 } 774 775 /** 776 * Check whether a shared document is available on LiveDocx service 777 * 778 * @param string $filename 779 * @return boolean 780 * @since LiveDocx 1.0 781 */ 782 public function sharedDocumentExists($filename) 783 { 784 $this->logIn(); 785 786 $ret = false; 787 $sharedDocuments = $this->listSharedDocuments(); 788 foreach ($sharedDocuments as $shareDocument) { 789 if (isset($shareDocument['filename']) 790 && (basename($filename) === $shareDocument['filename']) 791 ) { 792 $ret = true; 793 break; 794 } 795 } 796 797 return $ret; 798 } 799 800 /** 801 * Return supported template formats (lowercase) 802 * 803 * @return array 804 * @since LiveDocx 1.0 805 */ 806 public function getTemplateFormats() 807 { 808 $this->logIn(); 809 810 $ret = array(); 811 $result = $this->getSoapClient()->GetTemplateFormats(); 812 813 if (isset($result->GetTemplateFormatsResult->string)) { 814 $ret = $result->GetTemplateFormatsResult->string; 815 $ret = array_map('strtolower', $ret); 816 } 817 818 return $ret; 819 } 820 821 /** 822 * Return supported document formats (lowercase) 823 * 824 * @return array 825 * @since LiveDocx 1.1 826 */ 827 public function getDocumentFormats() 828 { 829 $this->logIn(); 830 831 $ret = array(); 832 $result = $this->getSoapClient()->GetDocumentFormats(); 833 834 if (isset($result->GetDocumentFormatsResult->string)) { 835 $ret = $result->GetDocumentFormatsResult->string; 836 $ret = array_map('strtolower', $ret); 837 } 838 839 return $ret; 840 } 841 842 /* 843 * Return supported image formats (lowercase) 844 * 845 * @return array 846 * @since LiveDocx 1.2 847 */ 848 public function getImageFormats() 849 { 850 $this->logIn(); 851 852 $ret = array(); 853 $result = $this->getSoapClient()->GetImageFormats(); 854 855 if (isset($result->GetImageFormatsResult->string)) { 856 $ret = $result->GetImageFormatsResult->string; 857 $ret = array_map('strtolower', $ret); 858 } 859 860 return $ret; 861 } 862 863 /** 864 * Return the names of all fonts that are installed on backend server 865 * 866 * @return array 867 * @since LiveDocx 1.2 868 */ 869 public function getFontNames() 870 { 871 $this->logIn(); 872 873 $ret = array(); 874 $result = $this->getSoapClient()->GetFontNames(); 875 876 if (isset($result->GetFontNamesResult->string)) { 877 $ret = $result->GetFontNamesResult->string; 878 } 879 880 return $ret; 881 } 882 883 /** 884 * Return supported document access options 885 * 886 * @return array 887 * @since LiveDocx 1.2 Premium 888 */ 889 public function getDocumentAccessOptions() 890 { 891 $this->logIn(); 892 893 $ret = array(); 894 $result = $this->getSoapClient()->GetDocumentAccessOptions(); 895 896 if (isset($result->GetDocumentAccessOptionsResult->string)) { 897 $ret = $result->GetDocumentAccessOptionsResult->string; 898 } 899 900 return $ret; 901 } 902 903 /** 904 * Convert LiveDocx service return value from list methods to consistent PHP array 905 * 906 * @param array $list 907 * @return array 908 * @since LiveDocx 1.0 909 */ 910 protected function _backendListArrayToMultiAssocArray($list) 911 { 912 $this->logIn(); 913 914 $ret = array(); 915 if (isset($list->ArrayOfString)) { 916 foreach ($list->ArrayOfString as $a) { 917 if (is_array($a)) { // 1 template only 918 $o = new stdClass(); 919 $o->string = $a; 920 } else { // 2 or more templates 921 $o = $a; 922 } 923 unset($a); 924 925 if (isset($o->string)) { 926 $date1 = new Zend_Date($o->string[3], Zend_Date::RFC_1123); 927 $date2 = new Zend_Date($o->string[1], Zend_Date::RFC_1123); 928 929 $ret[] = array ( 930 'filename' => $o->string[0], 931 'fileSize' => (integer) $o->string[2], 932 'createTime' => (integer) $date1->get(Zend_Date::TIMESTAMP), 933 'modifyTime' => (integer) $date2->get(Zend_Date::TIMESTAMP), 934 ); 935 } 936 } 937 } 938 939 return $ret; 940 } 941 942 /** 943 * Convert assoc array to required SOAP type 944 * 945 * @param array $assoc 946 * 947 * @return array 948 * @since LiveDocx 1.0 949 */ 950 public static function assocArrayToArrayOfArrayOfString($assoc) 951 { 952 $arrayKeys = array_keys($assoc); 953 $arrayValues = array_values($assoc); 954 955 return array($arrayKeys, $arrayValues); 956 } 957 958 /** 959 * Convert multi assoc array to required SOAP type 960 * 961 * @param array $multi 962 * @return array 963 * @since LiveDocx 1.0 964 */ 965 public static function multiAssocArrayToArrayOfArrayOfString($multi) 966 { 967 $arrayKeys = array_keys($multi[0]); 968 $arrayValues = array(); 969 970 foreach ($multi as $v) { 971 $arrayValues[] = array_values($v); 972 } 973 974 $arrayKeys = array($arrayKeys); 975 976 return array_merge($arrayKeys, $arrayValues); 977 } 978 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |