diff --git a/action.php b/action.php new file mode 100644 index 0000000..aa62bcf --- /dev/null +++ b/action.php @@ -0,0 +1,60 @@ +error = false; + $action = KTUtil::arrayGet($_SERVER, 'PATH_INFO'); + $action = trim($action); + $action = trim($action, "/"); + if (empty($action)) { + $this->error = true; + $this->errorPage("No action given"); + } + $oRegistry =& KTActionRegistry::getSingleton(); + $aActionInfo = $oRegistry->getActionByNsname($action); + if (empty($aActionInfo)) { + $this->error = true; + $this->errorPage("No such action exists in KnowledgeTree"); + } + $oAction = new $aActionInfo[0]; + $oAction->dispatch(); + } + + /** + * Handle output from this dispatcher. + * + * If there's an error in _this_ dispatcher, use the standard + * surroundings. If not, don't put anything around the output - the + * chained dispatcher will take care of that. + */ + function handleOutput ($data) { + if ($this->error) { + parent::handleOutput($data); + } else { + print $data; + } + } +} +$d = new KTActionDispatcher(); +$d->dispatch();