/** * @param string $context */ public static function rejectComposite($context = '') { return \Bitrix\Main\Data\StaticHtmlCache::applyComponentFrameMode($context); }
function __IncludePHPTemplate(&$arResult, &$arParams, $parentTemplateFolder = "") { /** @noinspection PhpUnusedLocalVariableInspection */ global $APPLICATION, $USER, $DB; if (!$this->__bInited) { return false; } // these vars are used in the template file /** @noinspection PhpUnusedLocalVariableInspection */ $templateName = $this->__name; /** @noinspection PhpUnusedLocalVariableInspection */ $templateFile = $this->__file; /** @noinspection PhpUnusedLocalVariableInspection */ $templateFolder = $this->__folder; /** @noinspection PhpUnusedLocalVariableInspection */ $componentPath = $this->__component->GetPath(); $component =& $this->__component; if ($this->__fileAlt != '') { include $_SERVER["DOCUMENT_ROOT"] . $this->__fileAlt; return null; } $templateData = false; include $_SERVER["DOCUMENT_ROOT"] . $this->__file; /** @var \Bitrix\Main\Page\FrameHelper $frame */ foreach ($this->frames as $frame) { if ($frame->isStarted() && !$frame->isEnded()) { $frame->end(); } } if (!$this->frameMode) { \Bitrix\Main\Data\StaticHtmlCache::applyComponentFrameMode($this->__file); } $component_epilog = $this->__folder . "/component_epilog.php"; if (file_exists($_SERVER["DOCUMENT_ROOT"] . $component_epilog)) { //These will be available with extract then component will //execute epilog without template $component->SetTemplateEpilog(array("epilogFile" => $component_epilog, "templateName" => $this->__name, "templateFile" => $this->__file, "templateFolder" => $this->__folder, "templateData" => $templateData)); } return null; }
/** * 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 = \Bitrix\Main\Data\Cache::createInstance(); if ($this->__cache->startDataCache($cacheTime, $this->__cacheID, $this->__cachePath)) { $this->__NavNum = $GLOBALS["NavNum"]; if (defined("BX_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) { \Bitrix\Main\Page\FrameHelper::applyCachedData($frameState); } } if (array_key_exists("frameMode", $templateCachedData) && $templateCachedData["frameMode"] === false) { $context = isset($templateCachedData["frameModeCtx"]) ? "(from component cache) " . $templateCachedData["frameModeCtx"] : $this->__name . " - a cached template set frameMode=false"; \Bitrix\Main\Data\StaticHtmlCache::applyComponentFrameMode($context); } if (isset($templateCachedData["externalCss"])) { foreach ($templateCachedData["externalCss"] as $cssPath) { $APPLICATION->SetAdditionalCSS($cssPath); //Check if parent component exists and plug css it to it's "collection" if ($this->__parent) { $this->__parent->addChildCSS($cssPath); } } } if (isset($templateCachedData["externalJs"])) { foreach ($templateCachedData["externalJs"] as $jsPath) { $APPLICATION->AddHeadScript($jsPath); //Check if parent component exists and plug js it to it's "collection" if ($this->__parent) { $this->__parent->addChildJS($jsPath); } } } } 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; } }