Mercurial > hg > extraction-interface
view classes/basecontroller.php @ 78:960ba96efce1 extractapp
Update: click to popup remove-tag-window; select to popup tag-window
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Mon, 20 Apr 2015 15:44:54 +0200 |
parents | 97c1e5102a22 |
children | f1f849d31272 |
line wrap: on
line source
<?php /** * An instance of the BaseController class can't be created directly. * It can only be extended/inherited by other classes. */ 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. * 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 require 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; * 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); } } protected function ReturnView_localtest($viewmodel, $fullview) { /** 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); } } } ?>