public function serviceDocument() { $service = new KT_cmis_atom_serviceDoc(KT_APP_BASE_URI); foreach ($this->services as $workspace => $collection) { //Creating the Default Workspace for use with standard atomPub Clients $ws = $service->newWorkspace(); $hadDetail = false; if (isset($this->workspaceDetail[$workspace])) { if (is_array($this->workspaceDetail[$workspace])) { foreach ($this->workspaceDetail[$workspace] as $wsTag => $wsValue) { $ws->appendChild($service->newElement($wsTag, $wsValue)); $hadDetail = true; } } } if (!$hadDetail) { $ws->appendChild($service->newElement('atom:title', $workspace)); } $ws->appendChild($service->newAttr('cmis:repositoryRelationship', $this->repositoryInfo['repositoryRelationship'])); // repository information $element = $service->newElement('cmis:repositoryInfo'); foreach ($this->repositoryInfo as $key => $repoData) { if ($key == 'rootFolderId') { $repoData = CMIS_APP_BASE_URI . $workspace . '/folder/' . rawurlencode($repoData); } if (!is_array($repoData)) { $element->appendChild($service->newElement('cmis:' . $key, $repoData)); } else { $elementSub = $service->newElement('cmis:' . $key); foreach ($repoData as $key2 => $data) { $elementSub->appendChild($service->newElement('cmis:' . $key2, CMISUtil::boolToString($data))); } $element->appendChild($elementSub); } } $ws->appendChild($element); foreach ($collection as $serviceName => $serviceInstance) { foreach ($serviceInstance as $instance) { $collectionStr = CMIS_APP_BASE_URI . $workspace . '/' . $serviceName . '/' . (is_array($instance['parameters']) ? implode('/', $instance['parameters']) . '/' : ''); $col = $service->newCollection($collectionStr, $instance['title'], $instance['collectionType'], $instance['accept'], $ws); } } } $this->output = $service->getAPPdoc(); }
/** * Retrieves the list of types|type definition as a CMIS AtomPub feed * * @param string $typeDef Type requested - 'All Types' indicates a listing, else only a specific type * @param array $types The types found * @return string CMIS AtomPub feed */ public static function getTypeFeed($typeDef, $types) { $typesString = ''; $typesHeading = ''; switch ($typeDef) { case 'all': case 'children': case 'descendants': $typesString = 'types-' . $typeDef; $typesHeading = 'All Types'; break; default: $typesString = 'type-' . $typeDef; $typesHeading = $typeDef; break; } //Create a new response feed $feed = new KT_cmis_atom_responseFeed_GET(CMIS_APP_BASE_URI); $workspace = $feed->getWorkspace(); $feed->newField('title', $typesHeading, $feed); $feed->newField('id', 'urn:uuid:' . $typesString, $feed); // TODO set page number correctly - to be done when we support paging the the API // author // TODO generate this dynamically (based on???)\ $feedElement = $feed->newField('author'); $element = $feed->newField('name', 'admin', $feedElement); $feed->appendChild($feedElement); // NOTE spec says this link MUST be present but is vague on where it points // as of 0.61c: // "The source link relation points to the underlying CMIS Type Definition as Atom Entry" // so what is the underlying CMIS Type Definition for a collection of base types? // suspect that it only applies when not listing all types, i.e. a base type is asked for /* $link = $feed->newElement('link'); $link->appendChild($feed->newAttr('rel','source')); $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/type/' . strtolower($type['typeId']))); $feed->appendChild($link); */ // current time: format = 2009-07-13T14:49:27.659+02:00 $feed->appendChild($feed->newElement('updated', self::formatDatestamp())); foreach ($types as $type) { $entry = $feed->newEntry(); $feedElement = $feed->newField('author'); $element = $feed->newField('name', 'admin', $feedElement); $entry->appendChild($feedElement); $feedElement = $feed->newField('content', $type['typeId']); $entry->appendChild($feedElement); $feed->newField('id', 'urn:uuid:type-' . $type['typeId'], $feed); // TODO add parents link when not selecting a base type. // TODO add children link when type has children // TODO add descendants link when type has children // NOTE KnowledgeTree currently only supports base types so these are not important at the present time. // links $link = $feed->newElement('link'); $link->appendChild($feed->newAttr('rel', 'self')); $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/type/' . strtolower($type['typeId']))); $entry->appendChild($link); // TODO type link MUST point to base type // KnowledgeTree currently only supports base types so this is not important // at the present time as it will always point at the base type. $link = $feed->newElement('link'); $link->appendChild($feed->newAttr('rel', 'type')); $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . $workspace . '/type/' . strtolower($type['typeId']))); $entry->appendChild($link); $link = $feed->newElement('link'); $link->appendChild($feed->newAttr('rel', 'repository')); $link->appendChild($feed->newAttr('href', CMIS_APP_BASE_URI . '/servicedocument')); $entry->appendChild($link); $entry->appendChild($feed->newElement('summary', $type['typeId'] . ' Type')); $entry->appendChild($feed->newElement('title', $type['typeId'])); $entry->appendChild($feed->newElement('updated', self::formatDatestamp())); // main CMIS entry $feedElement = $feed->newElement('cmis:' . strtolower($type['typeId']) . 'Type'); foreach ($type as $property => $value) { $feed->newField('cmis:' . $property, CMISUtil::boolToString($value), $feedElement); } $entry->appendChild($feedElement); // after every entry, append a cmis:terminator tag $entry->appendChild($feed->newElement('cmis:terminator')); } return $feed; }