Commit 43d2d64d584625c64e61430590411e09b4f2bab1
1 parent
810f45ac
Minor re-factor of some CMIS code to allow easier loading of object entries in multiple areas
Committed by: Paul Barrett
Showing
7 changed files
with
199 additions
and
163 deletions
ktatompub/services/cmis/ObjectFeed.inc.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +class CMISObjectFeed { | |
| 4 | + | |
| 5 | + /** | |
| 6 | + * Creates an AtomPub entry for a CMIS entry and adds it to the supplied feed | |
| 7 | + * | |
| 8 | + * @param object $feed The feed to which we add the entry | |
| 9 | + * @param array $cmisEntry The entry data | |
| 10 | + * @param string $parent The parent folder | |
| 11 | + */ | |
| 12 | + static public function createEntry(&$feed, $cmisEntry, $parent) | |
| 13 | + { | |
| 14 | + $entry = $feed->newEntry(); | |
| 15 | + $feed->newId('urn:uuid:' . $cmisEntry['properties']['ObjectId']['value'] . '-' | |
| 16 | + . strtolower($cmisEntry['properties']['ObjectTypeId']['value']), $entry); | |
| 17 | + | |
| 18 | + /* | |
| 19 | +<link rel="edit" href="http://10.33.4.34:8080/alfresco/service/api/node/workspace/SpacesStore/e98319fa-76e4-478f-8ce8-a3a0fd683e2c"/> | |
| 20 | +<link rel="cmis-allowableactions" href="http://10.33.4.34:8080/alfresco/service/api/node/workspace/SpacesStore/e98319fa-76e4-478f-8ce8-a3a0fd683e2c/permissions"/> | |
| 21 | +<link rel="cmis-relationships" href="http://10.33.4.34:8080/alfresco/service/api/node/workspace/SpacesStore/e98319fa-76e4-478f-8ce8-a3a0fd683e2c/associations"/> | |
| 22 | + */ | |
| 23 | + | |
| 24 | + // links | |
| 25 | +// $link = $feed->newElement('link'); | |
| 26 | +// $link->appendChild($feed->newAttr('rel','self')); | |
| 27 | +// $link->appendChild($feed->newAttr('href', CMIS_BASE_URI . strtolower($cmisEntry['properties']['ObjectTypeId']['value']) | |
| 28 | +// . '/' . $cmisEntry['properties']['ObjectId']['value'])); | |
| 29 | +// $entry->appendChild($link); | |
| 30 | + $link = $feed->newElement('link'); | |
| 31 | + $link->appendChild($feed->newAttr('rel','cmis-parent')); | |
| 32 | + $link->appendChild($feed->newAttr('href', CMIS_BASE_URI . 'folder/' . $parent)); | |
| 33 | + $entry->appendChild($link); | |
| 34 | + | |
| 35 | + if (strtolower($cmisEntry['properties']['ObjectTypeId']['value']) == 'folder') | |
| 36 | + { | |
| 37 | + $link = $feed->newElement('link'); | |
| 38 | + $link->appendChild($feed->newAttr('rel','cmis-folderparent')); | |
| 39 | + $link->appendChild($feed->newAttr('href', CMIS_BASE_URI . 'folder/' . $parent)); | |
| 40 | + $entry->appendChild($link); | |
| 41 | + $link = $feed->newElement('link'); | |
| 42 | + $link->appendChild($feed->newAttr('rel','cmis-children')); | |
| 43 | + $link->appendChild($feed->newAttr('href', CMIS_BASE_URI | |
| 44 | + . strtolower($cmisEntry['properties']['ObjectTypeId']['value']) | |
| 45 | + . '/' . $cmisEntry['properties']['ObjectId']['value'] . '/children')); | |
| 46 | + $entry->appendChild($link); | |
| 47 | + $link = $feed->newElement('link'); | |
| 48 | + $link->appendChild($feed->newAttr('rel','cmis-descendants')); | |
| 49 | + $link->appendChild($feed->newAttr('href', CMIS_BASE_URI | |
| 50 | + . strtolower($cmisEntry['properties']['ObjectTypeId']['value']) | |
| 51 | + . '/' . $cmisEntry['properties']['ObjectId']['value'] . '/descendants')); | |
| 52 | + $entry->appendChild($link); | |
| 53 | + } | |
| 54 | + | |
| 55 | + $link = $feed->newElement('link'); | |
| 56 | + $link->appendChild($feed->newAttr('rel','cmis-type')); | |
| 57 | + $link->appendChild($feed->newAttr('href', CMIS_BASE_URI . 'type/' . strtolower($cmisEntry['properties']['ObjectTypeId']['value']))); | |
| 58 | + $entry->appendChild($link); | |
| 59 | + $link = $feed->newElement('link'); | |
| 60 | + $link->appendChild($feed->newAttr('rel','cmis-repository')); | |
| 61 | + $link->appendChild($feed->newAttr('href', CMIS_BASE_URI . 'repository')); | |
| 62 | + $entry->appendChild($link); | |
| 63 | + // end links | |
| 64 | + | |
| 65 | + $entry->appendChild($feed->newElement('summary', $cmisEntry['properties']['Name']['value'])); | |
| 66 | + $entry->appendChild($feed->newElement('title', $cmisEntry['properties']['Name']['value'])); | |
| 67 | + | |
| 68 | + // main CMIS entry | |
| 69 | + $objectElement = $feed->newElement('cmis:object'); | |
| 70 | + $propertiesElement = $feed->newElement('cmis:properties'); | |
| 71 | + // <cmis:propertyId cmis:name="ObjectId"><cmis:value>D2</cmis:value></cmis:propertyId> | |
| 72 | + | |
| 73 | + foreach($cmisEntry['properties'] as $propertyName => $property) | |
| 74 | + { | |
| 75 | + $propElement = $feed->newElement('cmis:' . $property['type']); | |
| 76 | + $propElement->appendChild($feed->newAttr('cmis:name', $propertyName)); | |
| 77 | + $feed->newField('value', CMISUtil::boolToString($property['value']), $propElement); | |
| 78 | + $propertiesElement->appendChild($propElement); | |
| 79 | + } | |
| 80 | + | |
| 81 | + $objectElement->appendChild($propertiesElement); | |
| 82 | + $entry->appendChild($objectElement); | |
| 83 | + } | |
| 84 | + | |
| 85 | +} | |
| 86 | + | |
| 87 | +?> | ... | ... |
ktatompub/services/cmis/document.inc.php
| ... | ... | @@ -4,20 +4,9 @@ |
| 4 | 4 | * Document access/management functions for CMIS AtomPub |
| 5 | 5 | * Output returned as an AtomPub feed |
| 6 | 6 | */ |
| 7 | +include 'services/cmis/ObjectFeed.inc.php'; | |
| 7 | 8 | |
| 8 | -include 'services/cmis/RepositoryService.inc.php'; | |
| 9 | -include 'services/cmis/ObjectService.inc.php'; | |
| 10 | - | |
| 11 | -$RepositoryService = new RepositoryService(); | |
| 12 | -$repositories = $RepositoryService->getRepositories(); | |
| 13 | -$repositoryId = $repositories[0]['repositoryId']; | |
| 14 | - | |
| 15 | -$ObjectService = new ObjectService(); | |
| 16 | -$ObjectService->startSession($username, $password); | |
| 17 | - | |
| 18 | -$output = CMISDocumentFeed::getDocumentFeed($ObjectService, $repositoryId, $query[2]); | |
| 19 | - | |
| 20 | -class CMISDocumentFeed { | |
| 9 | +class CMISDocumentFeed extends CMISObjectFeed { | |
| 21 | 10 | |
| 22 | 11 | /** |
| 23 | 12 | * Retrieves data about a specific document |
| ... | ... | @@ -29,6 +18,17 @@ class CMISDocumentFeed { |
| 29 | 18 | */ |
| 30 | 19 | static public function getDocumentFeed($ObjectService, $repositoryId, $documentId) |
| 31 | 20 | { |
| 21 | + $cmisEntry = $ObjectService->getProperties($repositoryId, $documentId, false, false); | |
| 22 | + | |
| 23 | + $feed = new KTCMISAPPFeed(KT_APP_BASE_URI, $cmisEntry['properties']['ObjectTypeId']['value'], null, null, null, | |
| 24 | + 'urn:uuid:' . $cmisEntry['properties']['ObjectId']['value']); | |
| 25 | + | |
| 26 | + CMISDocumentFeed::createEntry($feed, $cmisEntry, $cmisEntry['properties']['ParentId']['value']); | |
| 27 | + | |
| 28 | + // <cmis:hasMoreItems>false</cmis:hasMoreItems> | |
| 29 | + | |
| 30 | + $output = $feed->getAPPdoc(); | |
| 31 | + | |
| 32 | 32 | // $documentData = $ObjectService->getProperties($repositoryId, $documentId, false, false); |
| 33 | 33 | // |
| 34 | 34 | // $feed = new KTCMISAPPFeed(KT_APP_BASE_URI, 'Root Folder Children', null, null, null, |
| ... | ... | @@ -88,7 +88,7 @@ class CMISDocumentFeed { |
| 88 | 88 | // // <cmis:hasMoreItems>false</cmis:hasMoreItems> |
| 89 | 89 | // |
| 90 | 90 | // $output = $feed->getAPPdoc(); |
| 91 | - $output = '<?xml version="1.0" encoding="UTF-8"?> | |
| 91 | + $outputs = '<?xml version="1.0" encoding="UTF-8"?> | |
| 92 | 92 | <feed xmlns="http://www.w3.org/2005/Atom" xmlns:cmis="http://www.cmis.org/2008/05"> |
| 93 | 93 | <entry> |
| 94 | 94 | <author><name>admin</name></author> |
| ... | ... | @@ -142,4 +142,16 @@ class CMISDocumentFeed { |
| 142 | 142 | |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | +include 'services/cmis/RepositoryService.inc.php'; | |
| 146 | +include 'services/cmis/ObjectService.inc.php'; | |
| 147 | + | |
| 148 | +$RepositoryService = new RepositoryService(); | |
| 149 | +$repositories = $RepositoryService->getRepositories(); | |
| 150 | +$repositoryId = $repositories[0]['repositoryId']; | |
| 151 | + | |
| 152 | +$ObjectService = new ObjectService(); | |
| 153 | +$ObjectService->startSession($username, $password); | |
| 154 | + | |
| 155 | +$output = CMISDocumentFeed::getDocumentFeed($ObjectService, $repositoryId, $query[2]); | |
| 156 | + | |
| 145 | 157 | ?> | ... | ... |
ktatompub/services/cmis/folder.inc.php
| ... | ... | @@ -5,30 +5,9 @@ |
| 5 | 5 | * Output returned as an AtomPub feed |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -include 'services/cmis/RepositoryService.inc.php'; | |
| 9 | -include 'services/cmis/NavigationService.inc.php'; | |
| 10 | -include 'services/cmis/ObjectService.inc.php'; | |
| 8 | +include 'services/cmis/ObjectFeed.inc.php'; | |
| 11 | 9 | |
| 12 | -$RepositoryService = new RepositoryService(); | |
| 13 | -$repositories = $RepositoryService->getRepositories(); | |
| 14 | -$repositoryId = $repositories[0]['repositoryId']; | |
| 15 | - | |
| 16 | -if (isset($query[3]) && (($query[3] == 'children') || ($query[3] == 'descendants'))) | |
| 17 | -{ | |
| 18 | - $NavigationService = new NavigationService(); | |
| 19 | - $NavigationService->startSession($username, $password); | |
| 20 | - | |
| 21 | - $output = CMISFolderFeed::getFolderChildrenFeed($NavigationService, $repositoryId, $query[2], $query[3]); | |
| 22 | -} | |
| 23 | -else | |
| 24 | -{ | |
| 25 | - $ObjectService = new ObjectService(); | |
| 26 | - $ObjectService->startSession($username, $password); | |
| 27 | - | |
| 28 | - $output = CMISFolderFeed::getFolderFeed($ObjectService, $repositoryId, $query[2]); | |
| 29 | -} | |
| 30 | - | |
| 31 | -class CMISFolderFeed { | |
| 10 | +class CMISFolderFeed extends CMISObjectFeed { | |
| 32 | 11 | |
| 33 | 12 | /** |
| 34 | 13 | * Retrieves children/descendants of the specified folder |
| ... | ... | @@ -55,7 +34,7 @@ class CMISFolderFeed { |
| 55 | 34 | } |
| 56 | 35 | |
| 57 | 36 | $feed = new KTCMISAPPFeed(KT_APP_BASE_URI, $folderName . ' Children', null, null, null, |
| 58 | - 'urn:' . $cmisEntry['properties']['ObjectId']['value'] . '-children'); | |
| 37 | + 'urn:uuid:' . $cmisEntry['properties']['ObjectId']['value'] . '-children'); | |
| 59 | 38 | |
| 60 | 39 | foreach($entries as $cmisEntry) |
| 61 | 40 | { |
| ... | ... | @@ -501,86 +480,29 @@ class CMISFolderFeed { |
| 501 | 480 | return $output; |
| 502 | 481 | } |
| 503 | 482 | |
| 504 | - /** | |
| 505 | - * Creates an AtomPub entry for a CMIS entry and adds it to the supplied feed | |
| 506 | - * | |
| 507 | - * @param object $feed The feed to which we add the entry | |
| 508 | - * @param array $cmisEntry The entry data | |
| 509 | - * @param string $parent The parent folder | |
| 510 | - */ | |
| 511 | - function createEntry(&$feed, $cmisEntry, $parent) | |
| 512 | - { | |
| 513 | - $entry = $feed->newEntry(); | |
| 514 | - $feed->newId('urn:' . $cmisEntry['properties']['ObjectId']['value'] . '-' | |
| 515 | - . strtolower($cmisEntry['properties']['ObjectTypeId']['value']), $entry); | |
| 483 | +} | |
| 516 | 484 | |
| 517 | - /* | |
| 518 | -<link rel="edit" href="http://10.33.4.34:8080/alfresco/service/api/node/workspace/SpacesStore/e98319fa-76e4-478f-8ce8-a3a0fd683e2c"/> | |
| 519 | -<link rel="cmis-allowableactions" href="http://10.33.4.34:8080/alfresco/service/api/node/workspace/SpacesStore/e98319fa-76e4-478f-8ce8-a3a0fd683e2c/permissions"/> | |
| 520 | -<link rel="cmis-relationships" href="http://10.33.4.34:8080/alfresco/service/api/node/workspace/SpacesStore/e98319fa-76e4-478f-8ce8-a3a0fd683e2c/associations"/> | |
| 521 | - */ | |
| 522 | - | |
| 523 | - // links | |
| 524 | -// $link = $feed->newElement('link'); | |
| 525 | -// $link->appendChild($feed->newAttr('rel','self')); | |
| 526 | -// $link->appendChild($feed->newAttr('href', CMIS_BASE_URI . strtolower($cmisEntry['properties']['ObjectTypeId']['value']) | |
| 527 | -// . '/' . $cmisEntry['properties']['ObjectId']['value'])); | |
| 528 | -// $entry->appendChild($link); | |
| 529 | - $link = $feed->newElement('link'); | |
| 530 | - $link->appendChild($feed->newAttr('rel','cmis-parent')); | |
| 531 | - $link->appendChild($feed->newAttr('href', CMIS_BASE_URI . 'folder/' . $parent)); | |
| 532 | - $entry->appendChild($link); | |
| 533 | - | |
| 534 | - if (strtolower($cmisEntry['properties']['ObjectTypeId']['value']) == 'folder') | |
| 535 | - { | |
| 536 | - $link = $feed->newElement('link'); | |
| 537 | - $link->appendChild($feed->newAttr('rel','cmis-folderparent')); | |
| 538 | - $link->appendChild($feed->newAttr('href', CMIS_BASE_URI . 'folder/' . $parent)); | |
| 539 | - $entry->appendChild($link); | |
| 540 | - $link = $feed->newElement('link'); | |
| 541 | - $link->appendChild($feed->newAttr('rel','cmis-children')); | |
| 542 | - $link->appendChild($feed->newAttr('href', CMIS_BASE_URI | |
| 543 | - . strtolower($cmisEntry['properties']['ObjectTypeId']['value']) | |
| 544 | - . '/' . $cmisEntry['properties']['ObjectId']['value'] . '/children')); | |
| 545 | - $entry->appendChild($link); | |
| 546 | - $link = $feed->newElement('link'); | |
| 547 | - $link->appendChild($feed->newAttr('rel','cmis-descendants')); | |
| 548 | - $link->appendChild($feed->newAttr('href', CMIS_BASE_URI | |
| 549 | - . strtolower($cmisEntry['properties']['ObjectTypeId']['value']) | |
| 550 | - . '/' . $cmisEntry['properties']['ObjectId']['value'] . '/descendants')); | |
| 551 | - $entry->appendChild($link); | |
| 552 | - } | |
| 485 | +include 'services/cmis/RepositoryService.inc.php'; | |
| 486 | +include 'services/cmis/NavigationService.inc.php'; | |
| 487 | +include 'services/cmis/ObjectService.inc.php'; | |
| 553 | 488 | |
| 554 | - $link = $feed->newElement('link'); | |
| 555 | - $link->appendChild($feed->newAttr('rel','cmis-type')); | |
| 556 | - $link->appendChild($feed->newAttr('href', CMIS_BASE_URI . 'type/' . strtolower($cmisEntry['properties']['ObjectTypeId']['value']))); | |
| 557 | - $entry->appendChild($link); | |
| 558 | - $link = $feed->newElement('link'); | |
| 559 | - $link->appendChild($feed->newAttr('rel','cmis-repository')); | |
| 560 | - $link->appendChild($feed->newAttr('href', CMIS_BASE_URI . 'repository')); | |
| 561 | - $entry->appendChild($link); | |
| 562 | - // end links | |
| 563 | - | |
| 564 | - $entry->appendChild($feed->newElement('summary', $cmisEntry['properties']['Name']['value'])); | |
| 565 | - $entry->appendChild($feed->newElement('title', $cmisEntry['properties']['Name']['value'])); | |
| 566 | - | |
| 567 | - // main CMIS entry | |
| 568 | - $objectElement = $feed->newElement('cmis:object'); | |
| 569 | - $propertiesElement = $feed->newElement('cmis:properties'); | |
| 570 | - // <cmis:propertyId cmis:name="ObjectId"><cmis:value>D2</cmis:value></cmis:propertyId> | |
| 571 | - | |
| 572 | - foreach($cmisEntry['properties'] as $propertyName => $property) | |
| 573 | - { | |
| 574 | - $propElement = $feed->newElement('cmis:' . $property['type']); | |
| 575 | - $propElement->appendChild($feed->newAttr('cmis:name', $propertyName)); | |
| 576 | - $feed->newField('value', CMISUtil::boolToString($property['value']), $propElement); | |
| 577 | - $propertiesElement->appendChild($propElement); | |
| 578 | - } | |
| 489 | +$RepositoryService = new RepositoryService(); | |
| 490 | +$repositories = $RepositoryService->getRepositories(); | |
| 491 | +$repositoryId = $repositories[0]['repositoryId']; | |
| 579 | 492 | |
| 580 | - $objectElement->appendChild($propertiesElement); | |
| 581 | - $entry->appendChild($objectElement); | |
| 582 | - } | |
| 493 | +if (isset($query[3]) && (($query[3] == 'children') || ($query[3] == 'descendants'))) | |
| 494 | +{ | |
| 495 | + $NavigationService = new NavigationService(); | |
| 496 | + $NavigationService->startSession($username, $password); | |
| 497 | + | |
| 498 | + $output = CMISFolderFeed::getFolderChildrenFeed($NavigationService, $repositoryId, $query[2], $query[3]); | |
| 499 | +} | |
| 500 | +else | |
| 501 | +{ | |
| 502 | + $ObjectService = new ObjectService(); | |
| 503 | + $ObjectService->startSession($username, $password); | |
| 583 | 504 | |
| 505 | + $output = CMISFolderFeed::getFolderFeed($ObjectService, $repositoryId, $query[2]); | |
| 584 | 506 | } |
| 585 | 507 | |
| 586 | 508 | ?> | ... | ... |
ktatompub/services/cmis/index.php
| ... | ... | @@ -32,7 +32,7 @@ switch($arg) |
| 32 | 32 | include('services/cmis/checkedout.inc.php'); |
| 33 | 33 | break; |
| 34 | 34 | case 'document': |
| 35 | - include('services/cmis/folder.inc.php'); | |
| 35 | + include('services/cmis/document.inc.php'); | |
| 36 | 36 | break; |
| 37 | 37 | case 'folder': |
| 38 | 38 | include('services/cmis/folder.inc.php'); | ... | ... |
lib/api/ktcmis/ktcmis.inc.php
| ... | ... | @@ -372,6 +372,12 @@ class KTObjectService extends KTCMISBase { |
| 372 | 372 | // instantiate underlying CMIS service |
| 373 | 373 | $this->ObjectService = new CMISObjectService(); |
| 374 | 374 | } |
| 375 | + | |
| 376 | + public function startSession($username, $password) | |
| 377 | + { | |
| 378 | + parent::startSession($username, $password); | |
| 379 | + $this->ObjectService->setInterface($this->ktapi); | |
| 380 | + } | |
| 375 | 381 | |
| 376 | 382 | /** |
| 377 | 383 | * Gets the properties for the selected object |
| ... | ... | @@ -387,7 +393,7 @@ class KTObjectService extends KTCMISBase { |
| 387 | 393 | public function getProperties($repositoryId, $objectId, $includeAllowableActions, $includeRelationships, |
| 388 | 394 | $returnVersion = false, $filter = '') |
| 389 | 395 | { |
| 390 | - $propertiesResult = $this->ObjectService->getProperties($repositoryId, $objectId, $includeAllowableActions, $includeRelationships); | |
| 396 | + $propertyCollection = $this->ObjectService->getProperties($repositoryId, $objectId, $includeAllowableActions, $includeRelationships); | |
| 391 | 397 | |
| 392 | 398 | if (PEAR::isError($propertiesResult)) |
| 393 | 399 | { |
| ... | ... | @@ -397,17 +403,7 @@ class KTObjectService extends KTCMISBase { |
| 397 | 403 | ); |
| 398 | 404 | } |
| 399 | 405 | |
| 400 | - // will need to convert to array format, so: | |
| 401 | - $propertyCollection['objectId'] = $propertiesResult->getValue('objectId'); | |
| 402 | - $propertyCollection['URI'] = $propertiesResult->getValue('URI'); | |
| 403 | - $propertyCollection['typeId'] = $propertiesResult->getValue('typeId'); | |
| 404 | - $propertyCollection['createdBy'] = $propertiesResult->getValue('createdBy'); | |
| 405 | - $propertyCollection['creationDate'] = $propertiesResult->getValue('creationDate'); | |
| 406 | - $propertyCollection['lastModifiedBy'] = $propertiesResult->getValue('lastModifiedBy'); | |
| 407 | - $propertyCollection['lastModificationDate'] = $propertiesResult->getValue('lastModificationDate'); | |
| 408 | - $propertyCollection['changeToken'] = $propertiesResult->getValue('changeToken'); | |
| 409 | - | |
| 410 | - $properties = array(array('properties' => $propertyCollection, 'child' => null)); | |
| 406 | + $properties = CMISUtil::createObjectPropertiesEntry($propertyCollection); | |
| 411 | 407 | |
| 412 | 408 | return array( |
| 413 | 409 | "status_code" => 0, | ... | ... |
lib/api/ktcmis/services/CMISObjectService.inc.php
| ... | ... | @@ -11,10 +11,15 @@ class CMISObjectService { |
| 11 | 11 | |
| 12 | 12 | protected $ktapi; |
| 13 | 13 | |
| 14 | -// function CMISObjectService(&$ktapi) | |
| 15 | -// { | |
| 16 | -// $this->ktapi = $ktapi; | |
| 17 | -// } | |
| 14 | + /** | |
| 15 | + * Sets the interface to be used to query the repository | |
| 16 | + * | |
| 17 | + * @param object $ktapi The KnowledgeTree API interface | |
| 18 | + */ | |
| 19 | + function setInterface(&$ktapi) | |
| 20 | + { | |
| 21 | + $this->ktapi = $ktapi; | |
| 22 | + } | |
| 18 | 23 | |
| 19 | 24 | /** |
| 20 | 25 | * Fetches the properties for the specified object | ... | ... |
lib/api/ktcmis/util/CMISUtil.inc.php
| ... | ... | @@ -221,43 +221,57 @@ class CMISUtil { |
| 221 | 221 | $object = $entry['object']; |
| 222 | 222 | $properties = $object->getProperties(); |
| 223 | 223 | |
| 224 | - // TODO additional properties to be returned | |
| 225 | - $hierarchy[$key]['properties']['ObjectId'] = array('type' => $properties->getFieldType('ObjectId'), | |
| 226 | - 'value' => $properties->getValue('ObjectId')); | |
| 227 | - $hierarchy[$key]['properties']['BaseType'] = array('type' => $properties->getFieldType('BaseType'), | |
| 228 | - 'value' => $properties->getValue('BaseType')); | |
| 229 | - $hierarchy[$key]['properties']['ObjectTypeId'] = array('type' => $properties->getFieldType('ObjectTypeId'), | |
| 230 | - 'value' => $properties->getValue('ObjectTypeId')); | |
| 231 | - $hierarchy[$key]['properties']['Name'] = array('type' => $properties->getFieldType('Name'), | |
| 232 | - 'value' => $properties->getValue('Name')); | |
| 233 | - $hierarchy[$key]['Author'] = array('value' => $properties->getValue('Author')); | |
| 234 | - if (strtolower($properties->getValue('ObjectTypeId')) == 'folder') | |
| 235 | - { | |
| 236 | - $hierarchy[$key]['properties']['ParentId'] = array('type' => $properties->getFieldType('ParentId'), | |
| 237 | - 'value' => CMISUtil::encodeObjectId('Folder', | |
| 238 | - $properties->getValue('ParentId'))); | |
| 239 | - } else { | |
| 240 | - $hierarchy[$key]['properties']['ContentStreamLength'] = array('type' => $properties->getFieldType('ContentStreamLength'), | |
| 241 | - 'value' => $properties->getValue('ContentStreamLength')); | |
| 242 | - $hierarchy[$key]['properties']['ContentStreamMimeType'] = array('type' => $properties->getFieldType('ContentStreamMimeType'), | |
| 243 | - 'value' => $properties->getValue('ContentStreamMimeType')); | |
| 244 | - } | |
| 245 | - // if we have found a child/parent with one or more children/parents, recurse into the child/parent object | |
| 246 | - if (count($entry['items']) > 0) | |
| 247 | - { | |
| 248 | - $hierarchy[$key][$linkText] = CMISUtil::decodeObjectHierarchy($entry['items'], $linkText); | |
| 249 | - } | |
| 250 | - // NOTE may need to set a null value here in case webservices don't like it unset | |
| 251 | - // so we'll set it just in case... | |
| 252 | - else | |
| 253 | - { | |
| 254 | - $hierarchy[$key][$linkText] = null; | |
| 255 | - } | |
| 224 | + $hierarchy[$key] = CMISUtil::createObjectPropertiesEntry($properties); | |
| 256 | 225 | } |
| 257 | 226 | |
| 258 | 227 | return $hierarchy; |
| 259 | 228 | } |
| 260 | 229 | |
| 230 | + static function createObjectPropertiesEntry($properties) | |
| 231 | + { | |
| 232 | + $object = array(); | |
| 233 | + | |
| 234 | + // TODO additional properties to be returned | |
| 235 | + $object['properties']['ObjectId'] = array('type' => $properties->getFieldType('ObjectId'), | |
| 236 | + 'value' => $properties->getValue('ObjectId')); | |
| 237 | + $object['properties']['BaseType'] = array('type' => $properties->getFieldType('BaseType'), | |
| 238 | + 'value' => $properties->getValue('BaseType')); | |
| 239 | + $object['properties']['ObjectTypeId'] = array('type' => $properties->getFieldType('ObjectTypeId'), | |
| 240 | + 'value' => $properties->getValue('ObjectTypeId')); | |
| 241 | + $object['properties']['Name'] = array('type' => $properties->getFieldType('Name'), | |
| 242 | + 'value' => $properties->getValue('Name')); | |
| 243 | + $object['Author'] = array('value' => $properties->getValue('Author')); | |
| 244 | + | |
| 245 | + if (strtolower($properties->getValue('ObjectTypeId')) == 'folder') | |
| 246 | + { | |
| 247 | + $object['properties']['ParentId'] = array('type' => $properties->getFieldType('ParentId'), | |
| 248 | + 'value' => CMISUtil::encodeObjectId('Folder', | |
| 249 | + $properties->getValue('ParentId'))); | |
| 250 | + } | |
| 251 | + // TODO should check for content stream data before filling these in | |
| 252 | + else //if () | |
| 253 | + { | |
| 254 | + $object['properties']['ContentStreamLength'] = array('type' => $properties->getFieldType('ContentStreamLength'), | |
| 255 | + 'value' => $properties->getValue('ContentStreamLength')); | |
| 256 | + $object['properties']['ContentStreamMimeType'] = array('type' => $properties->getFieldType('ContentStreamMimeType'), | |
| 257 | + 'value' => $properties->getValue('ContentStreamMimeType')); | |
| 258 | + } | |
| 259 | + | |
| 260 | + // if we have found a child/parent with one or more children/parents, recurse into the child/parent object | |
| 261 | + if (count($entry['items']) > 0) | |
| 262 | + { | |
| 263 | + $object[$linkText] = CMISUtil::decodeObjectHierarchy($entry['items'], $linkText); | |
| 264 | + } | |
| 265 | + // NOTE may need to set a null value here in case webservices don't like it unset | |
| 266 | + // so we'll set it just in case... | |
| 267 | + else | |
| 268 | + { | |
| 269 | + $object[$linkText] = null; | |
| 270 | + } | |
| 271 | + | |
| 272 | + return $object; | |
| 273 | + } | |
| 274 | + | |
| 261 | 275 | /** |
| 262 | 276 | * This function takes a class object and converts it to an array structure |
| 263 | 277 | * via var_export (which returns a useable PHP string for creating the object from array content) | ... | ... |