15 "templateExt" => [
"php"],
41 private $frameMode =
null;
42 private $languageId =
false;
43 private $externalCss = [];
44 private $externalJs = [];
48 $this->__bInited =
false;
51 $this->__fileAlt =
"";
66 if (!$this->__bInited)
85 if (!$this->__bInited)
104 if (!$this->__bInited)
109 return $this->__file;
123 if (!$this->__bInited)
128 return $this->__folder;
142 if (!$this->__bInited)
147 return $this->__siteTemplate;
161 if (!$this->__bInited)
166 return $this->__templateInTheme;
178 $this->languageId = $languageId;
190 return $this->languageId;
205 if (!$this->__bInited)
212 if ($this->__folder <>
'')
214 $fname =
$_SERVER[
"DOCUMENT_ROOT"] . $this->__folder .
"/style.css";
215 if (file_exists($fname))
217 $arReturn[
"additionalCSS"] = $this->__folder .
"/style.css";
220 $fname =
$_SERVER[
"DOCUMENT_ROOT"] . $this->__folder .
"/script.js";
221 if (file_exists($fname))
223 $arReturn[
"additionalJS"] = $this->__folder .
"/script.js";
227 if (!empty($this->frames))
229 $arReturn[
"frames"] = [];
230 foreach ($this->frames as $frame)
232 $arReturn[
"frames"][] = $frame->getCachedData();
236 $arReturn[
"frameMode"] = $this->frameMode;
237 if (!$this->frameMode)
239 $arReturn[
"frameModeCtx"] = $this->__file;
242 if ($this->externalCss)
244 $arReturn[
"externalCss"] = $this->externalCss;
247 if ($this->externalJs)
249 $arReturn[
"externalJs"] = $this->externalJs;
268 if ($arData && is_array($arData))
270 if (array_key_exists(
"additionalCSS", $arData) && $arData[
"additionalCSS"] <>
'')
272 $APPLICATION->SetAdditionalCSS($arData[
"additionalCSS"]);
274 if ($this->__component && $this->__component->__parent)
276 $this->__component->__parent->addChildCSS($this->__folder .
"/style.css");
280 if (array_key_exists(
"additionalJS", $arData) && $arData[
"additionalJS"] <>
'')
284 if ($this->__component && $this->__component->__parent)
286 $this->__component->__parent->addChildJS($this->__folder .
"/script.js");
290 if (array_key_exists(
"frames", $arData) && is_array($arData[
"frames"]))
292 foreach ($arData[
"frames"] as $frameState)
295 if ($this->__component && $this->__component->__parent)
297 $this->__component->__parent->addChildFrame($frame);
302 if (array_key_exists(
"frameMode", $arData))
308 $context = isset($arData[
"frameModeCtx"]) ?
"(from component cache) " . $arData[
"frameModeCtx"] :
"";
314 if (isset($arData[
"externalCss"]))
316 foreach ($arData[
"externalCss"] as $cssPath)
320 if ($this->__component && $this->__component->__parent)
322 $this->__component->__parent->addChildCSS($cssPath);
327 if (isset($arData[
"externalJs"]))
329 foreach ($arData[
"externalJs"] as $jsPath)
333 if ($this->__component && $this->__component->__parent)
335 $this->__component->__parent->addChildJS($jsPath);
354 array_key_exists(
"arCustomTemplateEngines",
$GLOBALS)
355 && is_array(
$GLOBALS[
"arCustomTemplateEngines"])
356 && !empty(
$GLOBALS[
"arCustomTemplateEngines"])
362 if (is_array($arTemplateEngines) && !empty($arTemplateEngines))
373 foreach ($engineValue[
"templateExt"] as $ext)
390 public function Init(&$component, $siteTemplate =
false, $customTemplatePath =
"")
394 $this->__bInited =
false;
396 if ($siteTemplate ===
false)
398 $this->__siteTemplate = $component->getSiteTemplateId();
402 $this->__siteTemplate = $siteTemplate;
405 if ($this->__siteTemplate ==
'')
407 $this->__siteTemplate =
".default";
411 $this->__fileAlt =
"";
412 $this->__folder =
"";
419 if (!($component instanceof cbitrixcomponent))
424 $this->__component = &$component;
426 $this->__name = $this->__component->GetTemplateName();
427 if ($this->__name ==
'')
429 $this->__name =
".default";
432 $this->__name = preg_replace(
"'[\\\\/]+'",
"/", $this->__name);
433 $this->__name = trim($this->__name,
"/");
435 if (!self::CheckName($this->__name))
437 $this->__name =
".default";
440 $this->__page = $this->__component->GetTemplatePage();
441 if ($this->__page ==
'')
443 $this->__page =
"template";
453 $this->__bInited =
true;
468 return preg_match(
"#^([A-Za-z0-9_.-]+)(/[A-Za-z0-9_.-]+)?$#i",
$name) > 0;
498 if (file_exists($filePath) && is_file($filePath))
515 foreach ($folders as $folder)
517 if (is_dir(
$_SERVER[
"DOCUMENT_ROOT"] . $folder[
"path"] .
"/" . $this->__name))
536 foreach ($folders as $folder)
538 $folderPath =
$_SERVER[
"DOCUMENT_ROOT"] . $folder[
"path"];
539 $pageName = $templatePage . $ext;
540 if (file_exists(implode($delimeter, [$folderPath, $this->__name, $pageName])))
555 $relativePath = $component->GetRelativePath();
556 $parentComponent = $component->GetParent();
557 $siteTemplate = $component->getSiteTemplateId();
559 $defSiteTemplate = ($siteTemplate ==
".default");
560 $parentTemplatePath =
'';
561 $parentRelativePath =
'';
562 if ($parentComponent && $parentComponent->GetTemplate())
564 $parentRelativePath = $parentComponent->GetRelativePath();
565 $parentTemplateName = $parentComponent->GetTemplate()->GetName();
566 if ($parentTemplateName <>
'')
568 $parentTemplatePath =
"/" . $parentTemplateName;
571 if (!$defSiteTemplate)
574 "path" =>
"/local/templates/" . $siteTemplate .
"/components" . $parentRelativePath . $parentTemplatePath . $relativePath,
579 "path" =>
"/local/templates/.default/components" . $parentRelativePath . $parentTemplatePath . $relativePath,
581 "site_template" =>
".default",
584 "path" =>
"/local/components" . $parentRelativePath .
"/templates" . $parentTemplatePath . $relativePath,
586 "site_template" =>
"",
589 if (!$defSiteTemplate)
592 "path" =>
"/local/templates/" . $siteTemplate .
"/components" . $relativePath,
596 "path" =>
"/local/templates/.default/components" . $relativePath,
597 "site_template" =>
".default",
600 "path" =>
"/local/components" . $relativePath .
"/templates",
601 "site_template" =>
"",
604 if ($parentComponent)
606 if (!$defSiteTemplate)
609 "path" => BX_PERSONAL_ROOT .
"/templates/" . $siteTemplate .
"/components" . $parentRelativePath . $parentTemplatePath . $relativePath,
614 "path" => BX_PERSONAL_ROOT .
"/templates/.default/components" . $parentRelativePath . $parentTemplatePath . $relativePath,
616 "site_template" =>
".default",
619 "path" =>
"/bitrix/components" . $parentRelativePath .
"/templates" . $parentTemplatePath . $relativePath,
621 "site_template" =>
"",
624 if (!$defSiteTemplate)
627 "path" => BX_PERSONAL_ROOT .
"/templates/" . $siteTemplate .
"/components" . $relativePath,
631 "path" => BX_PERSONAL_ROOT .
"/templates/.default/components" . $relativePath,
632 "site_template" =>
".default",
635 "path" =>
"/bitrix/components" . $relativePath .
"/templates",
636 "site_template" =>
"",
667 $this->__fileAlt =
"";
668 $this->__folder =
"";
669 $this->__hasCSS =
null;
670 $this->__hasJS =
null;
672 $relativePath = $this->__component->GetRelativePath();
674 $parentRelativePath =
"";
675 $parentTemplateName =
"";
677 $parentComponent = $this->__component->GetParent();
679 if ($parentComponent && $parentComponent->GetTemplate())
681 $parentRelativePath = $parentComponent->GetRelativePath();
682 $parentTemplateName = $parentComponent->GetTemplate()->GetName();
687 if ($customTemplatePath <>
'' && $templatePageFile = $this->
__SearchTemplateFile($customTemplatePath, $this->__page))
689 $this->__fileAlt = $customTemplatePath .
"/" . $templatePageFile;
691 foreach ($arFolders as $folder)
693 if (is_dir(
$_SERVER[
"DOCUMENT_ROOT"] . $folder[
"path"] .
"/" . $this->__name))
695 $this->__file = $folder[
"path"] .
"/" . $this->__name .
"/" . $templatePageFile;
696 $this->__folder = $folder[
"path"] .
"/" . $this->__name;
699 if ($this->__file <>
'')
701 if (isset($folder[
"site_template"]))
703 $this->__siteTemplate = $folder[
"site_template"];
706 if (isset($folder[
"in_theme"]) && $folder[
"in_theme"] ===
true)
708 $this->__templateInTheme =
true;
712 $this->__templateInTheme =
false;
718 return ($this->__file <>
'');
722 $cache_id = $relativePath .
"|" . $this->__siteTemplate .
"|" . $parentRelativePath .
"|" . $parentTemplateName .
"|" . $this->__page .
"|" . $this->__name;
723 if (!isset($cache[$cache_id]))
725 foreach ($arFolders as $folder)
727 $fname = $folder[
"path"] .
"/" . $this->__name;
728 if (file_exists(
$_SERVER[
"DOCUMENT_ROOT"] . $fname))
730 if (is_dir(
$_SERVER[
"DOCUMENT_ROOT"] . $fname))
734 $this->__file = $fname .
"/" . $templatePageFile;
735 $this->__folder = $fname;
736 $this->__hasCSS = file_exists(
$_SERVER[
"DOCUMENT_ROOT"] . $fname .
"/style.css");
737 $this->__hasJS = file_exists(
$_SERVER[
"DOCUMENT_ROOT"] . $fname .
"/script.js");
742 $this->__file = $fname;
743 if (str_contains($this->__name,
"/"))
745 $this->__folder = $folder[
"path"] .
"/" . mb_substr($this->__name, 0,
bxstrrpos($this->__name,
"/"));
753 $this->__file = $folder[
"path"] .
"/" . $templatePageFile;
757 if ($this->__file !=
"")
759 if (isset($folder[
"site_template"]))
761 $this->__siteTemplate = $folder[
"site_template"];
764 if (isset($folder[
"in_theme"]) && $folder[
"in_theme"] ===
true)
766 $this->__templateInTheme =
true;
770 $this->__templateInTheme =
false;
776 $cache[$cache_id] = [
779 $this->__siteTemplate,
780 $this->__templateInTheme,
787 $this->__folder = $cache[$cache_id][0];
788 $this->__file = $cache[$cache_id][1];
789 $this->__siteTemplate = $cache[$cache_id][2];
790 $this->__templateInTheme = $cache[$cache_id][3];
791 $this->__hasCSS = $cache[$cache_id][4];
792 $this->__hasJS = $cache[$cache_id][5];
794 return ($this->__file !=
"");
817 if (!$this->__bInited)
824 $templateName = $this->__name;
826 $templateFile = $this->__file;
828 $templateFolder = $this->__folder;
832 $component = &$this->__component;
834 if ($this->__fileAlt <>
'')
836 include(
$_SERVER[
"DOCUMENT_ROOT"] . $this->__fileAlt);
840 $templateData =
false;
842 include(
$_SERVER[
"DOCUMENT_ROOT"] . $this->__file);
846 $frame = $this->frames[
$i];
847 if ($frame->isStarted() && !$frame->isEnded())
856 $page->giveNegativeComponentVote($this->__file);
859 $component_epilog = $this->__folder .
"/component_epilog.php";
861 if (!isset($exists[$component_epilog]))
863 $exists[$component_epilog] = file_exists(
$_SERVER[
"DOCUMENT_ROOT"] . $component_epilog);
866 if ($exists[$component_epilog])
870 $component->SetTemplateEpilog([
871 "epilogFile" => $component_epilog,
872 "templateName" => $this->__name,
873 "templateFile" => $this->__file,
874 "templateFolder" => $this->__folder,
875 "templateData" => $templateData,
894 if (!$this->__bInited)
899 $arLangMessages =
null;
902 $arParams = $this->__component->arParams;
904 if ($this->__folder <>
'')
915 if (!isset($this->__hasCSS) || $this->__hasCSS)
919 if (!isset($this->__hasJS) || $this->__hasJS)
925 $parentTemplateFolder =
"";
926 $parentComponent = $this->__component->GetParent();
927 if ($parentComponent)
929 $parentTemplate = $parentComponent->GetTemplate();
932 $parentTemplateFolder = $parentTemplate->GetFolder();
945 $parentTemplateFolder,
968 $arLangMessages = [];
970 if ($this->__folder <>
'')
972 if ($relativePath ==
"")
977 $absPath =
$_SERVER[
"DOCUMENT_ROOT"] . $this->__folder .
"/" . $relativePath;
979 if (
$lang ===
false && $return ===
false)
993 return $arLangMessages;
1008 static $exists = [];
1010 if ($this->__folder <>
'')
1012 $resultModifier = $this->__folder .
"/result_modifier.php";
1013 if (!isset($exists[$resultModifier]))
1015 $exists[$resultModifier] = file_exists(
$_SERVER[
"DOCUMENT_ROOT"] . $resultModifier);
1017 if ($exists[$resultModifier])
1019 include
$_SERVER[
"DOCUMENT_ROOT"] . $resultModifier;
1033 if ($this->__folder <>
'')
1037 || file_exists(
$_SERVER[
"DOCUMENT_ROOT"] . $this->__folder .
"/style.css")
1040 $APPLICATION->SetAdditionalCSS($this->__folder .
"/style.css");
1043 if ($this->__component && $this->__component->__parent)
1045 $this->__component->__parent->addChildCSS($this->__folder .
"/style.css");
1060 if ($this->__folder <>
'')
1064 || file_exists(
$_SERVER[
"DOCUMENT_ROOT"] . $this->__folder .
"/script.js")
1067 $APPLICATION->AddHeadScript($this->__folder .
"/script.js");
1069 if ($this->__component && $this->__component->__parent)
1071 $this->__component->__parent->addChildJS($this->__folder .
"/script.js");
1085 $templateName = trim($templateName,
". \r\n\t");
1086 $arTemplateName = explode(
".", $templateName);
1087 return mb_strtolower($arTemplateName[
count($arTemplateName) - 1]);
1111 $this->__engineID =
"php";
1128 $view = &$this->__view;
1130 if (!isset($view[$target]))
1132 $view[$target] = [];
1134 $view[$target][] = [
false, $pos];
1151 $view = &$this->__view;
1156 $target_key = key($view);
1160 end($view[$target_key]);
1161 $sub_target_key = key($view[$target_key]);
1163 $sub_target = &$view[$target_key][$sub_target_key];
1164 if ($sub_target[0] ===
false)
1166 $sub_target[0] = ob_get_contents();
1167 $APPLICATION->AddViewContent($target_key, $sub_target[0], $sub_target[1]);
1168 $this->__component->addViewTarget($target_key, $sub_target[0], $sub_target[1]);
1199 $this->__component->addEditButton([
'AddEditAction', $entryId, $editLink, $editTitle,
$arParams]);
1220 $this->__component->addEditButton([
'AddDeleteAction', $entryId, $deleteLink, $deleteTitle,
$arParams]);
1237 return $this->__component->GetEditAreaId($entryId);
1250 return $this->__component->randString($length);
1262 if (in_array($mode, [
true,
false,
null],
true))
1264 $this->frameMode = $mode;
1274 if ($this->frameMode !==
null)
1276 return $this->frameMode;
1279 if (!$this->__component)
1285 $frameMode = $this->__component->getDefaultFrameMode();
1286 if ($frameMode ===
null)
1296 return $this->frameMode;
1316 $this->frameMode =
true;
1317 if (!is_string($id) || $id ==
'')
1323 $this->frames[] = $frame;
1325 if ($this->__component && $this->__component->__parent)
1327 $this->__component->__parent->addChildFrame($frame);
1346 $this->externalCss[] = $cssPath;
1349 if ($this->__component && $this->__component->__parent)
1351 $this->__component->__parent->addChildCSS($cssPath);
1368 $this->externalJs[] = $jsPath;
1371 if ($this->__component && $this->__component->__parent)
1373 $this->__component->__parent->addChildJS($jsPath);
1383 return $this->__component;
static applyCachedData($cachedData)
static loadLanguageFile($file, $language=null, $normalize=true)
static loadMessages($file)
static sortByColumn(array &$array, $columns, $callbacks='', $defaultValueIfNotSetValue=null, $preserveKeys=false)
AddDeleteAction($entryId, $deleteLink, $deleteTitle=false, $arParams=[])
InitTemplateEngines($arTemplateEngines=[])
setLanguageId($languageId)
IncludeTemplate(&$arResult)
hasTemplatePage(string $templatePage)
__SearchTemplateFile($path, $fileName)
IncludeLangFile($relativePath="", $lang=false, $return=false)
__SearchTemplate($customTemplatePath="")
__IncludeMutatorFile(&$arResult, &$arParams)
__IncludePHPTemplate(&$arResult, &$arParams, $parentTemplateFolder="")
createFrame($id=null, $autoContainer=true)
Init(&$component, $siteTemplate=false, $customTemplatePath="")
AddEditAction($entryId, $editLink, $editTitle=false, $arParams=[])
SetViewTarget($target, $pos=500)
generatePossibleTemplatePath()
__GetTemplateExtension($templateName)
if( $strWarning=="") if($strWarning=="") $componentPath
global $arBXAvailableTemplateEngines
global $arBXRuntimeTemplateEngines
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
$_SERVER["DOCUMENT_ROOT"]
if(!defined('SITE_ID')) $lang
bxstrrpos($haystack, $needle)
bx_basename($path, $ext="")
randString($pass_len=10, $pass_chars=false)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
$GLOBALS['_____370096793']