Mercurial > hg > extraction-interface
view classes/loader.php @ 58:a11f9103b8db extractapp
New: 1.display messages 2.handle saving conflict:up-to-date or reload text
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 31 Mar 2015 10:59:52 +0200 |
parents | 886f43b26ee2 |
children | 97c1e5102a22 |
line wrap: on
line source
<?php class Loader { private $controller; private $action; private $urlvalues; private $postdata = 0; //store the URL values on object creation public function __construct($urlvalues, $postdata) { $this->urlvalues = $urlvalues; $this->postdata = $postdata; if ($this->urlvalues['controller'] == "") { $this->controller = "extractapp"; // TODO: develope home page for the whole service. // change $this->controller to home after developed extract app. // $this->controller = "home"; } else { $this->controller = $this->urlvalues['controller']; } if ($this->urlvalues['action'] == "") { $this->action = "taggingtext"; // $this->action = "index"; } else { $this->action = $this->urlvalues['action']; } } //establish the requested controller as an object public function CreateController() { //does the class exist? if (class_exists($this->controller)) { $parents = class_parents($this->controller); //does the class extend the controller class? if (in_array("BaseController",$parents)) { //does the class contain the requested method? if (method_exists($this->controller,$this->action)) { return new $this->controller($this->action,$this->urlvalues,$this->postdata); } else { //bad method error return new Error("badUrl",$this->urlvalues); } } else { //bad controller error return new Error("badUrl",$this->urlvalues); } } else { //bad controller error return new Error("badUrl",$this->urlvalues); } } } ?>