1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
top_panel.php
См. документацию.
1<?php
12
13if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true)
14{
15 die();
16}
17
18use Bitrix\Main;
21
22IncludeModuleLangFile(__FILE__);
23
25{
26 //Check permissions functions
27 public static function IsCanCreatePage($currentDirPath, $documentRoot, $filemanExists)
28 {
29 global $USER;
30
32 if (
33 !$io->DirectoryExists($documentRoot.$currentDirPath)
34 || !$USER->CanDoFileOperation("fm_create_new_file", [SITE_ID, $currentDirPath])
35 )
36 {
37 return false;
38 }
39
40 if ($filemanExists)
41 {
42 return $USER->CanDoOperation("fileman_admin_files");
43 }
44
45 return true;
46 }
47
48 public static function IsCanCreateSection($currentDirPath, $documentRoot, $filemanExists)
49 {
50 global $USER;
51
53
54 if (
55 !$io->DirectoryExists($documentRoot.$currentDirPath) ||
56 !$USER->CanDoFileOperation("fm_create_new_folder", Array(SITE_ID, $currentDirPath)) ||
57 !$USER->CanDoFileOperation("fm_create_new_file", Array(SITE_ID, $currentDirPath))
58 )
59 {
60 return false;
61 }
62
63 if ($filemanExists)
64 {
65 return ($USER->CanDoOperation("fileman_admin_folders") && $USER->CanDoOperation("fileman_admin_files"));
66 }
67
68 return true;
69 }
70
71 public static function IsCanEditPage($currentFilePath, $documentRoot, $filemanExists)
72 {
73 global $USER;
74
76
77 if (
78 !$io->FileExists($documentRoot.$currentFilePath)
79 || !$USER->CanDoFileOperation("fm_edit_existent_file", [SITE_ID, $currentFilePath])
80 )
81 {
82 return false;
83 }
84
85 //need fm_lpa for every .php file, even with no php code inside
86 if (
87 in_array(GetFileExtension($currentFilePath), GetScriptFileExt())
88 && !$USER->CanDoFileOperation('fm_lpa', [SITE_ID, $currentFilePath])
89 && !$USER->CanDoOperation('edit_php')
90 )
91 {
92 return false;
93 }
94
95 if ($filemanExists)
96 {
97 return ($USER->CanDoOperation("fileman_admin_files") && $USER->CanDoOperation("fileman_edit_existent_files"));
98 }
99
100 return true;
101 }
102
103 public static function IsCanEditSection($currentDirPath, $filemanExists)
104 {
105 global $USER;
106
107 if (!$USER->CanDoFileOperation("fm_edit_existent_folder", [SITE_ID, $currentDirPath]))
108 {
109 return false;
110 }
111
112 if ($filemanExists)
113 {
114 return ($USER->CanDoOperation("fileman_edit_existent_folders") && $USER->CanDoOperation("fileman_admin_folders"));
115 }
116
117 return true;
118 }
119
120 public static function IsCanEditPermission($currentFilePath, $documentRoot, $filemanExists)
121 {
122 global $USER;
123
125
126 if (
127 !($io->FileExists($documentRoot.$currentFilePath) || $io->DirectoryExists($documentRoot.$currentFilePath))
128 || !$USER->CanDoFileOperation("fm_edit_existent_folder", [SITE_ID, $currentFilePath])
129 || !$USER->CanDoFileOperation("fm_edit_permission", [SITE_ID, $currentFilePath])
130 )
131 {
132 return false;
133 }
134
135 if ($filemanExists)
136 {
137 return ($USER->CanDoOperation("fileman_edit_existent_folders") && $USER->CanDoOperation("fileman_admin_folders"));
138 }
139
140 return true;
141 }
142
143 public static function IsCanDeletePage($currentFilePath, $documentRoot, $filemanExists)
144 {
145 global $USER;
146
148
149 if (
150 !$io->FileExists($documentRoot.$currentFilePath)
151 || !$USER->CanDoFileOperation("fm_delete_file", [SITE_ID, $currentFilePath])
152 )
153 {
154 return false;
155 }
156
157 if ($filemanExists)
158 {
159 return ($USER->CanDoOperation("fileman_admin_files"));
160 }
161
162 return true;
163 }
164
165 public static function GetStandardButtons()
166 {
167 global $USER, $APPLICATION, $DB;
168
169 if (isset($_SERVER["REAL_FILE_PATH"]) && $_SERVER["REAL_FILE_PATH"] != "")
170 {
171 $currentDirPath = dirname($_SERVER["REAL_FILE_PATH"]);
172 $currentFilePath = $_SERVER["REAL_FILE_PATH"];
173 }
174 else
175 {
176 $currentDirPath = $APPLICATION->GetCurDir();
177 $currentFilePath = $APPLICATION->GetCurPage(true);
178 }
179
180 if (self::isProtectedPath($currentFilePath))
181 {
182 return;
183 }
184
185 $encCurrentDirPath = urlencode($currentDirPath);
186 $encCurrentFilePath = urlencode($currentFilePath);
187 $encRequestUri = urlencode($_SERVER["REQUEST_URI"]);
188 $siteTemplateId = (defined('SITE_TEMPLATE_ID') ? SITE_TEMPLATE_ID : '.default');
189 $encSiteTemplateId = urlencode($siteTemplateId);
190
191 $documentRoot = CSite::GetSiteDocRoot(SITE_ID);
192 $filemanExists = IsModuleInstalled("fileman");
193
194 //create button
195 $defaultUrl = "";
196 $bCanCreatePage = CTopPanel::IsCanCreatePage($currentDirPath, $documentRoot, $filemanExists);
197 $bCanCreateSection = CTopPanel::IsCanCreateSection($currentDirPath, $documentRoot, $filemanExists);
198
199 if ($bCanCreatePage || $bCanCreateSection)
200 {
201 require_once($_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/admin_tools.php");
202 //create page from new template
203 $arActPageTemplates = CPageTemplate::GetList([$siteTemplateId]);
204 //create page from old template
205 $arPageTemplates = GetFileTemplates(SITE_ID, [$siteTemplateId]);
206 }
207
208 // CREATE PAGE button and submenu
209 $arMenu = [];
210 if ($bCanCreatePage)
211 {
212 $defaultUrl = $APPLICATION->GetPopupLink([
213 'URL' => "/bitrix/admin/public_file_new.php?lang=" . LANGUAGE_ID . "&site=" . SITE_ID
214 . "&templateID=".$encSiteTemplateId . "&path=" . $encCurrentDirPath . "&back_url="
215 . $encRequestUri,
216 'PARAMS' => ['min_width' => 450, 'min_height' => 250]
217 ]);
218
219 $arMenu[] = [
220 'TEXT' => Loc::getMessage('top_panel_create_page'),
221 'TITLE' => Loc::getMessage('top_panel_create_page_title'),
222 'ICON' => 'panel-new-file',
223 'ACTION' => $defaultUrl,
224 'DEFAULT' => true,
225 'SORT' => 10,
226 'HK_ID' => "top_panel_create_page"
227 ];
228
229 //templates menu for pages
230 $arSubmenu = [];
231 if (!empty($arActPageTemplates))
232 {
233 foreach ($arActPageTemplates as $pageTemplate)
234 {
235 if ($pageTemplate['type'] == '' || $pageTemplate['type'] == 'page')
236 {
237 $arSubmenu[] = [
238 "TEXT" => $pageTemplate['name'],
239 "TITLE" => Loc::getMessage("top_panel_template")." ".$pageTemplate['file'].($pageTemplate['description'] <> ''? "\n".$pageTemplate['description']:""),
240 "ICON" => ($pageTemplate['icon'] == ''? "panel-new-file-template":""),
241 "IMAGE" => ($pageTemplate['icon'] <> ''? $pageTemplate['icon']:""),
242 "ACTION" => str_replace("public_file_new.php?", "public_file_new.php?wiz_template=".urlencode($pageTemplate['file'])."&", $defaultUrl),
243 ];
244 }
245 }
246 }
247
248 if (!empty($arPageTemplates) && (!empty($arSubmenu) || count($arPageTemplates)>1))
249 {
250 foreach ($arPageTemplates as $pageTemplate)
251 {
252 $arSubmenu[] = [
253 "TEXT" => $pageTemplate['name'],
254 "TITLE" => Loc::getMessage("top_panel_template") . " " . $pageTemplate['file'],
255 "ICON" => "panel-new-file-template",
256 "ACTION" => str_replace("public_file_new.php?", "public_file_new.php?page_template=" . urlencode($pageTemplate['file']) . "&", $defaultUrl),
257 ];
258 }
259 }
260
261 //page from template
262 if (!empty($arSubmenu))
263 {
264 $arMenu[] = [
265 "TEXT" => Loc::getMessage("top_panel_create_from_template"),
266 "TITLE" => Loc::getMessage("top_panel_create_from_template_title"),
267 "ICON" => "panel-new-file-template",
268 "MENU" => $arSubmenu,
269 "SORT" => 20
270 ];
271 }
272 }
273
274 if (!empty($arMenu))
275 {
276 $APPLICATION->AddPanelButton([
277 "HREF" => ($defaultUrl == "" ? "" : "javascript:".$defaultUrl),
278 'TYPE' => 'BIG',
279 "ID" => "create",
280 "ICON" => "bx-panel-create-page-icon",
281 "ALT" => Loc::getMessage("top_panel_create_title"),
282 "TEXT" => Loc::getMessage("top_panel_create_new"),
283 "MAIN_SORT" => "100",
284 "SORT" => 10,
285 "MENU" => $arMenu,
286 "RESORT_MENU" => true,
287 "HK_ID" => "top_panel_create_new",
288 "HINT" => [
289 "TITLE" => Loc::getMessage("top_panel_create_new_tooltip_title"),
290 "TEXT" => Loc::getMessage("top_panel_create_new_tooltip")
291 ],
292 "HINT_MENU" => [
293 "TITLE" => Loc::getMessage("top_panel_create_new_menu_tooltip_title"),
294 "TEXT" => Loc::getMessage("top_panel_create_new_menu_tooltip")
295 ]
296 ]);
297 }
298
299 // CREATE SECTION button and submenu
300 $arMenu = [];
301 if ($bCanCreateSection)
302 {
303 $defaultUrl = $APPLICATION->GetPopupLink([
304 "URL" => "/bitrix/admin/public_file_new.php?lang=" . LANGUAGE_ID . "&site=" . SITE_ID . "&templateID="
305 . $encSiteTemplateId . "&newFolder=Y&path=" . $encCurrentDirPath . "&back_url=" . $encRequestUri,
306 "PARAMS" => ["min_width" => 450, "min_height" => 250]
307 ]);
308
309 $arMenu[] = [
310 "TEXT" => Loc::getMessage("top_panel_create_folder"),
311 "TITLE" => Loc::getMessage("top_panel_create_folder_title"),
312 "ICON" => "panel-new-folder",
313 'DEFAULT' => true,
314 "ACTION" => $defaultUrl,
315 "SORT" => 10,
316 "HK_ID" => "top_panel_create_folder",
317 ];
318
319 //templates menu for sections
320 $arSectSubmenu = [];
321 if (!empty($arActPageTemplates))
322 {
323 foreach ($arActPageTemplates as $pageTemplate)
324 {
325 if ($pageTemplate['type'] == '' || $pageTemplate['type'] == 'section')
326 {
327 $arSectSubmenu[] = [
328 "TEXT" => $pageTemplate['name'],
329 "TITLE" => Loc::getMessage("top_panel_template") . " " . $pageTemplate['file'] . ($pageTemplate['description'] <> '' ? "\n" . $pageTemplate['description'] : ""),
330 "ICON" => ($pageTemplate['icon'] == '' ? "panel-new-file-template" : ""),
331 "IMAGE" => ($pageTemplate['icon'] <> '' ? $pageTemplate['icon'] : ""),
332 "ACTION" => str_replace("public_file_new.php?", "public_file_new.php?newFolder=Y&wiz_template=".urlencode($pageTemplate['file'])."&", $defaultUrl),
333 ];
334 }
335 }
336 }
337
338 if (!empty($arPageTemplates) && (!empty($arSectSubmenu) || count($arPageTemplates)>1))
339 {
340 if (!empty($arSectSubmenu))
341 {
342 $arSectSubmenu[] = ["SEPARATOR" => true];
343 }
344
345 foreach ($arPageTemplates as $pageTemplate)
346 {
347 $arSectSubmenu[] = [
348 "TEXT" => $pageTemplate['name'],
349 "TITLE" => Loc::getMessage("top_panel_template")." ".$pageTemplate['file'],
350 "ICON" => "panel-new-file-template",
351 "ACTION" => str_replace("public_file_new.php?", "public_file_new.php?newFolder=Y&page_template=".urlencode($pageTemplate['file'])."&", $defaultUrl),
352 ];
353 }
354 }
355
356 //section from template
357 if (!empty($arSectSubmenu))
358 {
359 $arMenu[] = [
360 "TEXT" => Loc::getMessage("top_panel_create_folder_template"),
361 "TITLE" => Loc::getMessage("top_panel_create_folder_template_title"),
362 "ICON" => "panel-new-folder-template",
363 "MENU" => $arSectSubmenu,
364 "SORT" => 20,
365 ];
366 }
367 }
368
369 if (!empty($arMenu))
370 {
371 $APPLICATION->AddPanelButton([
372 "HREF" => ($defaultUrl == "" ? "" : "javascript:".$defaultUrl),
373 'TYPE' => 'BIG',
374 "ID" => "create_section",
375 "ICON" => "bx-panel-create-section-icon",
376 "ALT" => Loc::getMessage("top_panel_create_title"),
377 "TEXT" => Loc::getMessage("top_panel_create_folder_new"),
378 "MAIN_SORT" => "100",
379 "SORT" => 20,
380 "MENU" => $arMenu,
381 "RESORT_MENU" => true,
382 "HK_ID" => "top_panel_create_folder_new",
383 "HINT" => [
384 "TITLE" => Loc::getMessage("top_panel_create_folder_new_tooltip_title"),
385 "TEXT" => Loc::getMessage("top_panel_create_folder_new_tooltip")
386 ],
387 "HINT_MENU" => [
388 "TITLE" => Loc::getMessage("top_panel_create_folder_new_menu_tooltip_title"),
389 "TEXT" => Loc::getMessage("top_panel_create_folder_new_menu_tooltip")
390 ]
391 ]);
392 }
393
394 // EDIT PAGE button and submenu
395 $defaultUrl = "";
396 $arMenu = [];
397 if (CTopPanel::IsCanEditPage($currentFilePath, $documentRoot, $filemanExists))
398 {
399 $defaultUrl = $APPLICATION->GetPopupLink([
400 "URL" => "/bitrix/admin/public_file_edit.php?lang=" . LANGUAGE_ID . "&path=" . $encCurrentFilePath . "&site=" . SITE_ID . "&back_url=" . $encRequestUri . "&templateID=" . $encSiteTemplateId,
401 "PARAMS" => [
402 "width" => 780,
403 "height" => 470,
404 "resizable" => true,
405 "min_width" => 780,
406 "min_height" => 400,
407 'dialog_type' => 'EDITOR'
408 ],
409 ]);
410
411 $arMenu[] = [
412 "TEXT" => Loc::getMessage("top_panel_edit_page"),
413 "TITLE" => Loc::getMessage("top_panel_edit_page_title"),
414 "ICON" => "panel-edit-visual",
415 "ACTION" => $defaultUrl,
416 "DEFAULT" => true,
417 "SORT" => 10,
418 "HK_ID" => "top_panel_edit_page",
419 ];
420
421 $arMenu[] = [
422 "TEXT" => Loc::getMessage("top_panel_page_prop"),
423 "TITLE" => Loc::getMessage("top_panel_page_prop_title"),
424 "ICON" => "panel-file-props",
425 "ACTION" => $APPLICATION->GetPopupLink([
426 "URL" => "/bitrix/admin/public_file_property.php?lang=" . LANGUAGE_ID . "&site=" . SITE_ID . "&path=" . $encCurrentFilePath . "&back_url=" . $encRequestUri,
427 "PARAMS" => ["min_width"=>450, "min_height" => 250]
428 ]),
429 "SORT" => 20,
430 "HK_ID"=>"top_panel_page_prop"
431 ];
432
433 $arMenu[] = ["SEPARATOR" => true, "SORT"=>49];
434 $arMenu[] = [
435 "TEXT" => Loc::getMessage("top_panel_edit_page_html"),
436 "TITLE" => Loc::getMessage("top_panel_edit_page_html_title"),
437 "ICON" => "panel-edit-text",
438 "ACTION" => $APPLICATION->GetPopupLink([
439 "URL" => "/bitrix/admin/public_file_edit.php?lang=" . LANGUAGE_ID . "&noeditor=Y&path=" . $encCurrentFilePath . "&site=" . SITE_ID . "&back_url=" . $encRequestUri,
440 "PARAMS" => ["width" => 780, "height" => 470, 'dialog_type' => 'EDITOR', "min_width" => 700, "min_height" => 400]
441 ]),
442 "SORT" => 50,
443 "HK_ID"=>"top_panel_edit_page_html",
444 ];
445
446 if ($USER->CanDoOperation("edit_php"))
447 {
448 $arMenu[] = [
449 "TEXT" => Loc::getMessage("top_panel_edit_page_php"),
450 "TITLE" => Loc::getMessage("top_panel_edit_page_php_title"),
451 "ICON" => "panel-edit-php",
452 "ACTION" => $APPLICATION->GetPopupLink([
453 "URL" => "/bitrix/admin/public_file_edit_src.php?lang=" . LANGUAGE_ID . "&path=" . $encCurrentFilePath . "&site=" . SITE_ID . "&back_url=" . $encRequestUri . "&templateID=" . $encSiteTemplateId,
454 "PARAMS" => ["width" => 770, "height" => 470, 'dialog_type' => 'EDITOR', "min_width" => 700, "min_height" => 400]
455 ]),
456 "SORT" => 60,
457 "HK_ID" => "top_panel_edit_page_php",
458 ];
459 }
460 }
461
462 $bNeedSep = false;
463 if (CTopPanel::IsCanEditPermission($currentFilePath, $documentRoot, $filemanExists))
464 {
465 $bNeedSep = true;
466 //access button
467 $arMenu[] = [
468 "TEXT" => Loc::getMessage("top_panel_access_page_new"),
469 "TITLE" => Loc::getMessage("top_panel_access_page_title"),
470 "ICON" => "panel-file-access",
471 "ACTION" => $APPLICATION->GetPopupLink([
472 "URL" => "/bitrix/admin/public_access_edit.php?lang=" . LANGUAGE_ID . "&site=" . SITE_ID . "&path=" . $encCurrentFilePath . "&back_url=" . $encRequestUri,
473 "PARAMS" => ["min_width" => 450, "min_height" => 250]
474 ]),
475 "SORT" => 30,
476 "HK_ID" => "top_panel_access_page_new"
477 ];
478 }
479
480 //delete button
481 if (CTopPanel::IsCanDeletePage($currentFilePath, $documentRoot, $filemanExists))
482 {
483 $bNeedSep = true;
484 $arMenu[] = [
485 "ID" => "delete",
486 "ICON" => "icon-delete",
487 "ALT" => Loc::getMessage("top_panel_del_page"),
488 "TEXT" => Loc::getMessage("top_panel_del_page"),
489 "ACTION" => $APPLICATION->GetPopupLink([
490 "URL" => "/bitrix/admin/public_file_delete.php?lang=" . LANGUAGE_ID . "&site=" . SITE_ID . "&path=" . $encCurrentFilePath,
491 "PARAMS" => [
492 "min_width" => 250,
493 "min_height" => 180,
494 'height' => 180,
495 'width' => 440
496 ]
497 ]),
498 "SORT" => 40,
499 "HK_ID" => "top_panel_del_page"
500 ];
501 }
502
503 if ($bNeedSep)
504 {
505 $arMenu[] = ["SEPARATOR" => true, "SORT" => 29];
506 }
507
508 if (!empty($arMenu))
509 {
510 //check anonymous access
511 $arOperations = CUser::GetFileOperations([SITE_ID, $currentFilePath], [2]);
512 $bAllowAnonymous = in_array("fm_view_file", $arOperations);
513
514 $APPLICATION->AddPanelButton([
515 "HREF" => ($defaultUrl == "" ? "" : "javascript:".$defaultUrl),
516 "TYPE" => "BIG",
517 "ID" => "edit",
518 "ICON" => ($bAllowAnonymous ? "bx-panel-edit-page-icon" : "bx-panel-edit-secret-page-icon"),
519 "ALT" => Loc::getMessage("top_panel_edit_title"),
520 "TEXT" => Loc::getMessage("top_panel_edit_new"),
521 "MAIN_SORT" => "200",
522 "SORT" => 10,
523 "MENU" => $arMenu,
524 "HK_ID" => "top_panel_edit_new",
525 "RESORT_MENU" => true,
526 "HINT" => [
527 "TITLE" => Loc::getMessage("top_panel_edit_new_tooltip_title"),
528 "TEXT" => Loc::getMessage("top_panel_edit_new_tooltip")
529 ],
530 "HINT_MENU" => [
531 "TITLE" => Loc::getMessage("top_panel_edit_new_menu_tooltip_title"),
532 "TEXT" => Loc::getMessage("top_panel_edit_new_menu_tooltip")
533 ]
534 ]);
535 }
536
537 // EDIT SECTION button
538 $arMenu = [];
539 if (CTopPanel::IsCanEditSection($currentDirPath, $filemanExists))
540 {
541 $defaultUrl = 'javascript:'.$APPLICATION->GetPopupLink([
542 "URL" => "/bitrix/admin/public_folder_edit.php?lang=" . LANGUAGE_ID . "&site=" . SITE_ID . "&path=" . urlencode($APPLICATION->GetCurDir()) . "&back_url=" . $encRequestUri,
543 "PARAMS" => ["min_width" => 450, "min_height" => 250]
544 ]);
545
546 $arMenu[] = [
547 "TEXT" => Loc::getMessage("top_panel_folder_prop"),
548 "TITLE" => Loc::getMessage("top_panel_folder_prop_title"),
549 "ICON" => "panel-folder-props",
550 "DEFAULT" => true,
551 "ACTION" => $defaultUrl,
552 "SORT" => 10,
553 "HK_ID" => "top_panel_folder_prop",
554 ];
555 }
556
557 if (CTopPanel::IsCanEditPermission($currentDirPath, $documentRoot, $filemanExists))
558 {
559 $arMenu[] = [
560 "TEXT" => Loc::getMessage("top_panel_access_folder_new"),
561 "TITLE" => Loc::getMessage("top_panel_access_folder_title"),
562 "ICON" => "panel-folder-access",
563 "ACTION" => $APPLICATION->GetPopupLink([
564 "URL" => "/bitrix/admin/public_access_edit.php?lang=" . LANGUAGE_ID . "&site=" . SITE_ID . "&path=" . $encCurrentDirPath . "&back_url=" . $encRequestUri,
565 "PARAMS" => ["min_width"=>450, "min_height" => 250]
566 ]),
567 "SORT" => 30,
568 "HK_ID" => "top_panel_access_folder_new",
569 ];
570 }
571
572 if (!empty($arMenu))
573 {
574 //check anonymous access
575 $arOperations = CUser::GetFileOperations([SITE_ID, $currentDirPath], [2]);
576 $bAllowAnonymous = in_array("fm_view_listing", $arOperations);
577
578 $APPLICATION->AddPanelButton([
579 "HREF" => $defaultUrl,
580 "ID" => 'edit_section',
581 "TYPE" => "BIG",
582 "TEXT" => Loc::getMessage("top_panel_folder_prop_new"),
583 "TITLE" => Loc::getMessage("top_panel_folder_prop_title"),
584 "ICON" => ($bAllowAnonymous ? "bx-panel-edit-section-icon" : "bx-panel-edit-secret-section-icon"),
585 "MAIN_SORT" => "200",
586 "SORT" => 20,
587 "MENU" => $arMenu,
588 "HK_ID" => "top_panel_folder_prop_new",
589 "RESORT_MENU" => true,
590 "HINT" => [
591 "TITLE" => Loc::getMessage("top_panel_folder_prop_new_tooltip_title"),
592 "TEXT" => Loc::getMessage("top_panel_folder_prop_new_tooltip")
593 ],
594 "HINT_MENU" => [
595 "TITLE" => Loc::getMessage("top_panel_folder_prop_new_menu_tooltip_title"),
596 "TEXT" => Loc::getMessage("top_panel_folder_prop_new_menu_tooltip")
597 ]
598 ]);
599 }
600
601 // STRUCTURE button and submenu
602 if ($USER->CanDoOperation('fileman_view_file_structure') && $USER->CanDoFileOperation('fm_edit_existent_folder', [SITE_ID, "/"]))
603 {
604 $defaultUrl = $APPLICATION->GetPopupLink([
605 "URL" => "/bitrix/admin/public_structure.php?lang=" . LANGUAGE_ID . "&site=" . SITE_ID . "&path=" . $encCurrentFilePath . "&templateID=" . $encSiteTemplateId,
606 "PARAMS" => ["width" => 350, "height" => 470, "resize" => true]
607 ]);
608
609 $arMenu = [];
610 if ($filemanExists)
611 {
612 $arMenu[] = [
613 "TEXT" => Loc::getMessage("main_top_panel_struct"),
614 "TITLE"=> Loc::getMessage("main_top_panel_struct_title"),
615 "ACTION" => $defaultUrl,
616 "DEFAULT" => true,
617 "HK_ID" => "main_top_panel_struct",
618 ];
619 $arMenu[] = ['SEPARATOR' => true];
620 $arMenu[] = [
621 "TEXT" => Loc::getMessage("main_top_panel_struct_panel"),
622 "TITLE" => Loc::getMessage("main_top_panel_struct_panel_title"),
623 "ACTION" => "jsUtils.Redirect([], '" . CUtil::JSEscape("/bitrix/admin/fileman_admin.php?lang=" . LANGUAGE_ID . "&site=" . SITE_ID . "&path=" . urlencode($APPLICATION->GetCurDir())) . "')",
624 "HK_ID" => "main_top_panel_struct_panel",
625 ];
626 }
627
628 $APPLICATION->AddPanelButton([
629 "HREF" => "javascript:" . $defaultUrl,
630 "ID" => "structure",
631 "ICON" => "bx-panel-site-structure-icon",
632 "ALT" => Loc::getMessage("main_top_panel_struct_title"),
633 "TEXT" => Loc::getMessage("main_top_panel_structure"),
634 "MAIN_SORT" => "300",
635 "SORT" => 30,
636 "MENU" => $arMenu,
637 "HK_ID" => "main_top_panel_structure",
638 "HINT" => [
639 "TITLE" => Loc::getMessage("main_top_panel_structure_tooltip_title"),
640 "TEXT" => Loc::getMessage("main_top_panel_structure_tooltip")
641 ],
642 ]);
643 }
644
645 //cache button
646 if ($USER->CanDoOperation("cache_control"))
647 {
648 //recreate cache on the current page
649 $arMenu = [[
650 "TEXT" => Loc::getMessage("top_panel_cache_page"),
651 "TITLE" => Loc::getMessage("top_panel_cache_page_title"),
652 "ICON" => "panel-page-cache",
653 "ACTION" => "BX.clearCache()",
654 "DEFAULT" => true,
655 "HK_ID" => "top_panel_cache_page",
656 ]];
657
658 if (!empty($APPLICATION->aCachedComponents))
659 {
660 $arMenu[] = [
661 "TEXT" => Loc::getMessage("top_panel_cache_comp"),
662 "TITLE" => Loc::getMessage("top_panel_cache_comp_title"),
663 "ICON" => "panel-comp-cache",
664 "ACTION" => "jsComponentUtils.ClearCache('component_name=" . CUtil::addslashes(implode(",", $APPLICATION->aCachedComponents)) . "&site_id=" . SITE_ID . "&" . bitrix_sessid_get() . "');",
665 "HK_ID" => "top_panel_cache_comp",
666 ];
667 }
668 $arMenu[] = ["SEPARATOR" => true];
669
670 $sessionClearCache = (isset(\Bitrix\Main\Application::getInstance()->getKernelSession()["SESS_CLEAR_CACHE"]) && \Bitrix\Main\Application::getInstance()->getSession()["SESS_CLEAR_CACHE"] == "Y");
671 $arMenu[] = [
672 "TEXT" => Loc::getMessage("top_panel_cache_not"),
673 "TITLE" => Loc::getMessage("top_panel_cache_not_title"),
674 "CHECKED" => $sessionClearCache,
675 "ACTION" => "jsUtils.Redirect([], '" . CUtil::addslashes($APPLICATION->GetCurPageParam("clear_cache_session=" . ($sessionClearCache ? "N" : "Y"), ["clear_cache_session"])) . "');",
676 "HK_ID" => "top_panel_cache_not",
677 ];
678
679 $APPLICATION->AddPanelButton([
680 "HREF" => "javascript:BX.clearCache()",
681 "TYPE" => "BIG",
682 "ICON" => "bx-panel-clear-cache-icon",
683 "TEXT" => Loc::getMessage("top_panel_cache_new"),
684 "ALT" => Loc::getMessage("top_panel_clear_cache"),
685 "MAIN_SORT" => "400",
686 "SORT" => 10,
687 "MENU" => $arMenu,
688 "HK_ID" => "top_panel_clear_cache",
689 "HINT" => [
690 "TITLE" => Loc::getMessage("top_panel_cache_new_tooltip_title"),
691 "TEXT" => Loc::getMessage("top_panel_cache_new_tooltip")
692 ],
693 "HINT_MENU" => [
694 "TITLE" => Loc::getMessage("top_panel_cache_new_menu_tooltip_title"),
695 "TEXT" => Loc::getMessage("top_panel_cache_new_menu_tooltip")
696 ],
697 ]);
698 }
699
700 $bHideComponentsMenu = false;
701 if ($USER->CanDoOperation('edit_php') || !empty($APPLICATION->arPanelFutureButtons['components']))
702 {
703 if (empty($APPLICATION->arPanelFutureButtons['components']))
704 {
705 if ($APPLICATION->GetShowIncludeAreas() != 'Y')
706 {
707 $APPLICATION->AddPanelButtonMenu('components',
708 [
709 "TEXT" => Loc::getMessage("top_panel_edit_mode"),
710 "TITLE" => Loc::getMessage("top_panel_edit_mode_title"),
711 "ACTION" => "jsUtils.Redirect([], BX('bx-panel-toggle').href);",
712 "HK_ID" => "top_panel_edit_mode",
713 ]
714 );
715 }
716 else
717 {
718 $bHideComponentsMenu = true;
719 }
720 }
721
722 if ($bHideComponentsMenu)
723 {
724 $APPLICATION->AddPanelButton([
725 "ID" => "components_empty",
726 "HREF" => "javascript:void(0)",
727 "ICON" => "bx-panel-components-icon",
728 "TEXT" => Loc::getMessage("top_panel_comp"),
729 "MAIN_SORT" => "500",
730 "SORT" => 10,
731 "HINT" => [
732 "TITLE" => Loc::getMessage("top_panel_comp_tooltip_title"),
733 "TEXT" => Loc::getMessage('top_panel_comp_tooltip_empty')
734 ],
735 ]);
736 }
737 else
738 {
739 $APPLICATION->AddPanelButton([
740 "ID" => "components",
741 "ICON" => "bx-panel-components-icon",
742 "TEXT" => Loc::getMessage("top_panel_comp"),
743 "MAIN_SORT" => "500",
744 "SORT" => 10,
745 "HINT" => [
746 "TITLE" => Loc::getMessage("top_panel_comp_tooltip_title"),
747 "TEXT" => Loc::getMessage("top_panel_comp_tooltip")
748 ],
749 ]);
750 }
751 }
752
753 //TEMPLATE button and submenu
754 if ($USER->CanDoOperation("edit_php") || $USER->CanDoOperation("lpa_template_edit"))
755 {
756 $arMenu = [];
757 $bUseSubmenu = false;
758 $defaultUrl = '';
759
760 if ($USER->CanDoOperation("edit_php"))
761 {
762 $siteTemplatePath = (defined('SITE_TEMPLATE_PATH') ? SITE_TEMPLATE_PATH : '/bitrix/templates/.default');
763 $filePath = $siteTemplatePath . "/styles.css";
764
765 if (file_exists($_SERVER['DOCUMENT_ROOT'] . $filePath))
766 {
767 $arMenu[] = [
768 "TEXT" => Loc::getMessage("top_panel_templ_site_css"),
769 "TITLE" => Loc::getMessage("top_panel_templ_site_css_title"),
770 "ICON" => "panel-edit-text",
771 "HK_ID" => "top_panel_templ_site_css",
772 "ACTION"=> $APPLICATION->GetPopupLink([
773 "URL" => "/bitrix/admin/public_file_edit_src.php?lang=" . LANGUAGE_ID . "&path=" . urlencode($filePath) . "&site=" . SITE_ID . "&back_url=" . $encRequestUri,
774 "PARAMS" => [
775 "width" => 770,
776 'height' => 470,
777 'resize' => true,
778 'dialog_type' => 'EDITOR',
779 "min_width" => 700,
780 "min_height" => 400
781 ]
782 ]),
783 ];
784 $bUseSubmenu = true;
785 }
786
787 $filePath = $siteTemplatePath . "/template_styles.css";
788 if (file_exists($_SERVER['DOCUMENT_ROOT'] . $filePath))
789 {
790 $arMenu[] = [
791 "TEXT" => Loc::getMessage("top_panel_templ_templ_css"),
792 "TITLE" => Loc::getMessage("top_panel_templ_templ_css_title"),
793 "ICON" => "panel-edit-text",
794 "HK_ID" => "top_panel_templ_templ_css",
795 "ACTION" => $APPLICATION->GetPopupLink([
796 "URL" => "/bitrix/admin/public_file_edit_src.php?lang=".LANGUAGE_ID."&path=".urlencode($filePath)."&site=".SITE_ID."&back_url=".$encRequestUri,
797 "PARAMS" => [
798 "width" => 770,
799 'height' => 470,
800 'resize' => true,
801 'dialog_type' => 'EDITOR',
802 "min_width" => 700,
803 "min_height" => 400
804 ]
805 ]),
806 ];
807 $bUseSubmenu = true;
808 }
809 }
810
811 $arSubMenu = [
812 [
813 "TEXT" => Loc::getMessage("top_panel_templ_edit"),
814 "TITLE" =>Loc::getMessage("top_panel_templ_edit_title"),
815 "ICON" => "icon-edit",
816 "ACTION" => "jsUtils.Redirect([], '/bitrix/admin/template_edit.php?lang=" . LANGUAGE_ID . "&ID=" . $encSiteTemplateId . "')",
817 "DEFAULT" =>!$bUseSubmenu,
818 "HK_ID" =>"top_panel_templ_edit",
819 ],
820 [
821 "TEXT" => Loc::getMessage("top_panel_templ_site"),
822 "TITLE" => Loc::getMessage("top_panel_templ_site_title"),
823 "ICON" => "icon-edit",
824 "ACTION" => "jsUtils.Redirect([], '/bitrix/admin/site_edit.php?lang=".LANGUAGE_ID."&LID=".SITE_ID."')",
825 "DEFAULT" => false,
826 "HK_ID" =>"top_panel_templ_site",
827 ],
828 ];
829
830 if ($bUseSubmenu)
831 {
832 $arMenu[] = ['SEPARATOR' => "Y"];
833 $arMenu[] = ["TEXT" => Loc::getMessage("top_panel_cp"), "MENU" => $arSubMenu,];
834 }
835 else
836 {
837 $arMenu = $arSubMenu;
838 $defaultUrl = "javascript:" . $arSubMenu[0]['ACTION'];
839 }
840
841 $APPLICATION->AddPanelButton([
842 "HREF" => $defaultUrl,
843 "ICON" => "bx-panel-site-template-icon",
844 "ALT" => Loc::getMessage("top_panel_templ_title"),
845 "TEXT" => Loc::getMessage("top_panel_templ"),
846 "MAIN_SORT" => "500",
847 "SORT" => 30,
848 "MENU" => $arMenu,
849 "HK_ID"=>"top_panel_templ",
850 "HINT" => [
851 "TITLE" => Loc::getMessage("top_panel_templ_tooltip_title"),
852 "TEXT" => Loc::getMessage("top_panel_templ_tooltip")
853 ],
854 ]);
855 }
856
857 //statistics buttons
858 if ($USER->CanDoOperation("edit_php"))
859 {
860 //show debug information
861 $tmp = self::getDebugSettings();
862 $sessionShowIncludeTimeExec = $tmp['INCLUDE_TIME_EXEC'];
863 $sessionShowTimeExec = $tmp['TIME_EXEC'];
864 $cmd = $tmp['CMD'];
865 $url = $tmp['URL'];
866
867 $arMenu = [
868 [
869 "TEXT" => Loc::getMessage("top_panel_debug_summ"),
870 "TITLE" => Loc::getMessage("top_panel_debug_summ_title"),
871 "CHECKED" => ($cmd == "N"),
872 "ACTION" => "jsUtils.Redirect([], '" . CUtil::addslashes($url) . "');",
873 "DEFAULT" => true,
874 "HK_ID" => "top_panel_debug_summ",
875 ],
876 ["SEPARATOR" => true],
877 [
878 "TEXT" => Loc::getMessage("top_panel_debug_sql"),
879 "TITLE" => Loc::getMessage("top_panel_debug_sql_title"),
880 "CHECKED" => (!!$DB->ShowSqlStat),
881 "ACTION" => "jsUtils.Redirect([], '" . CUtil::addslashes($APPLICATION->GetCurPageParam("show_sql_stat=" . ($DB->ShowSqlStat? "N" : "Y"), ["show_sql_stat"])) . "');",
882 "HK_ID" => "top_panel_debug_sql",
883 ],
884 [
885 "TEXT" => Loc::getMessage("top_panel_debug_cache"),
886 "TITLE" => Loc::getMessage("top_panel_debug_cache_title"),
887 "CHECKED" => (!!\Bitrix\Main\Data\Cache::getShowCacheStat()),
888 "ACTION" => "jsUtils.Redirect([], '" . CUtil::addslashes($APPLICATION->GetCurPageParam("show_cache_stat=" . (\Bitrix\Main\Data\Cache::getShowCacheStat() ? "N" : "Y"), ["show_cache_stat"])) . "');",
889 "HK_ID" => "top_panel_debug_cache",
890 ],
891 [
892 "TEXT" => Loc::getMessage("top_panel_debug_incl"),
893 "TITLE" => Loc::getMessage("top_panel_debug_incl_title"),
894 "CHECKED" => $sessionShowIncludeTimeExec,
895 "ACTION" => "jsUtils.Redirect([], '" . CUtil::addslashes($APPLICATION->GetCurPageParam("show_include_exec_time=" . ($sessionShowIncludeTimeExec? "N" : "Y"), ["show_include_exec_time"])) . "');",
896 "HK_ID" => "top_panel_debug_incl",
897 ],
898 [
899 "TEXT" => Loc::getMessage("top_panel_debug_time"),
900 "TITLE" => Loc::getMessage("top_panel_debug_time_title"),
901 "CHECKED" => $sessionShowTimeExec,
902 "ACTION" => "jsUtils.Redirect([], '" . CUtil::addslashes($APPLICATION->GetCurPageParam("show_page_exec_time=" . ($sessionShowTimeExec ? "N" : "Y"), ["show_page_exec_time"])) . "');",
903 "HK_ID" => "top_panel_debug_time",
904 ],
905 ];
906
907 $APPLICATION->AddPanelButton([
908 "HREF" => $url,
909 "ICON" => "bx-panel-performance-icon",
910 "TEXT" => Loc::getMessage("top_panel_debug"),
911 "ALT" => Loc::getMessage("top_panel_show_debug"),
912 "MAIN_SORT" => "500",
913 "SORT" => 40,
914 "MENU" => $arMenu,
915 "HK_ID" => "top_panel_debug",
916 "HINT" => [
917 "TITLE" => Loc::getMessage("top_panel_debug_tooltip_title"),
918 "TEXT" => Loc::getMessage("top_panel_debug_tooltip")
919 ],
920 ]);
921 }
922
924 if($USER->CanDoOperation('manage_short_uri'))
925 {
926 $url = $APPLICATION->GetPopupLink([
927 "URL" => "/bitrix/admin/short_uri_edit.php?lang=" . LANGUAGE_ID . "&public=Y&bxpublic=Y&str_URI=" . urlencode($APPLICATION->GetCurPageParam("", ["clear_cache", "sessid", "login", "logout", "register", "forgot_password", "change_password", "confirm_registration", "confirm_code", "confirm_user_id", "bitrix_include_areas", "show_page_exec_time", "show_include_exec_time", "show_sql_stat", "show_link_stat"])) . "&site=" . SITE_ID . "&back_url=" . $encRequestUri,
928 "PARAMS" => [
929 "width" => 770,
930 'height' => 270,
931 'resize' => true,
932 ]
933 ]);
934 $APPLICATION->AddPanelButton([
935 "HREF" => "javascript:" . $url,
936 "ICON" => "bx-panel-short-url-icon",
937 "ALT" => Loc::getMessage("MTP_SHORT_URI_ALT"),
938 "TEXT" => Loc::getMessage("MTP_SHORT_URI"),
939 "MAIN_SORT" => 1000,
940 "HK_ID" => "MTP_SHORT_URI",
941 "MENU" => [
942 [
943 "TEXT" => Loc::getMessage("MTP_SHORT_URI1"),
944 "TITLE" => Loc::getMessage("MTP_SHORT_URI_ALT1"),
945 "ACTION" => "javascript:".$url,
946 "DEFAULT" => true,
947 "HK_ID"=>"MTP_SHORT_URI1",
948 ],
949 [
950 "TEXT" => Loc::getMessage("MTP_SHORT_URI_LIST"),
951 "TITLE" => Loc::getMessage("MTP_SHORT_URI_LIST_ALT"),
952 "ACTION"=>"jsUtils.Redirect([], '".CUtil::addslashes("/bitrix/admin/short_uri_admin.php?lang=".LANGUAGE_ID)."');",
953 "HK_ID"=>"MTP_SHORT_URI_LIST",
954 ]
955 ],
956 "MODE" => "view",
957 "HINT" => [
958 "TITLE" => Loc::getMessage("MTP_SHORT_URI_HINT"),
959 "TEXT" => Loc::getMessage("MTP_SHORT_URI_HINT_ALT"),
960 ]
961 ]);
962 }
963 }
964
965 public static function InitPanelIcons()
966 {
967 static $bPanelIcons = false;
968 if ($bPanelIcons)
969 {
970 return;
971 }
972 $bPanelIcons = true;
973
975 global $DOCUMENT_ROOT, $APPLICATION, $USER, $MESS; //don't remove!
976
977 if (isset($USER) && is_object($USER) && $USER->IsAuthorized())
978 {
979 if (file_exists($_SERVER["DOCUMENT_ROOT"].BX_PERSONAL_ROOT . "/php_interface/include/add_top_panel.php"))
980 {
981 include($_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/php_interface/include/add_top_panel.php");
982 }
983
985 foreach (GetModuleEvents("main", "OnPanelCreate", true) as $arEvent)
986 {
987 ExecuteModuleEventEx($arEvent);
988 }
989 }
990 }
991
992 public static function ShowPanelScripts($bReturn=false)
993 {
994 global $APPLICATION, $adminPage;
995
996 static $bPanelScriptsIncluded = false;
997 if ($bPanelScriptsIncluded)
998 {
999 return null;
1000 }
1001 $bPanelScriptsIncluded = true;
1002
1003 require_once($_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/interface/init_admin.php");
1004
1005 if (!$bReturn)
1006 {
1007 CUtil::InitJSCore(['window', 'ajax', 'admin']);
1008 $APPLICATION->AddHeadString($adminPage->ShowScript());
1009 $APPLICATION->AddHeadScript('/bitrix/js/main/public_tools.js');
1010 $APPLICATION->SetAdditionalCSS(ADMIN_THEMES_PATH . '/' . ADMIN_THEME_ID . '/pubstyles.css');
1011 }
1012 else
1013 {
1014 return
1015 CUtil::InitJSCore(['window', 'ajax', 'admin'], true)
1016 . $adminPage->ShowScript()
1017 . '<script src="'.CUtil::GetAdditionalFileURL('/bitrix/js/main/public_tools.js', true).'"></script>'
1018 . '<link rel="stylesheet" type="text/css" href="'.CUtil::GetAdditionalFileURL(ADMIN_THEMES_PATH.'/'.ADMIN_THEME_ID.'/pubstyles.css', true).'" />';
1019 }
1020 return null;
1021 }
1022
1023 protected static function IsShownForUser()
1024 {
1025 global $USER;
1026
1027 $userCodes = null;
1028
1029 //hiding the panel has the higher priority
1030 $codes = unserialize(COption::GetOptionString("main", "hide_panel_for_users"), ['allowed_classes' => false]);
1031 if (!empty($codes))
1032 {
1033 $userCodes = $USER->GetAccessCodes();
1034 $diff = array_intersect($codes, $userCodes);
1035 if (!empty($diff))
1036 {
1037 return false;
1038 }
1039 }
1040
1041 //we have settings in the main module options
1042 $codes = unserialize(COption::GetOptionString("main", "show_panel_for_users"), ['allowed_classes' => false]);
1043 if (!empty($codes))
1044 {
1045 if ($userCodes === null)
1046 {
1047 $userCodes = $USER->GetAccessCodes();
1048 }
1049 $diff = array_intersect($codes, $userCodes);
1050 if (!empty($diff))
1051 {
1052 return true;
1053 }
1054 }
1055
1056 return null;
1057 }
1058
1063 public static function shouldShowPanel()
1064 {
1065 static $showPanel = null;
1066
1067 if ($showPanel !== null)
1068 {
1069 return $showPanel;
1070 }
1071
1072 global $USER, $APPLICATION;
1073
1074 if (!($USER instanceof CUser))
1075 {
1076 return false;
1077 }
1078
1079 if ($APPLICATION->ShowPanel === false || (!$USER->IsAuthorized() && $APPLICATION->ShowPanel !== true))
1080 {
1081 return false;
1082 }
1083
1084 $showPanel = false;
1085
1086 // if the panel is always hidden there is no reason to init it
1087 $showForUser = self::IsShownForUser();
1088 if ($showForUser === false)
1089 {
1090 return false;
1091 }
1092
1094
1095 if ($showForUser)
1096 {
1097 $showPanel = true;
1098 }
1099 else
1100 {
1101 foreach ($APPLICATION->arPanelButtons as $arValue)
1102 {
1103 if (trim($arValue["HREF"]) <> "" || is_array($arValue["MENU"]) && !empty($arValue["MENU"]))
1104 {
1105 $showPanel = true;
1106 break;
1107 }
1108 }
1109 }
1110
1111 return $showPanel;
1112 }
1113
1114 public static function InitPanel()
1115 {
1116 if (self::shouldShowPanel())
1117 {
1119 }
1120 }
1121
1122 public static function AddAttrHint($hint_title, $hint_text = false)
1123 {
1124 if (!$hint_text)
1125 {
1126 return 'onmouseover="BX.hint(this, \'' . htmlspecialcharsbx(CUtil::JSEscape($hint_title)) . '\')"';
1127 }
1128 else
1129 {
1130 return 'onmouseover="BX.hint(this, \'' . htmlspecialcharsbx(CUtil::JSEscape($hint_title)) . '\', \'' . htmlspecialcharsbx(CUtil::JSEscape($hint_text)) . '\')"';
1131 }
1132 }
1133
1134 public static function AddConstantHint($element_id, $hint_title, $hint_text, $hint_id = false)
1135 {
1136 return '<script>BX.ready(function() {BX.hint(BX(\''.CUtil::JSEscape($element_id).'\'), \''.CUtil::JSEscape($hint_title).'\', \''.CUtil::JSEscape($hint_text).'\''.($hint_id ? ', \''.CUtil::JSEscape($hint_id).'\'' : '').')});</script>';
1137 }
1138
1139 public static function GetPanelHtml()
1140 {
1141 global $USER, $APPLICATION;
1142 if ($APPLICATION->ShowPanel === false || (!$USER->IsAuthorized() && $APPLICATION->ShowPanel !== true))
1143 {
1144 return "";
1145 }
1146
1147 $bShowPanel = self::shouldShowPanel();
1148 if (!$bShowPanel && $APPLICATION->ShowPanel !== true)
1149 {
1150 return "";
1151 }
1152
1153 $APPLICATION->PanelShowed = true;
1154
1155 if (
1156 isset($_GET["back_url_admin"])
1157 && $_GET["back_url_admin"] != ""
1158 && str_starts_with($_GET["back_url_admin"], "/")
1159 )
1160 {
1161 \Bitrix\Main\Application::getInstance()->getSession()["BACK_URL_ADMIN"] = $_GET["back_url_admin"];
1162 }
1163
1164 $aUserOpt = CUserOptions::GetOption("admin_panel", "settings");
1165 $aUserOptGlobal = CUserOptions::GetOption("global", "settings");
1166
1167 $toggleModeSet = false;
1168 if (isset($_GET["bitrix_include_areas"]) && $_GET["bitrix_include_areas"] <> "")
1169 {
1170 $APPLICATION->SetShowIncludeAreas($_GET["bitrix_include_areas"] == "Y");
1171 $toggleModeSet = true;
1172 }
1173
1174 $params = DeleteParam(["bitrix_include_areas", "bitrix_show_mode", "back_url_admin"]);
1175 $href = $APPLICATION->GetCurPage();
1176 $hrefEnc = htmlspecialcharsbx($href);
1177
1178 $toggleModeDynamic = ($aUserOptGlobal['panel_dynamic_mode'] ?? '') == 'Y';
1179 $toggleMode = $toggleModeDynamic && !$toggleModeSet
1180 ? $aUserOpt['edit'] == 'on'
1181 : $APPLICATION->GetShowIncludeAreas() == 'Y';
1182
1183 //Save if changed
1184 $old_edit = $aUserOpt['edit'];
1185 $aUserOpt['edit'] = $toggleMode ? 'on' : 'off';
1186 if ($old_edit !== $aUserOpt['edit'])
1187 {
1188 CUserOptions::SetOption('admin_panel', 'settings', $aUserOpt);
1189 }
1190
1191 $toggleModeLink = $hrefEnc.'?bitrix_include_areas='.($toggleMode ? 'N' : 'Y').($params<>""? "&amp;".htmlspecialcharsbx($params):"");
1192 $result = CTopPanel::ShowPanelScripts(true);
1193 $result .= '
1194 <!--[if lte IE 7]>
1195 <style type="text/css">#bx-panel {display:none !important;}</style>
1196 <div id="bx-panel-error">' . Loc::getMessage("top_panel_browser").'</div><![endif]-->
1197 <script>BX.admin.dynamic_mode='.($toggleModeDynamic ? 'true' : 'false').'; BX.admin.dynamic_mode_show_borders = '.($toggleMode ? 'true' : 'false').';</script>
1198 <div style="display:none; overflow:hidden;" id="bx-panel-back"></div>
1199 <div id="bx-panel"'.(($aUserOpt["collapsed"] ?? '') == "on" ? ' class="bx-panel-folded"':'').'>
1200 <div id="bx-panel-top">
1201 <div id="bx-panel-top-gutter"></div>
1202 <div id="bx-panel-tabs">
1203 ';
1204 $result .= '<a id="bx-panel-menu" href="" '.CTopPanel::AddAttrHint(Loc::getMessage('top_panel_start_menu_tooltip_title'), Loc::getMessage('top_panel_start_menu_tooltip')).'><span id="bx-panel-menu-icon"></span><span id="bx-panel-menu-text">'.Loc::getMessage("top_panel_menu").'</span></a><div id="bx-panel-btn-wrap">';
1205 $backUrlParamName = 'back_url_pub';
1206 $siteList = [];
1207
1208 if (
1209 Main\Config\Option::get('sale', '~IS_SALE_CRM_SITE_MASTER_FINISH') === 'Y'
1210 || Main\Config\Option::get('sale', '~IS_SALE_BSM_SITE_MASTER_FINISH') === 'Y'
1211 )
1212 {
1213 $siteList = self::getSiteList();
1214 if (count($siteList) > 1)
1215 {
1216 $siteMenu = [];
1217 $defaultButtonTitle = '';
1218 $protocol = Main\Context::getCurrent()->getRequest()->isHttps() ? "https://" : "http://";
1219 foreach ($siteList as $site)
1220 {
1221 $siteId = $site['ID'] ?? null;
1222 $isDefault = $siteId === SITE_ID;
1223 $menuItemTitle = $site['NAME'] . ' (' . $site['SERVER_NAME'] . ')' . ($siteId ? ' [' . $siteId . ']' : '');
1224 $siteMenu[] = [
1225 'TEXT' => $menuItemTitle,
1226 'ACTION' => 'jsUtils.Redirect([], \''.CUtil::JSEscape($protocol.$site['SERVER_NAME']).'\')',
1227 'DEFAULT' => $isDefault,
1228 ];
1229
1230 if ($isDefault)
1231 {
1232 $defaultButtonTitle = $menuItemTitle;
1233 }
1234 }
1235
1236 if (!$defaultButtonTitle)
1237 {
1238 $defaultButtonTitle = current($siteMenu)['TEXT'];
1239 }
1240
1241 $defaultButtonTitle = htmlspecialcharsbx($defaultButtonTitle);
1242 if (mb_strlen($defaultButtonTitle) > 30)
1243 {
1244 $defaultButtonTitle = mb_substr($defaultButtonTitle, 0, 30) . '...';
1245 }
1246
1247 $result .= '<a id="bx-panel-view-tab" class="bx-panel-view-tab-btn"><strong><span id="bx-panel-view-tab-select">'.$defaultButtonTitle.'</span></strong></a>';
1248 $result .= '
1249 <script>
1250 BX.admin.panel.RegisterButton({
1251 ID: "bx-panel-view-tab-select",
1252 TYPE: "SMALL",
1253 MENU: ' . Json::encode($siteMenu) . ',
1254 TEXT: "'.$defaultButtonTitle.'",
1255 GROUP_ID: 0
1256 })
1257 </script>
1258 ';
1259 }
1260 else
1261 {
1262 $result .= '<a id="bx-panel-view-tab"><span>'.Loc::getMessage("top_panel_site").'</span></a>';
1263 }
1264 }
1265 else
1266 {
1267 $result .= '<a id="bx-panel-view-tab"><span>'.Loc::getMessage("top_panel_site").'</span></a>';
1268 }
1269
1270 $isBackUrlAdmin = (
1271 isset(Main\Application::getInstance()->getSession()["BACK_URL_ADMIN"])
1272 && Main\Application::getInstance()->getSession()["BACK_URL_ADMIN"] != ""
1273 );
1274 $adminHref = (
1275 $isBackUrlAdmin
1276 ? htmlspecialcharsbx(Main\Application::getInstance()->getSession()["BACK_URL_ADMIN"]) . (str_contains(Main\Application::getInstance()->getSession()["BACK_URL_ADMIN"], "?") ? "&amp;" : "?")
1277 : '/bitrix/admin/index.php?lang=' . LANGUAGE_ID . '&amp;'
1278 ) . $backUrlParamName . '=' . urlencode($href . ($params != "" ? "?".$params : ""));
1279
1280 if (count($siteList) > 1)
1281 {
1282 $result .= '<a id="bx-panel-admin-tab" class="bx-panel-admin-tab-btn" href="'.$adminHref.'"><span>'.Loc::getMessage("top_panel_admin").'</span></a>';
1283 }
1284 else
1285 {
1286 $result .= '<a id="bx-panel-admin-tab" href="'.$adminHref.'"><span>'.Loc::getMessage("top_panel_admin").'</span></a>';
1287 }
1288
1289 $result .= "</div>";
1290
1291 $back_url = CUtil::JSUrlEscape(CUtil::addslashes($href.($params<>""? "?".$params:"")));
1292 $arStartMenuParams = [
1293 'DIV' => 'bx-panel-menu',
1294 'ACTIVE_CLASS' => 'bx-pressed',
1295 'MENU_URL' => '/bitrix/admin/get_start_menu.php?lang=' . LANGUAGE_ID . '&back_url_pub=' . urlencode($back_url) . '&' . bitrix_sessid_get(),
1296 'MENU_PRELOAD' => (($aUserOptGlobal["start_menu_preload"] ?? '') == 'Y')
1297 ];
1298
1299 $result .= '<script>BX.message({MENU_ENABLE_TOOLTIP: '.(($aUserOptGlobal['start_menu_title'] ?? '') <> 'N' ? 'true' : 'false').'}); new BX.COpener(' . Json::encode($arStartMenuParams) . ');</script>';
1300
1301 $hkInstance = CHotKeys::getInstance();
1302 $Execs = $hkInstance->GetCodeByClassName("top_panel_menu",Loc::getMessage("top_panel_menu"));
1303 $result .= $hkInstance->PrintJSExecs($Execs);
1304 $Execs = $hkInstance->GetCodeByClassName("top_panel_admin",Loc::getMessage("top_panel_admin"));
1305 $result .= $hkInstance->PrintJSExecs($Execs);
1306
1307 $informerItemsCount = CAdminInformer::InsertMainItems();
1308
1309 if ($informerItemsCount > 0)
1310 {
1311 $result .= '<a class="adm-header-notif-block" id="adm-header-notif-block" onclick="return BX.adminInformer.Toggle(this);" href="" title="' . Loc::getMessage("top_panel_notif_block_title") . '"><span class="adm-header-notif-icon"></span><span id="adm-header-notif-counter" class="adm-header-notif-counter">' . CAdminInformer::$alertCounter . '</span></a>';
1312 }
1313
1314 if ($USER->CanDoOperation("cache_control"))
1315 {
1316 $result .= '<a id="bx-panel-clear-cache" href="" onclick="BX.clearCache(); return false;"><span id="bx-panel-clear-cache-icon"></span><span id="bx-panel-clear-cache-text">'
1317 . Loc::getMessage("top_panel_cache_new_tooltip_title") . '</span></a>';
1318 }
1319
1320 $result .= '</div><div id="bx-panel-userinfo">';
1321
1322 $bCanProfile = $USER->CanDoOperation('view_own_profile') || $USER->CanDoOperation('edit_own_profile');
1323
1324 $userName = CUser::FormatName(
1325 CSite::GetNameFormat(false),
1326 [
1327 "NAME" => $USER->GetFirstName(),
1328 "LAST_NAME" => $USER->GetLastName(),
1329 "SECOND_NAME" => $USER->GetSecondName(),
1330 "LOGIN" => $USER->GetLogin()
1331 ],
1332 true,
1333 true
1334 );
1335
1336 if ($bCanProfile)
1337 {
1338 $result .= '<a href="/bitrix/admin/user_edit.php?lang='.LANGUAGE_ID.'&ID='.$USER->GetID().'" id="bx-panel-user" '.CTopPanel::AddAttrHint(Loc::getMessage('top_panel_profile_tooltip')).'><span id="bx-panel-user-icon"></span><span id="bx-panel-user-text">'.$userName.'</span></a>';
1339 }
1340 else
1341 {
1342 $result .= '<a id="bx-panel-user"><span id="bx-panel-user-icon"></span><span id="bx-panel-user-text">'.$userName.'</span></a>';
1343 }
1344
1345 $result .= '<a href="'.$hrefEnc.'?'.htmlspecialcharsbx(CUser::getLogoutParams()).'" id="bx-panel-logout" '.CTopPanel::AddAttrHint(Loc::getMessage('top_panel_logout_tooltip').$hkInstance->GetTitle("bx-panel-logout",true)).'>'.Loc::getMessage("top_panel_logout").'</a>';
1346
1347 $toggleCaptionOn = '<span id="bx-panel-toggle-caption-mode-on">' . Loc::getMessage("top_panel_on") . '</span>';
1348 $toggleCaptionOff = '<span id="bx-panel-toggle-caption-mode-off">' . Loc::getMessage("top_panel_off") . '</span>';
1349 $toggleCaptions = $toggleMode ? $toggleCaptionOn.$toggleCaptionOff : $toggleCaptionOff.$toggleCaptionOn;
1350 $toogle = '<a href="'.$toggleModeLink.'" id="bx-panel-toggle" class="bx-panel-toggle'.($toggleMode ? '-on' : '-off').'"'.($toggleModeDynamic ? '' : ' '.CTopPanel::AddAttrHint(Loc::getMessage("top_panel_edit_mode_new_tooltip_title"), Loc::getMessage('top_panel_toggle_tooltip').$hkInstance->GetTitle("bx-panel-small-toggle",true))).'><span id="bx-panel-switcher-gutter-left"></span><span id="bx-panel-toggle-indicator"><span id="bx-panel-toggle-icon"></span><span id="bx-panel-toggle-icon-overlay"></span></span><span class="bx-panel-break"></span><span id="bx-panel-toggle-caption">'.Loc::getMessage("top_panel_edit_mode_new").'</span><span class="bx-panel-break"></span><span id="bx-panel-toggle-caption-mode">'.$toggleCaptions.'</span><span id="bx-panel-switcher-gutter-right"></span></a>';
1351 if (($aUserOpt["collapsed"] ?? '') == "on")
1352 {
1353 $result .= $toogle;
1354 }
1355
1356 $result .= '<a href="" id="bx-panel-expander" '.CTopPanel::AddAttrHint(Loc::getMessage("top_panel_expand_tooltip_title"), Loc::getMessage("top_panel_expand_tooltip").$hkInstance->GetTitle("bx-panel-expander",true)).'><span id="bx-panel-expander-text">'.Loc::getMessage("top_panel_expand").'</span><span id="bx-panel-expander-arrow"></span></a>';
1357 if ($hkInstance->IsActive())
1358 {
1359 $result .= '<a id="bx-panel-hotkeys" href="javascript:void(0)" onclick="BXHotKeys.ShowSettings();" '.CTopPanel::AddAttrHint(Loc::getMessage("HK_PANEL_TITLE").$hkInstance->GetTitle("bx-panel-hotkeys",true)).'></a>';
1360 }
1361
1362 $result .= '<a href="javascript:void(0)" id="bx-panel-pin"'.(($aUserOpt['fix'] ?? '') == 'on' ? ' class="bx-panel-pin-fixed"' : '').' '.CTopPanel::AddAttrHint(Loc::getMessage('top_panel_pin_tooltip')).'></a>';
1363
1364 $Execs = $hkInstance->GetCodeByClassName("bx-panel-logout",Loc::getMessage('top_panel_logout_tooltip'));
1365 $result .= $hkInstance->PrintJSExecs($Execs);
1366 $Execs = $hkInstance->GetCodeByClassName("bx-panel-small-toggle",Loc::getMessage("top_panel_edit_mode_new_tooltip_title"),'location.href="'.$href.'?bitrix_include_areas='.($toggleMode ? 'N' : 'Y').($params<>""? "&".$params:"").'";');
1367 $result .= $hkInstance->PrintJSExecs($Execs);
1368 $Execs = $hkInstance->GetCodeByClassName("bx-panel-expander",Loc::getMessage("top_panel_expand_tooltip_title")."/".Loc::getMessage("top_panel_collapse_tooltip_title"));
1369 $result .= $hkInstance->PrintJSExecs($Execs);
1370
1371 $result .= '</div></div>';
1372
1373 /* BUTTONS */
1374 $result .= '<div id="bx-panel-site-toolbar"><div id="bx-panel-buttons-gutter"></div><div id="bx-panel-switcher">';
1375
1376 if (($aUserOpt["collapsed"] ?? '') != "on")
1377 {
1378 $result .= $toogle;
1379 }
1380
1381 $result .= '<a href="" id="bx-panel-hider" '.CTopPanel::AddAttrHint(Loc::getMessage("top_panel_collapse_tooltip_title"), Loc::getMessage("top_panel_collapse_tooltip").$hkInstance->GetTitle("bx-panel-expander",true)).'>'.Loc::getMessage("top_panel_collapse").'<span id="bx-panel-hider-arrow"></span></a>';
1382 $result .= '</div><div id="bx-panel-buttons"><div id="bx-panel-buttons-inner">';
1383
1384 $main_sort = "";
1385 $last_btn_type = '';
1386 $last_btn_small_cnt = 0;
1387 $groupId = -1;
1388
1389 $result .= '<span class="bx-panel-button-group" data-group-id="'.++$groupId.'">';
1390
1391 $arPanelButtons = &$APPLICATION->arPanelButtons;
1392 sortByColumn($arPanelButtons, ["MAIN_SORT" => SORT_ASC, "SORT" => SORT_ASC]);
1393
1394 foreach ($arPanelButtons as $key=>$arButton)
1395 {
1396 $result .= $hkInstance->PrintTPButton($arButton);
1397
1398 if ($main_sort != $arButton["MAIN_SORT"] && $main_sort<>"")
1399 {
1400 $result .= '</span><span class="bx-panel-button-separator"></span><span class="bx-panel-button-group" data-group-id="'.++$groupId.'">';
1401 $last_btn_small_cnt = 0;
1402 }
1403
1404 if (!isset($arButton['TYPE']) || $arButton['TYPE'] != 'BIG')
1405 {
1406 $arButton['TYPE'] = 'SMALL';
1407 }
1408
1409 //very old behaviour
1410 if (is_set($arButton, "SRC_0"))
1411 {
1412 $arButton["SRC"] = $arButton["SRC_0"];
1413 }
1414
1415 $arButton['HREF'] = isset($arButton['HREF'])? trim($arButton['HREF']): '';
1416 $bHasAction = $arButton['HREF'] != '';
1417
1418 if (array_key_exists("RESORT_MENU", $arButton) && $arButton["RESORT_MENU"] === true && is_array($arButton['MENU']) && !empty($arButton['MENU']))
1419 {
1420 sortByColumn($arButton['MENU'], "SORT", '', PHP_INT_MAX/*nulls last*/);
1421 }
1422
1423 $bHasMenu = is_array(($arButton['MENU'] ?? null)) && !empty($arButton['MENU']);
1424 if ($bHasMenu && !$bHasAction)
1425 {
1426 foreach ($arButton['MENU'] as $arItem)
1427 {
1428 if (isset($arItem['DEFAULT']) && $arItem['DEFAULT'])
1429 {
1430 $arButton['HREF'] = $arItem['HREF'];
1431 $bHasAction = true;
1432 }
1433 }
1434 }
1435
1436 if ($last_btn_type != '' && $arButton['TYPE'] != $last_btn_type && $main_sort == $arButton["MAIN_SORT"])
1437 {
1438 $result .= '</span><span class="bx-panel-button-group" data-group-id="'.++$groupId.'">';
1439 $last_btn_small_cnt = 0;
1440 }
1441
1442 if ($bHasAction && str_starts_with(mb_strtolower($arButton['HREF']), 'javascript:'))
1443 {
1444 $arButton['ONCLICK'] = substr($arButton['HREF'], 11);
1445 $arButton['HREF'] = 'javascript:void(0)';
1446 }
1447
1448 if (isset($arButton['HINT']))
1449 {
1450 if (isset($arButton['HINT']['ID']) && $arButton['HINT']['ID'])
1451 {
1452 $hintOptions = CUtil::GetPopupOptions($arButton['HINT']['ID']);
1453
1454 if(isset($hintOptions['display']) && $hintOptions['display'] == 'off')
1455 {
1456 unset($arButton['HINT']);
1457 }
1458 }
1459
1460 if ($arButton['HINT'])
1461 {
1462 unset($arButton['ALT']);
1463 }
1464
1465 if ($bHasMenu && (!isset($arButton['HINT_MENU']) || !$arButton['HINT_MENU']))
1466 {
1467 $arButton['HINT']['TARGET'] = 'parent';
1468 }
1469 }
1470
1471 $title = isset($arButton['ALT'])? htmlspecialcharsbx($arButton['ALT']): '';
1472 $onClick = isset($arButton['ONCLICK'])? htmlspecialcharsbx($arButton['ONCLICK']): '';
1473 $onClickJs = isset($arButton['ONCLICK'])? CUtil::JSEscape($arButton['ONCLICK']): '';
1474 $hintMenu = isset($arButton['HINT_MENU'])? Json::encode($arButton['HINT_MENU']): '';
1475
1476 switch ($arButton['TYPE'])
1477 {
1478 case 'SMALL':
1479 if ($last_btn_small_cnt >= 3 && $main_sort == $arButton["MAIN_SORT"])
1480 {
1481 $result .= '</span><span class="bx-panel-button-group" data-group-id="'.++$groupId.'">';
1482 $last_btn_small_cnt = 0;
1483 }
1484 elseif ($last_btn_small_cnt > 0)
1485 {
1486 $result .= '<span class="bx-panel-break"></span>';
1487 }
1488
1489 $result .= '<span class="bx-panel-small-button"><span class="bx-panel-small-button-inner">';
1490
1491 $button_icon = '<span class="bx-panel-small-button-icon'.($arButton['ICON'] ? ' '.$arButton['ICON'] : '').'"'.(isset($arButton['SRC']) && $arButton['SRC'] ? ' style="background: scroll transparent url('.htmlspecialcharsbx($arButton['SRC']).') no-repeat center center !important;"' : '').'></span>';
1492 $button_text = '<span class="bx-panel-small-button-text">'.htmlspecialcharsbx($arButton['TEXT']).'</span>';
1493 $button_text_js = CUtil::JSEscape($arButton['TEXT']);
1494
1495 if ($bHasAction)
1496 {
1497 $result .= '<a href="'.htmlspecialcharsbx($arButton['HREF']).'" onclick="'.$onClick.';BX.removeClass(this.parentNode.parentNode, \'bx-panel-small-button'.($bHasMenu ? '-text' : '').'-active\')" id="bx_topmenu_btn_'.$key.'"'.($title ? ' title="'.$title.$hkInstance->GetTitle("bx_topmenu_btn_".$key).'"' : '').'>'.$button_icon.$button_text.'</a>';
1498 $result .= '<script>BX.admin.panel.RegisterButton({ID: \'bx_topmenu_btn_'.$key.'\', TYPE: \'SMALL\', ACTIVE_CSS: \'bx-panel-small-button'.($bHasMenu ? '-text' : '').'-active\', HOVER_CSS: \'bx-panel-small-button'.($bHasMenu ? '-text' : '').'-hover\'' . (isset($arButton['HINT']) ? ', HINT: ' . Json::encode($arButton['HINT']) : '') . ', GROUP_ID : '.$groupId.', SKIP : '.($bHasMenu ? "true" : "false").', LINK: "'.CUtil::JSEscape($arButton['HREF']).'", ACTION : "'.$onClickJs.'",TEXT : "'.$button_text_js.'" })</script>';
1499 if ($bHasMenu)
1500 {
1501 $result .= '<a href="javascript:void(0)" class="bx-panel-small-button-arrow" id="bx_topmenu_btn_'.$key.'_menu"><span class="bx-panel-small-button-arrow"></span></a>';
1502 $result .= '<script>BX.admin.panel.RegisterButton({ID: \'bx_topmenu_btn_'.$key.'_menu\', TYPE: \'SMALL\', MENU: ' . Json::encode($arButton['MENU']) . ', ACTIVE_CSS: \'bx-panel-small-button-arrow-active\', HOVER_CSS: \'bx-panel-small-button-arrow-hover\''.($hintMenu ? ', HINT: '.$hintMenu : '').', GROUP_ID : '.$groupId.', TEXT : "'.$button_text_js.'"})</script>';
1503 }
1504 }
1505 elseif ($bHasMenu)
1506 {
1507 $result .= '<a href="javascript:void(0)" id="bx_topmenu_btn_'.$key.'"'.($title ? ' title="'.$title.'"' : '').'>'.$button_icon.$button_text.'<span class="bx-panel-small-single-button-arrow"></span></a>';
1508 $result .= '<script>BX.admin.panel.RegisterButton({ID: \'bx_topmenu_btn_'.$key.'\', TYPE: \'SMALL\', MENU: ' . Json::encode($arButton['MENU']) . ', ACTIVE_CSS: \'bx-panel-small-button-active\', HOVER_CSS: \'bx-panel-small-button-hover\''.($arButton['HINT'] ? ', HINT: ' . Json::encode($arButton['HINT']) : '').', GROUP_ID : '.$groupId.', TEXT : "'.$button_text_js.'"})</script>';
1509 }
1510
1511 $result .= '</span></span>';
1512 $last_btn_small_cnt++;
1513
1514 break;
1515
1516 case 'BIG':
1517 $last_btn_small_cnt = 0;
1518
1519 $result .= '<span class="bx-panel-button"><span class="bx-panel-button-inner">';
1520
1521 $button_icon = '<span class="bx-panel-button-icon'.($arButton['ICON'] ? ' '.$arButton['ICON'] : '').'"'.(isset($arButton['SRC']) && $arButton['SRC'] ? ' style="background: scroll transparent url('.htmlspecialcharsbx($arButton['SRC']).') no-repeat center center !important;"' : '').'></span>';
1522 $button_text_js = CUtil::JSEscape(str_replace('#BR#', ' ', $arButton['TEXT']));
1523
1524 if ($bHasAction && $bHasMenu)
1525 {
1526 $button_text = '<span class="bx-panel-button-text">'.str_replace('#BR#', '<span class="bx-panel-break"></span>', $arButton['TEXT']).'&nbsp;<span class="bx-panel-button-arrow"></span></span>';
1527 $result .= '<a href="'.htmlspecialcharsbx($arButton['HREF']).'" onclick="'.$onClick.';BX.removeClass(this.parentNode.parentNode, \'bx-panel-button-icon-active\');" id="bx_topmenu_btn_'.$key.'"'.($title? ' title="'.$title.'"': '').'>'.$button_icon.'</a><a id="bx_topmenu_btn_'.$key.'_menu" href="javascript:void(0)">'.$button_text.'</a>';
1528 $result .= '<script>BX.admin.panel.RegisterButton({ID: \'bx_topmenu_btn_'.$key.'\', TYPE: \'BIG\', ACTIVE_CSS: \'bx-panel-button-icon-active\', HOVER_CSS: \'bx-panel-button-icon-hover\''.(!empty($arButton['HINT']) ? ', HINT: ' . Json::encode($arButton['HINT']) : '').', GROUP_ID : '.$groupId.', SKIP : true }); BX.admin.panel.RegisterButton({ID: \'bx_topmenu_btn_'.$key.'_menu\', TYPE: \'BIG\', MENU: ' . Json::encode($arButton['MENU']).', ACTIVE_CSS: \'bx-panel-button-text-active\', HOVER_CSS: \'bx-panel-button-text-hover\''.($hintMenu ? ', HINT: '.$hintMenu : '').', GROUP_ID : '.$groupId.', TEXT : "'.$button_text_js.'"})</script>';
1529 }
1530 else if ($bHasAction)
1531 {
1532 $button_text = '<span class="bx-panel-button-text">'.str_replace('#BR#', '<span class="bx-panel-break"></span>', $arButton['TEXT']).'</span>';
1533 $result .= '<a href="'.htmlspecialcharsbx($arButton['HREF']).'" onclick="'.$onClick.';BX.removeClass(this.parentNode.parentNode, \'bx-panel-button-active\');" id="bx_topmenu_btn_'.$key.'"'.($title ? ' title="'.$title.'"' : '').'>'.$button_icon.$button_text.'</a>';
1534 $result .= '<script>BX.admin.panel.RegisterButton({ID: \'bx_topmenu_btn_'.$key.'\', TYPE: \'BIG\', ACTIVE_CSS: \'bx-panel-button-active\', HOVER_CSS: \'bx-panel-button-hover\''.($arButton['HINT'] ? ', HINT: ' . Json::encode($arButton['HINT']) : '').', GROUP_ID : '.$groupId.', LINK: "'.CUtil::JSEscape($arButton['HREF']).'", ACTION : "'.$onClickJs.'", TEXT : "'.$button_text_js.'"});</script>';
1535 }
1536 else // if $bHasMenu
1537 {
1538 $button_text = '<span class="bx-panel-button-text">'.str_replace('#BR#', '<span class="bx-panel-break"></span>', $arButton['TEXT']).'&nbsp;<span class="bx-panel-button-arrow"></span></span>';
1539 $result .= '<a href="javascript:void(0)" id="bx_topmenu_btn_'.$key.'_menu">'.$button_icon.$button_text.'</a>';
1540 $result .= '<script>BX.admin.panel.RegisterButton({ID: \'bx_topmenu_btn_'.$key.'_menu\', TYPE: \'BIG\', MENU: ' . Json::encode($arButton['MENU']) . ', ACTIVE_CSS: \'bx-panel-button-active\', HOVER_CSS: \'bx-panel-button-hover\''.($arButton['HINT'] ? ', HINT: ' . Json::encode($arButton['HINT']) : '').', GROUP_ID : '.$groupId.', TEXT : "'.$button_text_js.'"});</script>';
1541 }
1542
1543 $result .= '</span></span>';
1544 break;
1545 }
1546
1547 $main_sort = $arButton["MAIN_SORT"];
1548 $last_btn_type = $arButton['TYPE'];
1549 }
1550 $result .= '</span></div></div></div>';
1551
1552 if ($USER->IsAdmin())
1553 {
1555 }
1556
1557 $result .= '</div>';
1558 $result .= '<script>
1559 BX.admin.panel.state = {
1560 fixed: '.(($aUserOpt["fix"] ?? '') == "on" ? 'true' : 'false').',
1561 collapsed: '.(($aUserOpt["collapsed"] ?? '') == "on" ? 'true' : 'false').'
1562 };
1563 BX.admin.moreButton.init({ buttonTitle : "'.GetMessageJS("top_panel_more_button_title").'"});
1564 </script>';
1565
1566 return $result;
1567 }
1568
1569 private static function getSiteList(): array
1570 {
1571 $siteList = [];
1572 $siteIdList = [];
1573 $isDefaultSiteExists = false;
1574
1575 $siteIterator = Main\SiteTable::getList([
1576 'select' => ['LID', 'NAME', 'DEF', 'SITE_NAME', 'SERVER_NAME', 'SORT'],
1577 'filter' => ['=ACTIVE' => 'Y',],
1578 'cache' => ['ttl' => 86400],
1579 ]);
1580 while ($siteData = $siteIterator->fetch())
1581 {
1582 $siteIdList[] = $siteData['LID'];
1583
1584 if (empty($siteData['SERVER_NAME']))
1585 {
1586 continue;
1587 }
1588
1589 $siteList[] = [
1590 'ID' => $siteData['LID'],
1591 'NAME' => $siteData['SITE_NAME'] ?: $siteData['NAME'],
1592 'SERVER_NAME' => $siteData['SERVER_NAME'],
1593 'SORT' => $siteData['SORT'],
1594 ];
1595
1596 if ($siteData['DEF'] === 'Y')
1597 {
1598 $isDefaultSiteExists = true;
1599 }
1600 }
1601
1602 if ($siteIdList)
1603 {
1604 $siteDomainIterator = Main\SiteDomainTable::getList([
1605 'select' => [
1606 'LID',
1607 'DOMAIN',
1608 'NAME' => 'SITE.NAME',
1609 'SITE_NAME' => 'SITE.SITE_NAME',
1610 'DEF' => 'SITE.DEF',
1611 'SORT' => 'SITE.SORT',
1612 ],
1613 'filter' => ['=LID' => $siteIdList,],
1614 'cache' => ['ttl' => 86400],
1615 ]);
1616 while ($siteDomainData = $siteDomainIterator->fetch())
1617 {
1618 $isDomainExists = (bool)array_filter($siteList, static function ($site) use ($siteDomainData) {
1619 return $site['SERVER_NAME'] === $siteDomainData['DOMAIN'];
1620 });
1621
1622 if (!$isDomainExists)
1623 {
1624 $siteList[] = [
1625 'ID' => $siteDomainData['LID'],
1626 'NAME' => $siteDomainData['SITE_NAME'] ?: $siteDomainData['NAME'],
1627 'SERVER_NAME' => $siteDomainData['DOMAIN'],
1628 'SORT' => $siteDomainData['SORT']
1629 ];
1630
1631 if ($siteDomainData['DEF'] === 'Y')
1632 {
1633 $isDefaultSiteExists = true;
1634 }
1635 }
1636 }
1637 }
1638
1639 if (!$isDefaultSiteExists)
1640 {
1641 $serverName = Main\Config\Option::get('main', 'server_name', '', '');
1642 $isDefaultSiteExists = (bool)array_filter($siteList, static function ($site) use ($serverName) {
1643 return $site['SERVER_NAME'] === $serverName;
1644 });
1645 if (!$isDefaultSiteExists)
1646 {
1647 $siteName = Main\Config\Option::get('main', 'site_name', '', '');
1648 array_unshift(
1649 $siteList,
1650 [
1651 'NAME' => $siteName,
1652 'SERVER_NAME' => $serverName,
1653 'SORT' => 1,
1654 ]
1655 );
1656 }
1657 }
1658
1659 Main\Type\Collection::sortByColumn($siteList, ['SORT' => SORT_ASC]);
1660 return $siteList;
1661 }
1662
1663 private static function getDebugSettings() : array
1664 {
1665 global $DB;
1666 global $APPLICATION;
1667
1668 $result = [
1669 'INCLUDE_TIME_EXEC' => isset(\Bitrix\Main\Application::getInstance()->getKernelSession()["SESS_SHOW_INCLUDE_TIME_EXEC"])
1670 && \Bitrix\Main\Application::getInstance()->getKernelSession()["SESS_SHOW_INCLUDE_TIME_EXEC"] == "Y",
1671
1672 'TIME_EXEC' => isset(\Bitrix\Main\Application::getInstance()->getKernelSession()["SESS_SHOW_TIME_EXEC"])
1673 && \Bitrix\Main\Application::getInstance()->getKernelSession()["SESS_SHOW_TIME_EXEC"]=="Y",
1674 ];
1675
1676 $result['CMD'] = ($result['INCLUDE_TIME_EXEC'] && $result['TIME_EXEC'] && $DB->ShowSqlStat ? "N" : "Y");
1677 $result['URL'] = $APPLICATION->GetCurPageParam(
1678 "show_page_exec_time={$result['CMD']}&show_include_exec_time={$result['CMD']}&show_sql_stat={$result['CMD']}"
1679 , ["show_page_exec_time", "show_include_exec_time", "show_sql_stat"]
1680 );
1681
1682 return $result;
1683 }
1684
1685 private static function isProtectedPath(string $pathOnDocumentRoot): bool
1686 {
1687 return
1688 in_array($pathOnDocumentRoot, [
1689 '/bitrix',
1690 '/local/modules',
1691 ])
1692 || str_starts_with($pathOnDocumentRoot, '/bitrix/')
1693 || str_starts_with($pathOnDocumentRoot, '/local/modules/')
1694 ;
1695 }
1696}
const BX_ROOT
Определения bx_root.php:3
global $APPLICATION
Определения include.php:80
change_password_forgot_link login popup forget pas AUTH_GOTO_FORGOT_FORM login btn wrap change_password_button login popup link login popup return auth javascript
Определения change_password.php:57
static getInstance()
Определения application.php:98
Определения json.php:9
static GetHtml()
Определения admin_notify.php:166
static GetInstance()
Определения virtual_io.php:60
Определения top_panel.php:25
static ShowPanelScripts($bReturn=false)
Определения top_panel.php:992
static shouldShowPanel()
Определения top_panel.php:1063
static InitPanelIcons()
Определения top_panel.php:965
static GetStandardButtons()
Определения top_panel.php:165
static IsCanDeletePage($currentFilePath, $documentRoot, $filemanExists)
Определения top_panel.php:143
static AddAttrHint($hint_title, $hint_text=false)
Определения top_panel.php:1122
static IsCanCreatePage($currentDirPath, $documentRoot, $filemanExists)
Определения top_panel.php:27
static IsCanEditPermission($currentFilePath, $documentRoot, $filemanExists)
Определения top_panel.php:120
static IsCanEditSection($currentDirPath, $filemanExists)
Определения top_panel.php:103
static IsShownForUser()
Определения top_panel.php:1023
static IsCanEditPage($currentFilePath, $documentRoot, $filemanExists)
Определения top_panel.php:71
static IsCanCreateSection($currentDirPath, $documentRoot, $filemanExists)
Определения top_panel.php:48
static InitPanel()
Определения top_panel.php:1114
Определения user.php:6037
if(!is_array($prop["VALUES"])) $tmp
Определения component_props.php:203
bx popup label bx hidden PROPERTY[<?=$propertyIndex?>][CODE]<?=htmlspecialcharsEx( $propertyCode)?> bx_view_property_<?=$propertyIndex?> overflow
Определения file_new.php:745
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
bx_acc_lim_group_list limitGroupList[] multiple<?=$group[ 'ID']?> ID selected margin top
Определения file_new.php:657
$arMenu
Определения file_new.php:216
$result
Определения get_property_values.php:14
$protocol
Определения .description.php:9
global $adminPage
Определения init_admin.php:7
const ADMIN_THEME_ID
Определения init_admin.php:5
global $MESS
Определения bill.php:2
$DOCUMENT_ROOT
Определения cron_frame.php:10
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
global $DB
Определения cron_frame.php:29
global $USER
Определения csv_new_run.php:40
$io
Определения csv_new_run.php:98
GetFileTemplates($lang=LANG, $arTemplates=array())
Определения admin_tools.php:35
foreach(['Bitrix\\Main'=> '/lib', 'Psr\\Container'=> '/vendor/psr/container/src', 'Psr\\Log'=> '/vendor/psr/log/src', 'Psr\\Http\\Message'=> '/vendor/psr/http-message/src', 'Psr\\Http\\Client'=> '/vendor/psr/http-client/src', 'Http\\Promise'=> '/vendor/php-http/promise/src', 'PHPMailer\\PHPMailer'=> '/vendor/phpmailer/phpmailer/src', 'GeoIp2'=> '/vendor/geoip2/geoip2/src', 'MaxMind\\Db'=> '/vendor/maxmind-db/reader/src/MaxMind/Db', 'PhpParser'=> '/vendor/nikic/php-parser/lib/PhpParser', 'Recurr'=> '/vendor/simshaun/recurr/src/Recurr',] as $namespace=> $namespacePath) $documentRoot
Определения autoload.php:27
const ADMIN_THEMES_PATH
Определения admin_lib.php:19
$siteId
Определения ajax.php:8
GetFileExtension($path)
Определения tools.php:2972
ExecuteModuleEventEx($arEvent, $arParams=[])
Определения tools.php:5214
IsModuleInstalled($module_id)
Определения tools.php:5301
GetScriptFileExt()
Определения tools.php:2912
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
GetModuleEvents($MODULE_ID, $MESSAGE_ID, $bReturnArray=false)
Определения tools.php:5177
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
bitrix_sessid_get($varname='sessid')
Определения tools.php:4695
GetMessageJS($name, $aReplace=false)
Определения tools.php:3392
Определения aliases.php:105
$aUserOpt
Определения prolog_auth_admin.php:23
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
<? endif;?> window document title
Определения prolog_main_admin.php:76
if(empty($signedUserToken)) $key
Определения quickway.php:257
die
Определения quickway.php:367
lang
Определения options.php:182
font style
Определения invoice.php:442
</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
$title
Определения pdf.php:123
$siteIterator
Определения options.php:48
$siteList
Определения options.php:47
$siteIdList
Определения options.php:46
const SITE_ID
Определения sonet_set_content_view.php:12
$url
Определения iframe.php:7
$site
Определения yandex_run.php:614
adm detail iblock types adm detail iblock list tr_SITE_ID display
Определения yandex_setup.php:388