diff --git a/ktatompub/Client/index.html b/ktatompub/Client/index.html index fae0993..d7c2442 100644 --- a/ktatompub/Client/index.html +++ b/ktatompub/Client/index.html @@ -20,7 +20,7 @@ - + - + */ this.libraries={ @@ -51,7 +51,7 @@ site=new function(){ 'js/ui/ui.core.js' :'jQuery UI Core', 'js/ui/ui.tabs.js' :'jQuery UI Tabs Plugin', 'js/jquery.dynatree.min.js' :'jQuery DynaTree Tree Menu Plugin', - 'js/ktApp.js' :'KT Atom Publishing Protocol Library' + 'js/KT_atom_server.js' :'KT Atom Publishing Protocol Library' } this.init=function(){ diff --git a/ktatompub/auth.php b/ktatompub/auth.php index f76ac4b..d0a8da8 100644 --- a/ktatompub/auth.php +++ b/ktatompub/auth.php @@ -42,7 +42,7 @@ * TODO: Thest HTTP Basic Auth - Try Library From Home */ -$SessionId=KTAPPHelper::login('admin','admin'); +$SessionId=KT_atom_service_helper::login('admin','admin'); $SessionId=$SessionId['session_id']; diff --git a/ktatompub/index.php b/ktatompub/index.php index 94b3aef..1809161 100644 --- a/ktatompub/index.php +++ b/ktatompub/index.php @@ -57,6 +57,7 @@ ob_start(); 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','lib/'); // Define whether to use in debug mode for viewing generated structures //define('KT_APP_WEB_OUTPUT',false); //defunct @@ -67,37 +68,38 @@ define('KT_APP_SYSTEM_URI',"http://".$_SERVER['HTTP_HOST']); * Includes */ include_once('../ktapi/ktapi.inc.php'); -include_once('lib/ktAPP.inc.php'); -include_once('lib/KTAPPHelper.inc.php'); //Containing helper bridge functions to KtAPI -include_once('lib/KTAPDoc.inc.php'); //Containing the parent class allowing easy XML manipulation -include_once('lib/KTAPPServiceDoc.inc.php'); //Containing the servicedoc class allowing easy ServiceDocument generation -include_once('lib/KTAPPFeed.inc.php'); //Containing the response feed class allowing easy atom feed generation -include_once('lib/KTAPP_ResponseFeed.inc.php'); //Containing the response feed class allowing easy atom feed generation -include_once('lib/ktAPP_Service.inc.php'); -include_once('lib/ktApp.default_dms_services.inc.php'); +include_once(KT_ATOM_LIB_FOLDER.'KT_atom_server.inc.php'); +include_once(KT_ATOM_LIB_FOLDER.'KT_atom_service_helper.inc.php'); //Containing helper bridge functions to KtAPI +include_once(KT_ATOM_LIB_FOLDER.'KT_atom_baseDoc.inc.php'); //Containing the parent class allowing easy XML manipulation +include_once(KT_ATOM_LIB_FOLDER.'KT_atom_serviceDoc.inc.php'); //Containing the servicedoc class allowing easy ServiceDocument generation +include_once(KT_ATOM_LIB_FOLDER.'KT_atom_responseFeed.inc.php'); //Containing the response feed class allowing easy atom feed generation +include_once(KT_ATOM_LIB_FOLDER.'KT_atom_service.inc.php'); +include_once(KT_ATOM_LIB_FOLDER.'KT_atom_server.default_dms_services.inc.php'); include_once('auth.php'); //Containing the authentication protocols //Start the AtomPubProtocol Routing Engine -$APP=new KTAPP(); +$APP=new KT_atom_server(); /** * Register Services * - * Registered services are classes extended from ktAPP_Service + * 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 */ -$APP->registerService('DMS','fulltree','ktAPP_Service_fullTree','Full Document Tree'); -$APP->registerService('DMS','folder','ktAPP_Service_folder','Folder Detail'); -$APP->registerService('DMS','document','ktAPP_Service_document','Document Detail'); +$APP->registerService('DMS','fulltree','KT_atom_service_fulltree','Full Document Tree'); +$APP->registerService('DMS','folder','KT_atom_service_folder','Folder Detail'); +$APP->registerService('DMS','document','KT_atom_service_document','Document Detail'); //Execute the current url/header request $APP->execute(); +//echo '
'.print_r($APP,true).''; + //Render the resulting feed response $APP->render(); diff --git a/ktatompub/lib/KTAPDoc.inc.php b/ktatompub/lib/KT_atom_baseDoc.inc.php index 22e2d86..fd6670b 100644 --- a/ktatompub/lib/KTAPDoc.inc.php +++ b/ktatompub/lib/KT_atom_baseDoc.inc.php @@ -41,7 +41,7 @@ * Includes */ -class KTAPDoc{ +class KT_atom_baseDoc{ const XML_ENCODING='utf-8'; const XML_VERSION='1.0'; diff --git a/ktatompub/lib/KT_atom_responseFeed.inc.php b/ktatompub/lib/KT_atom_responseFeed.inc.php new file mode 100644 index 0000000..fa64117 --- /dev/null +++ b/ktatompub/lib/KT_atom_responseFeed.inc.php @@ -0,0 +1,45 @@ +constructHeader(); + $this->baseURI=$baseURI; + } + + private function constructHeader(){ + $feed=$this->newElement('feed'); + $feed->appendChild($this->newAttr('xmlns','http://www.w3.org/2005/Atom')); + $this->feed=&$feed; + $this->DOM->appendChild($this->feed); + } + + public function &newEntry(){ + $entry=$this->newElement('entry'); + $this->feed->appendChild($entry); + return $entry; + } + + public function &newField($name=NULL,$value=NULL,&$attachToNode=NULL){ + $field=$this->newElement($name,$value); + if(isset($attachToNode))$attachToNode->appendChild($field); + return $field; + } + + public function render(){ + return $this->formatXmlString(trim($this->DOM->saveXML())); + } + + +} + +class KT_atom_ResponseFeed_GET extends KT_atom_responseFeed{} +class KT_atom_ResponseFeed_PUT extends KT_atom_responseFeed{} +class KT_atom_ResponseFeed_POST extends KT_atom_responseFeed{} +class KT_atom_ResponseFeed_DELETE extends KT_atom_responseFeed{} + +?> \ No newline at end of file diff --git a/ktatompub/lib/ktApp.default_dms_services.inc.php b/ktatompub/lib/KT_atom_server.default_dms_services.inc.php index 917e3a4..423b733 100644 --- a/ktatompub/lib/ktApp.default_dms_services.inc.php +++ b/ktatompub/lib/KT_atom_server.default_dms_services.inc.php @@ -6,13 +6,13 @@ * Tree structure obtained by referencing parent id * */ -class ktAPP_Service_fullTree extends ktAPP_Service { +class KT_atom_service_fulltree extends KT_atom_service { public function GET_action(){ //Create a new response feed - $feed=new KTAPPFeed(KT_APP_BASE_URI); + $feed=new KT_atom_ResponseFeed_GET(KT_APP_BASE_URI); //Invoke the KtAPI to get detail about the referenced document - $tree=KTAPPHelper::getFullTree(); + $tree=KT_atom_service_helper::getFullTree(); //Create the atom response feed foreach($tree as $item){ @@ -28,7 +28,7 @@ class ktAPP_Service_fullTree extends ktAPP_Service { } public function DELETE_action(){ - $feed = new ktAPP_ResponseFeed_DELETE(); + $feed = new KT_atom_ResponseFeed_DELETE(); $this->responseFeed=$feed; } } @@ -42,13 +42,13 @@ class ktAPP_Service_fullTree extends ktAPP_Service { * Returns detail on a particular folder * */ -class ktAPP_Service_folder extends ktAPP_Service { +class KT_atom_service_folder extends KT_atom_service { public function GET_action(){ //Create a new response feed - $feed=new KTAPPFeed(KT_APP_BASE_URI); + $feed=new KT_atom_responseFeed(KT_APP_BASE_URI); //Invoke the KtAPI to get detail about the referenced document - $folderDetail=KTAPPHelper::getFolderDetail($this->params[0]?$this->params[0]:1); + $folderDetail=KT_atom_service_helper::getFolderDetail($this->params[0]?$this->params[0]:1); //Create the atom response feed $entry=$feed->newEntry(); @@ -70,13 +70,13 @@ class ktAPP_Service_folder extends ktAPP_Service { * Returns detail on a particular document * */ -class ktAPP_Service_document extends ktAPP_Service { +class KT_atom_service_document extends KT_atom_service { public function GET_action(){ //Create a new response feed - $feed=new KTAPPFeed(KT_APP_BASE_URI); + $feed=new KT_atom_responseFeed(KT_APP_BASE_URI); //Invoke the KtAPI to get detail about the referenced document - $docDetail=KTAPPHelper::getDocumentDetail($this->params[0]); + $docDetail=KT_atom_service_helper::getDocumentDetail($this->params[0]); //Create the atom response feed $entry=$feed->newEntry(); diff --git a/ktatompub/lib/ktAPP.inc.php b/ktatompub/lib/KT_atom_server.inc.php index 56fd1cc..7ba14cf 100644 --- a/ktatompub/lib/ktAPP.inc.php +++ b/ktatompub/lib/KT_atom_server.inc.php @@ -1,12 +1,17 @@ -queryArray=$queryArray; $this->serviceName=$service; - + $this->method=$reqMethod; + $this->workspace=$workspace; + if($workspace=='servicedocument'){ $this->serviceDocument(); return; } - + $service=$this->getRegisteredService($workspace,$serviceName); - if(is_array($service)){ $serviceClass=$service['serviceClass']; + echo 'made it'; $serviceObject=new $serviceClass($reqMethod,$requestParams,$rawRequest); $this->output=$serviceObject->render(); }else{ - echo "Could not find service:{$service['serviceFunc']} in $workspace"; //TODO: ERROR HERE + $serviceObject=new KT_atom_service($requestParams,$rawRequest); + $serviceObject->setStatus(KT_atom_service::STATUS_NOT_FOUND); + $this->output=$serviceObject->render(); } } public function registerService($workspace=NULL,$serviceName=NULL,$serviceClass=NULL,$title=NULL){ $workspace=strtolower(trim($workspace)); $serviceName=strtolower(trim($serviceName)); - + $serviceRecord=array( 'fileName' =>$fileName, 'serviceClass' =>$serviceClass, 'title' =>$title ); - + $this->services[$workspace][$serviceName]=$serviceRecord; } - + public function getRegisteredService($workspace,$serviceName=NULL){ $serviceName=strtolower(trim($serviceName)); if(isset($this->services[$workspace][$serviceName]))return $this->services[$workspace][$serviceName]; return false; } - + public function serviceDocument(){ - $service=new KTAPPServiceDoc(KT_APP_BASE_URI); - + $service=new KT_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($workspace); - + foreach($collection as $serviceName=>$serviceInstance){ $col=$service->newCollection(KT_APP_BASE_URI.$workspace.'/'.$serviceName.'/',$serviceInstance['title'],$ws); } } - + $this->output=$service->getAPPdoc(); } diff --git a/ktatompub/lib/KtAPP_Service.inc.php b/ktatompub/lib/KT_atom_service.inc.php index 459464f..511992f 100644 --- a/ktatompub/lib/KtAPP_Service.inc.php +++ b/ktatompub/lib/KT_atom_service.inc.php @@ -1,12 +1,12 @@ method=$method; $this->params=$params; $this->rawContent=$content; - $this->parsedXMLContent=json_decode(json_encode(@simplexml_load_string($this->rawContent)),true); + $this->parseHeaders(); + $this->parsedXMLContent=$this->xml2array($this->rawContent); $this->setStatus(self::STATUS_OK); - $this->responseFeed=new KTAPPFeed(KT_APP_BASE_URI); + $this->responseFeed=new KT_atom_responseFeed(KT_APP_BASE_URI); switch(strtoupper($this->method)){ case 'GET': $this->GET_action();break; case 'PUT': $this->PUT_action();break; case 'POST': $this->POST_action();break; case 'DELETE': $this->DELETE_action();break; + default: $this->UNSUPPORTED_action();break; } } public function GET_action(){ - $this->setStatus(ktAPP_Service::STATUS_OK); + $this->setStatus(KT_atom_service::STATUS_OK); } public function PUT_action(){ - $this->setStatus(ktAPP_Service::STATUS_NOT_FOUND ); + $this->setStatus(KT_atom_service::STATUS_NOT_FOUND ); } public function POST_action(){ - $this->setStatus(ktAPP_Service::STATUS_NOT_FOUND ); + $this->setStatus(KT_atom_service::STATUS_NOT_FOUND ); } public function DELETE_action(){ - $this->setStatus(ktAPP_Service::STATUS_NOT_FOUND ); + $this->setStatus(KT_atom_service::STATUS_NOT_FOUND ); + } + + public function UNSUPPORTED_action(){ + $this->setStatus(KT_atom_service::STATUS_NOT_FOUND ); } @@ -53,11 +59,26 @@ class ktAPP_Service{ return $this->responseFeed->render(); } - private function parseHeaders(){ + private function xml2array($xml){ + $array=json_decode(json_encode(@simplexml_load_string($xml)),true); //TODO - XML2ARRAY Translation + return $array; + } + private function parseHeaders(){ + $headers=null; + if(function_exists('http_get_request_headers')){ //Try to use pcre_http library if it exists + $headers=http_get_request_headers(); + }else{ + if(function_exists('apache_request_headers')){ //If not: try to use apache specific headers + $headers=apache_request_headers(); + }else{ //If not: not supported - empty headers + $headers=array(); + } + } + $this->headers=$headers; } - private function setStatus($status=NULL){ + public function setStatus($status=NULL){ header("HTTP/1.1 ".$status); } @@ -65,6 +86,5 @@ class ktAPP_Service{ if($etagValue)header('ETag: '.$etagValue); } - } ?> \ No newline at end of file diff --git a/ktatompub/lib/KTAPPServiceDoc.inc.php b/ktatompub/lib/KT_atom_serviceDoc.inc.php index 5fd44b0..2fa2d37 100644 --- a/ktatompub/lib/KTAPPServiceDoc.inc.php +++ b/ktatompub/lib/KT_atom_serviceDoc.inc.php @@ -41,10 +41,10 @@ /** * Includes */ -include_once('KTAPDoc.inc.php'); +include_once('KT_atom_baseDoc.inc.php'); -class KTAPPServiceDoc extends KTAPDoc { +class KT_atom_serviceDoc extends KT_atom_baseDoc { private $baseURI=NULL; private $service=NULL; diff --git a/ktatompub/lib/KTAPPHelper.inc.php b/ktatompub/lib/KT_atom_service_helper.inc.php index 403981d..299a0f7 100644 --- a/ktatompub/lib/KTAPPHelper.inc.php +++ b/ktatompub/lib/KT_atom_service_helper.inc.php @@ -37,7 +37,7 @@ * */ -class KTAPPHelper{ +class KT_atom_service_helper{ private static $FOLDER_LIST_PROPERTIES=array('id','title','permissions','mime_icon_path'); private static $FILE_LIST_PROPERTIES=array('id','title','document_type','created_by','created_date','checked_out_by','checked_out_date','modified_by','modified_date','owned_by','mime_type','mime_icon_path','mime_display'); private static $FOLDER_RECURSION_LEVEL=100; @@ -49,7 +49,7 @@ class KTAPPHelper{ * @return void */ public function __construct(){ - die('KTAPPHelper should not be instantiated. Only use as a static class'); + die('KT_atom_service_helper should not be instantiated. Only use as a static class'); } @@ -181,11 +181,11 @@ class KTAPPHelper{ $session = $kt->start_session($username,$password, $ip); if (PEAR::isError($session)){ - $response['status_code']=KTAPP_FAILURE; + $response['status_code']=KT_atom_server_FAILURE; $response['session_id']=''; }else{ $session= $session->get_session(); - $response['status_code'] = KTAPP_SUCCESS; + $response['status_code'] = KT_atom_server_SUCCESS; $response['session_id'] = $session; } return $response; @@ -203,10 +203,10 @@ class KTAPPHelper{ $session = $kt->get_active_session($session_id, null); if (PEAR::isError($session)){ - $response['status_code']=KTAPP_FAILURE; + $response['status_code']=KT_atom_server_FAILURE; }else{ $session->logout(); - $response['status_code'] = KTAPP_SUCCESS; + $response['status_code'] = KT_atom_server_SUCCESS; } return $response; } diff --git a/ktatompub/lib/cmis/KTCMISAPPFeed.inc.php b/ktatompub/lib/cmis/KTCMISAPPFeed.inc.php index 973681c..4fc0741 100644 --- a/ktatompub/lib/cmis/KTCMISAPPFeed.inc.php +++ b/ktatompub/lib/cmis/KTCMISAPPFeed.inc.php @@ -40,13 +40,13 @@ /** * Includes */ -include_once('../KTAPDoc.inc.php'); +include_once('../KT_atom_baseDoc.inc.php'); /** * This class generates an AtomPub CMIS feed */ -class KTCMISAPPFeed extends KTAPDoc { +class KTCMISAPPFeed extends KT_atom_baseDoc { private $baseURI = NULL; private $id = NULL; diff --git a/ktatompub/lib/cmis/KTCMISAPPServiceDoc.inc.php b/ktatompub/lib/cmis/KTCMISAPPServiceDoc.inc.php index bee707b..8284faa 100644 --- a/ktatompub/lib/cmis/KTCMISAPPServiceDoc.inc.php +++ b/ktatompub/lib/cmis/KTCMISAPPServiceDoc.inc.php @@ -39,13 +39,13 @@ /** * Includes */ -include_once('../KTAPDoc.inc.php'); +include_once('../KT_atom_baseDoc.inc.php'); /** * This class generates an AtomPub CMIS service document */ -class KTCMISAPPServiceDoc extends KTAPDoc { +class KTCMISAPPServiceDoc extends KT_atom_baseDoc { private $baseURI=NULL; private $service=NULL; diff --git a/ktatompub/lib/ktAPP_ResponseFeed.inc.php b/ktatompub/lib/ktAPP_ResponseFeed.inc.php deleted file mode 100644 index bee5aa7..0000000 --- a/ktatompub/lib/ktAPP_ResponseFeed.inc.php +++ /dev/null @@ -1,11 +0,0 @@ - \ No newline at end of file diff --git a/ktatompub/phpinfo.php b/ktatompub/phpinfo.php new file mode 100644 index 0000000..968c8df --- /dev/null +++ b/ktatompub/phpinfo.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/ktatompub/services/cmis/NavigationService.inc.php b/ktatompub/services/cmis/NavigationService.inc.php deleted file mode 100644 index fe47e18..0000000 --- a/ktatompub/services/cmis/NavigationService.inc.php +++ /dev/null @@ -1,124 +0,0 @@ - diff --git a/ktatompub/services/cmis/ObjectFeed.inc.php b/ktatompub/services/cmis/ObjectFeed.inc.php deleted file mode 100644 index 5c8d4f4..0000000 --- a/ktatompub/services/cmis/ObjectFeed.inc.php +++ /dev/null @@ -1,92 +0,0 @@ -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/ktatompub/services/cmis/ObjectService.inc.php b/ktatompub/services/cmis/ObjectService.inc.php deleted file mode 100644 index 728de1f..0000000 --- a/ktatompub/services/cmis/ObjectService.inc.php +++ /dev/null @@ -1,37 +0,0 @@ - diff --git a/ktatompub/services/cmis/RepositoryService.inc.php b/ktatompub/services/cmis/RepositoryService.inc.php deleted file mode 100644 index 55a3a80..0000000 --- a/ktatompub/services/cmis/RepositoryService.inc.php +++ /dev/null @@ -1,85 +0,0 @@ - diff --git a/ktatompub/services/cmis/checkedout.inc.php b/ktatompub/services/cmis/checkedout.inc.php deleted file mode 100644 index 308baff..0000000 --- a/ktatompub/services/cmis/checkedout.inc.php +++ /dev/null @@ -1,50 +0,0 @@ -startSession($username, $password); - -$repositories = $RepositoryService->getRepositories(); -$repositoryId = $repositories[0]['repositoryId']; - -$checkedout = $NavigationService->getCheckedoutDocs($repositoryId); - -$feed = new KTCMISAPPFeed(KT_APP_BASE_URI, 'Checked out Documents', null, null, null, 'urn:uuid:checkedout'); - -foreach($checkedout as $document) -{ - $entry = $feed->newEntry(); - $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); -} - -$entry = null; -$feed->newField('hasMoreItems', 'false', $entry, true); - -$output = $feed->getAPPdoc(); - -?> diff --git a/ktatompub/services/cmis/document.inc.php b/ktatompub/services/cmis/document.inc.php deleted file mode 100644 index 1b765b3..0000000 --- a/ktatompub/services/cmis/document.inc.php +++ /dev/null @@ -1,98 +0,0 @@ -getProperties($repositoryId, $documentId, false, false); - - $feed = new KTCMISAPPFeed(KT_APP_BASE_URI, $cmisEntry['properties']['ObjectTypeId']['value'], null, null, null, - 'urn:uuid:' . $cmisEntry['properties']['ObjectId']['value']); - - CMISDocumentFeed::createEntry($feed, $cmisEntry, $cmisEntry['properties']['ParentId']['value']); - - //
'.print_r($children,true).''; + foreach($children as $fullChildName=>$childCollection){ + //$child=$childCollection; + $childName=split(':',$fullChildName); + foreach($childCollection as $child){ + $childParsed=self::parsetag($child,$childName[0],$rootXML); + //$cIndex=count($array[$tagName][$childName]); + $array[$tagName][]=$childParsed; + } } }else{ @@ -33,13 +30,14 @@ class xml2array{ return $array; } - private function hasChildren($xml){ - return count($this->getChildren($xml))>0; + private static function hasChildren($xml,$rootXML){ + return count(self::getChildren($xml,$rootXML))>0; } - private function getAttributes($xml){ + private static function getAttributes($xml,$rootXML){ $attr=array(); - foreach($this->namespaces as $namespace=>$uri){ + $namespaces=$rootXML->getNamespaces(true); + foreach($namespaces as $namespace=>$uri){ $nsAttrs=(array)$xml->attributes($uri); $nsAttrs=isset($nsAttrs['@attributes'])?$nsAttrs['@attributes']:array(); foreach($nsAttrs as $nsAttr=>$nsAttrVal){ //TODO: Support for multiple same name tags @@ -49,12 +47,16 @@ class xml2array{ return $attr; } - private function getChildren($xml){ + private static function getChildren($xml,$rootXML){ $children=array(); - foreach($this->namespaces as $namespace=>$uri){ + $namespaces=$rootXML->getNamespaces(true); + foreach($namespaces as $namespace=>$uri){ $nsChildren=$xml->children($uri); foreach($nsChildren as $nsChild){ //TODO: Support for multiple same name tags - $children[$namespace.':'.$nsChild->getName()]=$nsChild; + $childRealName=$namespace.':'.$nsChild->getName(); + if(!isset($children[$childRealName]))$children[$childRealName]=array(); + if(!is_array($children[$childRealName]))$children[$childRealName]=array(); + $children[$childRealName][]=$nsChild; } } return $children; @@ -63,6 +65,7 @@ class xml2array{ } + $xml='
'.htmlentities($xml).''; //echo '
'.print_r($struct,true).''; //echo '
'.print_r($sxml,true).''; //cho '
'.print_r(xml2array($xml),true).''; -echo '
'.print_r($nxml->parse2array(),true).''; +echo '
'.print_r(xml2array::parse($xml),true).''; -echo http_get_request_headers(); +//echo http_get_request_headers(); ?> \ No newline at end of file diff --git a/ktatompub/services/folder.inc.php b/webservice/atompub/auth.php index 2d49982..d0a8da8 100644 --- a/ktatompub/services/folder.inc.php +++ b/webservice/atompub/auth.php @@ -32,23 +32,18 @@ * 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): + * Contributor( s): * Mark Holtzhausen * */ - //Create a new response feed - $feed=new KTAPPFeed(KT_APP_BASE_URI); +/** + * Automatic Login bypassing HTTP Basic Auth + * TODO: Thest HTTP Basic Auth - Try Library From Home + */ - //Invoke the KtAPI to get detail about the referenced document - $folderDetail=KTAPPHelper::getFolderDetail($query[1]); +$SessionId=KT_atom_service_helper::login('admin','admin'); +$SessionId=$SessionId['session_id']; - //Create the atom response feed - $entry=$feed->newEntry(); - foreach($folderDetail as $property=>$value){ - $feed->newField($property,$value,$entry); - } - //Generate and set the output - $output=$feed->getAPPdoc(); ?> \ No newline at end of file diff --git a/webservice/atompub/demodms/KT_atom_server.default_dms_services.inc.php b/webservice/atompub/demodms/KT_atom_server.default_dms_services.inc.php new file mode 100644 index 0000000..423b733 --- /dev/null +++ b/webservice/atompub/demodms/KT_atom_server.default_dms_services.inc.php @@ -0,0 +1,93 @@ +newEntry(); + $feed->newField('id',$id,$entry); + foreach($item as $property=>$value){ + $feed->newField($property,$value,$entry); + } + } + //Expose the responseFeed + $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/demodms/KT_atom_service_helper.inc.php b/webservice/atompub/demodms/KT_atom_service_helper.inc.php new file mode 100644 index 0000000..299a0f7 --- /dev/null +++ b/webservice/atompub/demodms/KT_atom_service_helper.inc.php @@ -0,0 +1,227 @@ +. + * + * 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 + * + */ + +class KT_atom_service_helper{ + private static $FOLDER_LIST_PROPERTIES=array('id','title','permissions','mime_icon_path'); + private static $FILE_LIST_PROPERTIES=array('id','title','document_type','created_by','created_date','checked_out_by','checked_out_date','modified_by','modified_date','owned_by','mime_type','mime_icon_path','mime_display'); + private static $FOLDER_RECURSION_LEVEL=100; + private static $kt=NULL; + + /** + * Make sure the class is always treated statically and never instantiated. + * + * @return void + */ + public function __construct(){ + die('KT_atom_service_helper should not be instantiated. Only use as a static class'); + } + + + /** + * Get the KT singleton instance + * + * @return object + */ + public static function getKt(){ + if(!isset(self::$kt)){ + self::$kt=new KTAPI(); + self::$kt->get_active_session(session_id()); + } + return self::$kt; + } + + + /** + * Get the subfolders of the indicated folder + * + * @param integer $folderId + * @return array + */ + public static function getSubFolders($folderId=NULL){ + if(!(int)$folderId)$folderId=1; //Default to root folder + $folderInfo=self::getKT()->get_folder_contents($folderId,1); + $subfolders=array(); + foreach($folderInfo['results']['items'] as $item){ + if($item['item_type']=='F'){ + $subfolders[$item[id]]=self::extractFromArray($item,self::$FOLDER_LIST_PROPERTIES); + } + } + return $subfolders; + } + + + /** + * Get every folder & document in the repository + * + * @param integer $parent the id of the folder to start recursing from - defaults to root folder [1] + * @return array + */ + public static function getFullTree($parent=NULL){ + if(!(int)$parent)$parent=1; + $ktTree=self::getKT()->get_folder_contents($parent,1); + $appTree=array(); + foreach($ktTree['results']['items'] as $item){ + $newItem=array(); + $newItem['parent']=$parent; + $newItem['type']=$item['item_type']; + $newItem['title']=$item['title']; + $newItem['filename']=$item['filename']; + $newItem['id']=$item['id']; +// $newItem['fullrecord']=$item; + $appTree[]=$newItem; + if($newItem['type']=='F')$appTree=array_merge($appTree,self::getFullTree($item['id'])); + } + return $appTree; + } + + + /** + * Get detail about the folder + * + * @param integer $folderId The id of the folder to get detail on. + * @return array + */ + public static function getFolderDetail($folderId=NULL){ + $ktInfo=self::getKT()->get_folder_by_id($folderId); + return $ktInfo->get_detail(); + } + + + /** + * Get detail about the indicated document + * + * @param integer $docId The document Id + * @return array + */ + public static function getDocumentDetail($docId=NULL){ + $ktInfo=self::getKT()->get_document_detail($docId); + return $ktInfo; + } + + + /** + * Get a list of all the documents in a folder. + * + * @param integer $folderId The id of the folder + * @return array + */ + public static function getFileList($folderId=NULL){ + $folderContents=self::getKt()->get_folder_contents($folderId,1); + $folderFiles=array(); + foreach($folderContents['results']['items'] as $item){ + if($item['item_type']=='D'){ + $folderFiles[$item['id']]=self::extractFromArray($item,self::$FILE_LIST_PROPERTIES); + } + } + return $folderFiles; + } + + + /** + * Returns an array containing only the associated values from $array where the keys were found in $keyArray + * + * @param array $array The array to be processed + * @param array $keyArray The list of keys to extract from the array + * @return array + */ + public static function extractFromArray($array,$keyArray){ + $newArray=array(); + foreach($keyArray as $key){ + $newArray[$key]=isset($array[$key])?$array[$key]:NULL; + } + return $newArray; + } + + /** + * Log in to KT easily + * + * @param string $username + * @param string $password + * @param string $ip + * @return object Containing the status_code of the login and session id + */ + function login($username, $password, $ip=null){ + $kt = self::getKt(); + + $session = $kt->start_session($username,$password, $ip); + if (PEAR::isError($session)){ + $response['status_code']=KT_atom_server_FAILURE; + $response['session_id']=''; + }else{ + $session= $session->get_session(); + $response['status_code'] = KT_atom_server_SUCCESS; + $response['session_id'] = $session; + } + return $response; + } + + + /** + * Log out of KT using the session id + * + * @param string $session_id + * @return object Containing the status_code of the logout attempt + */ + function logout($session_id){ + $kt = self::getKt(); + $session = $kt->get_active_session($session_id, null); + + if (PEAR::isError($session)){ + $response['status_code']=KT_atom_server_FAILURE; + }else{ + $session->logout(); + $response['status_code'] = KT_atom_server_SUCCESS; + } + return $response; + } + + /** + * Check whether the session_id is logged into KT + * + * @param string $session_id + * @return boolean + */ + function isLoggedIn($session_id){ + $kt=self::getKt(); + $session=$kt->get_active_session($session_id); + return !PEAR::isError($session); + } + +} +?> \ No newline at end of file diff --git a/ktatompub/services/mimetypes.inc.php b/webservice/atompub/index.php index 000f45d..f70ac0d 100644 --- a/ktatompub/services/mimetypes.inc.php +++ b/webservice/atompub/index.php @@ -32,25 +32,75 @@ * 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): + * Contributor( s): * Mark Holtzhausen * */ - //Create a new response feed - $mimetypes=KTMime::getAllMimeTypes(); - - //Invoke the KtAPI to get detail about the referenced document - $feed=new KTAPPFeed(KT_APP_BASE_URI); - - //Create the atom response feed - foreach($mimetypes as $mimeType){ - $entry=$feed->newEntry(); - foreach($mimeType as $property=>$value){ - $feed->newField($property,$value,$entry); - } - } - - //Generate and set the output - $output=$feed->getAPPdoc(); +ob_start(); + +/** + * Constants + */ + +/** + * To sidestep url rewrites but still retain the atomPub URL convention, + * the entry point is: index.php?/ + * eg. 1. Accessing the servicedocument: http://example.com/ktatompub/index.php?/servicedocument + * 2. Accessing the folder service: http://example.com/ktatompub/index.php?/folder/1 + * + * If URL rewrites are used, they should point any reference below + * this folder to index.php?/ + * + * Because index.php is accessed as the default document, the url can be shortened to http://example.com/ktatompub/?/ + */ + +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/'); + +// Define whether to use in debug mode for viewing generated structures +//define('KT_APP_WEB_OUTPUT',false); //defunct + + + +/** + * Includes + */ +include_once('../../ktapi/ktapi.inc.php'); +include_once(KT_ATOM_LIB_FOLDER.'KT_atom_server.inc.php'); +include_once('demodms/KT_atom_service_helper.inc.php'); //Containing helper bridge functions to KtAPI +include_once(KT_ATOM_LIB_FOLDER.'KT_atom_baseDoc.inc.php'); //Containing the parent class allowing easy XML manipulation +include_once(KT_ATOM_LIB_FOLDER.'KT_atom_serviceDoc.inc.php'); //Containing the servicedoc class allowing easy ServiceDocument generation +include_once(KT_ATOM_LIB_FOLDER.'KT_atom_responseFeed.inc.php'); //Containing the response feed class allowing easy atom feed generation +include_once(KT_ATOM_LIB_FOLDER.'KT_atom_service.inc.php'); +include_once('demodms/KT_atom_server.default_dms_services.inc.php'); +include_once('auth.php'); //Containing the authentication protocols + + +//Start the AtomPubProtocol Routing Engine +$APP=new KT_atom_server(); + +/** + * 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 +*/ +$APP->registerService('DMS','fulltree','KT_atom_service_fulltree','Full Document Tree'); +$APP->registerService('DMS','folder','KT_atom_service_folder','Folder Detail'); +$APP->registerService('DMS','document','KT_atom_service_document','Document Detail'); + +//Execute the current url/header request +$APP->execute(); + +//echo '
'.print_r($APP,true).''; + +//Render the resulting feed response +$APP->render(); + ?> \ No newline at end of file diff --git a/webservice/classes/atompub/KT_atom_baseDoc.inc.php b/webservice/classes/atompub/KT_atom_baseDoc.inc.php new file mode 100644 index 0000000..fd6670b --- /dev/null +++ b/webservice/classes/atompub/KT_atom_baseDoc.inc.php @@ -0,0 +1,128 @@ +. + * + * 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 + * + */ + +/** + * Includes + */ + +class KT_atom_baseDoc{ + const XML_ENCODING='utf-8'; + const XML_VERSION='1.0'; + + public $DOM=NULL; + + public function __construct(){ + $this->DOM=new DOMDocument(self::XML_VERSION ,self::XML_ENCODING); + } + + public function &newAttr($name=NULL){ + $node=$this->DOM->createAttribute($name); + if(func_num_args()>1){ + $val=func_get_arg(1); + $node->value=$val; + } + return $node; + } + + public function &newElement($name=NULL){ + if(func_num_args()>1){ + $val=func_get_arg(1); + $node=$this->DOM->createElement($name,$val); + }else{ + $node=$this->DOM->createElement($name); + } + return $node; + } + + public function &newCDATA($data=NULL){ + $this->DOM->createCDATASection($data); + } + + public function &newB64Stream($tagName=NULL,$tagAttrs=array(),$streamString=NULL){ + $e=$this->newElement($tagName,chunk_split(base64_encode($streamString),75)); + foreach($tagAttrs as $attr=>$val){ + $attr=$this->newAttr($attr,$val); + $e->appendChild($attr); + } + return $e; + } + + + + public function formatXmlString($xml) { + // add marker linefeeds to aid the pretty-tokeniser (adds a linefeed between all tag-end boundaries) + $xml = preg_replace('/(>)(<)(\/*)/', "$1\n$2$3", $xml); + + // now indent the tags + $token = strtok($xml, "\n"); + $result = ''; // holds formatted version as it is built + $pad = 0; // initial indent + $matches = array(); // returns from preg_matches() + + // scan each line and adjust indent based on opening/closing tags + while ($token !== false) : + + // test for the various tag states + + // 1. open and closing tags on same line - no change + if (preg_match('/.+<\/\w[^>]*>$/', $token, $matches)) : + $indent=0; + // 2. closing tag - outdent now + elseif (preg_match('/^<\/\w/', $token, $matches)) : + $pad--; + // 3. opening tag - don't pad this one, only subsequent tags + elseif (preg_match('/^<\w[^>]*[^\/]>.*$/', $token, $matches)) : + $indent=1; + // 4. no indentation needed + else : + $indent = 0; + endif; + + // pad the line with the required number of leading spaces + $line = str_pad($token, strlen($token)+$pad, ' ', STR_PAD_LEFT); + $result .= $line . "\n"; // add to the cumulative result, with linefeed + $token = strtok("\n"); // get the next token + $pad += $indent; // update the pad size for subsequent lines + endwhile; + + return $result; + } +} + +?> \ No newline at end of file diff --git a/webservice/classes/atompub/KT_atom_responseFeed.inc.php b/webservice/classes/atompub/KT_atom_responseFeed.inc.php new file mode 100644 index 0000000..fa64117 --- /dev/null +++ b/webservice/classes/atompub/KT_atom_responseFeed.inc.php @@ -0,0 +1,45 @@ +constructHeader(); + $this->baseURI=$baseURI; + } + + private function constructHeader(){ + $feed=$this->newElement('feed'); + $feed->appendChild($this->newAttr('xmlns','http://www.w3.org/2005/Atom')); + $this->feed=&$feed; + $this->DOM->appendChild($this->feed); + } + + public function &newEntry(){ + $entry=$this->newElement('entry'); + $this->feed->appendChild($entry); + return $entry; + } + + public function &newField($name=NULL,$value=NULL,&$attachToNode=NULL){ + $field=$this->newElement($name,$value); + if(isset($attachToNode))$attachToNode->appendChild($field); + return $field; + } + + public function render(){ + return $this->formatXmlString(trim($this->DOM->saveXML())); + } + + +} + +class KT_atom_ResponseFeed_GET extends KT_atom_responseFeed{} +class KT_atom_ResponseFeed_PUT extends KT_atom_responseFeed{} +class KT_atom_ResponseFeed_POST extends KT_atom_responseFeed{} +class KT_atom_ResponseFeed_DELETE extends KT_atom_responseFeed{} + +?> \ No newline at end of file diff --git a/webservice/classes/atompub/KT_atom_server.inc.php b/webservice/classes/atompub/KT_atom_server.inc.php new file mode 100644 index 0000000..7ba14cf --- /dev/null +++ b/webservice/classes/atompub/KT_atom_server.inc.php @@ -0,0 +1,87 @@ +queryArray=$queryArray; + $this->serviceName=$service; + $this->method=$reqMethod; + $this->workspace=$workspace; + + if($workspace=='servicedocument'){ + $this->serviceDocument(); + return; + } + + $service=$this->getRegisteredService($workspace,$serviceName); + if(is_array($service)){ + $serviceClass=$service['serviceClass']; + echo 'made it'; + $serviceObject=new $serviceClass($reqMethod,$requestParams,$rawRequest); + $this->output=$serviceObject->render(); + }else{ + $serviceObject=new KT_atom_service($requestParams,$rawRequest); + $serviceObject->setStatus(KT_atom_service::STATUS_NOT_FOUND); + $this->output=$serviceObject->render(); + } + } + + public function registerService($workspace=NULL,$serviceName=NULL,$serviceClass=NULL,$title=NULL){ + $workspace=strtolower(trim($workspace)); + $serviceName=strtolower(trim($serviceName)); + + $serviceRecord=array( + 'fileName' =>$fileName, + 'serviceClass' =>$serviceClass, + 'title' =>$title + ); + + $this->services[$workspace][$serviceName]=$serviceRecord; + } + + public function getRegisteredService($workspace,$serviceName=NULL){ + $serviceName=strtolower(trim($serviceName)); + if(isset($this->services[$workspace][$serviceName]))return $this->services[$workspace][$serviceName]; + return false; + } + + public function serviceDocument(){ + $service=new KT_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($workspace); + + foreach($collection as $serviceName=>$serviceInstance){ + $col=$service->newCollection(KT_APP_BASE_URI.$workspace.'/'.$serviceName.'/',$serviceInstance['title'],$ws); + } + } + + $this->output=$service->getAPPdoc(); + } + + public function render(){ + ob_end_clean(); + header('Content-type: text/xml'); + echo $this->output; + } +} + +?> \ No newline at end of file diff --git a/webservice/classes/atompub/KT_atom_service.inc.php b/webservice/classes/atompub/KT_atom_service.inc.php new file mode 100644 index 0000000..511992f --- /dev/null +++ b/webservice/classes/atompub/KT_atom_service.inc.php @@ -0,0 +1,90 @@ +method=$method; + $this->params=$params; + $this->rawContent=$content; + $this->parseHeaders(); + $this->parsedXMLContent=$this->xml2array($this->rawContent); + $this->setStatus(self::STATUS_OK); + $this->responseFeed=new KT_atom_responseFeed(KT_APP_BASE_URI); + switch(strtoupper($this->method)){ + case 'GET': $this->GET_action();break; + case 'PUT': $this->PUT_action();break; + case 'POST': $this->POST_action();break; + case 'DELETE': $this->DELETE_action();break; + default: $this->UNSUPPORTED_action();break; + } + } + + public function GET_action(){ + $this->setStatus(KT_atom_service::STATUS_OK); + } + + public function PUT_action(){ + $this->setStatus(KT_atom_service::STATUS_NOT_FOUND ); + } + + public function POST_action(){ + $this->setStatus(KT_atom_service::STATUS_NOT_FOUND ); + } + + public function DELETE_action(){ + $this->setStatus(KT_atom_service::STATUS_NOT_FOUND ); + } + + public function UNSUPPORTED_action(){ + $this->setStatus(KT_atom_service::STATUS_NOT_FOUND ); + } + + + public function render(){ + return $this->responseFeed->render(); + } + + private function xml2array($xml){ + $array=json_decode(json_encode(@simplexml_load_string($xml)),true); //TODO - XML2ARRAY Translation + return $array; + } + + private function parseHeaders(){ + $headers=null; + if(function_exists('http_get_request_headers')){ //Try to use pcre_http library if it exists + $headers=http_get_request_headers(); + }else{ + if(function_exists('apache_request_headers')){ //If not: try to use apache specific headers + $headers=apache_request_headers(); + }else{ //If not: not supported - empty headers + $headers=array(); + } + } + $this->headers=$headers; + } + + public function setStatus($status=NULL){ + header("HTTP/1.1 ".$status); + } + + private function setEtag($etagValue=NULL){ + if($etagValue)header('ETag: '.$etagValue); + } + +} +?> \ No newline at end of file diff --git a/ktatompub/lib/KTAPPFeed.inc.php b/webservice/classes/atompub/KT_atom_serviceDoc.inc.php index c1c677c..2fa2d37 100644 --- a/ktatompub/lib/KTAPPFeed.inc.php +++ b/webservice/classes/atompub/KT_atom_serviceDoc.inc.php @@ -32,7 +32,7 @@ * 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): + * Contributor( s): * Mark Holtzhausen * */ @@ -41,75 +41,98 @@ /** * Includes */ -include_once('KTAPDoc.inc.php'); - -/* Remember to include support for feed attributes / nodes - -