/** * @param int $mode */ public function init($mode = Core::ROUTE_NORMAL) { $globalConfigs = array('ENV' => self::ENV_DEVELOPMENT, 'JS_FOLDER' => '/js', 'CSS_FOLDER' => '/css', 'CONSOLIDATE_FOLDER' => '/consolidated', 'PROFILER_ENABLED' => false); foreach ($globalConfigs as $config => $val) { if (!defined($config)) { define($config, $val); } } if (ENV == self::ENV_DEVELOPMENT) { error_reporting(E_ALL | E_STRICT); ini_set("display_errors", 1); } if (is_object($this->session) && $this->isCLI() === false) { $this->session->start(); } $this->mode = $mode; $this->startTimer(__CLASS__); // Assign our output handler to output clean errors ob_start(); // ingore user abort, is recommed for ajax request and db changes if ($this->request->isXmlHttpRequest()) { ignore_user_abort(true); } $this->registryManager->init(); if ($this->isCLI() === false) { // Sanitize all request variables $_GET = $this->sanitize($_GET); $_POST = $this->sanitize($_POST); $_COOKIE = $this->sanitize($_COOKIE); if ($mode === Core::ROUTE_NORMAL) { $this->cache->load(); // Try to load a site by the requested URI $this->route->loadSite(); if (!$this->request->isXmlHttpRequest() && !$this->request->isPost()) { echo '<!-- ' . $this->getPageLoadTime() . 'sec -->'; } $this->response->finish(false, true); } } else { $params = getopt('p:'); if ($params['p']) { $_SERVER['REQUEST_URI'] = $params['p']; $this->route->loadVirtualRoutes(); echo $this->route->checkVirtualRoute(); } } }
/** * @param int $mode */ public function init($mode = Core::ROUTE_NORMAL) { if (ENV == self::ENV_DEVELOPMENT) { error_reporting(E_ALL | E_STRICT); ini_set("display_errors", 1); } if (is_object($this->session) && $this->isCLI() === false) { $this->session->start(); } $this->mode = $mode; $this->startTimer(__CLASS__); // Assign our output handler to output clean errors ob_start(); // ingore user abort, is recommed for ajax request and db changes if ($this->request->isXmlHttpRequest()) { ignore_user_abort(true); } $this->registryManager->init(); if ($this->isCLI() === false) { // Sanitize all request variables $_GET = $this->sanitize($_GET); $_POST = $this->sanitize($_POST); $_COOKIE = $this->sanitize($_COOKIE); if ($mode === Core::ROUTE_NORMAL) { $this->cache->load(); // Try to load a site by the requested URI $this->route->loadSite(); $this->response->finish(false, true); } } else { $params = getopt('p:'); if ($params['p']) { $_SERVER['REQUEST_URI'] = $params['p']; $this->route->loadRoutes(); echo $this->route->getVirtualRouteContent(); } } }
/** * */ public function menuItemNotFound() { $page404 = null; if ($this->currentMenuItem) { $localeId = $this->session->get('localeId', false); $page404 = $this->db->createQueryBuilder()->select("menuItemTranslation, menuItem, template, site, locale")->from('\\Fraym\\Menu\\Entity\\MenuItemTranslation', 'menuItemTranslation')->join('menuItemTranslation.menuItem', 'menuItem')->leftJoin("menuItem.template", 'template')->join("menuItem.site", 'site')->join("menuItemTranslation.locale", 'locale')->setMaxResults(1)->setParameter('site', $this->currentMenuItem->site->id)->where("site.id = :site AND menuItem.is404 = 1 AND menuItem.active = 1"); if ($localeId) { $page404 = $page404->andWhere('locale.id = :locale')->setParameter('locale', $localeId); } else { $page404 = $page404->andWhere('locale.default = 1'); } $page404 = $page404->getQuery()->getOneOrNullResult(); } // call site note found view if (is_object($page404)) { $this->render404Site($page404); // cache the 404 page $this->cache->setCacheContent(); } else { error_log('Menuitem not found or template not set!'); $this->response->sendHTTPStatusCode(500); } $this->response->finish(true, true); }