public function __construct($db = null) { if ($db) { $this->db = $db; } else { $this->db = \RStatic::get('db'); } }
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();