/** * 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; } } } } }