public function run($method_params = array()) { $view_params = array(); if ($this->controller && $this->method) { $class_name = '\\' . APP_NAME . '\\controllers\\' . $this->controller; $controller = new $class_name($this->method, array_merge($this->params, $method_params)); $view_params = $controller->run(); } $content = ''; if ($this->view) { $view = new \core\classes\View(APP_VIEW_DIR . DS . $this->view . '.php', $view_params); ob_start(); $view->render(); $content = ob_get_clean(); } return $content; }
require_once LIB_DIR . DS . 'RLib/rstatic.php'; require_once LIB_DIR . DS . 'RLib/rdbiterator.php'; require_once APP_DIR . DS . 'config.php'; RStatic::set('config', $config = new \core\classes\config\Config($config)); RStatic::set('db', $db = new RDB('localhost', 'hmadmin', 'hmadmin', strtolower(APP_NAME))); RStatic::set('request', $request = new \core\classes\Request()); if ($request->str_path) { $page = $config->findPageByRequest($request); } else { $page = $config->getPageByTemplate('index'); } if (!$page) { $page = $config->getPageByTemplate('404'); } if (!$page) { header("HTTP/1.0 404 Not Found"); exit('Error 404'); } $page = $config->findRealPage($page); if ($page->redirect) { header("HTTP/1.0 301 Moved Permanently"); header("Location:" . $page->redirect); exit; } RStatic::set('session', $session = \core\classes\Session::instance()->start()); RStatic::set('page', $page); RStatic::set('layout', $layout = $page->layout); RStatic::set('params', $all_params = array_merge($config->params, $layout->params, $page->params)); $layout_params = array_merge($all_params, $page->getPlaceContent()); $layout = new \core\classes\View(APP_LAYOUT_DIR . DS . $layout->name . '.php', $layout_params); $layout->render();