Mercurial > hg > extraction-interface
comparison develop/classes/loader.php @ 6:63e08b98032f
rewrite extraction interface into PHP MVC architecture.
(Although js hasn't been rewritten into MVC, it's fitted into the current PHP MVC architecture.)
- The root of the new PHP MVC is at 'develop/'.
- extraction interface is called "Extractapp" with several action, eg TaggingText, EditWordlist, EditTaglist, ExportTable.
| author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
|---|---|
| date | Thu, 05 Feb 2015 16:07:53 +0100 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 5:cbbb7ef22394 | 6:63e08b98032f |
|---|---|
| 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 ?> |
