Mercurial > hg > extraction-interface
comparison classes/loader.php @ 77:97c1e5102a22 extractapp
New: export table for a file from LGService
| author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
|---|---|
| date | Thu, 16 Apr 2015 14:53:22 +0200 |
| parents | 886f43b26ee2 |
| children | f1f849d31272 |
comparison
equal
deleted
inserted
replaced
| 76:c49192885290 | 77:97c1e5102a22 |
|---|---|
| 1 <?php | 1 <?php |
| 2 /** | |
| 3 * Loader is used to route parameters from input url and set parameters for controller. | |
| 4 * The routing is done by the RewriteRule written in .htaccess file. | |
| 5 */ | |
| 2 | 6 |
| 3 class Loader { | 7 class Loader { |
| 4 private $controller; | 8 private $controller; |
| 5 private $action; | 9 private $action; |
| 6 private $urlvalues; | 10 private $urlvalues; |
| 7 private $postdata = 0; | 11 private $postdata = 0; |
| 8 | 12 |
| 9 //store the URL values on object creation | |
| 10 public function __construct($urlvalues, $postdata) { | 13 public function __construct($urlvalues, $postdata) { |
| 14 /** | |
| 15 * It stores the URL values on object creation. | |
| 16 * For example, the URL structure is like this: some_domain_name/Extractapp/TaggingText. | |
| 17 * The controller is "Extractapp" and the action is "TaggingText". | |
| 18 * For the "Extractapp" controller, there is a corresponding "extractapp.php" in "./controllers" folder. | |
| 19 * For the action "TaggingText", there is a corresponding "TaggingText.php" in "./views/Extractapp" folder. | |
| 20 * Under "./view" folder, the first level is named by the controller. Each action belongs to the controller is named by its action name. | |
| 21 */ | |
| 22 | |
| 11 $this->urlvalues = $urlvalues; | 23 $this->urlvalues = $urlvalues; |
| 12 $this->postdata = $postdata; | 24 $this->postdata = $postdata; |
| 13 if ($this->urlvalues['controller'] == "") { | 25 if ($this->urlvalues['controller'] == "") { |
| 14 $this->controller = "extractapp"; | 26 $this->controller = "Extractapp"; // the default controller |
| 15 // TODO: develope home page for the whole service. | 27 |
| 16 // change $this->controller to home after developed extract app. | |
| 17 // $this->controller = "home"; | |
| 18 | |
| 19 } else { | 28 } else { |
| 20 $this->controller = $this->urlvalues['controller']; | 29 $this->controller = $this->urlvalues['controller']; |
| 21 } | 30 } |
| 22 | 31 |
| 23 if ($this->urlvalues['action'] == "") { | 32 if ($this->urlvalues['action'] == "") { |
| 24 $this->action = "taggingtext"; | 33 $this->action = "TaggingText"; // the default action |
| 25 // $this->action = "index"; | 34 |
| 26 } else { | 35 } else { |
| 27 $this->action = $this->urlvalues['action']; | 36 $this->action = $this->urlvalues['action']; |
| 28 } | 37 } |
| 29 | |
| 30 } | 38 } |
| 31 | 39 |
| 32 //establish the requested controller as an object | |
| 33 public function CreateController() { | 40 public function CreateController() { |
| 41 /** | |
| 42 * Establish the requested controller as an object, and check if the query is valid. | |
| 43 * The queried controller, which should be extended from BaseController, exists and the queried action should be one of its method. | |
| 44 */ | |
| 45 | |
| 34 //does the class exist? | 46 //does the class exist? |
| 35 if (class_exists($this->controller)) { | 47 if (class_exists($this->controller)) { |
| 36 $parents = class_parents($this->controller); | 48 $parents = class_parents($this->controller); |
| 37 //does the class extend the controller class? | 49 //does the class extend the controller class? |
| 38 if (in_array("BaseController",$parents)) { | 50 if (in_array("BaseController",$parents)) { |
