114 if(is_object($component) && ($component instanceof cbitrixcomponent))
116 $this->__name = $component->__name;
117 $this->__relativePath = $component->__relativePath;
118 $this->__path = $component->__path;
119 $this->__templateName = $component->__templateName;
120 $this->__templatePage = $component->__templatePage;
121 $this->__template = $component->__template;
122 $this->__component_epilog = $component->__component_epilog;
123 $this->arParams = $component->arParams;
124 $this->arResult = $component->arResult;
125 $this->arResultCacheKeys = $component->arResultCacheKeys;
126 $this->__parent = $component->__parent;
127 $this->__bInited = $component->__bInited;
128 $this->__arIncludeAreaIcons = $component->__arIncludeAreaIcons;
129 $this->__NavNum = $component->__NavNum;
130 $this->__cache = $component->__cache;
131 $this->__cacheID = $component->__cacheID;
132 $this->__cachePath = $component->__cachePath;
133 $this->__children_css = $component->__children_css;
134 $this->__children_js = $component->__children_js;
135 $this->__children_epilogs = $component->__children_epilogs;
136 $this->__children_frames = $component->__children_frames;
137 $this->__view = $component->__view;
138 $this->__currentCounter = $component->__currentCounter;
139 $this->__currentCounters = $component->__currentCounters;
140 $this->__editButtons = $component->__editButtons;
141 $this->classOfComponent = $component->classOfComponent;
142 $this->
setSiteId($component->getSiteId());
151 if (defined(
'DEFAULT_COMPONENT_TEMPLATE_ID'))
155 else if (defined(
'SITE_TEMPLATE_ID'))
161 $this->request = \Bitrix\Main\Context::getCurrent()->getRequest();
460 $this->__bInited =
false;
465 $this->__ShowError(
"Empty component name");
470 if ($path2Comp ==
'')
472 $this->__ShowError(sprintf(
"'%s' is not a valid component name",
$componentName));
477 $this->classOfComponent = self::__getClassForPath(
$componentPath);
479 if($this->classOfComponent ===
"")
481 $componentFile =
$_SERVER[
"DOCUMENT_ROOT"].$componentPath.
"/component.php";
482 if (!file_exists($componentFile) || !is_file($componentFile))
484 $this->__ShowError(sprintf(
"'%s' is not a component",
$componentName));
490 $this->__currentCounter = self::$__componentCounter[
$componentName];
493 $this->__relativePath = $path2Comp;
495 $this->arResult =
array();
496 $this->arParams =
array();
497 $this->__parent =
null;
498 $this->__arIncludeAreaIcons =
array();
499 $this->__cache =
null;
503 $this->__bInited =
true;
787 if (!$this->__bInited)
790 if ($this->__template)
791 $this->__template->includeTemplate($this->arResult);
793 if(is_array($this->arResultCacheKeys))
795 $arNewResult =
array();
796 foreach($this->arResultCacheKeys as
$key)
797 if(array_key_exists(
$key, $this->arResult))
798 $arNewResult[
$key] = $this->arResult[
$key];
799 $this->arResult = $arNewResult;
802 if(!empty($this->__editButtons))
804 foreach($this->__editButtons as $button)
806 if($button[0] ==
'AddEditAction')
807 $this->
addEditAction($button[1], $button[2], $button[3], $button[4]);
809 $this->
addDeleteAction($button[1], $button[2], $button[3], $button[4]);
813 $this->__template->endViewTarget();
867 $LANGUAGE_ID = LANGUAGE_ID;
872 $SITE_TEMPLATE_ID = (defined(
"SITE_TEMPLATE_ID")? SITE_TEMPLATE_ID:
"");
876 $cacheID =
$SITE_ID.
"|".$LANGUAGE_ID.($SITE_TEMPLATE_ID !=
"" ?
"|".$SITE_TEMPLATE_ID:
"").
"|".$this->__name.
"|".$this->getTemplateName().
"|";
878 foreach($this->arParams as
$k=>$v)
879 if(strncmp(
"~",
$k, 1))
880 $cacheID .=
",".$k.
"=".serialize($v);
882 if(($offset = CTimeZone::getOffset()) <> 0)
883 $cacheID .=
"|".$offset;
885 if ($additionalCacheID !==
false)
886 $cacheID .=
"|".serialize($additionalCacheID);
888 if ($this->__currentCounter > 1)
890 $cacheID .=
"|".$this->__currentCounter;
904 final public function startResultCache($cacheTime =
false, $additionalCacheID =
false, $cachePath =
false)
909 if (!$this->__bInited)
912 if ($this->arParams[
"CACHE_TYPE"] ==
"N" || ($this->arParams[
"CACHE_TYPE"] ==
"A" && COption::getOptionString(
"main",
"component_cache_on",
"Y") ==
"N"))
915 if ($cacheTime ===
false)
916 $cacheTime = intval($this->arParams[
"CACHE_TIME"] ?? 0);
918 $this->__cacheID = $this->
getCacheID($additionalCacheID);
919 $this->__cachePath = $cachePath;
920 if ($this->__cachePath ===
false)
921 $this->__cachePath =
$CACHE_MANAGER->getCompCachePath($this->__relativePath);
923 $this->__cache = \Bitrix\Main\Data\Cache::createInstance([
'actual_data' =>
false]);
924 if ($this->__cache->startDataCache($cacheTime, $this->__cacheID, $this->__cachePath))
926 $this->__NavNum =
$GLOBALS[
"NavNum"] ??
null;
927 $this->__currentCounters = self::$__componentCounter;
929 if (defined(
"BX_COMP_MANAGED_CACHE") && $this->__cache->isStarted())
936 $arCache = $this->__cache->GetVars();
937 $this->arResult = $arCache[
"arResult"];
938 if (array_key_exists(
"templateCachedData", $arCache))
940 $templateCachedData = & $arCache[
"templateCachedData"];
942 if ($templateCachedData && is_array($templateCachedData))
944 if (array_key_exists(
"additionalCSS", $templateCachedData) && $templateCachedData[
"additionalCSS"] <>
'')
946 $APPLICATION->SetAdditionalCSS($templateCachedData[
"additionalCSS"]);
948 $this->__parent->addChildCSS($templateCachedData[
"additionalCSS"]);
951 if (array_key_exists(
"additionalJS", $templateCachedData) && $templateCachedData[
"additionalJS"] <>
'')
953 $APPLICATION->AddHeadScript($templateCachedData[
"additionalJS"]);
955 $this->__parent->addChildJS($templateCachedData[
"additionalJS"]);
958 if (array_key_exists(
"frames", $templateCachedData) && is_array($templateCachedData[
"frames"]))
960 foreach ($templateCachedData[
"frames"] as $frameState)
965 $this->__parent->addChildFrame($frame);
971 array_key_exists(
"__children_frames", $templateCachedData) &&
972 is_array($templateCachedData[
"__children_frames"])
975 foreach ($templateCachedData[
"__children_frames"] as $frame)
981 if (array_key_exists(
"frameMode", $templateCachedData))
983 $templateFrameMode = $templateCachedData[
"frameMode"];
992 $context = isset($templateCachedData[
"frameModeCtx"])
993 ?
"(from component cache) ".$templateCachedData[
"frameModeCtx"]
994 : $this->__name.
" - a cached template set frameMode=false";
1001 if (isset($templateCachedData[
"externalCss"]))
1003 foreach ($templateCachedData[
"externalCss"] as $cssPath)
1008 $this->__parent->addChildCSS($cssPath);
1012 if (isset($templateCachedData[
"externalJs"]))
1014 foreach ($templateCachedData[
"externalJs"] as $jsPath)
1019 $this->__parent->addChildJS($jsPath);
1024 if (isset($templateCachedData[
"__editButtons"]))
1026 foreach ($templateCachedData[
"__editButtons"] as $button)
1028 if ($button[0] ==
'AddEditAction')
1029 $this->
addEditAction($button[1], $button[2], $button[3], $button[4]);
1031 $this->
addDeleteAction($button[1], $button[2], $button[3], $button[4]);
1035 if (isset($templateCachedData[
"__view"]))
1037 foreach ($templateCachedData[
"__view"] as $view_id => $target)
1038 foreach ($target as $view_content)
1039 $APPLICATION->addViewContent($view_id, $view_content[0], $view_content[1]);
1042 if (array_key_exists(
"__NavNum", $templateCachedData))
1044 $GLOBALS[
"NavNum"]+= $templateCachedData[
"__NavNum"];
1047 if (array_key_exists(
"__currentCounters", $templateCachedData))
1055 if (array_key_exists(
"__children_css", $templateCachedData))
1057 foreach ($templateCachedData[
"__children_css"] as $css_url)
1061 if (array_key_exists(
"__children_js", $templateCachedData))
1063 foreach ($templateCachedData[
"__children_js"] as $js_url)
1067 if (array_key_exists(
"__children_epilogs", $templateCachedData))
1069 foreach ($templateCachedData[
"__children_epilogs"] as $component_epilog)
1070 $this->includeComponentEpilog($component_epilog);
1073 if (array_key_exists(
"component_epilog", $templateCachedData))
1075 $this->includeComponentEpilog($templateCachedData[
"component_epilog"]);
1092 if (!$this->__bInited)
1095 if (!$this->__cache)
1097 if ($this->__parent)
1099 foreach ($this->__children_css as $cssPath)
1101 $this->__parent->addChildCSS($cssPath);
1104 foreach ($this->__children_js as $jsPath)
1106 $this->__parent->addChildJS($jsPath);
1109 foreach ($this->__children_epilogs as $epilogFile)
1111 $this->__parent->addChildEpilog($epilogFile);
1114 foreach ($this->__children_frames as $frame)
1116 $this->__parent->addChildFrame($frame);
1123 "arResult" => $this->arResult,
1125 if ($this->__template)
1127 $arCache[
"templateCachedData"] = $this->__template->getCachedData();
1128 if ($this->__component_epilog)
1129 $arCache[
"templateCachedData"][
"component_epilog"] = $this->__component_epilog;
1133 $arCache[
"templateCachedData"] =
array();
1136 if (($this->__NavNum !==
false) && ($this->__NavNum !== $NavNum))
1138 $arCache[
"templateCachedData"][
"__NavNum"] = $NavNum - $this->__NavNum;
1141 $currentCountersDiff =
array();
1158 if (!empty($currentCountersDiff))
1160 $arCache[
"templateCachedData"][
"__currentCounters"] = $currentCountersDiff;
1163 if (!empty($this->__children_css))
1165 $arCache[
"templateCachedData"][
"__children_css"] = $this->__children_css;
1166 if ($this->__parent)
1168 foreach($this->__children_css as $cssPath)
1169 $this->__parent->addChildCSS($cssPath);
1173 if (!empty($this->__children_js))
1175 $arCache[
"templateCachedData"][
"__children_js"] = $this->__children_js;
1176 if ($this->__parent)
1178 foreach($this->__children_js as $jsPath)
1179 $this->__parent->addChildJS($jsPath);
1183 if (!empty($this->__children_epilogs))
1185 $arCache[
"templateCachedData"][
"__children_epilogs"] = $this->__children_epilogs;
1186 if ($this->__parent)
1188 foreach($this->__children_epilogs as $epilogFile)
1189 $this->__parent->addChildEpilog($epilogFile);
1193 if (!empty($this->__children_frames))
1195 $arCache[
"templateCachedData"][
"__children_frames"] =
1198 return $frame->getCachedData();
1200 $this->__children_frames
1203 if ($this->__parent)
1205 foreach ($this->__children_frames as $frame)
1207 $this->__parent->addChildFrame($frame);
1212 if (!empty($this->__view))
1213 $arCache[
"templateCachedData"][
"__view"] = $this->__view;
1215 if (!empty($this->__editButtons))
1216 $arCache[
"templateCachedData"][
"__editButtons"] = $this->__editButtons;
1218 $cacheWasStarted = $this->__cache->isStarted();
1219 $this->__cache->endDataCache($arCache);
1221 if (defined(
"BX_COMP_MANAGED_CACHE") && $cacheWasStarted)
1224 $this->__cache =
null;
1429 if (!$entryId || !$deleteLink)
1432 includeModuleLangFile(__FILE__);
1435 $deleteTitle =
GetMessage(
'DELETE_ACTION_TITLE_DEFAULT');
1442 $arParams[
'ICON'] =
'bx-context-toolbar-delete-icon';
1444 if (!str_starts_with($deleteLink,
'javascript:'))
1446 if (
false === mb_strpos($deleteLink,
'return_url='))
1447 $deleteLink.=
'&return_url='.urlencode(
$APPLICATION->getCurPageParam());
1449 $deleteLink.=
'&'.bitrix_sessid_get();
1453 $deleteLink =
'javascript:if(confirm(\''.CUtil::JSEscape($confirmText).
'\')) jsUtils.Redirect([], \
''.CUtil::JSEscape($deleteLink).
'\');
';
1458 'URL
' => $deleteLink,
1459 'TITLE
' => $deleteTitle,
1462 if ($arParams['ICON
'])
1463 $arBtn['ICON
'] = $arParams['ICON
'];
1464 elseif ($arParams['SRC
'] || $arParams['IMAGE
'])
1465 $arBtn['SRC
'] = $arParams['IMAGE
'] ? $arParams['IMAGE
'] : $arParams['SRC
'];
1467 $APPLICATION->setEditArea($this->getEditAreaId($entryId), array(