1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
component_util.php
См. документацию.
1<?php
8
10
12{
13 public static function __IncludeLang($filePath, $fileName, $lang = false)
14 {
15 if ($lang === false)
16 $lang = LANGUAGE_ID;
17
18 if ($lang != "en" && $lang != "ru")
19 {
20 $subst_lang = LangSubst($lang);
21 $fname = $_SERVER["DOCUMENT_ROOT"].$filePath."/lang/".$subst_lang."/".$fileName;
23 if (file_exists($fname))
24 {
25 __IncludeLang($fname, false, true);
26 }
27 }
28
29 $fname = $_SERVER["DOCUMENT_ROOT"].$filePath."/lang/".$lang."/".$fileName;
31 if (file_exists($fname))
32 {
33 __IncludeLang($fname, false, true);
34 }
35 }
36
37 public static function PrepareVariables(&$arData)
38 {
39 unset($arData["NEW_COMPONENT_TEMPLATE"]);
40
41 if (isset($arData["SEF_MODE"]) && $arData["SEF_MODE"] == "Y")
42 {
43 unset($arData["VARIABLE_ALIASES"]);
44 unset($arData["SEF_URL_TEMPLATES"]);
45
46 foreach ($arData as $dataKey => $dataValue)
47 {
48 if (str_starts_with($dataKey, "SEF_URL_TEMPLATES_"))
49 {
50 $len = strlen("SEF_URL_TEMPLATES_");
51 $arData["SEF_URL_TEMPLATES"][substr($dataKey, $len)] = $dataValue;
52 unset($arData[$dataKey]);
53
54 if (preg_match_all("'(\\?|&)(.+?)=#([^#]+?)#'is", $dataValue, $arMatches, PREG_SET_ORDER))
55 {
56 foreach ($arMatches as $arMatch)
57 $arData["VARIABLE_ALIASES"][substr($dataKey, $len)][$arMatch[3]] = $arMatch[2];
58 }
59 }
60 elseif (str_starts_with($dataKey, "VARIABLE_ALIASES_"))
61 {
62 unset($arData[$dataKey]);
63 }
64 }
65 }
66 else
67 {
68 unset($arData["VARIABLE_ALIASES"]);
69 unset($arData["SEF_URL_TEMPLATES"]);
70
71 foreach ($arData as $dataKey => $dataValue)
72 {
73 if (str_starts_with($dataKey, "SEF_URL_TEMPLATES_"))
74 {
75 unset($arData[$dataKey]);
76 }
77 elseif (str_starts_with($dataKey, "VARIABLE_ALIASES_"))
78 {
79 $arData["VARIABLE_ALIASES"][substr($dataKey, strlen("VARIABLE_ALIASES_"))] = $dataValue;
80 unset($arData[$dataKey]);
81 }
82 }
83 }
84 }
85
86 public static function __ShowError($errorMessage)
87 {
88 if ($errorMessage <> '')
89 echo "<font color=\"#FF0000\">".$errorMessage."</font>";
90 }
91
92 public static function __BuildTree($arPath, &$arTree, &$arComponent, $level = 1)
93 {
94 $arBXTopComponentCatalogLevel = array("content", "service", "communication", "e-store", "utility");
95 $arBXTopComponentCatalogLevelSort = array(600, 700, 800, 900, 1000);
96
97 if (!isset($arTree["#"]) || !is_array($arTree["#"]))
98 $arTree["#"] = array();
99
100 if (!array_key_exists($arPath["ID"], $arTree["#"]))
101 {
102 $arTree["#"][$arPath["ID"]] = array();
103 $arTree["#"][$arPath["ID"]]["@"] = array();
104 $arTree["#"][$arPath["ID"]]["@"]["NAME"] = "";
105 $arTree["#"][$arPath["ID"]]["@"]["SORT"] = intval($arPath["SORT"] ?? 0);
106 if ($level == 1 && in_array($arPath["ID"], $arBXTopComponentCatalogLevel))
107 {
108 $arTree["#"][$arPath["ID"]]["@"]["NAME"] = GetMessage("VRT_COMP_CAT_".mb_strtoupper($arPath["ID"]));
109 $arTree["#"][$arPath["ID"]]["@"]["SORT"] = intval($arBXTopComponentCatalogLevelSort[array_search($arPath["ID"], $arBXTopComponentCatalogLevel)]);
110 }
111 if ($arTree["#"][$arPath["ID"]]["@"]["NAME"] == '')
112 $arTree["#"][$arPath["ID"]]["@"]["NAME"] = $arPath["NAME"] ?? '';
113 if ($arTree["#"][$arPath["ID"]]["@"]["SORT"] <= 0)
114 $arTree["#"][$arPath["ID"]]["@"]["SORT"] = 100;
115 }
116
117 if (array_key_exists("CHILD", $arPath))
118 {
119 CComponentUtil::__BuildTree($arPath["CHILD"], $arTree["#"][$arPath["ID"]], $arComponent, $level + 1);
120 }
121 else
122 {
123 if (!isset($arTree["#"][$arPath["ID"]]["*"]) || !is_array($arTree["#"][$arPath["ID"]]["*"]))
124 $arTree["#"][$arPath["ID"]]["*"] = array();
125
126 $arTree["#"][$arPath["ID"]]["*"][$arComponent["NAME"]] = $arComponent;
127 }
128 }
129
130 public static function isComponent($componentPath)
131 {
132 $bDirectoryExists = file_exists($_SERVER["DOCUMENT_ROOT"].$componentPath)
133 && is_dir($_SERVER["DOCUMENT_ROOT"].$componentPath);
134 if(!$bDirectoryExists)
135 return false;
136
137 $bComponentExists = file_exists($_SERVER["DOCUMENT_ROOT"].$componentPath."/component.php")
138 && is_file($_SERVER["DOCUMENT_ROOT"].$componentPath."/component.php");
139 if($bComponentExists)
140 return true;
141
142 $bClassExists = file_exists($_SERVER["DOCUMENT_ROOT"].$componentPath."/class.php")
143 && is_file($_SERVER["DOCUMENT_ROOT"].$componentPath."/class.php");
144 if($bClassExists)
145 return true;
146
147 return false;
148 }
149
150 public static function __GetComponentsTree($filterNamespace = false, $arNameFilter = false, $arFilter = false)
151 {
152 $arTree = array();
154 $folders = array(
155 "/local/components",
156 "/bitrix/components",
157 );
158
159 foreach($folders as $componentFolder)
160 {
161 if(file_exists($_SERVER["DOCUMENT_ROOT"].$componentFolder))
162 {
163 if ($handle = opendir($_SERVER["DOCUMENT_ROOT"].$componentFolder))
164 {
165 while (($file = readdir($handle)) !== false)
166 {
167 if ($file == "." || $file == "..")
168 continue;
169
170 if (is_dir($_SERVER["DOCUMENT_ROOT"].$componentFolder."/".$file))
171 {
172 if (CComponentUtil::isComponent($componentFolder."/".$file))
173 {
174 // It's component
175 if ($filterNamespace !== false && $filterNamespace <> '')
176 continue;
177 if ($arNameFilter !== false && !CComponentUtil::CheckComponentName($file, $arNameFilter))
178 continue;
179
180 if (file_exists($_SERVER["DOCUMENT_ROOT"].$componentFolder."/".$file."/.description.php"))
181 {
182 CComponentUtil::__IncludeLang($componentFolder."/".$file, ".description.php");
183
185 include($_SERVER["DOCUMENT_ROOT"].$componentFolder."/".$file."/.description.php");
186
187 if (isset($arFilter["TYPE"]) && $arFilter["TYPE"] != $arComponentDescription["TYPE"])
188 continue;
189
190 if (array_key_exists("PATH", $arComponentDescription) && array_key_exists("ID", $arComponentDescription["PATH"]))
191 {
193 $arComponent["NAME"] = $file;
194 $arComponent["TYPE"] = (array_key_exists("TYPE", $arComponentDescription) ? $arComponentDescription["TYPE"] : "");
195 $arComponent["NAMESPACE"] = "";
196 $arComponent["TITLE"] = trim($arComponentDescription["NAME"]);
197 $arComponent["DESCRIPTION"] = $arComponentDescription["DESCRIPTION"];
198
199 if (array_key_exists("ICON", $arComponentDescription))
200 {
201 $arComponentDescription["ICON"] = ltrim($arComponentDescription["ICON"], "/");
202 if($arComponentDescription["ICON"] != "" && $io->FileExists($io->RelativeToAbsolutePath($componentFolder."/".$file."/".$arComponentDescription["ICON"])))
203 $arComponent["ICON"] = $componentFolder."/".$file."/".$arComponentDescription["ICON"];
204 else
205 $arComponent["ICON"] = "/bitrix/images/fileman/htmledit2/component.gif";
206 }
207 if (array_key_exists("COMPLEX", $arComponentDescription) && $arComponentDescription["COMPLEX"] == "Y")
208 $arComponent["COMPLEX"] = "Y";
209 else
210 $arComponent["COMPLEX"] = "N";
211 $arComponent["SORT"] = intval($arComponentDescription["SORT"]);
212 if ($arComponent["SORT"] <= 0)
213 $arComponent["SORT"] = 100;
214
215 $arComponent["SCREENSHOT"] = array();
216 if (array_key_exists("SCREENSHOT", $arComponentDescription))
217 {
218 if (!is_array($arComponentDescription["SCREENSHOT"]))
219 $arComponentDescription["SCREENSHOT"] = array($arComponentDescription["SCREENSHOT"]);
220
221 for ($i = 0, $cnt = count($arComponentDescription["SCREENSHOT"]); $i < $cnt; $i++)
222 $arComponent["SCREENSHOT"][] = $componentFolder."/".$file.$arComponentDescription["SCREENSHOT"][$i];
223 }
224
226 }
227 }
228 }
229 else
230 {
231 // It's not a component
232 if ($filterNamespace !== false && ($filterNamespace == '' || $filterNamespace != $file))
233 continue;
234
235 if ($handle1 = opendir($_SERVER["DOCUMENT_ROOT"].$componentFolder."/".$file))
236 {
237 while (($file1 = readdir($handle1)) !== false)
238 {
239 if ($file1 == "." || $file1 == "..")
240 continue;
241
242 if (is_dir($_SERVER["DOCUMENT_ROOT"].$componentFolder."/".$file."/".$file1))
243 {
244 if (CComponentUtil::isComponent($componentFolder."/".$file."/".$file1))
245 {
246 if ($arNameFilter !== false && !CComponentUtil::CheckComponentName($file1, $arNameFilter))
247 continue;
248 // It's component
249 if (file_exists($_SERVER["DOCUMENT_ROOT"].$componentFolder."/".$file."/".$file1."/.description.php"))
250 {
251 CComponentUtil::__IncludeLang($componentFolder."/".$file."/".$file1, ".description.php");
252
254 include($_SERVER["DOCUMENT_ROOT"].$componentFolder."/".$file."/".$file1."/.description.php");
255
256 if (isset($arFilter["TYPE"]) && (!isset($arComponentDescription["TYPE"]) || $arFilter["TYPE"] != $arComponentDescription["TYPE"]))
257 continue;
258
259 if (array_key_exists("PATH", $arComponentDescription) && array_key_exists("ID", $arComponentDescription["PATH"]))
260 {
262 $arComponent["NAME"] = $file.":".$file1;
263 $arComponent["TYPE"] = (array_key_exists("TYPE", $arComponentDescription) ? $arComponentDescription["TYPE"] : "");
264 $arComponent["NAMESPACE"] = $file;
265 $arComponent["TITLE"] = trim($arComponentDescription["NAME"]);
266 $arComponent["DESCRIPTION"] = $arComponentDescription["DESCRIPTION"];
267 if (array_key_exists("ICON", $arComponentDescription))
268 {
269 $arComponentDescription["ICON"] = ltrim($arComponentDescription["ICON"], "/");
270 if($arComponentDescription["ICON"] != "" && $io->FileExists($io->RelativeToAbsolutePath($componentFolder."/".$file."/".$file1."/".$arComponentDescription["ICON"])))
271 $arComponent["ICON"] = $componentFolder."/".$file."/".$file1."/".$arComponentDescription["ICON"];
272 else
273 $arComponent["ICON"] = "/bitrix/images/fileman/htmledit2/component.gif";
274 }
275 if (array_key_exists("COMPLEX", $arComponentDescription) && $arComponentDescription["COMPLEX"] == "Y")
276 $arComponent["COMPLEX"] = "Y";
277 else
278 $arComponent["COMPLEX"] = "N";
279 $arComponent["SORT"] = intval($arComponentDescription["SORT"] ?? 0);
280 if ($arComponent["SORT"] <= 0)
281 $arComponent["SORT"] = 100;
282
283 $arComponent["SCREENSHOT"] = array();
284 if (array_key_exists("SCREENSHOT", $arComponentDescription))
285 {
286 if (!is_array($arComponentDescription["SCREENSHOT"]))
287 $arComponentDescription["SCREENSHOT"] = array($arComponentDescription["SCREENSHOT"]);
288
289 for ($i = 0, $cnt = count($arComponentDescription["SCREENSHOT"]); $i < $cnt; $i++)
290 $arComponent["SCREENSHOT"][] = $componentFolder."/".$file."/".$file1.$arComponentDescription["SCREENSHOT"][$i];
291 }
292
294 }
295 }
296 }
297 }
298 }
299 closedir($handle1);
300 }
301 }
302 }
303 }
304 closedir($handle);
305 }
306 }
307 }
308
309 return $arTree;
310 }
311
312 public static function __TreeFolderCompare($a, $b)
313 {
314 if ($a["@"]["SORT"] < $b["@"]["SORT"] || $a["@"]["SORT"] == $b["@"]["SORT"] && mb_strtolower($a["@"]["NAME"]) < mb_strtolower($b["@"]["NAME"]))
315 return -1;
316 elseif ($a["@"]["SORT"] > $b["@"]["SORT"] || $a["@"]["SORT"] == $b["@"]["SORT"] && mb_strtolower($a["@"]["NAME"]) > mb_strtolower($b["@"]["NAME"]))
317 return 1;
318 else
319 return 0;
320 }
321
322 public static function __TreeItemCompare($a, $b)
323 {
324 if ($a["COMPLEX"] == "Y" && $b["COMPLEX"] == "Y" || $a["COMPLEX"] != "Y" && $b["COMPLEX"] != "Y")
325 {
326 if ($a["SORT"] < $b["SORT"] || $a["SORT"] == $b["SORT"] && mb_strtolower($a["TITLE"]) < mb_strtolower($b["TITLE"]))
327 return -1;
328 elseif ($a["SORT"] > $b["SORT"] || $a["SORT"] == $b["SORT"] && mb_strtolower($a["TITLE"]) > mb_strtolower($b["TITLE"]))
329 return 1;
330 else
331 return 0;
332 }
333 else
334 {
335 if ($a["COMPLEX"] == "Y")
336 return -1;
337 if ($b["COMPLEX"] == "Y")
338 return 1;
339 }
340 return 0;
341 }
342
343 public static function __SortComponentsTree(&$arTree)
344 {
345 uasort($arTree, array("CComponentUtil", "__TreeFolderCompare"));
346 foreach ($arTree as $key => $value)
347 {
348 if (array_key_exists("#", $arTree[$key]))
350 if (array_key_exists("*", $arTree[$key]))
351 uasort($arTree[$key]["*"], array("CComponentUtil", "__TreeItemCompare"));
352 }
353 }
354
355 public static function GetComponentsTree($filterNamespace = false, $arNameFilter = false, $arFilter = false)
356 {
357 $arTree = CComponentUtil::__GetComponentsTree($filterNamespace, $arNameFilter, $arFilter);
358
359 if (isset($arTree["#"]))
360 {
362 }
363
364 return $arTree;
365 }
366
367 public static function GetNamespaceList()
368 {
369 $arNamespaces = array();
370 $folders = array(
371 "/local/components",
372 "/bitrix/components",
373 );
374
375 foreach($folders as $componentFolder)
376 {
377 if(file_exists($_SERVER["DOCUMENT_ROOT"].$componentFolder))
378 {
379 if ($handle = opendir($_SERVER["DOCUMENT_ROOT"].$componentFolder))
380 {
381 while (($file = readdir($handle)) !== false)
382 {
383 if ($file == "." || $file == "..")
384 continue;
385
386 if (
387 is_dir($_SERVER["DOCUMENT_ROOT"].$componentFolder."/".$file)
388 && !CComponentUtil::isComponent($componentFolder."/".$file)
389 )
390 {
391 $arNamespaces[] = $file;
392 }
393 }
394 closedir($handle);
395 }
396 }
397 }
398
399 return array_unique($arNamespaces);
400 }
401
402 public static function GetComponentDescr($componentName)
403 {
405
406 static $cache = array();
407
408 if($componentName == '')
409 {
411 }
412 else
413 {
414 if(array_key_exists($componentName, $cache))
415 return $cache[$componentName];
416
417 $path2Comp = CComponentEngine::MakeComponentPath($componentName);
418 if($path2Comp == '')
419 {
421 }
422 else
423 {
424 $componentPath = getLocalPath("components".$path2Comp);
426 {
428 if(file_exists($_SERVER["DOCUMENT_ROOT"].$componentPath."/.description.php"))
429 {
431 include($_SERVER["DOCUMENT_ROOT"].$componentPath."/.description.php");
432 }
433 }
434 else
435 {
437 }
438 }
439 }
440
443 }
444
445 public static function __GroupParamsCompare($a, $b)
446 {
447 if ($a["SORT"] < $b["SORT"])
448 return -1;
449 elseif ($a["SORT"] > $b["SORT"])
450 return 1;
451 else
452 return 0;
453 }
454
461 public static function GetComponentProps($componentName, $arCurrentValues = array(), $templateProperties = array())
462 {
463 $arComponentParameters = array();
465 if ($componentName == '')
466 return false;
467
468 $path2Comp = CComponentEngine::MakeComponentPath($componentName);
469 if ($path2Comp == '')
470 return false;
471
472 $componentPath = getLocalPath("components".$path2Comp);
474 {
475 return false;
476 }
477
478 if (file_exists($_SERVER["DOCUMENT_ROOT"].$componentPath."/.parameters.php"))
479 {
481
482 include($_SERVER["DOCUMENT_ROOT"].$componentPath."/.parameters.php");
483 }
484
485 if ($templateProperties && is_array($templateProperties))
486 {
487 if(isset($arComponentParameters["PARAMETERS"]) && is_array($arComponentParameters["PARAMETERS"]))
488 $arComponentParameters["PARAMETERS"] = array_merge ($arComponentParameters["PARAMETERS"], $templateProperties);
489 else
490 $arComponentParameters["PARAMETERS"] = $templateProperties;
491 }
492
493 if (!array_key_exists("PARAMETERS", $arComponentParameters) || !is_array($arComponentParameters["PARAMETERS"]))
494 {
495 $arComponentParameters["PARAMETERS"] = array();
496 }
497
498 if (!array_key_exists("GROUPS", $arComponentParameters) || !is_array($arComponentParameters["GROUPS"]))
499 $arComponentParameters["GROUPS"] = array();
500
501 $arParamKeys = array_keys($arComponentParameters["GROUPS"]);
502 for ($i = 0, $cnt = count($arParamKeys); $i < $cnt; $i++)
503 {
504 if (!IsSet($arComponentParameters["GROUPS"][$arParamKeys[$i]]["SORT"]))
505 $arComponentParameters["GROUPS"][$arParamKeys[$i]]["SORT"] = 1000+$i;
506 $arComponentParameters["GROUPS"][$arParamKeys[$i]]["SORT"] = intval($arComponentParameters["GROUPS"][$arParamKeys[$i]]["SORT"]);
507 if ($arComponentParameters["GROUPS"][$arParamKeys[$i]]["SORT"] <= 0)
508 $arComponentParameters["GROUPS"][$arParamKeys[$i]]["SORT"] = 1000+$i;
509 }
510
511 $arVariableAliasesSettings = null;
512 $arParamKeys = array_keys($arComponentParameters["PARAMETERS"]);
513 for ($i = 0, $cnt = count($arParamKeys); $i < $cnt; $i++)
514 {
515 if ($arParamKeys[$i] == "SET_TITLE")
516 {
517 $arComponentParameters["GROUPS"]["ADDITIONAL_SETTINGS"] = array(
518 "NAME" => GetMessage("COMP_GROUP_ADDITIONAL_SETTINGS"),
519 "SORT" => 700
520 );
521
522 $arComponentParameters["PARAMETERS"]["SET_TITLE"] = array(
523 "PARENT" => "ADDITIONAL_SETTINGS",
524 "NAME" => GetMessage("COMP_PROP_SET_TITLE"),
525 "TYPE" => "CHECKBOX",
526 "DEFAULT" => "Y",
527 "ADDITIONAL_VALUES" => "N",
528 "REFRESH" => "Y"
529 );
530 }
531 elseif ($arParamKeys[$i] == "CACHE_TIME")
532 {
533 $arComponentParameters["GROUPS"]["CACHE_SETTINGS"] = array(
534 "NAME" => GetMessage("COMP_GROUP_CACHE_SETTINGS"),
535 "SORT" => 600
536 );
537
538 $arSavedParams = $arComponentParameters["PARAMETERS"];
539 $arComponentParameters["PARAMETERS"] = array();
540 foreach ($arSavedParams as $keyTmp => $valueTmp)
541 {
542 if ($keyTmp == "CACHE_TIME")
543 {
544 $arComponentParameters["PARAMETERS"]["CACHE_TYPE"] = array(
545 "PARENT" => "CACHE_SETTINGS",
546 "NAME" => GetMessage("COMP_PROP_CACHE_TYPE"),
547 "TYPE" => "LIST",
548 "VALUES" => array("A" => GetMessage("COMP_PROP_CACHE_TYPE_AUTO")." ".GetMessage("COMP_PARAM_CACHE_MAN"), "Y" => GetMessage("COMP_PROP_CACHE_TYPE_YES"), "N" => GetMessage("COMP_PROP_CACHE_TYPE_NO")),
549 "DEFAULT" => "A",
550 "ADDITIONAL_VALUES" => "N"
551 );
552 $arComponentParameters["PARAMETERS"]["CACHE_TIME"] = array(
553 "PARENT" => "CACHE_SETTINGS",
554 "NAME" => GetMessage("COMP_PROP_CACHE_TIME"),
555 "TYPE" => "STRING",
556 "MULTIPLE" => "N",
557 "DEFAULT" => intval($arSavedParams["CACHE_TIME"]["DEFAULT"]),
558 "COLS" => 5
559 );
560 $arComponentParameters["PARAMETERS"]["CACHE_NOTES"] = array(
561 "PARENT" => "CACHE_SETTINGS",
562 "TYPE" => "CUSTOM",
563 "JS_FILE" => "/bitrix/js/main/comp_props.js",
564 "JS_EVENT" => "BxShowComponentNotes",
565 "JS_DATA" => GetMessage("COMP_PROP_CACHE_NOTE", array(
566 "#LANG#" => LANGUAGE_ID,
567 "#AUTO_MODE#" => (COption::GetOptionString("main", "component_cache_on", "Y") == "Y"? GetMessage("COMP_PARAM_CACHE_AUTO_ON"):GetMessage("COMP_PARAM_CACHE_AUTO_OFF")),
568 "#MANAGED_MODE#" =>(defined("BX_COMP_MANAGED_CACHE")? GetMessage("COMP_PARAM_CACHE_MANAGED_ON"):GetMessage("COMP_PARAM_CACHE_MANAGED_OFF")),
569 )),
570 );
571 }
572 else
573 {
574 $arComponentParameters["PARAMETERS"][$keyTmp] = $valueTmp;
575 }
576 }
577 }
578 elseif ($arParamKeys[$i] == "SEF_MODE" && isset($arComponentParameters["PARAMETERS"]["SEF_RULE"]))
579 {
580 $arComponentParameters["GROUPS"]["SEF_MODE"] = array(
581 "NAME" => GetMessage("COMP_GROUP_SEF_MODE"),
582 "SORT" => 500
583 );
584 $arComponentParameters["PARAMETERS"]["SEF_MODE"] = array(
585 "PARENT" => "SEF_MODE",
586 "NAME" => GetMessage("COMP_PROP_SEF_MODE"),
587 "TYPE" => "CHECKBOX",
588 "DEFAULT" => "N",
589 );
590 $arComponentParameters["PARAMETERS"]["SEF_RULE"]["PARENT"] = "SEF_MODE";
591 }
592 elseif ($arParamKeys[$i] == "SEF_RULE")
593 {
594 $arComponentParameters["PARAMETERS"]["SEF_RULE"]["TYPE"] = "TEMPLATES";
595 $arComponentParameters["PARAMETERS"]["SEF_RULE"]["NAME"] = GetMessage("COMP_PARAM_SEF_RULE");
596 if (isset($arCurrentValues["SEF_MODE"]) && $arCurrentValues["SEF_MODE"] === "Y")
597 {
598 if (is_array($arComponentParameters["PARAMETERS"]["SEF_RULE"]["VALUES"]))
599 {
600 foreach ($arComponentParameters["PARAMETERS"]["SEF_RULE"]["VALUES"] as $sefRuleValue)
601 {
602 if (
603 is_array($sefRuleValue)
604 && isset($sefRuleValue["PARAMETER_LINK"])
605 && isset($arComponentParameters["PARAMETERS"][$sefRuleValue["PARAMETER_LINK"]])
606 )
607 {
608 $arComponentParameters["PARAMETERS"][$sefRuleValue["PARAMETER_LINK"]]["PARENT"] = "SEF_MODE";
609 }
610 }
611 }
612 }
613 }
614 elseif ($arParamKeys[$i] == "SEF_MODE")
615 {
616 $arComponentParameters["GROUPS"]["SEF_MODE"] = array(
617 "NAME" => GetMessage("COMP_GROUP_SEF_MODE"),
618 "SORT" => 500
619 );
620
621 $arSEFModeSettings = $arComponentParameters["PARAMETERS"]["SEF_MODE"];
622
623 $arComponentParameters["PARAMETERS"]["SEF_MODE"] = array(
624 "PARENT" => "SEF_MODE",
625 "NAME" => GetMessage("COMP_PROP_SEF_MODE"),
626 "TYPE" => "CHECKBOX",
627 "DEFAULT" => "N",
628 );
629 $arComponentParameters["PARAMETERS"]["SEF_FOLDER"] = array(
630 "PARENT" => "SEF_MODE",
631 "NAME" => GetMessage("COMP_PROP_SEF_FOLDER"),
632 "TYPE" => "STRING",
633 "MULTIPLE" => "N",
634 "DEFAULT" => "",
635 "COLS" => 30
636 );
637
638 if (is_array($arSEFModeSettings) && !empty($arSEFModeSettings))
639 {
640 if (!isset($arVariableAliasesSettings))
641 $arVariableAliasesSettings = $arComponentParameters["PARAMETERS"]["VARIABLE_ALIASES"];
642
643 foreach ($arSEFModeSettings as $templateKey => $arTemplateValue)
644 {
645 $arComponentParameters["PARAMETERS"]["SEF_URL_TEMPLATES_".$templateKey] = array(
646 "PARENT" => "SEF_MODE",
647 "NAME" => $arTemplateValue["NAME"],
648 "TYPE" => "STRING",
649 "MULTIPLE" => "N",
650 "DEFAULT" => $arTemplateValue["DEFAULT"],
651 "HIDDEN" => $arTemplateValue["HIDDEN"] ?? '',
652 "COLS" => 50,
653 "VARIABLES" => array(),
654 );
655
656 if (is_array($arVariableAliasesSettings) && !empty($arVariableAliasesSettings))
657 {
658 foreach ($arTemplateValue["VARIABLES"] as $variable)
659 {
660 if (!empty($arVariableAliasesSettings[$variable]["TEMPLATE"]))
661 {
662 $arComponentParameters["PARAMETERS"]["SEF_URL_TEMPLATES_".$templateKey]["TYPE"] = "TEMPLATES";
663 $arComponentParameters["PARAMETERS"]["SEF_URL_TEMPLATES_".$templateKey]["VALUES"][$variable] = array(
664 "TEXT" => $arVariableAliasesSettings[$variable]["NAME"],
665 "TEMPLATE" => $arVariableAliasesSettings[$variable]["TEMPLATE"],
666 );
667 }
668 $arComponentParameters["PARAMETERS"]["SEF_URL_TEMPLATES_".$templateKey]["VARIABLES"]["#".$variable."#"] = $arVariableAliasesSettings[$variable]["NAME"] ?? '';
669 }
670 }
671 }
672 }
673 }
674 elseif ($arParamKeys[$i] == "VARIABLE_ALIASES")
675 {
676 $arComponentParameters["GROUPS"]["SEF_MODE"] = array(
677 "NAME" => GetMessage("COMP_GROUP_SEF_MODE"),
678 "SORT" => 500
679 );
680
681 $arVariableAliasesSettings = $arComponentParameters["PARAMETERS"]["VARIABLE_ALIASES"];
682
683 unset($arComponentParameters["PARAMETERS"]["VARIABLE_ALIASES"]);
684
685 foreach ($arVariableAliasesSettings as $aliaseKey => $arAliaseValue)
686 {
687 $arComponentParameters["PARAMETERS"]["VARIABLE_ALIASES_".$aliaseKey] = array(
688 "PARENT" => "SEF_MODE",
689 "NAME" => $arAliaseValue["NAME"],
690 "TYPE" => "STRING",
691 "MULTIPLE" => "N",
692 "DEFAULT" => $aliaseKey,
693 "COLS" => 20,
694 );
695 }
696 }
697 elseif (IsSet($arComponentParameters["PARAMETERS"][$arParamKeys[$i]]["PARENT"]) && $arComponentParameters["PARAMETERS"][$arParamKeys[$i]]["PARENT"] <> '')
698 {
699 if ($arComponentParameters["PARAMETERS"][$arParamKeys[$i]]["PARENT"] == "URL_TEMPLATES")
700 {
701 $arComponentParameters["GROUPS"]["URL_TEMPLATES"] = array(
702 "NAME" => GetMessage("COMP_GROUP_URL_TEMPLATES"),
703 "SORT" => 400
704 );
705 }
706 elseif ($arComponentParameters["PARAMETERS"][$arParamKeys[$i]]["PARENT"] == "VISUAL")
707 {
708 $arComponentParameters["GROUPS"]["VISUAL"] = array(
709 "NAME" => GetMessage("COMP_GROUP_VISUAL"),
710 "SORT" => 300
711 );
712 }
713 elseif ($arComponentParameters["PARAMETERS"][$arParamKeys[$i]]["PARENT"] == "DATA_SOURCE")
714 {
715 $arComponentParameters["GROUPS"]["DATA_SOURCE"] = array(
716 "NAME" => GetMessage("COMP_GROUP_DATA_SOURCE"),
717 "SORT" => 200
718 );
719 }
720 elseif ($arComponentParameters["PARAMETERS"][$arParamKeys[$i]]["PARENT"] == "BASE")
721 {
722 $arComponentParameters["GROUPS"]["BASE"] = array(
723 "NAME" => GetMessage("COMP_GROUP_BASE"),
724 "SORT" => 100
725 );
726 }
727 elseif ($arComponentParameters["PARAMETERS"][$arParamKeys[$i]]["PARENT"] == "ADDITIONAL_SETTINGS")
728 {
729 $arComponentParameters["GROUPS"]["ADDITIONAL_SETTINGS"] = array(
730 "NAME" => GetMessage("COMP_GROUP_ADDITIONAL_SETTINGS"),
731 "SORT" => 700
732 );
733 }
734 }
735 elseif ($arParamKeys[$i] == "AJAX_MODE")
736 {
737 $arComponentParameters["GROUPS"]["AJAX_SETTINGS"] = array(
738 "NAME" => GetMessage("COMP_GROUP_AJAX_SETTINGS"),
739 "SORT" => 550
740 );
741
742 $arComponentParameters["PARAMETERS"]["AJAX_MODE"] = array(
743 "PARENT" => "AJAX_SETTINGS",
744 "NAME" => GetMessage("COMP_PROP_AJAX_MODE"),
745 "TYPE" => "CHECKBOX",
746 "DEFAULT" => "N",
747 "ADDITIONAL_VALUES" => "N"
748 );
749
750 // $arComponentParameters["PARAMETERS"]["AJAX_OPTION_SHADOW"] = array(
751 // "PARENT" => "AJAX_SETTINGS",
752 // "NAME" => GetMessage("COMP_PROP_AJAX_OPTIONS_SHADOW"),
753 // "TYPE" => "CHECKBOX",
754 // "MULTIPLE" => "N",
755 // "DEFAULT" => "Y",
756 // "ADDITIONAL_VALUES" => "N"
757 // );
758
759 $arComponentParameters["PARAMETERS"]["AJAX_OPTION_JUMP"] = array(
760 "PARENT" => "AJAX_SETTINGS",
761 "NAME" => GetMessage("COMP_PROP_AJAX_OPTIONS_JUMP"),
762 "TYPE" => "CHECKBOX",
763 "MULTIPLE" => "N",
764 "DEFAULT" => "N",
765 "ADDITIONAL_VALUES" => "N"
766 );
767
768 $arComponentParameters["PARAMETERS"]["AJAX_OPTION_STYLE"] = array(
769 "PARENT" => "AJAX_SETTINGS",
770 "NAME" => GetMessage("COMP_PROP_AJAX_OPTIONS_STYLE"),
771 "TYPE" => "CHECKBOX",
772 "MULTIPLE" => "N",
773 "DEFAULT" => "Y",
774 "ADDITIONAL_VALUES" => "N"
775 );
776
777 $arComponentParameters["PARAMETERS"]["AJAX_OPTION_HISTORY"] = array(
778 "PARENT" => "AJAX_SETTINGS",
779 "NAME" => GetMessage("COMP_PROP_AJAX_OPTIONS_HISTORY"),
780 "TYPE" => "CHECKBOX",
781 "MULTIPLE" => "N",
782 "DEFAULT" => "N",
783 "ADDITIONAL_VALUES" => "N"
784 );
785
786 $arComponentParameters["PARAMETERS"]["AJAX_OPTION_ADDITIONAL"] = array(
787 "PARENT" => "AJAX_SETTINGS",
788 "NAME" => GetMessage("COMP_PROP_AJAX_OPTIONS_ADDITIONAL"),
789 "TYPE" => "STRING",
790 "HIDDEN" => "Y",
791 "MULTIPLE" => "N",
792 "DEFAULT" => "",
793 "ADDITIONAL_VALUES" => "N"
794 );
795 }
796 elseif ($arParamKeys[$i] == "USER_CONSENT")
797 {
798 $arComponentParameters["GROUPS"]["USER_CONSENT"] = array(
799 "NAME" => GetMessage("COMP_GROUP_USER_CONSENT"),
800 "SORT" => 350
801 );
802
803 $arComponentParameters["PARAMETERS"]["USER_CONSENT"] = array(
804 "PARENT" => "USER_CONSENT",
805 "NAME" => GetMessage("COMP_PROP_USER_CONSENT_USE"),
806 "TYPE" => "CHECKBOX",
807 "DEFAULT" => "N",
808 "ADDITIONAL_VALUES" => "N"
809 );
810
811 $arComponentParameters["PARAMETERS"]["USER_CONSENT_ID"] = array(
812 "PARENT" => "USER_CONSENT",
813 "NAME" => GetMessage("COMP_PROP_USER_CONSENT_ID"),
814 "TYPE" => "LIST",
815 "VALUES" => array(GetMessage("COMP_PROP_USER_CONSENT_ID_DEF")) + \Bitrix\Main\UserConsent\Agreement::getActiveList(),
816 "MULTIPLE" => "N",
817 "DEFAULT" => "",
818 );
819
820 $arComponentParameters["PARAMETERS"]["USER_CONSENT_IS_CHECKED"] = array(
821 "PARENT" => "USER_CONSENT",
822 "NAME" => GetMessage("COMP_PROP_USER_CONSENT_IS_CHECKED"),
823 "TYPE" => "CHECKBOX",
824 "DEFAULT" => "Y",
825 "ADDITIONAL_VALUES" => "N"
826 );
827
828 $arComponentParameters["PARAMETERS"]["USER_CONSENT_IS_LOADED"] = array(
829 "PARENT" => "USER_CONSENT",
830 "NAME" => GetMessage("COMP_PROP_USER_CONSENT_IS_LOADED"),
831 "TYPE" => "CHECKBOX",
832 "DEFAULT" => "N",
833 "ADDITIONAL_VALUES" => "N"
834 );
835 }
836 else
837 {
838 $parent = $arComponentParameters["PARAMETERS"][$arParamKeys[$i]]["PARENT"] ?? null;
839 if (!isset($parent) || !isset($arComponentParameters["GROUPS"][$parent]))
840 {
841 $arComponentParameters["PARAMETERS"][$arParamKeys[$i]]["PARENT"] = "ADDITIONAL_SETTINGS";
842 if (!isset($arComponentParameters["GROUPS"]["ADDITIONAL_SETTINGS"]))
843 {
844 $arComponentParameters["GROUPS"]["ADDITIONAL_SETTINGS"] = array(
845 "NAME" => GetMessage("COMP_GROUP_ADDITIONAL_SETTINGS"),
846 "SORT" => 700
847 );
848 }
849 }
850 }
851 }
852
853 if (\Bitrix\Main\Composite\Helper::isOn())
854 {
855 $arComponentParameters["GROUPS"]["COMPOSITE_SETTINGS"] = array(
856 "NAME" => GetMessage("COMP_GROUP_COMPOSITE_SETTINGS"),
857 "SORT" => 800
858 );
859
860 $arComponentParameters["PARAMETERS"]["COMPOSITE_FRAME_MODE"] = array(
861 "PARENT" => "COMPOSITE_SETTINGS",
862 "NAME" => GetMessage("COMP_PROP_COMPOSITE_FRAME_MODE"),
863 "TYPE" => "LIST",
864 "VALUES" => array(
865 "A" => GetMessage("COMP_PROP_COMPOSITE_FRAME_MODE_AUTO"),
866 "Y" => GetMessage("COMP_PROP_COMPOSITE_FRAME_MODE_PRO"),
867 "N" => GetMessage("COMP_PROP_COMPOSITE_FRAME_MODE_CONTRA")
868 ),
869 "DEFAULT" => "A",
870 "REFRESH" => "Y",
871 "ADDITIONAL_VALUES" => "N"
872 );
873
874 if (
875 !isset($arCurrentValues["COMPOSITE_FRAME_MODE"]) ||
876 in_array($arCurrentValues["COMPOSITE_FRAME_MODE"], array("A", "Y")))
877 {
878 $arComponentParameters["PARAMETERS"]["COMPOSITE_FRAME_TYPE"] = array(
879 "PARENT" => "COMPOSITE_SETTINGS",
880 "NAME" => GetMessage("COMP_PROP_COMPOSITE_FRAME_TYPE"),
881 "TYPE" => "LIST",
882 "VALUES" => array(
883 "AUTO" => GetMessage("COMP_PROP_COMPOSITE_FRAME_TYPE_AUTO"),
884 "STATIC" => GetMessage("COMP_PROP_COMPOSITE_FRAME_TYPE_STATIC"),
885 "DYNAMIC_WITH_STUB" => GetMessage("COMP_PROP_COMPOSITE_FRAME_TYPE_DYNAMIC_WITH_STUB"),
886 "DYNAMIC_WITHOUT_STUB" => GetMessage("COMP_PROP_COMPOSITE_FRAME_TYPE_DYNAMIC_WITHOUT_STUB"),
887 "DYNAMIC_WITH_STUB_LOADING" => GetMessage("COMP_PROP_COMPOSITE_FRAME_TYPE_DYNAMIC_WITH_STUB_LOADING")
888 ),
889 "DEFAULT" => "A",
890 "ADDITIONAL_VALUES" => "N"
891 );
892 }
893
894 }
895
896 if(
897 (CPageOption::GetOptionString("main","tips_creation","no")=="allowed")
898 && (str_contains($componentPath, "/forum"))
899 )
900 {
901 //Create directories
902 $help_lang_path = $_SERVER["DOCUMENT_ROOT"].$componentPath."/lang";
903 if(!file_exists($help_lang_path))
904 mkdir($help_lang_path);
905 $help_lang_path .= "/ru";
906 if(!file_exists($help_lang_path))
907 mkdir($help_lang_path);
908 $help_lang_path .= "/help";
909 if(!file_exists($help_lang_path))
910 mkdir($help_lang_path);
911 if(is_dir($help_lang_path))
912 {
913 //Create files if none exists
914 $lang_filename = $help_lang_path."/.tooltips.php";
915 if(!file_exists($lang_filename))
916 {
917 $handle=fopen($lang_filename, "w");
918 fwrite($handle, "<?\n?>");
919 fclose($handle);
920 }
921 $handle=fopen($lang_filename, "r");
922 $lang_contents = fread($handle, filesize($lang_filename));
923 fclose($handle);
924 $lang_file_modified = false;
925 //Bug fix
926 if(str_contains($lang_contents, "\$MESS['"))
927 {
928 $lang_contents = str_replace("\$MESS['", "\$MESS ['", $lang_contents);
929 $lang_file_modified = true;
930 }
931 //Check out parameters
932 foreach($arComponentParameters["PARAMETERS"] as $strName=>$arParameter)
933 {
934 if(!str_contains($lang_contents, "\$MESS ['${strName}_TIP'] = "))
935 {
936 $lang_contents = str_replace("?>", "\$MESS ['${strName}_TIP'] = \"".str_replace("\$", "\\\$", str_replace('"','\\"',$arParameter["NAME"]))."\";\n?>", $lang_contents);
937 $lang_file_modified = true;
938 }
939 }
940 //Save the result of the work
941 if($lang_file_modified)
942 {
943 $handle=fopen($lang_filename, "w");
944 fwrite($handle, $lang_contents);
945 fclose($handle);
946 }
947 }
948 reset($arComponentParameters["PARAMETERS"]);
949 }
950 uasort($arComponentParameters["GROUPS"], array("CComponentUtil", "__GroupParamsCompare"));
951
952
953 return $arComponentParameters;
954 }
955
963 public static function GetTemplateProps($componentName, $templateName, $siteTemplate = "", $arCurrentValues = array())
964 {
965 $arTemplateParameters = array();
966
968 if ($componentName == '')
969 return $arTemplateParameters;
970
971 if ($templateName == '')
972 $templateName = ".default";
973
974 if(preg_match("#[^a-z0-9_.-]#i", $templateName))
975 return $arTemplateParameters;
976
977 $path2Comp = CComponentEngine::MakeComponentPath($componentName);
978 if ($path2Comp == '')
979 return $arTemplateParameters;
980
981 $componentPath = getLocalPath("components".$path2Comp);
982
984 {
985 return $arTemplateParameters;
986 }
987
988 if ($siteTemplate <> "")
989 {
990 $siteTemplate = _normalizePath($siteTemplate);
991 }
992
993 $folders = array();
994 if ($siteTemplate <> "")
995 {
996 $folders[] = "/local/templates/".$siteTemplate."/components".$path2Comp."/".$templateName;
997 }
998 $folders[] = "/local/templates/.default/components".$path2Comp."/".$templateName;
999 $folders[] = "/local/components".$path2Comp."/templates/".$templateName;
1000
1001 if ($siteTemplate <> "")
1002 {
1003 $folders[] = BX_PERSONAL_ROOT."/templates/".$siteTemplate."/components".$path2Comp."/".$templateName;
1004 }
1005 $folders[] = BX_PERSONAL_ROOT."/templates/.default/components".$path2Comp."/".$templateName;
1006 $folders[] = "/bitrix/components".$path2Comp."/templates/".$templateName;
1007
1008 foreach($folders as $templateFolder)
1009 {
1010 if (file_exists($_SERVER["DOCUMENT_ROOT"].$templateFolder))
1011 {
1012 if (file_exists($_SERVER["DOCUMENT_ROOT"].$templateFolder."/.parameters.php"))
1013 {
1014 CComponentUtil::__IncludeLang($templateFolder, ".parameters.php");
1015 include($_SERVER["DOCUMENT_ROOT"].$templateFolder."/.parameters.php");
1016 }
1017 return $arTemplateParameters;
1018 }
1019 }
1020
1021 return $arTemplateParameters;
1022 }
1023
1024 public static function GetTemplatesList($componentName, $currentTemplate = false)
1025 {
1027
1029 if ($componentName == '')
1030 return $arTemplatesList;
1031
1032 $path2Comp = CComponentEngine::MakeComponentPath($componentName);
1033 if ($path2Comp == '')
1034 return $arTemplatesList;
1035
1036 $componentPath = getLocalPath("components".$path2Comp);
1037
1039 {
1040 return $arTemplatesList;
1041 }
1042
1043 $templateFolders = array();
1044 $arExists = array();
1045 $folders = array(
1046 "/local/templates",
1047 BX_PERSONAL_ROOT."/templates",
1048 );
1049
1050 foreach($folders as $folder)
1051 {
1052 if(file_exists($_SERVER["DOCUMENT_ROOT"].$folder))
1053 {
1054 if ($handle = opendir($_SERVER["DOCUMENT_ROOT"].$folder))
1055 {
1056 while (($file = readdir($handle)) !== false)
1057 {
1058 if ($file == "." || $file == "..")
1059 continue;
1060
1061 if ($currentTemplate !== false && $currentTemplate != $file || $file == ".default")
1062 continue;
1063
1064 if (file_exists($_SERVER["DOCUMENT_ROOT"].$folder."/".$file."/components".$path2Comp))
1065 {
1066 $templateFolders[] = array(
1067 "path" => $folder."/".$file."/components".$path2Comp,
1068 "template" => $file,
1069 );
1070 }
1071 }
1072 closedir($handle);
1073
1074 if (file_exists($_SERVER["DOCUMENT_ROOT"].$folder."/.default/components".$path2Comp))
1075 {
1076 $templateFolders[] = array(
1077 "path" => $folder."/.default/components".$path2Comp,
1078 "template" => ".default",
1079 );
1080 }
1081 }
1082 }
1083 }
1084
1085 $templateFolders[] = array(
1086 "path" => $componentPath."/templates",
1087 "template" => "",
1088 );
1089
1090 foreach($templateFolders as $templateFolder)
1091 {
1092 $templateFolderPath = $templateFolder["path"];
1093 if ($handle1 = @opendir($_SERVER["DOCUMENT_ROOT"].$templateFolderPath))
1094 {
1095 while (($file1 = readdir($handle1)) !== false)
1096 {
1097 if ($file1 == "." || $file1 == "..")
1098 continue;
1099
1100 if (in_array($file1, $arExists))
1101 continue;
1102
1104 "NAME" => $file1,
1105 "TEMPLATE" => $templateFolder["template"],
1106 );
1107
1108 if (file_exists($_SERVER["DOCUMENT_ROOT"].$templateFolderPath."/".$file1."/.description.php"))
1109 {
1110 CComponentUtil::__IncludeLang($templateFolderPath."/".$file1, ".description.php");
1111
1112 $arTemplateDescription = array();
1113 include($_SERVER["DOCUMENT_ROOT"].$templateFolderPath."/".$file1."/.description.php");
1114
1115 $arTemplate["TITLE"] = $arTemplateDescription["NAME"];
1116 $arTemplate["DESCRIPTION"] = $arTemplateDescription["DESCRIPTION"];
1117 }
1118
1120 $arExists[] = $arTemplate["NAME"];
1121 }
1122 @closedir($handle1);
1123 }
1124 }
1125
1126 return $arTemplatesList;
1127 }
1128
1129 public static function CopyComponent($componentName, $newNamespace, $newName = false, $bRewrite = false)
1130 {
1132 global $APPLICATION;
1133
1135 if ($componentName == '')
1136 {
1137 $APPLICATION->ThrowException(GetMessage("comp_util_err1"), "EMPTY_COMPONENT_NAME");
1138 return false;
1139 }
1140
1141 $path2Comp = CComponentEngine::MakeComponentPath($componentName);
1142 if ($path2Comp == '')
1143 {
1144 $APPLICATION->ThrowException(str_replace("#NAME#", $componentName, GetMessage("comp_util_err2")), "ERROR_NOT_COMPONENT");
1145 return false;
1146 }
1147
1148 $componentPath = getLocalPath("components".$path2Comp);
1149
1151 {
1152 $APPLICATION->ThrowException(str_replace("#NAME#", $componentName, GetMessage("comp_util_err2")), "ERROR_NOT_COMPONENT");
1153 return false;
1154 }
1155
1156 $newNamespace = trim($newNamespace);
1157 if ($newNamespace <> '')
1158 {
1159 if (preg_match("#[^a-z0-9_.-]#i", $newNamespace))
1160 {
1161 $APPLICATION->ThrowException(str_replace("#NAME#", $newNamespace, GetMessage("comp_util_err3")), "ERROR_NEW_NAMESPACE");
1162 return false;
1163 }
1164 }
1165
1166 if ($newName == '')
1167 $newName = false;
1168
1169 if ($newName !== false)
1170 {
1171 if (!preg_match("#^([a-z0-9_-]+\\.)*([a-z0-9_-]+)$#i", $newName))
1172 {
1173 $APPLICATION->ThrowException(str_replace("#NAME#", $newName, GetMessage("comp_util_err4")), "ERROR_NEW_NAME");
1174 return false;
1175 }
1176 }
1177
1178 $namespace = "";
1180 if (($pos = mb_strpos($componentName, ":")) !== false)
1181 {
1182 $namespace = mb_substr($componentName, 0, $pos);
1183 $name = mb_substr($componentName, $pos + 1);
1184 }
1185
1186 if ($namespace == $newNamespace
1187 && ($newName === false || $name == $newName))
1188 {
1189 $APPLICATION->ThrowException(GetMessage("comp_util_err5"), "ERROR_DUPL1");
1190 return false;
1191 }
1192
1193 if ($newName !== false)
1194 $componentNameNew = $newNamespace.":".$newName;
1195 else
1196 $componentNameNew = $newNamespace.":".$name;
1197
1198 $path2CompNew = CComponentEngine::MakeComponentPath($componentNameNew);
1199 if ($path2CompNew == '')
1200 {
1201 $APPLICATION->ThrowException(str_replace("#NAME#", $componentNameNew, GetMessage("comp_util_err2")), "ERROR_NOT_COMPONENT");
1202 return false;
1203 }
1204
1205 $componentPathNew = getLocalPath("components".$path2CompNew);
1206
1207 if (file_exists($_SERVER["DOCUMENT_ROOT"].$componentPathNew))
1208 {
1209 if (!$bRewrite)
1210 {
1211 $APPLICATION->ThrowException(str_replace("#NAME#", $componentNameNew, GetMessage("comp_util_err6")), "ERROR_EXISTS");
1212 return false;
1213 }
1214 else
1215 {
1216 DeleteDirFilesEx($componentPathNew);
1217 }
1218 }
1219
1220 CheckDirPath($_SERVER["DOCUMENT_ROOT"].$componentPathNew);
1221
1222 CopyDirFiles($_SERVER["DOCUMENT_ROOT"].$componentPath, $_SERVER["DOCUMENT_ROOT"].$componentPathNew, true, true, false);
1223
1224 return null;
1225 }
1226
1227 public static function CopyTemplate($componentName, $templateName, $siteTemplate, $newSiteTemplate, $newName = false, $bRewrite = false)
1228 {
1229 global $APPLICATION;
1230
1232 if ($componentName == '')
1233 {
1234 $APPLICATION->ThrowException(GetMessage("comp_util_err1"), "EMPTY_COMPONENT_NAME");
1235 return false;
1236 }
1237
1238 $path2Comp = CComponentEngine::MakeComponentPath($componentName);
1239 if ($path2Comp == '')
1240 {
1241 $APPLICATION->ThrowException(str_replace("#NAME#", $componentName, GetMessage("comp_util_err2")), "ERROR_NOT_COMPONENT");
1242 return false;
1243 }
1244
1245 $componentPath = getLocalPath("components".$path2Comp);
1246
1248 {
1249 $APPLICATION->ThrowException(str_replace("#NAME#", $componentName, GetMessage("comp_util_err2")), "ERROR_NOT_COMPONENT");
1250 return false;
1251 }
1252
1253 if ($templateName == '')
1254 $templateName = ".default";
1255
1256 if (preg_match("#[^a-z0-9_.-]#i", $templateName))
1257 {
1258 $APPLICATION->ThrowException(str_replace("#NAME#", $templateName, GetMessage("comp_util_err7")), "ERROR_BAD_TEMPLATE_NAME");
1259 return false;
1260 }
1261
1262 if ($siteTemplate == '')
1263 $siteTemplate = false;
1264
1265 if ($siteTemplate != false)
1266 {
1267 $siteTemplateDir = getLocalPath("templates/".$siteTemplate, BX_PERSONAL_ROOT);
1268 if ($siteTemplateDir === false || !is_dir($_SERVER["DOCUMENT_ROOT"].$siteTemplateDir))
1269 {
1270 $APPLICATION->ThrowException(str_replace("#NAME#", $siteTemplate, GetMessage("comp_util_err8")), "ERROR_NO_SITE_TEMPL");
1271 return false;
1272 }
1273 }
1274
1275 if ($siteTemplate != false)
1276 $path = getLocalPath("templates/".$siteTemplate."/components".$path2Comp."/".$templateName, BX_PERSONAL_ROOT);
1277 else
1278 $path = getLocalPath("components".$path2Comp."/templates/".$templateName);
1279
1280 if ($path === false || !file_exists($_SERVER["DOCUMENT_ROOT"].$path))
1281 {
1282 $APPLICATION->ThrowException(str_replace("#C_NAME#", $componentName, str_replace("#T_NAME#", $templateName, GetMessage("comp_util_err9"))), "ERROR_NO_TEMPL");
1283 return false;
1284 }
1285
1286 if ($newSiteTemplate == '')
1287 {
1288 $APPLICATION->ThrowException(GetMessage("comp_util_err10"), "ERROR_EMPTY_SITE_TEMPL");
1289 return false;
1290 }
1291
1292 $newSiteTemplateDir = getLocalPath("templates/".$newSiteTemplate, BX_PERSONAL_ROOT);
1293 if ($newSiteTemplateDir === false || !is_dir($_SERVER["DOCUMENT_ROOT"].$newSiteTemplateDir))
1294 {
1295 $APPLICATION->ThrowException(str_replace("#NAME#", $newSiteTemplate, GetMessage("comp_util_err8")), "ERROR_NO_SITE_TEMPL");
1296 return false;
1297 }
1298
1299 if ($siteTemplate !== false
1300 && $siteTemplate == $newSiteTemplate
1301 && ($newName === false || $templateName == $newName))
1302 {
1303 $APPLICATION->ThrowException(GetMessage("comp_util_err11"), "ERROR_DUPL1");
1304 return false;
1305 }
1306
1307 if ($newName !== false)
1308 $templateNameNew = $newName;
1309 else
1310 $templateNameNew = $templateName;
1311
1312 if (preg_match("#[^a-z0-9_.-]#i", $templateNameNew))
1313 {
1314 $APPLICATION->ThrowException(str_replace("#NAME#", $templateNameNew, GetMessage("comp_util_err7")), "ERROR_BAD_TEMPLATE_NAME");
1315 return false;
1316 }
1317
1318 $pathNew = $newSiteTemplateDir."/components".$path2Comp."/".$templateNameNew;
1319
1320 if (file_exists($_SERVER["DOCUMENT_ROOT"].$pathNew))
1321 {
1322 if (!$bRewrite)
1323 {
1324 $APPLICATION->ThrowException(str_replace("#NAME#", $templateNameNew, GetMessage("comp_util_err12")), "ERROR_EXISTS");
1325 return false;
1326 }
1327 else
1328 {
1329 DeleteDirFilesEx($pathNew);
1330 }
1331 }
1332
1333 CopyDirFiles($_SERVER["DOCUMENT_ROOT"].$path, $_SERVER["DOCUMENT_ROOT"].$pathNew, true, true, false);
1334
1335 return true;
1336 }
1337
1338 public static function CheckComponentName($name, $arFilter)
1339 {
1340 foreach ($arFilter as $pattern)
1341 if (preg_match($pattern, $name))
1342 return true;
1343 return false;
1344 }
1345
1346 public static function GetDefaultNameTemplates()
1347 {
1348 return array(
1349 '#LAST_NAME# #NAME#' => GetMessage('COMP_NAME_TEMPLATE_SMITH_JOHN'),
1350 '#LAST_NAME# #NAME# #SECOND_NAME#' => GetMessage('COMP_NAME_TEMPLATE_SMITH_JOHN_LLOYD'),
1351 '#LAST_NAME#, #NAME# #SECOND_NAME#' => GetMessage('COMP_NAME_TEMPLATE_SMITH_COMMA_JOHN_LLOYD'),
1352 '#NAME# #SECOND_NAME# #LAST_NAME#' => GetMessage('COMP_NAME_TEMPLATE_JOHN_LLOYD_SMITH'),
1353 '#NAME_SHORT# #SECOND_NAME_SHORT# #LAST_NAME#' => GetMessage('COMP_NAME_TEMPLATE_J_L_SMITH'),
1354 '#NAME_SHORT# #LAST_NAME#' => GetMessage('COMP_NAME_TEMPLATE_J_SMITH'),
1355 '#LAST_NAME# #NAME_SHORT#' => GetMessage('COMP_NAME_TEMPLATE_SMITH_J'),
1356 '#LAST_NAME# #NAME_SHORT# #SECOND_NAME_SHORT#' => GetMessage('COMP_NAME_TEMPLATE_SMITH_J_L'),
1357 '#LAST_NAME#, #NAME_SHORT#' => GetMessage('COMP_NAME_TEMPLATE_SMITH_COMMA_J'),
1358 '#LAST_NAME#, #NAME_SHORT# #SECOND_NAME_SHORT#' => GetMessage('COMP_NAME_TEMPLATE_SMITH_COMMA_J_L'),
1359 '#NAME# #LAST_NAME#' => GetMessage('COMP_NAME_TEMPLATE_JOHN_SMITH'),
1360 '#NAME# #SECOND_NAME_SHORT# #LAST_NAME#' => GetMessage('COMP_NAME_TEMPLATE_JOHN_L_SMITH'),
1361 '' => GetMessage('COMP_PARAM_NAME_FORMAT_SITE')
1362 );
1363 }
1364
1365 public static function GetDateFormatField($name="", $parent="", $no_year = false)
1366 {
1367 $timestamp = mktime(0,0,0,2,6,2010);
1368 return array(
1369 "PARENT" => $parent,
1370 "NAME" => $name,
1371 "TYPE" => "LIST",
1372 "VALUES" => $no_year ?
1373 array(
1374 "d-m" => FormatDate("d-m", $timestamp),//"22-02",
1375 "m-d" => FormatDate("m-d", $timestamp),//"02-22",
1376 "d.m" => FormatDate("d.m", $timestamp),//"22.02",
1377 "d.M" => FormatDate("d.M", $timestamp),//"22.Feb",
1378 "m.d" => FormatDate("m.d", $timestamp),//"02.22",
1379 "j M" => FormatDate("j M", $timestamp),//"22 Feb",
1380 "M j" => FormatDate("M j", $timestamp),//"Feb 22",
1381 "j F" => FormatDate("j F", $timestamp),//"22 February",
1382 "f j" => FormatDate("f j", $timestamp),//"February 22"
1383 CComponentUtil::GetDateFormatDefault($no_year) => GetMessage('COMP_PARAM_DATE_FORMAT_SITE')
1384 ):
1385 array(
1386 "d-m-Y" => FormatDate("d-m-Y", $timestamp),//"22-02-2007",
1387 "m-d-Y" => FormatDate("m-d-Y", $timestamp),//"02-22-2007",
1388 "Y-m-d" => FormatDate("Y-m-d", $timestamp),//"2007-02-22",
1389 "d.m.Y" => FormatDate("d.m.Y", $timestamp),//"22.02.2007",
1390 "d.M.Y" => FormatDate("d.M.Y", $timestamp),//"22.Feb.2007",
1391 "m.d.Y" => FormatDate("m.d.Y", $timestamp),//"02.22.2007",
1392 "j M Y" => FormatDate("j M Y", $timestamp),//"22 Feb 2007",
1393 "M j, Y" => FormatDate("M j, Y", $timestamp),//"Feb 22, 2007",
1394 "j F Y" => FormatDate("j F Y", $timestamp),//"22 February 2007",
1395 "f j, Y" => FormatDate("f j, Y", $timestamp),//"February 22",
1396 "SHORT" => GetMessage('COMP_PARAM_DATE_FORMAT_SITE')
1397 ),
1398 "DEFAULT" => CComponentUtil::GetDateFormatDefault($no_year),
1399 "ADDITIONAL_VALUES" => "Y",
1400 );
1401 }
1402
1403 public static function GetDateFormatDefault($no_year = false)
1404 {
1405 global $DB;
1406
1407 return $DB->DateFormatToPHP($no_year ? preg_replace('/[\-\.\/]*[Y]{2,4}[\-\.\/]*/', '', CSite::GetDateFormat('SHORT')) : CSite::GetDateFormat("SHORT"));
1408 }
1409
1410 public static function GetDateTimeFormatField($name="", $parent="")
1411 {
1412 $timestamp = mktime(16,10,45,2,6,2010);
1413 return array(
1414 "PARENT" => $parent,
1415 "NAME" => $name,
1416 "TYPE" => "LIST",
1417 "VALUES" => array(
1418 "d-m-Y H:i:s" => FormatDate("d-m-Y H:i:s", $timestamp),//"22-02-2007 7:30",
1419 "m-d-Y H:i:s" => FormatDate("m-d-Y H:i:s", $timestamp),//"02-22-2007 7:30",
1420 "Y-m-d H:i:s" => FormatDate("Y-m-d H:i:s", $timestamp),//"2007-02-22 7:30",
1421 "d.m.Y H:i:s" => FormatDate("d.m.Y H:i:s", $timestamp),//"22.02.2007 7:30",
1422 "m.d.Y H:i:s" => FormatDate("m.d.Y H:i:s", $timestamp),//"02.22.2007 7:30",
1423 "j M Y H:i:s" => FormatDate("j M Y H:i:s", $timestamp),//"22 Feb 2007 7:30",
1424 "M j, Y H:i:s" => FormatDate("M j, Y H:i:s", $timestamp),//"Feb 22, 2007 7:30",
1425 "j F Y H:i:s" => FormatDate("j F Y H:i:s", $timestamp),//"22 February 2007 7:30",
1426 "f j, Y H:i:s" => FormatDate("f j, Y H:i:s", $timestamp),//"February 22, 2007",
1427 "d.m.y g:i:s A" => FormatDate("d.m.y g:i:s A", $timestamp),//"22.02.07 1:30 PM",
1428 "d.M.y g:i:s a" => FormatDate("d.M.y g:i:s a", $timestamp),//"22.Feb.07 1:30 pm",
1429 "d.M.Y g:i:s a" => FormatDate("d.M.Y g:i:s a", $timestamp),//"22.Feb.2007 1:30 pm",
1430 "d.m.y G:i" => FormatDate("d.m.y G:i", $timestamp),//"22.02.07 7:30",
1431 "j F Y G:i" => FormatDate("j F Y G:i", $timestamp),//"ZHL cool RUS",
1432 "j F Y g:i a" => FormatDate("j F Y g:i a", $timestamp),//"ZHL cool Burzh",
1433 "FULL" => GetMessage('COMP_PARAM_DATETIME_FORMAT_SITE')
1434 ),
1436 "ADDITIONAL_VALUES" => "Y",
1437 );
1438 }
1439
1440 public static function GetDateTimeFormatDefault()
1441 {
1442 global $DB;
1443
1444 return $DB->DateFormatToPHP(CSite::GetDateFormat("FULL"));
1445 }
1446
1447 public static function GetDateTimeFormatted($timestamp, $dateTimeFormat = false, $offset = 0, $hideToday = false)
1448 {
1449 if (is_array($timestamp))
1450 {
1451 $params = $timestamp;
1452 $timestamp = ($params['TIMESTAMP'] ?? false);
1453 $offset = (isset($params['TZ_OFFSET']) ? intval($params['TZ_OFFSET']) : 0);
1454 $hideToday = ($params['HIDE_TODAY'] ?? false);
1455 }
1456
1457 if (empty($timestamp))
1458 {
1459 return '';
1460 }
1461
1462 $culture = \Bitrix\Main\Context::getCurrent()->getCulture();
1463 $timeFormat = $culture->getShortTimeFormat();
1464 $dateTimeFormat = $culture->getLongDateFormat().' '.$timeFormat;
1465 $dateTimeFormatWOYear = $culture->getDayMonthFormat().' '.$timeFormat;
1466
1467 $arFormat = array(
1468 "tomorrow" => "tomorrow, ".$timeFormat,
1469 "today" => ($hideToday ? $timeFormat : "today, ".$timeFormat),
1470 "yesterday" => "yesterday, ".$timeFormat,
1471 "" => (
1472 date("Y", $timestamp) == date("Y")
1473 ? $dateTimeFormatWOYear
1474 : $dateTimeFormat
1475 )
1476 );
1477
1478 return FormatDate($arFormat, $timestamp, (time() + $offset));
1479 }
1480}
$path
Определения access_edit.php:21
global $APPLICATION
Определения include.php:80
static convertLangPath($langFile, $language)
Определения translation.php:267
static GetOptionString($module_id, $name, $def="", $site=false)
Определения pageoption.php:10
static GetInstance()
Определения virtual_io.php:60
static CheckComponentName($name, $arFilter)
Определения component_util.php:1338
static GetTemplateProps($componentName, $templateName, $siteTemplate="", $arCurrentValues=array())
Определения component_util.php:963
static GetComponentDescr($componentName)
Определения component_util.php:402
static __GroupParamsCompare($a, $b)
Определения component_util.php:445
static __SortComponentsTree(&$arTree)
Определения component_util.php:343
static GetDefaultNameTemplates()
Определения component_util.php:1346
static GetDateTimeFormatted($timestamp, $dateTimeFormat=false, $offset=0, $hideToday=false)
Определения component_util.php:1447
static __GetComponentsTree($filterNamespace=false, $arNameFilter=false, $arFilter=false)
Определения component_util.php:150
static isComponent($componentPath)
Определения component_util.php:130
static __TreeItemCompare($a, $b)
Определения component_util.php:322
static GetDateFormatDefault($no_year=false)
Определения component_util.php:1403
static GetTemplatesList($componentName, $currentTemplate=false)
Определения component_util.php:1024
static __ShowError($errorMessage)
Определения component_util.php:86
static GetComponentsTree($filterNamespace=false, $arNameFilter=false, $arFilter=false)
Определения component_util.php:355
static CopyTemplate($componentName, $templateName, $siteTemplate, $newSiteTemplate, $newName=false, $bRewrite=false)
Определения component_util.php:1227
static __IncludeLang($filePath, $fileName, $lang=false)
Определения component_util.php:13
static PrepareVariables(&$arData)
Определения component_util.php:37
static GetDateTimeFormatField($name="", $parent="")
Определения component_util.php:1410
static __BuildTree($arPath, &$arTree, &$arComponent, $level=1)
Определения component_util.php:92
static GetNamespaceList()
Определения component_util.php:367
static GetDateTimeFormatDefault()
Определения component_util.php:1440
static GetComponentProps($componentName, $arCurrentValues=array(), $templateProperties=array())
Определения component_util.php:461
static CopyComponent($componentName, $newNamespace, $newName=false, $bRewrite=false)
Определения component_util.php:1129
static __TreeFolderCompare($a, $b)
Определения component_util.php:312
static GetDateFormatField($name="", $parent="", $no_year=false)
Определения component_util.php:1365
if( $strWarning=="") if($strWarning=="") $componentPath
Определения component_props2.php:197
$componentName
Определения component_props2.php:49
$arComponentDescription
Определения component_props2.php:73
$arComponent
Определения component_props2.php:72
$arTemplate
Определения component_props.php:26
$arPath
Определения file_edit.php:72
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$handle
Определения include.php:55
while($arParentIBlockProperty=$dbParentIBlockProperty->Fetch()) $errorMessage
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
global $DB
Определения cron_frame.php:29
$io
Определения csv_new_run.php:98
if(!defined('SITE_ID')) $lang
Определения include.php:91
$culture
Определения include.php:61
CheckDirPath($path)
Определения tools.php:2707
FormatDate($format="", $timestamp=false, $now=false, ?string $languageId=null)
Определения tools.php:871
LangSubst($lang)
Определения tools.php:3854
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
DeleteDirFilesEx($path, $root=null)
Определения tools.php:2823
CopyDirFiles($path_from, $path_to, $ReWrite=true, $Recursive=false, $bDeleteAfterCopy=false, $strExclude="")
Определения tools.php:2732
GetMessage($name, $aReplace=null)
Определения tools.php:3397
getLocalPath($path, $baseFolder="/bitrix")
Определения tools.php:5092
_normalizePath($strPath)
Определения tools.php:3341
$name
Определения menu_edit.php:35
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$fileName
Определения quickway.php:305
if(empty($signedUserToken)) $key
Определения quickway.php:257
$i
Определения factura.php:643
</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
else $a
Определения template.php:137
if(!Loader::includeModule('sale')) $pattern
Определения index.php:20
$arTemplatesList
Определения template_copy.php:96
$arFilter
Определения user_search.php:106