Commit 6e49a0ce70f3d406c71e4e333584d8e1084cb4ed
Merge branch 'edge' of git@github.com:ktgit/knowledgetree into edge
Showing
1 changed file
with
12 additions
and
8 deletions
webservice/classes/atompub/KT_atom_server.inc.php
| @@ -10,13 +10,15 @@ class KT_atom_server { | @@ -10,13 +10,15 @@ class KT_atom_server { | ||
| 10 | protected $method=''; | 10 | protected $method=''; |
| 11 | protected $workspace=''; | 11 | protected $workspace=''; |
| 12 | protected $serviceObject = null; | 12 | protected $serviceObject = null; |
| 13 | + protected $renderBody=true; | ||
| 14 | + | ||
| 13 | 15 | ||
| 14 | public function __construct(){ | 16 | public function __construct(){ |
| 15 | } | 17 | } |
| 16 | 18 | ||
| 17 | protected function hook_beforeDocCreate($doc){return true;} | 19 | protected function hook_beforeDocCreate($doc){return true;} |
| 18 | protected function hook_beforeDocRender($doc){return true;} | 20 | protected function hook_beforeDocRender($doc){return true;} |
| 19 | - | 21 | + |
| 20 | /** | 22 | /** |
| 21 | * Run the server switchboard - find the correct service class to instantiate, execute & render that class with the passed parameteres | 23 | * Run the server switchboard - find the correct service class to instantiate, execute & render that class with the passed parameteres |
| 22 | * | 24 | * |
| @@ -33,21 +35,18 @@ class KT_atom_server { | @@ -33,21 +35,18 @@ class KT_atom_server { | ||
| 33 | $this->serviceName=$serviceName; | 35 | $this->serviceName=$serviceName; |
| 34 | $this->method=$reqMethod; | 36 | $this->method=$reqMethod; |
| 35 | $this->workspace=$workspace; | 37 | $this->workspace=$workspace; |
| 36 | - | 38 | + |
| 37 | if($workspace=='servicedocument'){ | 39 | if($workspace=='servicedocument'){ |
| 38 | $this->serviceDocument(); | 40 | $this->serviceDocument(); |
| 39 | return; | 41 | return; |
| 40 | } | 42 | } |
| 41 | - | 43 | + |
| 42 | $service=$this->getRegisteredService($workspace,$serviceName); | 44 | $service=$this->getRegisteredService($workspace,$serviceName); |
| 43 | if(is_array($service)){ | 45 | if(is_array($service)){ |
| 44 | $serviceClass=$service['serviceClass']; | 46 | $serviceClass=$service['serviceClass']; |
| 45 | -// echo 'made it'; | ||
| 46 | $serviceObject=new $serviceClass($reqMethod,$requestParams,$rawRequest); | 47 | $serviceObject=new $serviceClass($reqMethod,$requestParams,$rawRequest); |
| 47 | - $this->output=$serviceObject->render(); | 48 | + if($this->hook_beforeDocRender($serviceObject)) $this->output=$serviceObject->render(); |
| 48 | }else{ | 49 | }else{ |
| 49 | -// $this->serviceDocument(); | ||
| 50 | -// return; | ||
| 51 | $serviceObject=new KT_atom_service($requestParams,$rawRequest); | 50 | $serviceObject=new KT_atom_service($requestParams,$rawRequest); |
| 52 | $serviceObject->setStatus(KT_atom_service::STATUS_NOT_FOUND); | 51 | $serviceObject->setStatus(KT_atom_service::STATUS_NOT_FOUND); |
| 53 | if($this->hook_beforeDocRender($serviceObject)) $this->output=$serviceObject->render(); | 52 | if($this->hook_beforeDocRender($serviceObject)) $this->output=$serviceObject->render(); |
| @@ -111,8 +110,13 @@ class KT_atom_server { | @@ -111,8 +110,13 @@ class KT_atom_server { | ||
| 111 | public function render(){ | 110 | public function render(){ |
| 112 | ob_end_clean(); | 111 | ob_end_clean(); |
| 113 | header('Content-type: text/xml'); | 112 | header('Content-type: text/xml'); |
| 114 | - echo $this->output; | 113 | + if($this->renderBody)echo $this->output; |
| 114 | + } | ||
| 115 | + | ||
| 116 | + public function setNoContent($flag=false){ | ||
| 117 | + $this->renderBody=$flag?false:true; | ||
| 115 | } | 118 | } |
| 119 | + | ||
| 116 | } | 120 | } |
| 117 | 121 | ||
| 118 | ?> | 122 | ?> |
| 119 | \ No newline at end of file | 123 | \ No newline at end of file |