diff --git a/webservice/atompub/cmis/KT_cmis_atom_server.services.inc.php b/webservice/atompub/cmis/KT_cmis_atom_server.services.inc.php
new file mode 100644
index 0000000..e439971
--- /dev/null
+++ b/webservice/atompub/cmis/KT_cmis_atom_server.services.inc.php
@@ -0,0 +1,94 @@
+newEntry();
+// $feed->newField('id',$id,$entry);
+// foreach($item as $property=>$value){
+// $feed->newField($property,$value,$entry);
+// }
+// }
+// //Expose the responseFeed
+ $feed->newField('bla','bleh',$feed);
+ $this->responseFeed=$feed;
+ }
+
+ public function DELETE_action(){
+// $feed = new KT_atom_ResponseFeed_DELETE();
+// $this->responseFeed=$feed;
+ }
+}
+
+
+
+
+/**
+ * AtomPub Service: folder
+ *
+ * Returns detail on a particular folder
+ *
+ */
+class KT_atom_service_folder extends KT_atom_service {
+ public function GET_action(){
+ //Create a new response feed
+ $feed=new KT_atom_responseFeed(KT_APP_BASE_URI);
+
+ //Invoke the KtAPI to get detail about the referenced document
+ $folderDetail=KT_atom_service_helper::getFolderDetail($this->params[0]?$this->params[0]:1);
+
+ //Create the atom response feed
+ $entry=$feed->newEntry();
+ foreach($folderDetail as $property=>$value){
+ $feed->newField($property,$value,$entry);
+ }
+
+ //Expose the responseFeed
+ $this->responseFeed=$feed;
+ }
+}
+
+
+
+
+/**
+ * AtomPub Service: document
+ *
+ * Returns detail on a particular document
+ *
+ */
+class KT_atom_service_document extends KT_atom_service {
+ public function GET_action(){
+ //Create a new response feed
+ $feed=new KT_atom_responseFeed(KT_APP_BASE_URI);
+
+ //Invoke the KtAPI to get detail about the referenced document
+ $docDetail=KT_atom_service_helper::getDocumentDetail($this->params[0]);
+
+ //Create the atom response feed
+ $entry=$feed->newEntry();
+ foreach($docDetail['results'] as $property=>$value){
+ $feed->newField($property,$value,$entry);
+ }
+ //Add a downloaduri field manually
+ $feed->newField('downloaduri',urlencode(KT_APP_SYSTEM_URI.'/action.php?kt_path_info=ktcore.actions.document.view&fDocumentId='.$docDetail['results']['document_id']),$entry);
+
+ //Expose the responseFeed
+ $this->responseFeed=$feed;
+ }
+}
+?>
\ No newline at end of file
diff --git a/webservice/atompub/cmis/NavigationService.inc.php b/webservice/atompub/cmis/NavigationService.inc.php
new file mode 100644
index 0000000..fe47e18
--- /dev/null
+++ b/webservice/atompub/cmis/NavigationService.inc.php
@@ -0,0 +1,124 @@
+
diff --git a/webservice/atompub/cmis/ObjectFeed.inc.php b/webservice/atompub/cmis/ObjectFeed.inc.php
new file mode 100644
index 0000000..5c8d4f4
--- /dev/null
+++ b/webservice/atompub/cmis/ObjectFeed.inc.php
@@ -0,0 +1,92 @@
+newEntry();
+ $feed->newId('urn:uuid:' . $cmisEntry['properties']['Name']['value'] . '-'
+ . strtolower($cmisEntry['properties']['ObjectTypeId']['value']), $entry);
+
+ /*
+
+
+
+ */
+
+ // links
+// $link = $feed->newElement('link');
+// $link->appendChild($feed->newAttr('rel','self'));
+// $link->appendChild($feed->newAttr('href', CMIS_BASE_URI . strtolower($cmisEntry['properties']['ObjectTypeId']['value'])
+// . '/' . $cmisEntry['properties']['ObjectId']['value']));
+// $entry->appendChild($link);
+ $link = $feed->newElement('link');
+ $link->appendChild($feed->newAttr('rel','cmis-parent'));
+ $link->appendChild($feed->newAttr('href', CMIS_BASE_URI . 'folder/' . $path));
+ $entry->appendChild($link);
+
+ if (strtolower($cmisEntry['properties']['ObjectTypeId']['value']) == 'folder')
+ {
+ $link = $feed->newElement('link');
+ $link->appendChild($feed->newAttr('rel','cmis-folderparent'));
+ $link->appendChild($feed->newAttr('href', CMIS_BASE_URI . 'folder/' . $path));
+ $entry->appendChild($link);
+ $link = $feed->newElement('link');
+ $link->appendChild($feed->newAttr('rel','cmis-children'));
+ $link->appendChild($feed->newAttr('href', CMIS_BASE_URI
+ . strtolower($cmisEntry['properties']['ObjectTypeId']['value'])
+ . '/' . $path . '/' . urlencode($cmisEntry['properties']['Name']['value'])
+ . '/children'));
+ $entry->appendChild($link);
+ $link = $feed->newElement('link');
+ $link->appendChild($feed->newAttr('rel','cmis-descendants'));
+ $link->appendChild($feed->newAttr('href', CMIS_BASE_URI
+ . strtolower($cmisEntry['properties']['ObjectTypeId']['value'])
+ . '/' . $path . '/' . urlencode($cmisEntry['properties']['Name']['value'])
+ . '/descendants'));
+ $entry->appendChild($link);
+ }
+
+ $link = $feed->newElement('link');
+ $link->appendChild($feed->newAttr('rel','cmis-type'));
+ $link->appendChild($feed->newAttr('href', CMIS_BASE_URI . 'type/' . strtolower($cmisEntry['properties']['ObjectTypeId']['value'])));
+ $entry->appendChild($link);
+ $link = $feed->newElement('link');
+ $link->appendChild($feed->newAttr('rel','cmis-repository'));
+ $link->appendChild($feed->newAttr('href', CMIS_BASE_URI . 'repository'));
+ $entry->appendChild($link);
+ // end links
+
+ $entry->appendChild($feed->newElement('summary', $cmisEntry['properties']['Name']['value']));
+ $entry->appendChild($feed->newElement('title', $cmisEntry['properties']['Name']['value']));
+
+ // main CMIS entry
+ $objectElement = $feed->newElement('cmis:object');
+ $propertiesElement = $feed->newElement('cmis:properties');
+
+ foreach($cmisEntry['properties'] as $propertyName => $property)
+ {
+ $propElement = $feed->newElement('cmis:' . $property['type']);
+ $propElement->appendChild($feed->newAttr('cmis:name', $propertyName));
+ $feed->newField('value', CMISUtil::boolToString($property['value']), $propElement);
+ $propertiesElement->appendChild($propElement);
+ }
+
+ $objectElement->appendChild($propertiesElement);
+ $entry->appendChild($objectElement);
+ }
+
+}
+
+?>
diff --git a/webservice/atompub/cmis/ObjectService.inc.php b/webservice/atompub/cmis/ObjectService.inc.php
new file mode 100644
index 0000000..728de1f
--- /dev/null
+++ b/webservice/atompub/cmis/ObjectService.inc.php
@@ -0,0 +1,37 @@
+
diff --git a/webservice/atompub/cmis/RepositoryService.inc.php b/webservice/atompub/cmis/RepositoryService.inc.php
new file mode 100644
index 0000000..55a3a80
--- /dev/null
+++ b/webservice/atompub/cmis/RepositoryService.inc.php
@@ -0,0 +1,85 @@
+
diff --git a/webservice/atompub/cmis/index.php b/webservice/atompub/cmis/index.php
new file mode 100644
index 0000000..9af9909
--- /dev/null
+++ b/webservice/atompub/cmis/index.php
@@ -0,0 +1,127 @@
+.
+ *
+ * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
+ * California 94120-7775, or email info@knowledgetree.com.
+ *
+ * The interactive user interfaces in modified source and object code versions
+ * of this program must display Appropriate Legal Notices, as required under
+ * Section 5 of the GNU General Public License version 3.
+ *
+ * In accordance with Section 7(b) of the GNU General Public License version 3,
+ * these Appropriate Legal Notices must retain the display of the "Powered by
+ * KnowledgeTree" logo and retain the original copyright notice. If the display of the
+ * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
+ * Contributor( s):
+ * Mark Holtzhausen
+ * Paul Barrett
+ *
+ */
+
+require_once('../../../config/dmsDefaults.php');
+//include_once('lib/cmis/KTCMISAPPFeed.inc.php');
+
+define('KT_APP_BASE_URI', "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/?/');
+define('KT_APP_SYSTEM_URI', "http://".$_SERVER['HTTP_HOST']);
+define('KT_ATOM_LIB_FOLDER', '../../classes/atompub/');
+//echo KT_ATOM_LIB_FOLDER.'KT_atom_server.inc.php';exit;
+define ('CMIS_APP_BASE_URI', trim(KT_APP_BASE_URI, '/'));
+define('CMIS_APP_SYSTEM_URI', KT_APP_SYSTEM_URI);
+define ('CMIS_ATOM_LIB_FOLDER', trim(KT_ATOM_LIB_FOLDER, '/') . '/cmis/');
+
+// fetch username and password for auth; note that this apparently only works when PHP is run as an apache module
+// TODO method to fetch username and password when running PHP as CGI, if possible
+// HTTP Basic Auth:
+$username = $_SERVER['PHP_AUTH_USER'];
+$password = $_SERVER['PHP_AUTH_PW'];
+
+/**
+ * Includes
+ */
+include_once(CMIS_ATOM_LIB_FOLDER.'KT_cmis_atom_server.inc.php');
+include_once(CMIS_ATOM_LIB_FOLDER.'KT_cmis_atom_baseDoc.inc.php');
+include_once(CMIS_ATOM_LIB_FOLDER.'KT_cmis_atom_responseFeed.inc.php'); //Containing the response feed class allowing easy atom feed generation
+include_once(CMIS_ATOM_LIB_FOLDER.'KT_cmis_atom_serviceDoc.inc.php'); //Containing the servicedoc class allowing easy ServiceDocument generation
+include_once(CMIS_ATOM_LIB_FOLDER.'KT_cmis_atom_service.inc.php'); //Containing the servicedoc class allowing easy ServiceDocument generation
+
+include_once('KT_cmis_atom_server.services.inc.php');
+
+
+//Start the AtomPubProtocol Routing Engine
+$APP = new KT_cmis_atom_server();
+$APP->initServiceDocument();
+$APP->addWorkspaceTag('dms','atom:title','KnowledgeTree DMS');
+/**
+ * Register Services
+ *
+ * Registered services are classes extended from KT_atom_service
+ * The registration process takes the following parameters
+ * Workspace :The workspace within which the service collection will be grouped
+ * ServiceName :This is the name by which the service/collection is exposed
+ * ServiceClass :This is the class name of the class to be instantiated when this service is accessed
+ * Title :This is the title given to the service/collection in the servicedocument
+ * http://ktatompub/index.php?/service/param1/param2
+ * http://ktatompub/?/folder/children/whatfoldertolookat
+ * http://ktatompub/{folder/folder2/folder3/}service/param1/param2
+*/
+$APP->registerService('dms', 'folder', 'KT_cmis_atom_service_folder', 'Root Folder Children Collection', array($APP->repositoryInfo['rootFolderId'], 'children'), 'root-children');
+$APP->registerService('dms', 'folder', 'KT_cmis_atom_service_folder', 'Root Folder Children Collection', array($APP->repositoryInfo['rootFolderId'], 'descendants'), 'root-descendants');
+$APP->registerService('dms', 'checkedout', 'KT_cmis_atom_service_checkedout', 'Checked Out Document Collection', null, 'checkedout');
+$APP->registerService('dms', 'types', 'KT_cmis_atom_service_types', 'Object Type Collection', null, 'types-children');
+$APP->registerService('dms', 'types', 'KT_cmis_atom_service_types', 'Object Type Collection', null, 'types-descendants');
+
+//Execute the current url/header request
+$APP->execute();
+
+//echo '
'.print_r($APP,true).'
';
+
+//Render the resulting feed response
+$APP->render();
+
+// TODO response if failed auth, need generic response which can be used by all code
+
+//$arg = (isset($query[1]) ? $query[1] : '');
+//
+//switch($arg)
+//{
+// case 'checkedout':
+// include('services/cmis/checkedout.inc.php');
+// break;
+// case 'document':
+// include('services/cmis/document.inc.php');
+// break;
+// case 'folder':
+// include('services/cmis/folder.inc.php');
+// break;
+// case 'type':
+// case 'types':
+// include('services/cmis/types.inc.php');
+// break;
+// case 'repository':
+// default:
+// include('services/cmis/servicedocument.inc.php');
+// break;
+//}
+
+?>
diff --git a/webservice/classes/atompub/cmis/KT_cmis_atom_baseDoc.inc.php b/webservice/classes/atompub/cmis/KT_cmis_atom_baseDoc.inc.php
new file mode 100644
index 0000000..fc24e21
--- /dev/null
+++ b/webservice/classes/atompub/cmis/KT_cmis_atom_baseDoc.inc.php
@@ -0,0 +1,53 @@
+.
+ *
+ * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
+ * California 94120-7775, or email info@knowledgetree.com.
+ *
+ * The interactive user interfaces in modified source and object code versions
+ * of this program must display Appropriate Legal Notices, as required under
+ * Section 5 of the GNU General Public License version 3.
+ *
+ * In accordance with Section 7(b) of the GNU General Public License version 3,
+ * these Appropriate Legal Notices must retain the display of the "Powered by
+ * KnowledgeTree" logo and retain the original copyright notice. If the display of the
+ * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
+ * Contributor( s):
+ * Mark Holtzhausen
+ * Paul Barrett
+ *
+ */
+
+/**
+ * Includes
+ */
+
+include_once(KT_ATOM_LIB_FOLDER.'KT_atom_baseDoc.inc.php'); //Containing the parent class allowing easy XML manipulation
+
+class KT_cmis_atom_baseDoc extends KT_atom_baseDoc {
+
+ // override and extend as needed
+
+}
+
+?>
\ No newline at end of file
diff --git a/webservice/classes/atompub/cmis/KT_cmis_atom_responseFeed.inc.php b/webservice/classes/atompub/cmis/KT_cmis_atom_responseFeed.inc.php
new file mode 100644
index 0000000..3e0ffa9
--- /dev/null
+++ b/webservice/classes/atompub/cmis/KT_cmis_atom_responseFeed.inc.php
@@ -0,0 +1,16 @@
+
\ No newline at end of file
diff --git a/webservice/classes/atompub/cmis/KT_cmis_atom_server.inc.php b/webservice/classes/atompub/cmis/KT_cmis_atom_server.inc.php
new file mode 100644
index 0000000..03db4a8
--- /dev/null
+++ b/webservice/classes/atompub/cmis/KT_cmis_atom_server.inc.php
@@ -0,0 +1,107 @@
+getRepositories();
+ // fetch for default first repo; NOTE that this will probably have to change at some point, quick and dirty for now
+ $this->repositoryInfo = $RepositoryService->getRepositoryInfo($repositories[0]['repositoryId']);
+ }
+ }
+
+ 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 . 'folder/' . $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'], $ws);
+ }
+ }
+ }
+
+ $this->output = $service->getAPPdoc();
+ }
+
+ public function registerService($workspace = NULL, $serviceName = NULL, $serviceClass = NULL, $title = NULL,
+ $serviceParameters = NULL, $collectionType = NULL)
+ {
+ $workspace = strtolower(trim($workspace));
+ $serviceName = strtolower(trim($serviceName));
+
+ $serviceRecord = array(
+ 'fileName' => $fileName,
+ 'serviceClass' => $serviceClass,
+ 'title' => $title,
+ 'parameters' => $serviceParameters,
+ 'collectionType' => $collectionType
+ );
+
+ $this->services[$workspace][$serviceName][] = $serviceRecord;
+ }
+
+}
+
+?>
\ No newline at end of file
diff --git a/webservice/classes/atompub/cmis/KT_cmis_atom_service.inc.php b/webservice/classes/atompub/cmis/KT_cmis_atom_service.inc.php
new file mode 100644
index 0000000..26225ab
--- /dev/null
+++ b/webservice/classes/atompub/cmis/KT_cmis_atom_service.inc.php
@@ -0,0 +1,10 @@
+
\ No newline at end of file
diff --git a/webservice/classes/atompub/cmis/KT_cmis_atom_serviceDoc.inc.php b/webservice/classes/atompub/cmis/KT_cmis_atom_serviceDoc.inc.php
new file mode 100644
index 0000000..082535e
--- /dev/null
+++ b/webservice/classes/atompub/cmis/KT_cmis_atom_serviceDoc.inc.php
@@ -0,0 +1,125 @@
+.
+ *
+ * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
+ * California 94120-7775, or email info@knowledgetree.com.
+ *
+ * The interactive user interfaces in modified source and object code versions
+ * of this program must display Appropriate Legal Notices, as required under
+ * Section 5 of the GNU General Public License version 3.
+ *
+ * In accordance with Section 7(b) of the GNU General Public License version 3,
+ * these Appropriate Legal Notices must retain the display of the "Powered by
+ * KnowledgeTree" logo and retain the original copyright notice. If the display of the
+ * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
+ * must display the words "Powered by KnowledgeTree" and retain the original
+ * copyright notice.
+ * Contributor( s):
+ * Mark Holtzhausen
+ * Paul Barrett
+ *
+ */
+
+
+/**
+ * Includes
+ */
+include_once(KT_ATOM_LIB_FOLDER.'KT_atom_serviceDoc.inc.php');
+//include_once('KT_atom_baseDoc.inc.php');
+
+class KT_cmis_atom_serviceDoc extends KT_atom_serviceDoc {
+
+ // override and extend as needed
+
+ public $repositoryInfo = array();
+
+ public function __construct($baseURI = NULL)
+ {
+ parent::__construct();
+
+ // get repositoryInfo
+ // NOTE currently we only support one repository, which will be the first one found in the repositories.xml config
+ // TODO multiple repositories as individual workspaces
+
+ include 'services/cmis/RepositoryService.inc.php';
+ $RepositoryService = new RepositoryService();
+
+ // fetch data for response
+ $repositories = $RepositoryService->getRepositories();
+ // fetch for default first repo; NOTE that this will probably have to change at some point, quick and dirty for now
+ $this->repositoryInfo = $RepositoryService->getRepositoryInfo($repositories[0]['repositoryId']);
+ }
+
+ protected function constructServiceDocumentHeaders()
+ {
+ $service = $this->newElement('service');
+ $service->appendChild($this->newAttr('xmlns', 'http://www.w3.org/2007/app'));
+ $service->appendChild($this->newAttr('xmlns:atom', 'http://www.w3.org/2005/Atom'));
+ $service->appendChild($this->newAttr('xmlns:cmis', 'http://www.cmis.org/2008/05'));
+ $this->service =& $service;
+ $this->DOM->appendChild($this->service);
+ }
+
+ public function &newCollection($url = NULL, $title = NULL, $cmisCollectionType = NULL, &$ws = NULL)
+ {
+ $collection=$this->newElement('collection');
+ $collection->appendChild($this->newAttr('href', $url));
+ $collection->appendChild($this->newAttr('cmis:collectionType', $cmisCollectionType));
+ $collection->appendChild($this->newElement('atom:title', $title));
+ if(isset($ws))$ws->appendChild($collection);
+ return $collection;
+ }
+
+}
+
+/**
+
+
+
+ Main Site
+
+ My Blog Entries
+
+
+
+ Pictures
+ image/png
+ image/jpeg
+ image/gif
+
+
+
+ Sidebar Blog
+
+ Remaindered Links
+ application/atom+xml;type=entry
+
+
+
+
+
+
+
+
+ */
+
+
+?>
\ No newline at end of file