public function initView() { if ($this->view === null || !$this->view instanceof View) { $module = $this->getRequest()->getModuleName(); $paths = $this->getFrontController()->getControllerDirectory(); $modulePath = dirname($paths[$module]); $viewBaseDir = $modulePath . DIRECTORY_SEPARATOR . 'views'; $this->view = new View(array('basePath' => $viewBaseDir, 'encoding' => $this->defaultEncoding)); $this->view->setTheme(Application::getTheme()); $this->view->setModuleName($module); } return $this->view; }
/** * Dumps anything you need to see * * @param mixed $mixed - What to debug * @param string $element - Where to render it * @return string */ public static function debug($mixed, $element = '#content') { //TODO: RESTful debug $trace = debug_backtrace(); $view = new View(); $view->setModuleName('krn'); $view->loadTemplate('debug'); $view->setVariable('element', $element); $view->setVariable('trace', $trace); $view->setVariable('mixed', $mixed); $result = $view->render(); !Core::isAjax() || ($result = Html::ReplaceHtml($result, $element)); return $result; }
public function loadView($view_file) { if ($this->module != null) { $arr = explode("/", $view_file); if (count($arr) == 1) { $view_file .= "/index"; } $view = new View(); $view->setModuleName("module/" . $this->module); $view->setView($view_file); $view->setLayout($this->parent->getLayoutFile()); $view->setLayoutClass($this->parent->getLayout()); $view->setVar($this->parent->getVar()); $view->setVar($this->parent->getVar()); $view->setModuleMeta($this->parent->getModuleMeta()); $view->setModuleTitle($this->parent->getModuleTitle()); $view->setModuleCss($this->parent->getModuleCss()); $view->setModuleScript($this->parent->getModuleScript()); $view->CallView(); } else { return new TException("Vui lòng cho biết module cần truy cập. {$this->module}(module cân truy cập)", 401); } }
/** * Returns the error page * * The page is rendered using the * view template handler * * It also includes the trace of * the current execution * * This page can be edited in * the file tpl/krn/exception.tpl * * @param $error - The error trace ( an array('message' => 'The Error Message', 'file' => 'The File Name', 'Class' => 'The Class Name') ) * @return string - The rendered error page */ private static function throwException(array $error) { $trace = debug_backtrace(); $view = new View(); $view->setModuleName('krn'); $view->loadTemplate('exception'); $view->setVariable('error', $error); $view->setVariable('trace', $trace); return $view->render(false); }