comparison classes/loader.php @ 81:f1f849d31272 extractapp

book_id as string
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Thu, 23 Apr 2015 14:58:27 +0200
parents 97c1e5102a22
children
comparison
equal deleted inserted replaced
80:c15f53afd7a5 81:f1f849d31272
1 <?php 1 <?php
2 /*
3 * loader.php
4 * This file is part of Extraction-interface.
5 *
6 * Extraction-interface is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * Extraction-interface is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with Extraction-interface. If not, see <http://www.gnu.org/licenses/>.
18 */
19
2 /** 20 /**
3 * Loader is used to route parameters from input url and set parameters for controller. 21 * 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. 22 * The routing is done by the RewriteRule written in .htaccess file.
5 */ 23 */
6 24
7 class Loader { 25 class Loader {
8 private $controller; 26 private $controller;
9 private $action; 27 private $action;
10 private $urlvalues; 28 private $urlvalues;
11 private $postdata = 0; 29 private $postdata = 0;
12 30
13 public function __construct($urlvalues, $postdata) { 31 public function __construct($urlvalues, $postdata) {
14 /** 32 /**
15 * It stores the URL values on object creation. 33 * It stores parameters in URL on object creation.
16 * For example, the URL structure is like this: some_domain_name/Extractapp/TaggingText. 34 *
17 * The controller is "Extractapp" and the action is "TaggingText". 35 * For example, the URL structure is like this: some_domain_name/Extractapp/TaggingText.
18 * For the "Extractapp" controller, there is a corresponding "extractapp.php" in "./controllers" folder. 36 * The controller is "Extractapp" and the action is "TaggingText".
19 * For the action "TaggingText", there is a corresponding "TaggingText.php" in "./views/Extractapp" folder. 37 *
20 * Under "./view" folder, the first level is named by the controller. Each action belongs to the controller is named by its action name. 38 * For the "Extractapp" controller, there is a corresponding "extractapp.php" in "./controllers" folder.
21 */ 39 *
40 * For the action "TaggingText", there is a corresponding "TaggingText.php" in "./views/Extractapp" folder.
41 *
42 * Under "./view" folder, the first level of the sub-folder is named by the controller's name.
43 * Each action controlled by the controller has it's own php file. The file name is the same as the the action's name.
44 */
22 45
23 $this->urlvalues = $urlvalues; 46 $this->urlvalues = $urlvalues;
24 $this->postdata = $postdata; 47 $this->postdata = $postdata;
25 if ($this->urlvalues['controller'] == "") { 48 if ($this->urlvalues['controller'] == "") {
26 $this->controller = "Extractapp"; // the default controller 49 $this->controller = "Extractapp"; // the default controller
37 } 60 }
38 } 61 }
39 62
40 public function CreateController() { 63 public function CreateController() {
41 /** 64 /**
42 * Establish the requested controller as an object, and check if the query is valid. 65 * 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. 66 * The queried controller, which should be extended from BaseController, exists and the queried action should be one of its method.
44 */ 67 */
45 68
46 //does the class exist? 69 //does the class exist?
47 if (class_exists($this->controller)) { 70 if (class_exists($this->controller)) {
48 $parents = class_parents($this->controller); 71 $parents = class_parents($this->controller);
49 //does the class extend the controller class? 72 //does the class extend the controller class?