_controller = $controller; $this->_action = $action; $this->render = $r; $this->submenu = array(); $this->setMenu(); $this->params = $params; if(is_array($GLOBALS['vars']) && is_array($this->params)) $this->params = array_merge($this->params, $GLOBALS['vars']); $this->menu_image = '/css/imgs/empty.png'; if($GLOBALS['redis'] !== false) $this->r = $GLOBALS['redis']; else $this->r = false; } function setMenu() { $this->menu_text = ''; $this->menu_priority = 1; } function redirect($url) { header("Location: $url"); exit(); } /** * override this function to check if a user can use this object * @return true -> user will be able to access * @return false -> user will not be able to access and this page won't * be shown in the menu * */ public function maySeeThisPage() { return true; } function set($name, $value) { $this->variables[$name] = $value; } function get($name) { return $this->variables[$name]; } function __destruct() { // if($this->render) // $this->_template->render(); } function addHelpers($m) { $m->addHelper('case', [ 'lower' => function($value) { return strtolower((string) $value); }, 'upper' => function($value) { return strtoupper((string) $value); } ]); $m->addHelper('!!', function($value) { return $value . '!!'; }); return $m; } function renderPagecontent() { $controller_dir = ROOT . DS . 'pages' . DS . $this->_controller . DS; //when the template path starts with a / it is relative to the root of the project if($this->variables['template'][0]=='/') $this->variables['template'] = '../../'.$this->variables['template']; if($this->variables['template'] && file_exists(ROOT . DS . 'pages' . DS . $this->_controller . DS . $this->variables['template'])) $templatefile = ROOT . DS . 'pages' . DS . $this->_controller . DS . $this->variables['template']; //render template by running include ob_start(); extract($this->variables); if($templatefile!= '') include($templatefile); $pagecontent = ob_get_contents(); ob_end_clean(); //$pagecontent = $m->render($template, $this->variables); return $pagecontent; } }