/** * if cacheing is active and a cached file is availible it outputs the cache and exits the script * * @return void */ public function load() { // gets the current uri - example: /folder/folder2 $filename = $this->getCacheName(); // create the cache filename $cacheFilename = self::DIR_PAGES . $filename . '.cache.php'; $cacheFilenamePhpData = self::DIR_PAGES . $filename . '.cache.config.php'; $menuItemTranslation = false; $domain = false; $httpStatusCode = 200; $executedBlocks = []; if (defined('GLOBAL_CACHING_ENABLED') && GLOBAL_CACHING_ENABLED && !$this->request->isXmlHttpRequest() && !$this->request->isPost() && $this->user->isAdmin() === false && is_file($cacheFilename) && is_file($cacheFilenamePhpData)) { include $cacheFilenamePhpData; if ($menuItemTranslation) { $menuItemTranslation = json_decode($menuItemTranslation); if (is_object($menuItemTranslation)) { if ($this->request->isXmlHttpRequest() === false && $this->route->isHttps() === false && $menuItemTranslation->menuItem->https === true) { $this->route->redirectToUrl('https://' . $this->route->getRequestRoute()); } $this->locale->setLocale($menuItemTranslation->locale); $this->template->setSiteTemplateDir($menuItemTranslation->menuItem->site->templateDir); $this->route->setCurrentMenuItem($menuItemTranslation->menuItem); $this->route->setCurrentMenuItemTranslation($menuItemTranslation); $this->route->setCurrentDomain($domain); if ($this->isCachingActive($menuItemTranslation->menuItem)) { $this->blockParser->setExecutedBlocks(json_decode($executedBlocks)); // display the cached file to the client $contents = file_get_contents($cacheFilename); $this->blockParser->setParseCached(true); $content = $this->blockParser->parse($contents, 'outputFilter'); $this->response->sendHTTPStatusCode($httpStatusCode); echo $this->core->includeScript($content); exit; } } } } }
/** * @param $menuItemTranslation * @return bool */ private function setupPage($menuItemTranslation) { try { $this->currentMenuItemTranslation = $menuItemTranslation; $this->currentMenuItem = $menuItemTranslation->menuItem; $this->locale->setLocale($menuItemTranslation->locale); $this->template->setSiteTemplateDir($menuItemTranslation->menuItem->site->templateDir); $pageTitle = ((string) $menuItemTranslation->pageTitle === '' ? $menuItemTranslation->title : $menuItemTranslation->pageTitle) . ' | ' . $menuItemTranslation->menuItem->site->name; $this->template->setPageTitle($pageTitle); $this->template->setPageDescription($menuItemTranslation->longDescription); $this->template->setKeywords(explode(',', $menuItemTranslation->keywords)); setlocale(LC_ALL, $this->locale->getLocale()->locale); } catch (Exception $e) { return false; } return true; }
/** * @param $menuItemTranslation * @return bool * @throws \Exception */ protected function setupPage($menuItemTranslation) { try { $this->currentMenuItemTranslation = $menuItemTranslation; $this->currentMenuItem = $menuItemTranslation->menuItem; $this->db->setTranslatableLocale($menuItemTranslation->locale->locale); $this->template->setSiteTemplateDir($menuItemTranslation->menuItem->site->templateDir); if ($this->request->isXmlHttpRequest() || $this->user->isAdmin()) { $localeId = $this->request->gp('locale_id'); if ($localeId && is_numeric($localeId)) { $this->locale->setLocale($localeId); } else { $this->locale->setLocale($menuItemTranslation->locale); } } else { $this->locale->setLocale($menuItemTranslation->locale); } $pageTitle = (string) $menuItemTranslation->pageTitle === '' ? $menuItemTranslation->title : $menuItemTranslation->pageTitle; $pageTitle = str_replace('[SITE_NAME]', $menuItemTranslation->menuItem->site->name, $pageTitle); $this->template->setPageTitle($pageTitle); $this->template->setPageDescription($menuItemTranslation->description); $this->template->setKeywords(explode(',', $menuItemTranslation->keywords)); setlocale(LC_ALL, $this->locale->getLocale()->locale); } catch (Exception $e) { throw new \Exception('Error setup page: ' . $e->getMessage()); } return true; }