Mercurial > hg > extraction-interface
comparison classes/loader.php @ 47:886f43b26ee2 extractapp
move/remove develop folder
| author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
|---|---|
| date | Tue, 17 Mar 2015 10:54:13 +0100 |
| parents | |
| children | 97c1e5102a22 |
comparison
equal
deleted
inserted
replaced
| 46:b3ca5d2b4d3f | 47:886f43b26ee2 |
|---|---|
| 1 <?php | |
| 2 | |
| 3 class Loader { | |
| 4 private $controller; | |
| 5 private $action; | |
| 6 private $urlvalues; | |
| 7 private $postdata = 0; | |
| 8 | |
| 9 //store the URL values on object creation | |
| 10 public function __construct($urlvalues, $postdata) { | |
| 11 $this->urlvalues = $urlvalues; | |
| 12 $this->postdata = $postdata; | |
| 13 if ($this->urlvalues['controller'] == "") { | |
| 14 $this->controller = "extractapp"; | |
| 15 // TODO: develope home page for the whole service. | |
| 16 // change $this->controller to home after developed extract app. | |
| 17 // $this->controller = "home"; | |
| 18 | |
| 19 } else { | |
| 20 $this->controller = $this->urlvalues['controller']; | |
| 21 } | |
| 22 | |
| 23 if ($this->urlvalues['action'] == "") { | |
| 24 $this->action = "taggingtext"; | |
| 25 // $this->action = "index"; | |
| 26 } else { | |
| 27 $this->action = $this->urlvalues['action']; | |
| 28 } | |
| 29 | |
| 30 } | |
| 31 | |
| 32 //establish the requested controller as an object | |
| 33 public function CreateController() { | |
| 34 //does the class exist? | |
| 35 if (class_exists($this->controller)) { | |
| 36 $parents = class_parents($this->controller); | |
| 37 //does the class extend the controller class? | |
| 38 if (in_array("BaseController",$parents)) { | |
| 39 //does the class contain the requested method? | |
| 40 if (method_exists($this->controller,$this->action)) { | |
| 41 return new $this->controller($this->action,$this->urlvalues,$this->postdata); | |
| 42 } else { | |
| 43 //bad method error | |
| 44 return new Error("badUrl",$this->urlvalues); | |
| 45 } | |
| 46 } else { | |
| 47 //bad controller error | |
| 48 return new Error("badUrl",$this->urlvalues); | |
| 49 } | |
| 50 } else { | |
| 51 //bad controller error | |
| 52 return new Error("badUrl",$this->urlvalues); | |
| 53 } | |
| 54 } | |
| 55 } | |
| 56 | |
| 57 ?> |
