function getChildren($repositoryId, $folderId, $includeAllowableActions, $includeRelationships, $typeId = 'Any', $filter = '', $maxItems = 0, $skipCount = 0) { // TODO paging // TODO optional parameters $children = array(); $repository = new CMISRepository($repositoryId); // if this is not a folder, cannot get children $folderId = CMISUtil::decodeObjectId($folderId, $type); // NOTE this will quite possibly break the webservices if ($type != 'Folder') { return $children; } $folder = $this->ktapi->get_folder_by_id($folderId); $children = $folder->get_listing(); $children = CMISUtil::createChildObjectHierarchy($children, $repository->getRepositoryURI, $this->ktapi); return $children; }
/** * Takes an array of KnowledgeTree KTAPI objects and returns an array of CMIS objects of the same type * * Utilises the descending structure already present within KTAPI * * @param array $input * @param string $repositoryURI * @param object $ktapi // reference to ktapi instance * @return array $CMISArray */ public static function createChildObjectHierarchy($input, $repositoryURI, &$ktapi) { $CMISArray = array(); $count = -1; foreach ($input as $object) { ++$count; if (is_array($object)) { if (isset($object['id'])) { switch ($object['item_type']) { case 'D': $CMISObject = new CMISDocumentObject($object['id'], $ktapi, $repositoryURI); break; case 'F': $CMISObject = new CMISFolderObject($object['id'], $ktapi, $repositoryURI); break; } $CMISArray[$count]['object'] = $CMISObject; // if sub-array if (count($object['items']) > 0) { $CMISArray[$count]['items'] = CMISUtil::createChildObjectHierarchy($object['items'], $repositoryURI, $ktapi); } } else { // NOTE why is this necessary? That's what you get for not commenting it at the time // TODO comment this properly $CMISArray[$count] = CMISUtil::createChildObjectHierarchy($object, $repositoryURI, $ktapi); } } } return $CMISArray; }