예제 #1
0
파일: Response.php 프로젝트: fraym/core
 /**
  * @param bool $exit
  * @param bool $parseOutput
  * @return $this
  */
 public function finish($exit = true, $parseOutput = false)
 {
     // get the output and eval for precaching
     $content = ob_get_clean();
     if ($parseOutput === true) {
         // Output the source to the client, for dynamic cache we need to eval the output source
         $content = $this->core->includeScript($content);
         // Filter the output to assign css or js files, sets title or meta tags
         $content = $this->template->outputFilter($content);
     }
     $this->addHTTPHeader("Content-Length: " . strlen($content));
     foreach ($this->_httpHeaders as $header) {
         $this->sendHTTPHeader($header);
     }
     echo $content;
     if ($exit) {
         exit;
     }
     return $this;
 }
예제 #2
0
파일: Cache.php 프로젝트: fraym/core
 /**
  * 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;
                 }
             }
         }
     }
 }
예제 #3
0
파일: BlockParser.php 프로젝트: fraym/core
 /**
  * @param $xml
  * @return array|string
  */
 protected function contentChildViews($xml)
 {
     $childsHtml = [];
     foreach ($xml->children() as $child) {
         $contentId = $this->getContentId($child);
         $blocks = $this->getDataFromBlocksByContentId($contentId);
         // In Editmode we want to render all views to insert content
         if (empty($blocks) && $this->getXmlAttr($child, 'hideEmpty') !== false && empty($placeholder) && $this->block->inEditMode() === false) {
             continue;
         }
         if (empty($blocks) && !empty($placeholder) && $this->block->inEditMode() === false) {
             $blocks = $this->blockController->createEditViewElement($child, $placeholder);
         }
         // result returns an array
         $result = $this->contentChildViews($child);
         $addContent = $this->getXmlAttr($child, 'add') ?: 'afterContent';
         if (!isset($childsHtml[$addContent])) {
             $childsHtml[$addContent] = '';
         }
         if (count($result) > 0) {
             $blockhtml = (isset($result['beforeContent']) ? $result['beforeContent'] : '') . $this->core->includeScript($blocks) . (isset($result['afterContent']) ? $result['afterContent'] : '');
             if (trim($blockhtml) === '') {
                 $childsHtml[$addContent] .= isset($childsHtml[$addContent]) ? $childsHtml[$addContent] : '';
             } else {
                 $childsHtml[$addContent] .= (isset($childsHtml[$addContent]) ? $childsHtml[$addContent] : '') . $this->blockController->createEditViewElement($child, $blockhtml);
             }
         } else {
             $blockhtml = $this->core->includeScript($blocks);
             if (trim($blockhtml) === '') {
                 $childsHtml[$addContent] .= '';
             } else {
                 $childsHtml[$addContent] .= $this->blockController->createEditViewElement($child, $blockhtml);
             }
         }
     }
     return $childsHtml;
 }
예제 #4
0
파일: Template.php 프로젝트: fraym/core
 /**
  * @param null $content
  * @return string
  */
 public function prepareTemplate($content = null)
 {
     if ($content === null) {
         // get the template content
         $content = $this->getTemplateContent();
     }
     $this->currentTemplateContent = $content;
     $content = $this->replaceCustomTemplateFunctions($content);
     $content = $this->replaceTemplateTags($content);
     $this->template = null;
     $vars = $this->getTemplateVarString();
     return $this->core->includeScript($vars . $content, [&$this, 'errorHandler']);
 }