Mercurial > hg > extraction-interface
diff classes/basecontroller.php @ 114:7d6a107c37da extractapp
refactoring, make it more condensed.
author | Calvin Yeh <cyeh@mpiwg-berlin.mpg.de> |
---|---|
date | Thu, 28 Sep 2017 14:01:59 +0200 |
parents | f1f849d31272 |
children |
line wrap: on
line diff
--- a/classes/basecontroller.php Thu Sep 28 13:44:57 2017 +0200 +++ b/classes/basecontroller.php Thu Sep 28 14:01:59 2017 +0200 @@ -16,63 +16,61 @@ * along with Extraction-interface. If not, see <http://www.gnu.org/licenses/>. */ -/** - * A controller can send commands to the model to process or update the model's state. +/** + * A controller can send commands to the model to process or update the model's state. * It can also pass the commands or data (from model) to the associated view to change the view's presentation. - * + * * An instance of the BaseController class can't be created directly. - * It can only be extended/inherited by other classes. - * For example in controllers/ folder, Extractapp is extended from the BaseController. + * It can only be extended/inherited by other classes. + * For example in controllers/ folder, Extractapp is extended from the BaseController. * An instance of Extractapp can be created directly. - * + * */ abstract class BaseController { - + protected $urlvalues; protected $action; - + public function __construct($action, $urlvalues, $postdata) { $this->action = $action; $this->urlvalues = $urlvalues; $this->postdata = $postdata; } - + public function ExecuteAction() { return $this->{$this->action}(); } - + protected function ReturnView($viewmodel, $fullview) { - /** - * Return the corresponding view in the views folder. + /** + * Return the corresponding view in the views folder. * We use the same class name as the folder's name and action name as the file's name in the folder hierarchy. * In this design, we can query the corresponding views php code by defining controller and action in url. - * - * If you also require the maintemplate.php, which now only contains scripts that need to be inclued, set $fullview to be true; + * + * If you also require the maintemplate.php, which now only contains scripts that need to be inclued, set $fullview to be true; * otherwise, the maintemplate.php will not be applied. */ $viewloc = 'views/' . get_class($this) . '/' . $this->action . '.php'; if ($fullview) { - require('views/maintemplate.php'); - require($viewloc); - } else { - require($viewloc); + //require('views/maintemplate.php'); } + + require($viewloc); } protected function ReturnView_localtest($viewmodel, $fullview) { - /** Return the corresponding view in the views folder. - * - * This is only been used when developing on local machine. + /** Return the corresponding view in the views folder. + * + * This is only been used when developing on local machine. */ $viewloc = 'views/' . get_class($this) . '/' . $this->action . '.php'; if ($fullview) { - require('views/maintemplate_local.php'); - require($viewloc); - } else { - require($viewloc); + //require('views/maintemplate_local.php'); } + + require($viewloc); } } -?> \ No newline at end of file +?>