/** * Function starts the caching block of the component execution. * * @param int|bool $cacheTime * @param mixed $additionalCacheID * @param string|bool $cachePath * @return string * */ public final function startResultCache($cacheTime = false, $additionalCacheID = false, $cachePath = false) { /** @global CMain $APPLICATION */ global $APPLICATION, $CACHE_MANAGER; if (!$this->__bInited) { return null; } if ($this->arParams["CACHE_TYPE"] == "N" || $this->arParams["CACHE_TYPE"] == "A" && COption::getOptionString("main", "component_cache_on", "Y") == "N") { return true; } if ($cacheTime === false) { $cacheTime = intval($this->arParams["CACHE_TIME"]); } $this->__cacheID = $this->getCacheID($additionalCacheID); $this->__cachePath = $cachePath; if ($this->__cachePath === false) { $this->__cachePath = $CACHE_MANAGER->getCompCachePath($this->__relativePath); } $this->__cache = \Freetrix\Main\Data\Cache::createInstance(); if ($this->__cache->startDataCache($cacheTime, $this->__cacheID, $this->__cachePath)) { $this->__NavNum = $GLOBALS["NavNum"]; if (defined("FX_COMP_MANAGED_CACHE") && $this->__cache->isStarted()) { $CACHE_MANAGER->startTagCache($this->__cachePath); } return true; } else { $arCache = $this->__cache->GetVars(); $this->arResult = $arCache["arResult"]; if (array_key_exists("templateCachedData", $arCache)) { $templateCachedData =& $arCache["templateCachedData"]; if ($templateCachedData && is_array($templateCachedData)) { if (array_key_exists("additionalCSS", $templateCachedData) && strlen($templateCachedData["additionalCSS"]) > 0) { $APPLICATION->SetAdditionalCSS($templateCachedData["additionalCSS"]); if ($this->__parent) { $this->__parent->addChildCSS($templateCachedData["additionalCSS"]); } } if (array_key_exists("additionalJS", $templateCachedData) && strlen($templateCachedData["additionalJS"]) > 0) { $APPLICATION->AddHeadScript($templateCachedData["additionalJS"]); if ($this->__parent) { $this->__parent->addChildJS($templateCachedData["additionalJS"]); } } if (array_key_exists("frames", $templateCachedData) && is_array($templateCachedData["frames"])) { foreach ($templateCachedData["frames"] as $frameState) { \Freetrix\Main\Page\FrameHelper::applyCachedData($frameState); } } } if ($templateCachedData["__editButtons"]) { foreach ($templateCachedData["__editButtons"] as $button) { if ($button[0] == 'AddEditAction') { $this->addEditAction($button[1], $button[2], $button[3], $button[4]); } else { $this->addDeleteAction($button[1], $button[2], $button[3], $button[4]); } } } if ($templateCachedData["__view"]) { foreach ($templateCachedData["__view"] as $view_id => $target) { foreach ($target as $view_content) { $APPLICATION->addViewContent($view_id, $view_content[0], $view_content[1]); } } } if (array_key_exists("__NavNum", $templateCachedData)) { $GLOBALS["NavNum"] += $templateCachedData["__NavNum"]; } if (array_key_exists("__children_css", $templateCachedData)) { foreach ($templateCachedData["__children_css"] as $css_url) { $APPLICATION->setAdditionalCSS($css_url); } } if (array_key_exists("__children_js", $templateCachedData)) { foreach ($templateCachedData["__children_js"] as $js_url) { $APPLICATION->addHeadScript($js_url); } } if (array_key_exists("__children_epilogs", $templateCachedData)) { foreach ($templateCachedData["__children_epilogs"] as $component_epilog) { $this->includeComponentEpilog($component_epilog); } } if (array_key_exists("component_epilog", $templateCachedData)) { $this->includeComponentEpilog($templateCachedData["component_epilog"]); } } return false; } }
function ApplyCachedData($arData) { /** @global CMain $APPLICATION */ global $APPLICATION; if ($arData && is_array($arData)) { if (array_key_exists("additionalCSS", $arData) && strlen($arData["additionalCSS"]) > 0) { $APPLICATION->SetAdditionalCSS($arData["additionalCSS"]); //Check if parent component exists and plug css it to it's "collection" if ($this->__component && $this->__component->__parent) { $this->__component->__parent->addChildCSS($this->__folder . "/style.css"); } } if (array_key_exists("additionalJS", $arData) && strlen($arData["additionalJS"]) > 0) { $APPLICATION->AddHeadScript($arData["additionalJS"]); //Check if parent component exists and plug js it to it's "collection" if ($this->__component && $this->__component->__parent) { $this->__component->__parent->addChildJS($this->__folder . "/script.js"); } } if (array_key_exists("frames", $arData) && is_array($arData["frames"])) { foreach ($arData["frames"] as $frameState) { \Freetrix\Main\Page\FrameHelper::applyCachedData($frameState); } } } }