diff 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
line wrap: on
line diff
--- a/classes/loader.php	Mon Apr 13 15:43:59 2015 +0200
+++ b/classes/loader.php	Thu Apr 16 14:53:22 2015 +0200
@@ -1,4 +1,8 @@
 <?php
+/** 
+* Loader is used to route parameters from input url and set parameters for controller.
+* The routing is done by the RewriteRule written in .htaccess file.
+*/
 
 class Loader {
 	private $controller;
@@ -6,31 +10,39 @@
 	private $urlvalues;
 	private $postdata = 0;
 
-	//store the URL values on object creation
 	public function __construct($urlvalues, $postdata) {
+		/** 
+		* It stores the URL values on object creation.
+		* For example, the URL structure is like this: some_domain_name/Extractapp/TaggingText. 
+		* The controller is "Extractapp" and the action is "TaggingText".
+		* For the "Extractapp" controller, there is a corresponding "extractapp.php" in "./controllers" folder.
+		* For the action "TaggingText", there is a corresponding "TaggingText.php" in "./views/Extractapp" folder.
+		* Under "./view" folder, the first level is named by the controller. Each action belongs to the controller is named by its action name.
+		*/
+
 		$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";
-			
+			$this->controller = "Extractapp";	// the default controller
+
 		} else {
 			$this->controller = $this->urlvalues['controller'];
 		}
 
 		if ($this->urlvalues['action'] == "") {
-			$this->action = "taggingtext";
-			// $this->action = "index";
+			$this->action = "TaggingText";	// the default action
+
 		} else {
 			$this->action = $this->urlvalues['action'];
 		}
-
 	}
 	
-	//establish the requested controller as an object
 	public function CreateController() {
+		/** 
+		* Establish the requested controller as an object, and check if the query is valid.
+		* The queried controller, which should be extended from BaseController, exists and the queried action should be one of its method.
+		*/
+
 		//does the class exist?
 		if (class_exists($this->controller)) {
 			$parents = class_parents($this->controller);