Commit bc7af7924e3f389df17892b829216d86807723b4

Authored by Paul Barrett
1 parent 8e953826

Various changes to ktcmis code made while implementing atompub responses. Moved…

… ktcmis code into lib/api/ to clean up the root of the folder tree.

Committed by: Paul Barrett
Showing 17 changed files with 207 additions and 198 deletions
ktcmis/classes/CMISBaseObject.inc.php renamed to lib/api/ktcmis/classes/CMISBaseObject.inc.php
... ... @@ -40,10 +40,9 @@
40 40 * @version Version 0.1
41 41 */
42 42  
43   -require_once(CMIS_DIR . '/classes/CMISObject.inc.php');
  43 +//require_once(CMIS_DIR . '/classes/CMISObject.inc.php');
44 44  
45   -// NOTE chemistry class was abstract but this has gone in a different direction anyway
46   -abstract class CMISBaseObject implements CMISObject {
  45 +abstract class CMISBaseObject {
47 46  
48 47 protected $typeId;
49 48 protected $queryName;
... ... @@ -60,7 +59,7 @@ abstract class CMISBaseObject implements CMISObject {
60 59  
61 60 protected $properties; // list of property objects which define the additional properties for this object
62 61  
63   - // TODO all we have here so far is getAttributes & getProperties :)
  62 + // TODO all we have here so far is getAttributes & getProperties
64 63 // add all the other methods as we go along
65 64  
66 65 function __construct()
... ...
ktcmis/classes/CMISDocumentPropertyCollection.inc.php renamed to lib/api/ktcmis/classes/CMISDocumentPropertyCollection.inc.php
... ... @@ -47,21 +47,26 @@ require_once(CMIS_DIR . '/classes/CMISPropertyCollection.inc.php');
47 47 */
48 48 class CMISDocumentPropertyCollection extends CMISPropertyCollection {
49 49  
50   - static $name;
51   - static $isImmutable;
52   - static $isLatestVersion;
53   - static $isMajorVersion;
54   - static $isLatestMajorVersion;
55   - static $versionLabel;
56   - static $versionSeriesId;
57   - static $isVersionSeriesCheckedOut;
58   - static $versionSeriesCheckedOutBy;
59   - static $versionSeriesCheckedOutId;
60   - static $checkinComment;
61   - static $contentStreamLength;
62   - static $contentStreamMimeType;
63   - static $contentStreamFilename;
64   - static $contentStreamUri;
  50 + static $Name;
  51 + static $IsImmutable;
  52 + static $IsLatestVersion;
  53 + static $IsMajorVersion;
  54 + static $IsLatestMajorVersion;
  55 + static $VersionLabel;
  56 + static $VersionSeriesId;
  57 + static $IsVersionSeriesCheckedOut;
  58 + static $VersionSeriesCheckedOutBy;
  59 + static $VersionSeriesCheckedOutId;
  60 + static $CheckinComment;
  61 + static $ContentStreamLength;
  62 + static $ContentStreamMimeType;
  63 + static $ContentStreamFilename;
  64 + static $ContentStreamUri;
  65 +
  66 + function __construct()
  67 + {
  68 + parent::__construct();
  69 + }
65 70  
66 71 }
67 72  
... ...
ktcmis/classes/CMISFolderPropertyCollection.inc.php renamed to lib/api/ktcmis/classes/CMISFolderPropertyCollection.inc.php
... ... @@ -47,9 +47,14 @@ require_once(CMIS_DIR . '/classes/CMISPropertyCollection.inc.php');
47 47 */
48 48 class CMISFolderPropertyCollection extends CMISPropertyCollection {
49 49  
50   - static $name;
51   - static $parentId;
52   - static $allowedChildObjectTypeIds;
  50 + static $Name;
  51 + static $ParentId;
  52 + static $AllowedChildObjectTypeIds;
  53 +
  54 + function __construct()
  55 + {
  56 + parent::__construct();
  57 + }
53 58  
54 59 }
55 60  
... ...
ktcmis/classes/CMISObject.inc.php renamed to lib/api/ktcmis/classes/CMISObject.inc.php
ktcmis/classes/CMISObjectTypes.inc.php renamed to lib/api/ktcmis/classes/CMISObjectTypes.inc.php
ktcmis/classes/CMISPropertyCollection.inc.php renamed to lib/api/ktcmis/classes/CMISPropertyCollection.inc.php
... ... @@ -45,14 +45,26 @@
45 45 */
46 46 abstract class CMISPropertyCollection {
47 47  
48   - static $objectId;
  48 + static $ObjectId;
49 49 static $URI;
50   - static $typeId;
51   - static $createdBy;
52   - static $creationDate;
53   - static $lastModifiedBy;
54   - static $lastModificationDate;
55   - static $changeToken;
  50 + static $ObjectTypeId;
  51 + static $CreatedBy;
  52 + static $CreationDate;
  53 + static $LastModifiedBy;
  54 + static $LastModificationDate;
  55 + static $ChangeToken;
  56 +
  57 + // TODO these definitions probably belong elsewhere, but here will do for now
  58 + static $propertyTypes;
  59 +
  60 + function __construct()
  61 + {
  62 + $this->propertyTypes = array('ObjectId' => 'propertyId', 'BaseType' => 'propertyString',
  63 + 'ObjectTypeId' => 'propertyString', 'CreatedBy' => 'propertyString',
  64 + 'CreationDate' => 'propertyDateTime', 'LastModifiedBy' => 'propertyString',
  65 + 'LastModificationDate' => 'propertyDateTime', 'Name' => 'propertyString',
  66 + 'ParentId' => 'propertyId');
  67 + }
56 68  
57 69 /**
58 70 * Gets the property value.
... ... @@ -71,6 +83,11 @@ abstract class CMISPropertyCollection {
71 83 $this->{$field} = $value;
72 84 }
73 85  
  86 + function getFieldType($field)
  87 + {
  88 + return $this->propertyTypes[$field];
  89 + }
  90 +
74 91 }
75 92  
76 93 ?>
... ...
ktcmis/classes/CMISRepository.inc.php renamed to lib/api/ktcmis/classes/CMISRepository.inc.php
... ... @@ -98,13 +98,13 @@ class CMISRepository {
98 98 }
99 99  
100 100 // set capabilities
101   - foreach($config->repositoryCapabilities->children() as $field => $value)
  101 + foreach($config->repositoryCapabilities[0] as $field => $value)
102 102 {
103 103 $this->setCapabilityField($field, (string)$value);
104 104 }
105 105  
106 106 // set supported document types
107   - foreach($config->supportedTypes->children() as $field => $value)
  107 + foreach($config->supportedTypes[0] as $field => $value)
108 108 {
109 109 $this->objectTypes[] = (string)$value;
110 110 }
... ...
ktcmis/classes/CMISRepositoryCapabilities.inc.php renamed to lib/api/ktcmis/classes/CMISRepositoryCapabilities.inc.php
ktcmis/classes/CMISRepositoryInfo.inc.php renamed to lib/api/ktcmis/classes/CMISRepositoryInfo.inc.php
ktcmis/config/repositories.xml renamed to lib/api/ktcmis/config/repositories.xml
... ... @@ -12,15 +12,15 @@
12 12 <repository>
13 13 <repositoryURI>http://127.0.0.1/</repositoryURI>
14 14 <repositoryInfo>
15   - <repositoryId>1</repositoryId>
  15 + <repositoryId>0ad7de04-7914-41b1-b5ee-be9f0b626437</repositoryId>
16 16 <repositoryName>KnowledgeTree</repositoryName>
17 17 <repositoryRelationship>self</repositoryRelationship>
18 18 <repositoryDescription>KnowledgeTree Repository</repositoryDescription>
19 19 <vendorName>KnowledgeTree</vendorName>
20   - <productName>KnowledgeTree</productName>
  20 + <productName>KnowledgeTree Document Management System</productName>
21 21 <productVersion>3.6.2</productVersion>
22   - <rootFolderId>1</rootFolderId>
23   - <cmisVersionsSupported>cmis 0.61c</cmisVersionsSupported>
  22 + <rootFolderId>F1</rootFolderId>
  23 + <cmisVersionsSupported>0.61c</cmisVersionsSupported>
24 24 </repositoryInfo>
25 25 <repositoryCapabilities>
26 26 <capabilityMultifiling>false</capabilityMultifiling>
... ... @@ -41,7 +41,7 @@
41 41 <repository>
42 42 <repositoryURI>http://12s7.w0.0.1/</repositoryURI>
43 43 <repositoryInfo>
44   - <repositoryId>44</repositoryId>
  44 + <repositoryId>b60bd6c5-e8f9-4776-b292-8d544468c9e4</repositoryId>
45 45 <repositoryName>asdasdasd</repositoryName>
46 46 <repositoryRelationship>self</repositoryRelationship>
47 47 <repositoryDescription>KnowledgeTree Repository</repositoryDescription>
... ... @@ -49,7 +49,7 @@
49 49 <productName>KnowledgeTree</productName>
50 50 <productVersion>3.6.1</productVersion>
51 51 <rootFolderId>1</rootFolderId>
52   - <cmisVersionsSupported>0.61</cmisVersionsSupported>
  52 + <cmisVersionsSupported>0.61c</cmisVersionsSupported>
53 53 </repositoryInfo>
54 54 <repositoryCapabilities>
55 55 <capabilityMultifiling>false</capabilityMultifiling>
... ...
ktcmis/ktcmis.inc.php renamed to lib/api/ktcmis/ktcmis.inc.php
... ... @@ -40,39 +40,29 @@
40 40 * @version Version 0.9
41 41 */
42 42  
  43 +/**
  44 + * Split into individual classes to handle each section of functionality.
  45 + * This is really just a handling layer between CMIS and the web services.
  46 + */
  47 +
43 48 // TODO implement exceptions in various calls (in the underlying classes)
44 49 // FIXME none of the error handling actually does anything, it's leftover from copy/paste of some ktapi code
45 50  
46   -require_once(realpath(dirname(__FILE__) . '/../config/dmsDefaults.php'));
  51 +require_once(realpath(dirname(__FILE__) . '/../../../config/dmsDefaults.php'));
47 52 require_once(KT_DIR . '/ktapi/ktapi.inc.php');
48 53  
49   -define ('CMIS_DIR', KT_DIR . '/ktcmis');
  54 +define ('CMIS_DIR', KT_LIB_DIR . '/api/ktcmis');
50 55 require_once(CMIS_DIR . '/services/CMISRepositoryService.inc.php');
51 56 require_once(CMIS_DIR . '/services/CMISNavigationService.inc.php');
52 57 require_once(CMIS_DIR . '/services/CMISObjectService.inc.php');
53 58 require_once(CMIS_DIR . '/util/CMISUtil.inc.php');
54 59  
55   -class KTCMIS {
  60 +/**
  61 + * Handles authentication
  62 + */
  63 +class KTCMISBase {
56 64  
57 65 /**
58   - * Class for CMIS Repository Services
59   - *
60   - * @var object
61   - */
62   - protected $RepositoryService;
63   - /**
64   - * Class for CMIS Navigation Services
65   - *
66   - * @var object
67   - */
68   - protected $NavigationService;
69   - /**
70   - * Class for CMIS Object Services
71   - *
72   - * @var object
73   - */
74   - protected $ObjectService;
75   - /**
76 66 * KnowledgeTree API instance
77 67 *
78 68 * @var object
... ... @@ -85,51 +75,41 @@ class KTCMIS {
85 75 */
86 76 protected $session;
87 77  
88   - function __construct(&$ktapi = null, $user = '', $password = '')
  78 + public function startSession($username, $password)
89 79 {
90   - // ktapi interface
  80 + global $default;
  81 + $default->log->debug("attempt auth with $username :: $password");
91 82 $this->session = null;
92   -// if (is_null($ktapi))
93   -// {
94   -// // TODO this should probably throw an exception instead
95   -// return PEAR::RaiseError('Cannot continue without KTAPI instance');
96   - // FIXME this CANNOT be allowed in a live environment
97   - // possibly we should insist on a ktapi instance being passed
98   - // or at least user/pass for logging in here, if one or other
99   - // not sent, return error
100   - $user = 'admin';
101   - $password = 'admin';
102   - $this->ktapi = new KTAPI();
103   - $this->session = $this->ktapi->start_session($user, $password);
104   -// }
105   -// else
106   -// {
107   -// $this->ktapi = $ktapi;
108   -// }
109   -
110   - // instantiate services
111   - $this->RepositoryService = new CMISRepositoryService();
112   - $this->NavigationService = new CMISNavigationService($this->ktapi);
113   - $this->ObjectService = new CMISObjectService($this->ktapi);
  83 + // remove as soon as actual auth code is in place
  84 + $username = 'admin';
  85 + $password = 'admin';
  86 + $this->ktapi = new KTAPI();
  87 + $this->session =& $this->ktapi->start_session($username, $password);
  88 +
  89 + if (PEAR::isError($this->session))
  90 + {
  91 + $default->log->debug("FAILED $username :: $password FAILED");
  92 + }
  93 +
  94 + return $this->session;
114 95 }
115 96  
116   - function __destruct()
  97 + // TODO what about destroying sessions?
  98 +}
  99 +
  100 +/**
  101 + * Handles low level repository information queries
  102 + */
  103 +class KTRepositoryService extends KTCMISBase {
  104 +
  105 + protected $RepositoryService;
  106 +
  107 + public function __construct()
117 108 {
118   -// if ($this->session instanceOf KTAPI_UserSession)
119   -// {
120   -// try
121   -// {
122   -// $this->session->logout();
123   -// }
124   -// catch (Exception $e)
125   -// {
126   -// // no output
127   -// }
128   -// }
  109 + // instantiate underlying CMIS service
  110 + $this->RepositoryService = new CMISRepositoryService();
129 111 }
130 112  
131   - // Repository service functions
132   -
133 113 /**
134 114 * Fetch a list of all available repositories
135 115 *
... ... @@ -137,7 +117,7 @@ class KTCMIS {
137 117 *
138 118 * @return repositoryList[]
139 119 */
140   - function getRepositories()
  120 + public function getRepositories()
141 121 {
142 122 $repositories = $this->RepositoryService->getRepositories();
143 123 if (PEAR::isError($repositories))
... ... @@ -170,7 +150,7 @@ class KTCMIS {
170 150 *
171 151 * @param string $repositoryId
172 152 */
173   - function getRepositoryInfo($repositoryId)
  153 + public function getRepositoryInfo($repositoryId)
174 154 {
175 155 $repositoryInfo = $this->RepositoryService->getRepositoryInfo($repositoryId);
176 156 if (PEAR::isError($repositoryInfo))
... ... @@ -194,7 +174,7 @@ class KTCMIS {
194 174 *
195 175 * @param string $repositoryId
196 176 */
197   - function getTypes($repositoryId, $typeId = '', $returnPropertyDefinitions = false,
  177 + public function getTypes($repositoryId, $typeId = '', $returnPropertyDefinitions = false,
198 178 $maxItems = 0, $skipCount = 0, &$hasMoreItems = false)
199 179 {
200 180 $repositoryObjectTypeResult = $this->RepositoryService->getTypes($repositoryId, $typeId, $returnPropertyDefinitions,
... ... @@ -229,10 +209,10 @@ class KTCMIS {
229 209 * @param string $repositoryId
230 210 * @param string $typeId
231 211 */
232   - function getTypeDefinition($repositoryId, $typeId)
  212 + public function getTypeDefinition($repositoryId, $typeId)
233 213 {
234 214 $typeDefinitionResult = $this->RepositoryService->getTypeDefinition($repositoryId, $typeId);
235   -
  215 +
236 216 if (PEAR::isError($typeDefinitionResult))
237 217 {
238 218 return array(
... ... @@ -252,7 +232,26 @@ class KTCMIS {
252 232 );
253 233 }
254 234  
255   - // Navigation service functions
  235 +}
  236 +
  237 +/*
  238 + * Handles repository navigation
  239 + */
  240 +class KTNavigationService extends KTCMISBase {
  241 +
  242 + protected $NavigationService;
  243 +
  244 + public function __construct()
  245 + {
  246 + // instantiate underlying CMIS service
  247 + $this->NavigationService = new CMISNavigationService();
  248 + }
  249 +
  250 + public function startSession($username, $password)
  251 + {
  252 + parent::startSession($username, $password);
  253 + $this->NavigationService->setInterface($this->ktapi);
  254 + }
256 255  
257 256 /**
258 257 * Get descendents of the specified folder, up to the depth indicated
... ... @@ -266,7 +265,7 @@ class KTCMIS {
266 265 * @param string $filter
267 266 * @return array $descendants
268 267 */
269   - function getDescendants($repositoryId, $folderId, $includeAllowableActions, $includeRelationships,
  268 + public function getDescendants($repositoryId, $folderId, $includeAllowableActions, $includeRelationships,
270 269 $depth = 1, $typeID = 'Any', $filter = '')
271 270 {
272 271 // TODO optional parameters
... ... @@ -284,11 +283,6 @@ class KTCMIS {
284 283 // format for webservices consumption
285 284 // NOTE this will almost definitely be changing in the future, this is just to get something working
286 285 $descendants = CMISUtil::decodeObjectHierarchy($descendantsResult, 'child');
287   -// $descendants = array(array('properties' => array('objectId' => 'D2', 'typeId' => 'Document', 'name' => 'test document'),
288   -// 'child' => array(array('properties' => array('objectId' => 'D7',
289   -// 'typeId' => 'Document', 'name' => 'CHILD document'), 'child' => null),
290   -// array('properties' => array('objectId' => 'F34',
291   -// 'typeId' => 'Folder', 'name' => 'CHILD FOLDER'), 'child' => null))));
292 286  
293 287 return array (
294 288 "status_code" => 0,
... ... @@ -309,7 +303,7 @@ class KTCMIS {
309 303 * @param int $skipCount
310 304 * @return array $descendants
311 305 */
312   - function getChildren($repositoryId, $folderId, $includeAllowableActions, $includeRelationships,
  306 + public function getChildren($repositoryId, $folderId, $includeAllowableActions, $includeRelationships,
313 307 $typeID = 'Any', $filter = '', $maxItems = 0, $skipCount = 0)
314 308 {
315 309 // TODO paging
... ... @@ -325,8 +319,6 @@ class KTCMIS {
325 319 }
326 320  
327 321 $children = CMISUtil::decodeObjectHierarchy($childrenResult, 'child');
328   -// $children = array(array('properties' => array('objectId' => 'D2', 'typeId' => 'Document', 'name' => 'test document'),
329   -// 'child' => null));
330 322  
331 323 return array(
332 324 "status_code" => 0,
... ... @@ -345,7 +337,7 @@ class KTCMIS {
345 337 * @param string $filter
346 338 * @return ancestry[]
347 339 */
348   - function getFolderParent($repositoryId, $folderId, $includeAllowableActions, $includeRelationships, $returnToRoot, $filter = '')
  340 + public function getFolderParent($repositoryId, $folderId, $includeAllowableActions, $includeRelationships, $returnToRoot, $filter = '')
349 341 {
350 342 $ancestryResult = $this->NavigationService->getFolderParent($repositoryId, $folderId, $includeAllowableActions,
351 343 $includeRelationships, $returnToRoot);
... ... @@ -359,8 +351,6 @@ class KTCMIS {
359 351 }
360 352  
361 353 $ancestry = CMISUtil::decodeObjectHierarchy($ancestryResult, 'child');
362   -// $ancestry = array(array('properties' => array('objectId' => 'D2', 'typeId' => 'Document', 'name' => 'test document'),
363   -// 'child' => null));
364 354  
365 355 return array(
366 356 "status_code" => 0,
... ... @@ -368,42 +358,19 @@ class KTCMIS {
368 358 );
369 359 }
370 360  
371   - /**
372   - * Gets the parents for the selected object
373   - *
374   - * @param string $repositoryId
375   - * @param string $folderId
376   - * @param boolean $includeAllowableActions
377   - * @param boolean $includeRelationships
378   - * @param string $filter
379   - * @return ancestry[]
380   - */
381   - function getObjectParents($repositoryId, $objectId, $includeAllowableActions, $includeRelationships, $filter = '')
382   - {
383   - $ancestryResult = $this->NavigationService->getObjectParents($repositoryId, $objectId, $includeAllowableActions,
384   - $includeRelationships);
385   -
386   - if (PEAR::isError($ancestryResult))
387   - {
388   - return array(
389   - "status_code" => 1,
390   - "message" => "Failed getting ancestry for object"
391   - );
392   - }
  361 +}
393 362  
394   - $ancestry = CMISUtil::decodeObjectHierarchy($ancestryResult, 'child');
395   -// $ancestry = array(array('properties' => array('objectId' => 'D2', 'typeId' => 'Document', 'name' => 'test document'),
396   -// 'child' => null));
  363 +/**
  364 + * Handles requests for and actions on Folders and Documents
  365 + */
  366 +class KTObjectService extends KTCMISBase {
397 367  
398   -// $ancestry = array(array('properties' => array(array('property' => array('name' => 'objectId', $value => 'D2')),
399   -// array('property' => array('name' => 'typeId', $value => 'Document')),
400   -// array('property' => array('name' => 'name', $value => 'test document')))),
401   -// 'child' => null);
  368 + protected $ObjectService;
402 369  
403   - return array(
404   - "status_code" => 0,
405   - "results" => $ancestry
406   - );
  370 + public function __construct()
  371 + {
  372 + // instantiate underlying CMIS service
  373 + $this->ObjectService = new CMISObjectService();
407 374 }
408 375  
409 376 /**
... ... @@ -417,7 +384,7 @@ class KTCMIS {
417 384 * @param string $filter
418 385 * @return properties[]
419 386 */
420   - function getProperties($repositoryId, $objectId, $includeAllowableActions, $includeRelationships,
  387 + public function getProperties($repositoryId, $objectId, $includeAllowableActions, $includeRelationships,
421 388 $returnVersion = false, $filter = '')
422 389 {
423 390 $propertiesResult = $this->ObjectService->getProperties($repositoryId, $objectId, $includeAllowableActions, $includeRelationships);
... ... @@ -429,7 +396,7 @@ class KTCMIS {
429 396 "message" => "Failed getting properties for object"
430 397 );
431 398 }
432   -// echo '<pre>'.print_r($propertiesResult, true).'</pre>';
  399 +
433 400 // will need to convert to array format, so:
434 401 $propertyCollection['objectId'] = $propertiesResult->getValue('objectId');
435 402 $propertyCollection['URI'] = $propertiesResult->getValue('URI');
... ... @@ -441,19 +408,13 @@ class KTCMIS {
441 408 $propertyCollection['changeToken'] = $propertiesResult->getValue('changeToken');
442 409  
443 410 $properties = array(array('properties' => $propertyCollection, 'child' => null));
444   -// echo '<pre>'.print_r($properties, true).'</pre>';
445   -//
446   -// $properties = array(array('properties' => array('objectId' => 'F2', 'URI' => '', 'typeId' => 'Document',
447   -// 'createdBy' => 'Administrator', 'creationDate' => '1 June 2009',
448   -// 'lastModifiedBy' => 'Administrator', 'lastModificationDate' => '1 June 2009',
449   -// 'changeToken' => ''),
450   -// 'child' => null));
451 411  
452 412 return array(
453 413 "status_code" => 0,
454 414 "results" => $properties
455 415 );
456 416 }
  417 +
457 418 }
458 419  
459 420 ?>
... ...
ktcmis/objecttypes/CMISDocumentObject.inc.php renamed to lib/api/ktcmis/objecttypes/CMISDocumentObject.inc.php
... ... @@ -107,7 +107,7 @@ class CMISDocumentObject extends CMISBaseObject {
107 107  
108 108 $objectProperties = $object->get_detail();
109 109  
110   - $this->_setPropertyInternal('objectId', CMISUtil::encodeObjectId($this->typeId, $objectProperties['document_id']));
  110 + $this->_setPropertyInternal('ObjectId', CMISUtil::encodeObjectId($this->typeId, $objectProperties['document_id']));
111 111 // prevent doubled '/' chars
112 112 $uri = preg_replace_callback('/([^:]\/)\//',
113 113 create_function('$matches', 'return $matches[1];'),
... ... @@ -116,28 +116,28 @@ class CMISDocumentObject extends CMISBaseObject {
116 116 . $objectProperties['document_id']);
117 117 // NOTE what about instead creating a downloadable version with appropriate link? see ktapi::download_document
118 118 // also ktapidocument::get_download_url
119   - $this->_setPropertyInternal('Uri', $uri);
  119 + $this->_setPropertyInternal('URI', $uri);
120 120 // TODO what is this? Assuming it is the object type id, and not OUR document type?
121   - $this->_setPropertyInternal('typeId', $this->getAttribute('typeId'));
122   - $this->_setPropertyInternal('createdBy', $objectProperties['created_by']);
123   - $this->_setPropertyInternal('creationDate', $objectProperties['created_date']);
124   - $this->_setPropertyInternal('lastModifiedBy', $objectProperties['modified_by']);
125   - $this->_setPropertyInternal('lastModificationDate', $objectProperties['modified_date']);
126   - $this->_setPropertyInternal('changeToken', null);
127   - $this->_setPropertyInternal('name', $objectProperties['title']);
128   - $this->_setPropertyInternal('isImmutable', $objectProperties['is_immutable']);
  121 + $this->_setPropertyInternal('ObjectTypeId', $this->getAttribute('typeId'));
  122 + $this->_setPropertyInternal('CreatedBy', $objectProperties['created_by']);
  123 + $this->_setPropertyInternal('CreationDate', $objectProperties['created_date']);
  124 + $this->_setPropertyInternal('LastModifiedBy', $objectProperties['modified_by']);
  125 + $this->_setPropertyInternal('LastModificationDate', $objectProperties['modified_date']);
  126 + $this->_setPropertyInternal('ChangeToken', null);
  127 + $this->_setPropertyInternal('Name', $objectProperties['title']);
  128 + $this->_setPropertyInternal('IsImmutable', $objectProperties['is_immutable']);
129 129 // NOTE if access to older versions is allowed, this will need to be checked, else just set to yes
130 130 // see ktapi::get_document_version_history
131 131 // NOTE see ktapi::is_latest_version
132   - $this->_setPropertyInternal('isLatestVersion', true);
133   - $this->_setPropertyInternal('isMajorVersion', (strstr($objectProperties['version'], '.') ? false : true));
  132 + $this->_setPropertyInternal('IsLatestVersion', true);
  133 + $this->_setPropertyInternal('IsMajorVersion', (strstr($objectProperties['version'], '.') ? false : true));
134 134 // NOTE if access to older versions is allowed, this will need to be checked, else just set to yes
135 135 // see ktapi::get_document_version_history
136 136 // NOTE see ktapi::is_latest_version
137   - $this->_setPropertyInternal('isLatestMajorVersion', true);
138   - $this->_setPropertyInternal('versionLabel', $objectProperties['version']);
  137 + $this->_setPropertyInternal('IsLatestMajorVersion', true);
  138 + $this->_setPropertyInternal('VersionLabel', $objectProperties['version']);
139 139 // TODO what determines this, do we have anything?
140   - $this->_setPropertyInternal('versionSeriesId', null);
  140 + $this->_setPropertyInternal('VersionSeriesId', null);
141 141 if ($objectProperties['checked_out_by'] != 'n/a')
142 142 {
143 143 $checkedOut = true;
... ... @@ -151,18 +151,18 @@ class CMISDocumentObject extends CMISBaseObject {
151 151 $checkedOutBy = null;
152 152 $checkedOutId = null;
153 153 }
154   - $this->_setPropertyInternal('isVersionSeriesCheckedOut', $checkedOut);
155   - $this->_setPropertyInternal('versionSeriesCheckedOutBy', $checkedOutBy);
  154 + $this->_setPropertyInternal('IsVersionSeriesCheckedOut', $checkedOut);
  155 + $this->_setPropertyInternal('VersionSeriesCheckedOutBy', $checkedOutBy);
156 156 // TODO presumably this is the ID of the Private Working Copy created on checkout?
157 157 // will find out more when we do checkout/checkin
158   - $this->_setPropertyInternal('versionSeriesCheckedOutId', $checkedOutId);
  158 + $this->_setPropertyInternal('VersionSeriesCheckedOutId', $checkedOutId);
159 159 // TODO currently not returned by KnowledgeTree?
160   - $this->_setPropertyInternal('checkinComment', null);
  160 + $this->_setPropertyInternal('CheckinComment', null);
161 161 // TODO if we implement content streams
162   - $this->_setPropertyInternal('contentStreamLength', null);
163   - $this->_setPropertyInternal('contentStreamMimeType', null);
164   - $this->_setPropertyInternal('contentStreamFilename', null);
165   - $this->_setPropertyInternal('contentStreamUri', null);
  162 + $this->_setPropertyInternal('ContentStreamLength', null);
  163 + $this->_setPropertyInternal('ContentStreamMimeType', null);
  164 + $this->_setPropertyInternal('ContentStreamFilename', null);
  165 + $this->_setPropertyInternal('ContentStreamUri', null);
166 166 }
167 167  
168 168 }
... ...
ktcmis/objecttypes/CMISFolderObject.inc.php renamed to lib/api/ktcmis/objecttypes/CMISFolderObject.inc.php
... ... @@ -86,7 +86,7 @@ class CMISFolderObject extends CMISBaseObject {
86 86  
87 87 $objectProperties = $object->get_detail();
88 88  
89   - $this->_setPropertyInternal('objectId', CMISUtil::encodeObjectId($this->typeId, $objectProperties['id']));
  89 + $this->_setPropertyInternal('ObjectId', CMISUtil::encodeObjectId($this->typeId, $objectProperties['id']));
90 90 // prevent doubled '/' chars
91 91 $uri = preg_replace_callback('/([^:]\/)\//',
92 92 create_function('$matches', 'return $matches[1];'),
... ... @@ -94,20 +94,20 @@ class CMISFolderObject extends CMISBaseObject {
94 94 . '/browse.php?fFolderId='
95 95 . $objectProperties['id']);
96 96 // TODO this url is probably incorrect...needs to be checked
97   - $this->_setPropertyInternal('Uri', $uri);
  97 + $this->_setPropertyInternal('URI', $uri);
98 98 // TODO what is this? Assuming it is the object type id, and not OUR document type?
99   - $this->_setPropertyInternal('typeId', $this->getAttribute('typeId'));
100   - $this->_setPropertyInternal('createdBy', $objectProperties['created_by']);
  99 + $this->_setPropertyInternal('ObjectTypeId', $this->getAttribute('typeId'));
  100 + $this->_setPropertyInternal('CreatedBy', $objectProperties['created_by']);
101 101 // TODO cannot currently retrieve via ktapi or regular folder code - add as with created by
102   - $this->_setPropertyInternal('creationDate', $objectProperties['created_date']);
  102 + $this->_setPropertyInternal('CreationDate', $objectProperties['created_date']);
103 103 // TODO cannot currently retrieve via ktapi or regular folder code - add as with created by
104   - $this->_setPropertyInternal('lastModifiedBy', $objectProperties['modified_by']);
  104 + $this->_setPropertyInternal('LastModifiedBy', $objectProperties['modified_by']);
105 105 // TODO cannot currently retrieve via ktapi or regular folder code - add as with created by
106   - $this->_setPropertyInternal('lastModificationDate', $objectProperties['modified_date']);
107   - $this->_setPropertyInternal('changeToken', null);
108   - $this->_setPropertyInternal('name', $objectProperties['folder_name']);
109   - $this->_setPropertyInternal('parentId', $objectProperties['parent_id']);
110   - $this->_setPropertyInternal('allowedChildObjectTypeIds', array('Document', 'Folder'));
  106 + $this->_setPropertyInternal('LastModificationDate', $objectProperties['modified_date']);
  107 + $this->_setPropertyInternal('ChangeToken', null);
  108 + $this->_setPropertyInternal('Name', $objectProperties['folder_name']);
  109 + $this->_setPropertyInternal('ParentId', $objectProperties['parent_id']);
  110 + $this->_setPropertyInternal('AllowedChildObjectTypeIds', array('Document', 'Folder'));
111 111 }
112 112  
113 113 }
... ...
ktcmis/services/CMISNavigationService.inc.php renamed to lib/api/ktcmis/services/CMISNavigationService.inc.php
... ... @@ -48,7 +48,12 @@ class CMISNavigationService {
48 48  
49 49 protected $ktapi;
50 50  
51   - function CMISNavigationService(&$ktapi)
  51 + /**
  52 + * Sets the interface to be used to query the repository
  53 + *
  54 + * @param object $ktapi The KnowledgeTree API interface
  55 + */
  56 + function setInterface(&$ktapi)
52 57 {
53 58 $this->ktapi = $ktapi;
54 59 }
... ...
ktcmis/services/CMISObjectService.inc.php renamed to lib/api/ktcmis/services/CMISObjectService.inc.php
... ... @@ -11,10 +11,10 @@ class CMISObjectService {
11 11  
12 12 protected $ktapi;
13 13  
14   - function CMISObjectService(&$ktapi)
15   - {
16   - $this->ktapi = $ktapi;
17   - }
  14 +// function CMISObjectService(&$ktapi)
  15 +// {
  16 +// $this->ktapi = $ktapi;
  17 +// }
18 18  
19 19 /**
20 20 * Fetches the properties for the specified object
... ...
ktcmis/services/CMISRepositoryService.inc.php renamed to lib/api/ktcmis/services/CMISRepositoryService.inc.php
ktcmis/util/CMISUtil.inc.php renamed to lib/api/ktcmis/util/CMISUtil.inc.php
... ... @@ -139,6 +139,7 @@ class CMISUtil {
139 139 $CMISObject = new CMISFolderObject($ktapi, $repositoryURI);
140 140 break;
141 141 }
  142 +
142 143 $CMISObject->get($object['id']);
143 144 $CMISArray[$count]['object'] = $CMISObject;
144 145  
... ... @@ -220,9 +221,13 @@ class CMISUtil {
220 221 $object = $entry['object'];
221 222 $properties = $object->getProperties();
222 223  
223   - $hierarchy[$key]['properties']['objectId'] = $properties->getValue('objectId');
224   - $hierarchy[$key]['properties']['typeId'] = $properties->getValue('typeId');
225   - $hierarchy[$key]['properties']['name'] = $properties->getValue('name');
  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']['ObjectTypeId'] = array('type' => $properties->getFieldType('ObjectTypeId'),
  228 + 'value' => $properties->getValue('ObjectTypeId'));
  229 + $hierarchy[$key]['properties']['Name'] = array('type' => $properties->getFieldType('Name'),
  230 + 'value' => $properties->getValue('Name'));
226 231  
227 232 // if we have found a child/parent with one or more children/parents, recurse into the child/parent object
228 233 if (count($entry['items']) > 0)
... ... @@ -272,6 +277,18 @@ class CMISUtil {
272 277 return $array;
273 278 }
274 279  
  280 + /**
  281 + * Converts a boolean value to string representation
  282 + * If input is not true or false, return unaltered
  283 + *
  284 + * @param boolean/other $input
  285 + * @return string
  286 + */
  287 + function boolToString($input)
  288 + {
  289 + return (($input === true) ? 'true' : (($input === false) ? 'false' : $input));
  290 + }
  291 +
275 292 }
276 293  
277 294 ?>
... ...