1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
component.php
См. документацию.
1<?php
8
10
12{
13 public $__name = "";
14 private $__relativePath = "";
15 public $__path = "";
16
17 private $__templateName = "";
18 public $__templatePage = "";
19
21 public $__template = null;
22
23 private $__component_epilog = false;
24
25 public $arParams = array();
26 public $arResult = array();
28 public $arResultCacheKeys = false;
29
31 public $__parent = null;
32
33 private $__bInited = false;
34
35 private $__arIncludeAreaIcons = array();
36
37 private $__NavNum = false;
38
40 private $__cache = null;
41 private $__cacheID = "";
42 private $__cachePath = "";
43
44 private $__children_css = array();
45 private $__children_js = array();
46 private $__children_epilogs = array();
47
49 private $__children_frames = array();
50
51 private $__view = array();
52
53 private static $__componentCounter = array();
54 private $__currentCounter = 0;
55 private $__currentCounters = array();
56
57 private $__editButtons = array();
58 private static $__classes_map = array();
59 private static $classes = array();
60 private $classOfComponent = "";
61 private $randomSequence = null;
62 private $frameMode = null;
63
65 protected $request;
66
67 private $siteId = false;
68 private $siteTemplateId = false;
69 private $languageId = false;
70
73
83 {
84 return $arParams;
85 }
86
93 public function onIncludeComponentLang()
94 {
95 $this->includeComponentLang();
96 }
97
103 public function executeComponent()
104 {
105 return $this->__includeComponent();
106 }
107
112 public function __construct($component = null)
113 {
114 if(is_object($component) && ($component instanceof cbitrixcomponent))
115 {
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());
143 $this->setLanguageId($component->getLanguageId());
144 $this->setSiteTemplateId($component->getSiteTemplateId());
145 }
146 else
147 {
148 $this->setSiteId(SITE_ID);
149 $this->setLanguageId(LANGUAGE_ID);
150
151 if (defined('DEFAULT_COMPONENT_TEMPLATE_ID'))
152 {
153 $this->setSiteTemplateId(DEFAULT_COMPONENT_TEMPLATE_ID);
154 }
155 else if (defined('SITE_TEMPLATE_ID'))
156 {
157 $this->setSiteTemplateId(SITE_TEMPLATE_ID);
158 }
159 }
160
161 $this->request = \Bitrix\Main\Context::getCurrent()->getRequest();
162 }
163
170 final public function getName()
171 {
172 if ($this->__bInited)
173 return $this->__name;
174 else
175 return null;
176 }
177
184 final public function getRelativePath()
185 {
186 if ($this->__bInited)
187 return $this->__relativePath;
188 else
189 return null;
190 }
191
198 final public function getPath()
199 {
200 if ($this->__bInited)
201 return $this->__path;
202 else
203 return null;
204 }
205
212 final public function getTemplateName()
213 {
214 if ($this->__bInited)
215 return $this->__templateName;
216 else
217 return null;
218 }
219
227 final public function setTemplateName($templateName)
228 {
229 if (!$this->__bInited)
230 return null;
231
232 $this->__templateName = $templateName;
233 return true;
234 }
235
239 public function setSiteTemplateId($siteTemplateId)
240 {
241 $this->siteTemplateId = $siteTemplateId;
242 }
243
247 public function getSiteTemplateId()
248 {
249 return $this->siteTemplateId;
250 }
251
255 public function setSiteId($siteId)
256 {
257 $this->siteId = $siteId;
258 }
259
263 public function getSiteId()
264 {
265 return $this->siteId;
266 }
267
271 public function setLanguageId($languageId)
272 {
273 $this->languageId = $languageId;
274 }
275
279 public function getLanguageId()
280 {
281 return $this->languageId;
282 }
283
292 final public function getSignedParameters()
293 {
294 return $this->signedParameters;
295 }
296
305 private function storeSignedParameters(array $params)
306 {
307 $this->signedParameters = \Bitrix\Main\Component\ParameterSigner::signParameters($this->getName(), $params);
308
309 return $this;
310 }
311
317 protected function listKeysSignedParameters()
318 {
319 return null;
320 }
321
329 final public function getTemplatePage()
330 {
331 if ($this->__bInited)
332 return $this->__templatePage;
333 else
334 return null;
335 }
336
343 final public function getTemplate()
344 {
345 if ($this->__bInited && $this->__template)
346 return $this->__template;
347 else
348 return null;
349 }
350
357 final public function getParent()
358 {
359 if ($this->__bInited && $this->__parent)
360 return $this->__parent;
361 else
362 return null;
363 }
364
371 final public function getTemplateCachedData()
372 {
373 if ($this->__bInited && $this->__template)
374 return $this->__template->GetCachedData();
375 else
376 return null;
377 }
378
386 final public function setTemplateCachedData($templateCachedData)
387 {
388 if ($this->__bInited && $this->__template)
389 $this->__template->ApplyCachedData($templateCachedData);
390 }
391
398 final public static function includeComponentClass($componentName)
399 {
400 $component = new CBitrixComponent;
401 $component->initComponent($componentName);
402
403 return $component->classOfComponent;
404 }
405
414 private function __getClassForPath($componentPath)
415 {
416 if (!isset(self::$__classes_map[$componentPath]))
417 {
418 $fname = $_SERVER["DOCUMENT_ROOT"].$componentPath."/class.php";
419 if (file_exists($fname) && is_file($fname))
420 {
421 $beforeClasses = get_declared_classes();
422 $beforeClassesCount = count($beforeClasses);
423 include_once($fname);
424 $afterClasses = get_declared_classes();
425 $afterClassesCount = count($afterClasses);
426
427 for ($i = $beforeClassesCount; $i < $afterClassesCount; $i++)
428 {
429 if (!isset(self::$classes[$afterClasses[$i]]) && is_subclass_of($afterClasses[$i], "cbitrixcomponent"))
430 {
431 if (!isset(self::$__classes_map[$componentPath]) || is_subclass_of($afterClasses[$i], self::$__classes_map[$componentPath]))
432 {
433 self::$__classes_map[$componentPath] = $afterClasses[$i];
434
435 //recursion control
436 self::$classes[$afterClasses[$i]] = true;
437 }
438 }
439 }
440 }
441 else
442 {
443 //no need to try for several times
444 self::$__classes_map[$componentPath] = "";
445 }
446 }
447 return self::$__classes_map[$componentPath] ?? null;
448 }
458 final public function initComponent($componentName, $componentTemplate = false)
459 {
460 $this->__bInited = false;
461
463 if ($componentName == '')
464 {
465 $this->__ShowError("Empty component name");
466 return false;
467 }
468
469 $path2Comp = CComponentEngine::MakeComponentPath($componentName);
470 if ($path2Comp == '')
471 {
472 $this->__ShowError(sprintf("'%s' is not a valid component name", $componentName));
473 return false;
474 }
475
476 $componentPath = getLocalPath("components".$path2Comp);
477 $this->classOfComponent = self::__getClassForPath($componentPath);
478
479 if($this->classOfComponent === "")
480 {
481 $componentFile = $_SERVER["DOCUMENT_ROOT"].$componentPath."/component.php";
482 if (!file_exists($componentFile) || !is_file($componentFile))
483 {
484 $this->__ShowError(sprintf("'%s' is not a component", $componentName));
485 return false;
486 }
487 }
488
489 self::increaseComponentCounter($componentName);
490 $this->__currentCounter = self::$__componentCounter[$componentName];
491
492 $this->__name = $componentName;
493 $this->__relativePath = $path2Comp;
494 $this->__path = $componentPath;
495 $this->arResult = array();
496 $this->arParams = array();
497 $this->__parent = null;
498 $this->__arIncludeAreaIcons = array();
499 $this->__cache = null;
500 if ($componentTemplate !== false)
501 $this->__templateName = $componentTemplate;
502
503 $this->__bInited = true;
504
505 return true;
506 }
507
514 final public function __prepareComponentParams(&$arParams)
515 {
516 if(!is_array($arParams))
517 {
518 return;
519 }
520
521 $p = $arParams; //this avoids endless loop
522 foreach($p as $k => $v)
523 {
524 if (str_starts_with($k, '~'))
525 {
526 // already stored raw value
527 continue;
528 }
529
530 // store raw value
531 $arParams["~".$k] = $v;
532
533 if (isset($v))
534 {
535 if (is_string($v))
536 {
537 if (preg_match("/[;&<>\"]/", $v))
538 {
540 }
541 }
542 elseif (is_array($v))
543 {
544 //one more cycle, php 7 bug https://bugs.php.net/bug.php?id=71969
545 foreach($v as $kk => $vv)
546 {
547 if (is_string($vv))
548 {
549 $arParams[$k][$kk] = htmlspecialcharsEx($vv);
550 }
551 }
552 }
553 }
554 }
555 }
556
566 final public function includeComponentLang($relativePath = "", $lang = false)
567 {
568 if (!$this->__bInited)
569 return null;
570
571 if ($relativePath == "")
572 $relativePath = "component.php";
573
574 $path = $_SERVER["DOCUMENT_ROOT"].$this->__path."/".$relativePath;
575
576 if($lang === false)
577 {
579 }
580 else
581 {
583 }
584 }
585
593 final protected function __includeComponent()
594 {
596 global $APPLICATION, $USER, $DB;
597
598 if (!$this->__bInited)
599 return null;
600
601 //these vars are used in the component file
604
605 $componentPath = $this->__path;
606 $componentName = $this->__name;
608
609 if ($this->__parent)
610 {
611 $parentComponentName = $this->__parent->__name;
612 $parentComponentPath = $this->__parent->__path;
613 $parentComponentTemplate = $this->__parent->getTemplateName();
614 }
615 else
616 {
617 $parentComponentName = "";
618 $parentComponentPath = "";
619 $parentComponentTemplate = "";
620 }
621
622 return include($_SERVER["DOCUMENT_ROOT"].$this->__path."/component.php");
623 }
624
634 final public function includeComponent($componentTemplate, $arParams, $parentComponent, $returnResult = false)
635 {
636 if (!$this->__bInited)
637 return null;
638
639 if ($componentTemplate !== false)
640 $this->setTemplateName($componentTemplate);
641
642 if ($parentComponent instanceof cbitrixcomponent)
643 $this->__parent = $parentComponent;
644
645 if (!isset($arParams["CACHE_TYPE"]) || ($arParams["CACHE_TYPE"] != "Y" && $arParams["CACHE_TYPE"] != "N"))
646 {
647 $arParams["CACHE_TYPE"] = "A";
648 }
649
650 if($this->classOfComponent)
651 {
653 $component = new $this->classOfComponent($this);
654 $component->onIncludeComponentLang();
655
656 $keysToExport = $component->listKeysSignedParameters();
657 if($keysToExport)
658 {
659 $component->storeSignedParameters(array_intersect_key($arParams, array_combine($keysToExport, $keysToExport)));
660 }
661
662 $component->arParams = $component->onPrepareComponentParams($arParams);
663 $component->__prepareComponentParams($component->arParams);
664
665 $componentFrame = new \Bitrix\Main\Composite\Internals\AutomaticArea($component);
666 $componentFrame->start();
667
668 if($returnResult)
669 {
670 $component->executeComponent();
671 $result = $component->arResult;
672 }
673 else
674 {
675 $result = $component->executeComponent();
676 }
677
678 $this->__arIncludeAreaIcons = $component->__arIncludeAreaIcons;
679 $frameMode = $component->getFrameMode();
680
681 $componentFrame->end();
682 }
683 else
684 {
685 $this->includeComponentLang();
687 $this->arParams = $arParams;
688
689 $componentFrame = new \Bitrix\Main\Composite\Internals\AutomaticArea($this);
690 $componentFrame->start();
691
692 if($returnResult)
693 {
694 $this->__IncludeComponent();
696 }
697 else
698 {
699 $result = $this->__IncludeComponent();
700 }
701
702 $frameMode = $this->getFrameMode();
703
704 $componentFrame->end();
705 }
706
707 if (!$frameMode)
708 {
709 $page = \Bitrix\Main\Composite\Page::getInstance();
710 $page->giveNegativeComponentVote($this->__name);
711 }
712
713 return $result;
714 }
724 final public function includeComponentTemplate($templatePage = "", $customTemplatePath = "")
725 {
726 if (!$this->__bInited)
727 return null;
728
729 if ($this->initComponentTemplate($templatePage, $this->getSiteTemplateId(), $customTemplatePath))
730 {
731 $this->showComponentTemplate();
732 if($this->__component_epilog)
733 $this->includeComponentEpilog($this->__component_epilog);
734 }
735 else
736 {
737 $this->abortResultCache();
738 $this->__showError(str_replace(
739 array("#PAGE#", "#NAME#"),
740 array($templatePage, $this->getTemplateName()),
741 "Cannot find '#NAME#' template with page '#PAGE#'"
742 ));
743 }
744 $this->__template->__component = null;
745 }
746
757 final public function initComponentTemplate($templatePage = "", $siteTemplate = false, $customTemplatePath = "")
758 {
759 if (!$this->__bInited)
760 return null;
761
762 try
763 {
764 $this->__templatePage = IO\Path::normalize($templatePage);
765 }
766 catch (IO\InvalidPathException $e)
767 {
768 $this->__templatePage = '';
769 }
770
771 $this->__template = new CBitrixComponentTemplate();
772 $this->__template->setLanguageId($this->getLanguageId());
773 if ($this->__template->Init($this, $siteTemplate, $customTemplatePath))
774 return true;
775 else
776 return false;
777 }
778
785 final public function showComponentTemplate()
786 {
787 if (!$this->__bInited)
788 return null;
789
790 if ($this->__template)
791 $this->__template->includeTemplate($this->arResult);
792
793 if(is_array($this->arResultCacheKeys))
794 {
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;
800 }
801
802 if(!empty($this->__editButtons))
803 {
804 foreach($this->__editButtons as $button)
805 {
806 if($button[0] == 'AddEditAction')
807 $this->addEditAction($button[1], $button[2], $button[3], $button[4]);
808 else
809 $this->addDeleteAction($button[1], $button[2], $button[3], $button[4]);
810 }
811 }
812
813 $this->__template->endViewTarget();
814
815 $this->endResultCache();
816 }
817
824 final public function addIncludeAreaIcon($arIcon)
825 {
826 if (!isset($this->__arIncludeAreaIcons) || !is_array($this->__arIncludeAreaIcons))
827 $this->__arIncludeAreaIcons = array();
828
829 $this->__arIncludeAreaIcons[] = $arIcon;
830 }
831
838 final public function addIncludeAreaIcons($arIcons)
839 {
840 if(is_array($arIcons))
841 $this->__arIncludeAreaIcons = $arIcons;
842 }
843
849 final public function getIncludeAreaIcons()
850 {
851 return $this->__arIncludeAreaIcons;
852 }
853
859 public function getCacheID($additionalCacheID = false)
860 {
861 if(!$this->getSiteId())
863 else
864 $SITE_ID = $this->getSiteId();
865
866 if(!$this->getLanguageId())
867 $LANGUAGE_ID = LANGUAGE_ID;
868 else
869 $LANGUAGE_ID = $this->getLanguageId();
870
871 if(!$this->getSiteTemplateId())
872 $SITE_TEMPLATE_ID = (defined("SITE_TEMPLATE_ID")? SITE_TEMPLATE_ID:"");
873 else
874 $SITE_TEMPLATE_ID = $this->getSiteTemplateId();
875
876 $cacheID = $SITE_ID."|".$LANGUAGE_ID.($SITE_TEMPLATE_ID != "" ? "|".$SITE_TEMPLATE_ID:"")."|".$this->__name."|".$this->getTemplateName()."|";
877
878 foreach($this->arParams as $k=>$v)
879 if(strncmp("~", $k, 1))
880 $cacheID .= ",".$k."=".serialize($v);
881
882 if(($offset = CTimeZone::getOffset()) <> 0)
883 $cacheID .= "|".$offset;
884
885 if ($additionalCacheID !== false)
886 $cacheID .= "|".serialize($additionalCacheID);
887
888 if ($this->__currentCounter > 1)
889 {
890 $cacheID .= "|".$this->__currentCounter;
891 }
892
893 return $cacheID;
894 }
895
904 final public function startResultCache($cacheTime = false, $additionalCacheID = false, $cachePath = false)
905 {
908
909 if (!$this->__bInited)
910 return null;
911
912 if ($this->arParams["CACHE_TYPE"] == "N" || ($this->arParams["CACHE_TYPE"] == "A" && COption::getOptionString("main", "component_cache_on", "Y") == "N"))
913 return true;
914
915 if ($cacheTime === false)
916 $cacheTime = intval($this->arParams["CACHE_TIME"] ?? 0);
917
918 $this->__cacheID = $this->getCacheID($additionalCacheID);
919 $this->__cachePath = $cachePath;
920 if ($this->__cachePath === false)
921 $this->__cachePath = $CACHE_MANAGER->getCompCachePath($this->__relativePath);
922
923 $this->__cache = \Bitrix\Main\Data\Cache::createInstance(['actual_data' => false]);
924 if ($this->__cache->startDataCache($cacheTime, $this->__cacheID, $this->__cachePath))
925 {
926 $this->__NavNum = $GLOBALS["NavNum"] ?? null;
927 $this->__currentCounters = self::$__componentCounter;
928
929 if (defined("BX_COMP_MANAGED_CACHE") && $this->__cache->isStarted())
930 $CACHE_MANAGER->startTagCache($this->__cachePath);
931
932 return true;
933 }
934 else
935 {
936 $arCache = $this->__cache->GetVars();
937 $this->arResult = $arCache["arResult"];
938 if (array_key_exists("templateCachedData", $arCache))
939 {
940 $templateCachedData = & $arCache["templateCachedData"];
941
942 if ($templateCachedData && is_array($templateCachedData))
943 {
944 if (array_key_exists("additionalCSS", $templateCachedData) && $templateCachedData["additionalCSS"] <> '')
945 {
946 $APPLICATION->SetAdditionalCSS($templateCachedData["additionalCSS"]);
947 if($this->__parent)
948 $this->__parent->addChildCSS($templateCachedData["additionalCSS"]);
949 }
950
951 if (array_key_exists("additionalJS", $templateCachedData) && $templateCachedData["additionalJS"] <> '')
952 {
953 $APPLICATION->AddHeadScript($templateCachedData["additionalJS"]);
954 if($this->__parent)
955 $this->__parent->addChildJS($templateCachedData["additionalJS"]);
956 }
957
958 if (array_key_exists("frames", $templateCachedData) && is_array($templateCachedData["frames"]))
959 {
960 foreach ($templateCachedData["frames"] as $frameState)
961 {
963 if ($this->__parent)
964 {
965 $this->__parent->addChildFrame($frame);
966 }
967 }
968 }
969
970 if (
971 array_key_exists("__children_frames", $templateCachedData) &&
972 is_array($templateCachedData["__children_frames"])
973 )
974 {
975 foreach ($templateCachedData["__children_frames"] as $frame)
976 {
978 }
979 }
980
981 if (array_key_exists("frameMode", $templateCachedData))
982 {
983 $templateFrameMode = $templateCachedData["frameMode"];
984
985 if ($this->getRealFrameMode() !== false)
986 {
987 $this->setFrameMode($templateFrameMode);
988 }
989
990 if ($this->getRealFrameMode() === false)
991 {
992 $context = isset($templateCachedData["frameModeCtx"])
993 ? "(from component cache) ".$templateCachedData["frameModeCtx"]
994 : $this->__name." - a cached template set frameMode=false";
995
997 $page->giveNegativeComponentVote($context);
998 }
999 }
1000
1001 if (isset($templateCachedData["externalCss"]))
1002 {
1003 foreach ($templateCachedData["externalCss"] as $cssPath)
1004 {
1005 $APPLICATION->SetAdditionalCSS($cssPath);
1006 //Check if parent component exists and plug css it to it's "collection"
1007 if($this->__parent)
1008 $this->__parent->addChildCSS($cssPath);
1009 }
1010 }
1011
1012 if (isset($templateCachedData["externalJs"]))
1013 {
1014 foreach ($templateCachedData["externalJs"] as $jsPath)
1015 {
1016 $APPLICATION->AddHeadScript($jsPath);
1017 //Check if parent component exists and plug js it to it's "collection"
1018 if($this->__parent)
1019 $this->__parent->addChildJS($jsPath);
1020 }
1021 }
1022 }
1023
1024 if (isset($templateCachedData["__editButtons"]))
1025 {
1026 foreach ($templateCachedData["__editButtons"] as $button)
1027 {
1028 if ($button[0] == 'AddEditAction')
1029 $this->addEditAction($button[1], $button[2], $button[3], $button[4]);
1030 else
1031 $this->addDeleteAction($button[1], $button[2], $button[3], $button[4]);
1032 }
1033 }
1034
1035 if (isset($templateCachedData["__view"]))
1036 {
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]);
1040 }
1041
1042 if (array_key_exists("__NavNum", $templateCachedData))
1043 {
1044 $GLOBALS["NavNum"]+= $templateCachedData["__NavNum"];
1045 }
1046
1047 if (array_key_exists("__currentCounters", $templateCachedData))
1048 {
1049 foreach ($templateCachedData["__currentCounters"] as $componentName => $counter)
1050 {
1051 self::increaseComponentCounter($componentName, $counter);
1052 }
1053 }
1054
1055 if (array_key_exists("__children_css", $templateCachedData))
1056 {
1057 foreach ($templateCachedData["__children_css"] as $css_url)
1058 $APPLICATION->setAdditionalCSS($css_url);
1059 }
1060
1061 if (array_key_exists("__children_js", $templateCachedData))
1062 {
1063 foreach ($templateCachedData["__children_js"] as $js_url)
1064 $APPLICATION->addHeadScript($js_url);
1065 }
1066
1067 if (array_key_exists("__children_epilogs", $templateCachedData))
1068 {
1069 foreach ($templateCachedData["__children_epilogs"] as $component_epilog)
1070 $this->includeComponentEpilog($component_epilog);
1071 }
1072
1073 if (array_key_exists("component_epilog", $templateCachedData))
1074 {
1075 $this->includeComponentEpilog($templateCachedData["component_epilog"]);
1076 }
1077 }
1078 return false;
1079 }
1080 }
1081
1088 final public function endResultCache()
1089 {
1090 global $NavNum, $CACHE_MANAGER;
1091
1092 if (!$this->__bInited)
1093 return null;
1094
1095 if (!$this->__cache)
1096 {
1097 if ($this->__parent)
1098 {
1099 foreach ($this->__children_css as $cssPath)
1100 {
1101 $this->__parent->addChildCSS($cssPath);
1102 }
1103
1104 foreach ($this->__children_js as $jsPath)
1105 {
1106 $this->__parent->addChildJS($jsPath);
1107 }
1108
1109 foreach ($this->__children_epilogs as $epilogFile)
1110 {
1111 $this->__parent->addChildEpilog($epilogFile);
1112 }
1113
1114 foreach ($this->__children_frames as $frame)
1115 {
1116 $this->__parent->addChildFrame($frame);
1117 }
1118 }
1119 return null;
1120 }
1121
1122 $arCache = array(
1123 "arResult" => $this->arResult,
1124 );
1125 if ($this->__template)
1126 {
1127 $arCache["templateCachedData"] = $this->__template->getCachedData();
1128 if ($this->__component_epilog)
1129 $arCache["templateCachedData"]["component_epilog"] = $this->__component_epilog;
1130 }
1131 else
1132 {
1133 $arCache["templateCachedData"] = array();
1134 }
1135
1136 if (($this->__NavNum !== false) && ($this->__NavNum !== $NavNum))
1137 {
1138 $arCache["templateCachedData"]["__NavNum"] = $NavNum - $this->__NavNum;
1139 }
1140
1141 $currentCountersDiff = array();
1142 foreach (self::$__componentCounter as $componentName => $counter)
1143 {
1144 if (array_key_exists($componentName, $this->__currentCounters))
1145 {
1146 if (self::$__componentCounter[$componentName] > $this->__currentCounters[$componentName])
1147 {
1148 $currentCountersDiff[$componentName] =
1149 self::$__componentCounter[$componentName] - $this->__currentCounters[$componentName];
1150 }
1151 }
1152 else
1153 {
1154 $currentCountersDiff[$componentName] = self::$__componentCounter[$componentName];
1155 }
1156 }
1157
1158 if (!empty($currentCountersDiff))
1159 {
1160 $arCache["templateCachedData"]["__currentCounters"] = $currentCountersDiff;
1161 }
1162
1163 if (!empty($this->__children_css))
1164 {
1165 $arCache["templateCachedData"]["__children_css"] = $this->__children_css;
1166 if ($this->__parent)
1167 {
1168 foreach($this->__children_css as $cssPath)
1169 $this->__parent->addChildCSS($cssPath);
1170 }
1171 }
1172
1173 if (!empty($this->__children_js))
1174 {
1175 $arCache["templateCachedData"]["__children_js"] = $this->__children_js;
1176 if ($this->__parent)
1177 {
1178 foreach($this->__children_js as $jsPath)
1179 $this->__parent->addChildJS($jsPath);
1180 }
1181 }
1182
1183 if (!empty($this->__children_epilogs))
1184 {
1185 $arCache["templateCachedData"]["__children_epilogs"] = $this->__children_epilogs;
1186 if ($this->__parent)
1187 {
1188 foreach($this->__children_epilogs as $epilogFile)
1189 $this->__parent->addChildEpilog($epilogFile);
1190 }
1191 }
1192
1193 if (!empty($this->__children_frames))
1194 {
1195 $arCache["templateCachedData"]["__children_frames"] =
1196 array_map(
1197 function($frame) {
1198 return $frame->getCachedData();
1199 },
1200 $this->__children_frames
1201 );
1202
1203 if ($this->__parent)
1204 {
1205 foreach ($this->__children_frames as $frame)
1206 {
1207 $this->__parent->addChildFrame($frame);
1208 }
1209 }
1210 }
1211
1212 if (!empty($this->__view))
1213 $arCache["templateCachedData"]["__view"] = $this->__view;
1214
1215 if (!empty($this->__editButtons))
1216 $arCache["templateCachedData"]["__editButtons"] = $this->__editButtons;
1217
1218 $cacheWasStarted = $this->__cache->isStarted();
1219 $this->__cache->endDataCache($arCache);
1220
1221 if (defined("BX_COMP_MANAGED_CACHE") && $cacheWasStarted)
1222 $CACHE_MANAGER->endTagCache();
1223
1224 $this->__cache = null;
1225 }
1226
1233 final public function abortResultCache()
1234 {
1235 global $CACHE_MANAGER;
1236
1237 if (!$this->__bInited)
1238 return null;
1239
1240 if (!$this->__cache)
1241 return null;
1242
1243 $cacheWasStarted = $this->__cache->isStarted();
1244 $this->__cache->abortDataCache();
1245
1246 if(defined("BX_COMP_MANAGED_CACHE") && $cacheWasStarted)
1247 $CACHE_MANAGER->abortTagCache();
1248
1249 $this->__cache = null;
1250 }
1251
1260 final public function clearResultCache($additionalCacheID = false, $cachePath = false)
1261 {
1262 global $CACHE_MANAGER;
1263
1264 if (!$this->__bInited)
1265 return null;
1266
1267 $this->__cacheID = $this->getCacheID($additionalCacheID);
1268
1269 $this->__cachePath = $cachePath;
1270 if ($this->__cachePath === false)
1271 $this->__cachePath = $CACHE_MANAGER->getCompCachePath($this->__relativePath);
1272
1273 $cache = new CPHPCache();
1274 $cache->clean($this->__cacheID, $this->__cachePath);
1275 }
1276
1285 final public static function clearComponentCache($componentName, $siteId = "")
1286 {
1288 global $CACHE_MANAGER;
1289
1290 $componentRelativePath = CComponentEngine::MakeComponentPath($componentName);
1291 if ($componentRelativePath != "")
1292 {
1293 $obCache = new CPHPCache;
1294 $obCache->CleanDir($componentRelativePath, "cache");
1295 BXClearCache(true, $componentRelativePath);
1296
1297 if ($siteId == "")
1298 {
1299 $rsSite = \Bitrix\Main\SiteTable::getList(array('order' => array('SORT' => 'ASC')));
1300 while ($site = $rsSite->fetch())
1301 {
1302 $componentCachePath = "/".$site["LID"].$componentRelativePath;
1303 $obCache = new CPHPCache;
1304 $obCache->CleanDir($componentCachePath, "cache");
1305 BXClearCache(true, $componentCachePath);
1306 }
1307 }
1308 else
1309 {
1310 $componentCachePath = "/".$siteId.$componentRelativePath;
1311 $obCache = new CPHPCache;
1312 $obCache->CleanDir($componentCachePath, "cache");
1313 BXClearCache(true, $componentCachePath);
1314 }
1315
1316 if(defined("BX_COMP_MANAGED_CACHE"))
1317 $CACHE_MANAGER->ClearByTag($componentName);
1318 }
1319 }
1320
1326 final public function getCachePath()
1327 {
1328 return $this->__cachePath;
1329 }
1330
1339 {
1340 if ($this->arResultCacheKeys === false)
1341 $this->arResultCacheKeys = $arResultCacheKeys;
1342 else
1343 $this->arResultCacheKeys = array_merge($this->arResultCacheKeys, $arResultCacheKeys);
1344 }
1345
1352 final public function getEditAreaId($entryId)
1353 {
1354 return 'bx_'.abs(crc32($this->GetName().'_'.$this->__currentCounter)).'_'.$entryId;
1355 }
1356
1366 final public function addEditAction($entryId, $editLink, $editTitle = false, $arParams = array())
1367 {
1369 global $APPLICATION;
1370
1371 if (!$entryId || !$editLink)
1372 return;
1373
1374 if (!$editTitle)
1375 {
1376 IncludeModuleLangFile(__FILE__);
1377 $editTitle = GetMessage('EDIT_ACTION_TITLE_DEFAULT');
1378 }
1379
1380 if (!is_array($arParams))
1381 $arParams = array();
1382
1383 if (!($arParams['WINDOW'] ?? null))
1384 $arParams['WINDOW'] = array(
1385 "width" => 780,
1386 "height" => 500,
1387 );
1388
1389 if (!($arParams['ICON'] ?? '') && !($arParams['SRC'] ?? '') && !($arParams['IMAGE'] ?? ''))
1390 $arParams['ICON'] = 'bx-context-toolbar-edit-icon';
1391
1392 $arBtn = array(
1393 'URL' => 'javascript:'.$APPLICATION->getPopupLink(array(
1394 'URL' => $editLink,
1395 "PARAMS" => $arParams['WINDOW'],
1396 )),
1397 'TITLE' => $editTitle,
1398 );
1399
1400 if ($arParams['ICON'])
1401 $arBtn['ICON'] = $arParams['ICON'];
1402 elseif ($arParams['SRC'] || $arParams['IMAGE'])
1403 $arBtn['SRC'] = $arParams['IMAGE'] ? $arParams['IMAGE'] : $arParams['SRC'];
1404
1405 $APPLICATION->setEditArea($this->getEditAreaId($entryId), array(
1406 $arBtn,
1407 ));
1408 }
1409
1424 final public function addDeleteAction($entryId, $deleteLink, $deleteTitle = false, $arParams = array())
1425 {
1427 global $APPLICATION;
1428
1429 if (!$entryId || !$deleteLink)
1430 return;
1431
1432 includeModuleLangFile(__FILE__);
1433 if (!$deleteTitle)
1434 {
1435 $deleteTitle = GetMessage('DELETE_ACTION_TITLE_DEFAULT');
1436 }
1437
1438 if (!is_array($arParams))
1439 $arParams = array();
1440
1441 if (!($arParams['ICON'] ?? '') && !($arParams['SRC'] ?? '') && !($arParams['IMAGE'] ?? ''))
1442 $arParams['ICON'] = 'bx-context-toolbar-delete-icon';
1443
1444 if (!str_starts_with($deleteLink, 'javascript:'))
1445 {
1446 if (false === mb_strpos($deleteLink, 'return_url='))
1447 $deleteLink.= '&return_url='.urlencode($APPLICATION->getCurPageParam());
1448
1449 $deleteLink.= '&'.bitrix_sessid_get();
1450 if ($arParams['CONFIRM'] !== false)
1451 {
1452 $confirmText = $arParams['CONFIRM'] ? $arParams['CONFIRM'] : GetMessage('DELETE_ACTION_CONFIRM');
1453 $deleteLink = 'javascript:if(confirm(\''.CUtil::JSEscape($confirmText).'\')) jsUtils.Redirect([], \''.CUtil::JSEscape($deleteLink).'\');';
1454 }
1455 }
1456
1457 $arBtn = array(
1458 'URL' => $deleteLink,
1459 'TITLE' => $deleteTitle,
1460 );
1461
1462 if ($arParams['ICON'])
1463 $arBtn['ICON'] = $arParams['ICON'];
1464 elseif ($arParams['SRC'] || $arParams['IMAGE'])
1465 $arBtn['SRC'] = $arParams['IMAGE'] ? $arParams['IMAGE'] : $arParams['SRC'];
1466
1467 $APPLICATION->setEditArea($this->getEditAreaId($entryId), array(
1468 $arBtn,
1469 ));
1470 }
1471
1478 final public function setTemplateEpilog($arEpilogInfo)
1479 {
1480 $this->__component_epilog = $arEpilogInfo;
1481 //Check if parent component exists and plug epilog it to it's "collection"
1482 if ($this->__parent)
1483 $this->__parent->addChildEpilog($this->__component_epilog);
1484 }
1485
1492 final public function includeComponentEpilog($arEpilogInfo)
1493 {
1495 global $APPLICATION, $USER, $DB;
1496
1497 // available variables in the epilog file:
1498 // $templateName, $templateFile, $templateFolder, $templateData
1500 extract($arEpilogInfo);
1501 if ($epilogFile <> '' && file_exists($_SERVER["DOCUMENT_ROOT"].$epilogFile))
1502 {
1503 //these vars can be used in the epilog file
1506 $componentPath = $this->GetPath();
1507 $component = $this;
1508 include($_SERVER["DOCUMENT_ROOT"].$epilogFile);
1509 }
1510 }
1519 public function __showError($errorMessage, $errorCode = "")
1520 {
1521 if ($errorMessage <> '')
1522 echo "<font color=\"#FF0000\">".htmlspecialcharsbx($errorMessage.($errorCode <> '' ? " [".$errorCode."]" : ""))."</font>";
1523 }
1524
1531 final public function addChildCSS($cssPath)
1532 {
1533 $this->__children_css[] = $cssPath;
1534 }
1535
1542 final public function addChildJS($jsPath)
1543 {
1544 $this->__children_js[] = $jsPath;
1545 }
1546
1553 final public function addChildEpilog($epilogFile)
1554 {
1555 $this->__children_epilogs[] = $epilogFile;
1556 }
1557
1565 final public function addChildFrame($frame)
1566 {
1567 $this->__children_frames[] = $frame;
1568 }
1569
1577 final public function addEditButton($arButton)
1578 {
1579 $this->__editButtons[] = $arButton;
1580 }
1581
1590 final public function addViewTarget($target, $content, $pos)
1591 {
1592 if(!isset($this->__view[$target]))
1593 $this->__view[$target] = array();
1594
1595 $this->__view[$target][] = array($content, $pos);
1596 }
1597
1598 private static function increaseComponentCounter($componentName, $counter = 1)
1599 {
1600 if (!isset(self::$__componentCounter[$componentName]))
1601 {
1602 self::$__componentCounter[$componentName] = $counter;
1603 }
1604 else
1605 {
1606 self::$__componentCounter[$componentName] += $counter;
1607 }
1608 }
1609
1618 public function randString($length = 6)
1619 {
1620 if (!$this->randomSequence)
1621 {
1622 $seed = $this->__name."|".self::$__componentCounter[$this->__name];
1623 $this->randomSequence = new \Bitrix\Main\Type\RandomSequence($seed);
1624 }
1625 return $this->randomSequence->randString($length);
1626 }
1627
1637 public function setFrameMode($mode)
1638 {
1639 if (in_array($mode, array(true, false, null), true))
1640 {
1641 $this->frameMode = $mode;
1642 }
1643 }
1644
1645 public function getFrameMode()
1646 {
1647 if ($this->frameMode !== null)
1648 {
1649 return $this->frameMode;
1650 }
1651
1652 return true;
1653 }
1654
1655 public function getRealFrameMode()
1656 {
1657 return $this->frameMode;
1658 }
1659
1660 public function getDefaultFrameMode()
1661 {
1662 $frameMode = null;
1663
1664 $compositeOptions = \Bitrix\Main\Composite\Helper::getOptions();
1666
1667 if (
1668 isset($componentParams["COMPOSITE_FRAME_MODE"]) &&
1669 in_array($componentParams["COMPOSITE_FRAME_MODE"], array("Y", "N"))
1670 )
1671 {
1672 $frameMode = $componentParams["COMPOSITE_FRAME_MODE"] === "Y";
1673 }
1674 else if (isset($compositeOptions["FRAME_MODE"]))
1675 {
1676 $frameMode = $compositeOptions["FRAME_MODE"] === "Y";
1677 }
1678
1679 return $frameMode;
1680 }
1681}
$arParams
Определения access_dialog.php:21
$path
Определения access_edit.php:21
global $APPLICATION
Определения include.php:80
$arResult
Определения generate_coupon.php:16
static signParameters($componentName, $parameters)
Определения parametersigner.php:19
static getOptions()
Определения helper.php:504
static getInstance()
Определения page.php:76
static applyCachedData($cachedData)
Определения staticarea.php:222
static loadLanguageFile($file, $language=null, $normalize=true)
Определения loc.php:225
static loadMessages($file)
Определения loc.php:65
static getList(array $parameters=array())
Определения datamanager.php:431
Определения component.php:12
addViewTarget($target, $content, $pos)
Определения component.php:1590
onPrepareComponentParams($arParams)
Определения component.php:82
$__name
Определения component.php:13
randString($length=6)
Определения component.php:1618
addEditAction($entryId, $editLink, $editTitle=false, $arParams=array())
Определения component.php:1366
setLanguageId($languageId)
Определения component.php:271
getSignedParameters()
Определения component.php:292
$arResultCacheKeys
Определения component.php:28
getEditAreaId($entryId)
Определения component.php:1352
setSiteId($siteId)
Определения component.php:255
$arResult
Определения component.php:26
static clearComponentCache($componentName, $siteId="")
Определения component.php:1285
addIncludeAreaIcon($arIcon)
Определения component.php:824
__construct($component=null)
Определения component.php:112
$__parent
Определения component.php:31
initComponent($componentName, $componentTemplate=false)
Определения component.php:458
getIncludeAreaIcons()
Определения component.php:849
clearResultCache($additionalCacheID=false, $cachePath=false)
Определения component.php:1260
getTemplatePage()
Определения component.php:329
addChildJS($jsPath)
Определения component.php:1542
getTemplateCachedData()
Определения component.php:371
getPath()
Определения component.php:198
setTemplateCachedData($templateCachedData)
Определения component.php:386
getName()
Определения component.php:170
getSiteId()
Определения component.php:263
listKeysSignedParameters()
Определения component.php:317
addEditButton($arButton)
Определения component.php:1577
initComponentTemplate($templatePage="", $siteTemplate=false, $customTemplatePath="")
Определения component.php:757
__showError($errorMessage, $errorCode="")
Определения component.php:1519
addIncludeAreaIcons($arIcons)
Определения component.php:838
setFrameMode($mode)
Определения component.php:1637
$__template
Определения component.php:21
getTemplate()
Определения component.php:343
$arParams
Определения component.php:25
getTemplateName()
Определения component.php:212
startResultCache($cacheTime=false, $additionalCacheID=false, $cachePath=false)
Определения component.php:904
getDefaultFrameMode()
Определения component.php:1660
addChildFrame($frame)
Определения component.php:1565
endResultCache()
Определения component.php:1088
abortResultCache()
Определения component.php:1233
getFrameMode()
Определения component.php:1645
includeComponentTemplate($templatePage="", $customTemplatePath="")
Определения component.php:724
getParent()
Определения component.php:357
onIncludeComponentLang()
Определения component.php:93
getCacheID($additionalCacheID=false)
Определения component.php:859
__includeComponent()
Определения component.php:593
getCachePath()
Определения component.php:1326
getLanguageId()
Определения component.php:279
addDeleteAction($entryId, $deleteLink, $deleteTitle=false, $arParams=array())
Определения component.php:1424
setResultCacheKeys($arResultCacheKeys)
Определения component.php:1338
addChildEpilog($epilogFile)
Определения component.php:1553
$__templatePage
Определения component.php:18
$request
Определения component.php:65
getRealFrameMode()
Определения component.php:1655
includeComponentLang($relativePath="", $lang=false)
Определения component.php:566
setSiteTemplateId($siteTemplateId)
Определения component.php:239
setTemplateName($templateName)
Определения component.php:227
getRelativePath()
Определения component.php:184
executeComponent()
Определения component.php:103
$signedParameters
Определения component.php:72
getSiteTemplateId()
Определения component.php:247
showComponentTemplate()
Определения component.php:785
__prepareComponentParams(&$arParams)
Определения component.php:514
addChildCSS($cssPath)
Определения component.php:1531
static includeComponentClass($componentName)
Определения component.php:398
$__path
Определения component.php:15
Определения cache.php:11
CleanDir($initdir=false, $basedir="cache")
Определения cache.php:25
global $CACHE_MANAGER
Определения clear_component_cache.php:7
$content
Определения commerceml.php:144
$componentTemplate
Определения component_props2.php:50
if( $strWarning=="") if($strWarning=="") $componentPath
Определения component_props2.php:197
$componentName
Определения component_props2.php:49
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
$p
Определения group_list_element_edit.php:23
$componentParams
Определения group_wiki_index.php:20
while($arParentIBlockProperty=$dbParentIBlockProperty->Fetch()) $errorMessage
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
global $DB
Определения cron_frame.php:29
global $USER
Определения csv_new_run.php:40
$context
Определения csv_new_setup.php:223
if(!defined('SITE_ID')) $lang
Определения include.php:91
$siteId
Определения ajax.php:8
htmlspecialcharsEx($str)
Определения tools.php:2685
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
GetMessage($name, $aReplace=null)
Определения tools.php:3397
BXClearCache($full=false, $initdir='')
Определения tools.php:5150
getLocalPath($path, $baseFolder="/bitrix")
Определения tools.php:5092
Определения directory.php:3
$GLOBALS['____1690880296']
Определения license.php:1
$counter
Определения options.php:5
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
if(empty($signedUserToken)) $key
Определения quickway.php:257
$i
Определения factura.php:643
$page
Определения order_form.php:33
</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."%"
Определения waybill.php:936
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
const SITE_ID
Определения sonet_set_content_view.php:12
$k
Определения template_pdf.php:567
$SITE_ID
Определения yandex_run.php:607
$site
Определения yandex_run.php:614