_controller = $route['controller']; $this->_action = $route['action']; $this->_params = $route['params']; $this->set('_action',$this->_action); $this->set('_controller',$this->_controller); $this->set('title',capitalize($this->_action)); if (isset($this->_before)) { foreach ($this->_before as $method) { $this->$method(); } } } function render($action='') { global $errors; if ($action == '') { $action = $this->_action; } if ($this->_rendered) { return; } if ($errors->alwaysPrint()) print($errors->getHtml()); extract($this->_tplvars); $layouthead = LAYOUTS_PATH.$this->_layout.'/header.php'; $layoutfoot = LAYOUTS_PATH.$this->_layout.'/footer.php'; $tpl = VIEWS_PATH.strtolower($this->_controller).'/'.strtolower($action).'.php'; if (file_exists($layouthead)) { include($layouthead); } if (file_exists($tpl)) { include($tpl); } if (file_exists($layoutfoot)) { include($layoutfoot); } $this->_rendered = true; } function go() { $method = $this->_action; if (method_exists($this,$method)) { $this->$method(); } $this->render(); } function set($var,$val) { $this->_tplvars[$var] = $val; } function setLayout($layout) { $this->_layout = $layout; } function redirect($path) { $redirect = urlfor($path); header('Location: '.$redirect); exit; } function includeFile($file,$args=array()) { extract($args); include(VIEWS_PATH.$file); } } ?>