1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
site.php
См. документацию.
1<?php
2namespace Bitrix\Landing;
3
4use \Bitrix\Landing\Copilot;
5use \Bitrix\Landing\Metrika;
6use \Bitrix\Main\Localization\Loc;
7use \Bitrix\Main\Event;
8use \Bitrix\Main\EventResult;
9
10Loc::loadMessages(__FILE__);
11
13{
18 public static $internalClass = 'SiteTable';
19
24 protected static $pings = [];
25
32 public static function ping(int $id, bool $deleted = false): bool
33 {
34 if (array_key_exists($id, self::$pings))
35 {
36 return self::$pings[$id];
37 }
38
39 $filter = [
40 'ID' => $id
41 ];
42 if ($deleted)
43 {
44 $filter['=DELETED'] = ['Y', 'N'];
45 }
46
47 $check = Site::getList([
48 'select' => [
49 'ID'
50 ],
51 'filter' => $filter
52 ]);
53 self::$pings[$id] = (boolean) $check->fetch();
54
55 return self::$pings[$id];
56 }
57
63 protected static function clearPing(int $id): void
64 {
65 if (array_key_exists($id, self::$pings))
66 {
67 unset(self::$pings[$id]);
68 }
69 }
70
79 public static function getPublicUrl($id, bool $full = true, bool $hostInclude = true, bool $previewForNotActive = false)
80 {
81 $paths = [];
82 $isB24 = Manager::isB24();
83
84 $siteKeyCode = Site\Type::getKeyCode();
85 $defaultPubPath = rtrim(Manager::getPublicationPath(), '/');
86 $hostUrl = Domain::getHostUrl();
87 $disableCloud = Manager::isCloudDisable();
88 $res = self::getList(array(
89 'select' => array(
90 'DOMAIN_PROTOCOL' => 'DOMAIN.PROTOCOL',
91 'DOMAIN_NAME' => 'DOMAIN.DOMAIN',
92 'DOMAIN_ID',
93 'SMN_SITE_ID',
94 'CODE',
95 'TYPE',
96 'ACTIVE',
97 'DELETED',
98 'ID'
99 ),
100 'filter' => array(
101 'ID' => $id,
102 '=DELETED' => ['Y', 'N'],
103 'CHECK_PERMISSIONS' => 'N'
104 )
105 ));
106 while ($row = $res->fetch())
107 {
108 $pubPath = '';
109 $isB24localVar = $isB24;
110
111 if ($row['TYPE'] == 'SMN')
112 {
113 $isB24localVar = false;
114 }
115
116 if (!$isB24localVar || $disableCloud)
117 {
119 null,
120 $row['SMN_SITE_ID'] ? $row['SMN_SITE_ID'] : null
121 );
122 $pubPath = rtrim($pubPath, '/');
123 }
124
125 if ($siteKeyCode == 'ID')
126 {
127 $row['CODE'] = '/' . $row['ID'] . '/';
128 }
129
130 // force https
131 if (Manager::isHttps())
132 {
134 }
135
136 if ($row['DOMAIN_ID'])
137 {
138 $paths[$row['ID']] = ($hostInclude ? ($disableCloud ? $hostUrl : $row['DOMAIN_PROTOCOL'] . '://' . $row['DOMAIN_NAME']) : '') . $pubPath;
139 if ($full)
140 {
141 if ($disableCloud && $isB24localVar)
142 {
143 $paths[$row['ID']] .= $row['CODE'];
144 }
145 else if (!$isB24localVar)
146 {
147 $paths[$row['ID']] .= '/';
148 }
149 }
150 }
151 else
152 {
153 $paths[$row['ID']] = ($hostInclude ? $hostUrl : '') . $defaultPubPath . ($full ? $row['CODE'] : '');
154 }
155 if ($previewForNotActive && ($row['ACTIVE'] === 'N' || $row['DELETED'] === 'Y'))
156 {
157 $paths[$row['ID']] .= 'preview/' . self::getPublicHash($row['ID'], $row['DOMAIN_NAME']) . '/';
158 }
159 }
160
161 if (is_array($id))
162 {
163 return $paths;
164 }
165 else
166 {
167 return isset($paths[$id]) ? $paths[$id] : '';
168 }
169 }
170
177 public static function getPreview(int $siteId, bool $skipCloud = false): string
178 {
179 $res = self::getList([
180 'select' => [
181 'LANDING_ID_INDEX'
182 ],
183 'filter' => [
184 'ID' => $siteId
185 ],
186 ]);
187 if ($row = $res->fetch())
188 {
189 if ($row['LANDING_ID_INDEX'])
190 {
191 return Landing::createInstance(0)->getPreview($row['LANDING_ID_INDEX'], $skipCloud);
192 }
193 }
194
195 return Manager::getUrlFromFile('/bitrix/images/landing/nopreview.jpg');
196 }
197
203 public static function getHooks($id)
204 {
206 {
207 return [];
208 }
209
210 return Hook::getForSite($id);
211 }
212
218 public static function getVersion($siteId): int
219 {
220 static $versions;
221
222 if (isset($versions[$siteId]))
223 {
224 return $versions[$siteId];
225 }
226
227 $resSite = self::getList([
228 'select' => [
229 'VERSION'
230 ],
231 'filter' => [
232 '=ID' => $siteId
233 ]
234 ]);
235 if ($site = $resSite->fetch())
236 {
237 $versions[$siteId] = (int)$site['VERSION'];
238 }
239 else
240 {
241 $versions[$siteId] = 0;
242 }
243
244 return $versions[$siteId];
245 }
246
247
253 public static function getAdditionalFields($id)
254 {
255 $fields = array();
256
257 // now we can get additional fields only from hooks
258 foreach (self::getHooks($id) as $hook)
259 {
260 $fields += $hook->getPageFields();
261 }
262
263 return $fields;
264 }
265
272 public static function saveAdditionalFields($id, array $data)
273 {
274 // now we can get additional fields only from hooks
275 Hook::saveForSite($id, $data);
276 }
277
282 public static function getTypes()
283 {
284 static $types = null;
285
286 if ($types !== null)
287 {
288 return $types;
289 }
290
291 $types = [
292 'PAGE' => Loc::getMessage('LANDING_TYPE_PAGE'),
293 'STORE' => Loc::getMessage('LANDING_TYPE_STORE'),
294 'SMN' => Loc::getMessage('LANDING_TYPE_SMN'),
295 'KNOWLEDGE' => Loc::getMessage('LANDING_TYPE_KNOWLEDGE'),
296 'GROUP' => Loc::getMessage('LANDING_TYPE_GROUP'),
297 'MAINPAGE' => Loc::getMessage('LANDING_TYPE_MAINPAGE'),
298 ];
299
300 return $types;
301 }
302
307 public static function getDefaultType()
308 {
309 return 'PAGE';
310 }
311
318 public static function delete($id, $pagesDelete = false)
319 {
320 // first delete all pages if you want
321 if ($pagesDelete)
322 {
324 'select' => [
325 'ID', 'FOLDER_ID'
326 ],
327 'filter' => [
328 'SITE_ID' => $id,
329 '=DELETED' => ['Y', 'N']
330 ]
331 ]);
332 while ($row = $res->fetch())
333 {
334 if ($row['FOLDER_ID'])
335 {
336 Landing::update($row['ID'], [
337 'FOLDER_ID' => 0
338 ]);
339 }
340 $resDel = Landing::delete($row['ID'], true);
341 if (!$resDel->isSuccess())
342 {
343 return $resDel;
344 }
345 }
346 }
347
348 // delete site
349 $result = parent::delete($id);
350 self::clearPing($id);
351
352 return $result;
353 }
354
360 public static function markDelete($id)
361 {
362 $event = new Event('landing', 'onBeforeSiteRecycle', array(
363 'id' => $id,
364 'delete' => 'Y'
365 ));
366 $event->send();
367
368 foreach ($event->getResults() as $result)
369 {
370 if ($result->getType() == EventResult::ERROR)
371 {
372 $return = new \Bitrix\Main\Result;
373 foreach ($result->getErrors() as $error)
374 {
375 $return->addError(
376 $error
377 );
378 }
379 return $return;
380 }
381 }
382
383 if (($currentScope = Site\Type::getCurrentScopeId()))
384 {
385 Agent::addUniqueAgent('clearRecycleScope', [$currentScope]);
386 }
387
388 $res = parent::update($id, array(
389 'DELETED' => 'Y'
390 ));
391 self::clearPing($id);
392
393 return $res;
394 }
395
401 public static function markUnDelete($id)
402 {
403 $event = new Event('landing', 'onBeforeSiteRecycle', array(
404 'id' => $id,
405 'delete' => 'N'
406 ));
407 $event->send();
408
409 foreach ($event->getResults() as $result)
410 {
411 if ($result->getType() == EventResult::ERROR)
412 {
413 $return = new \Bitrix\Main\Result;
414 foreach ($result->getErrors() as $error)
415 {
416 $return->addError(
417 $error
418 );
419 }
420 return $return;
421 }
422 }
423
424 $res = parent::update($id, array(
425 'DELETED' => 'N'
426 ));
427 self::clearPing($id);
428
429 return $res;
430 }
431
437 public static function copy($siteId)
438 {
439 $siteId = intval($siteId);
440 $result = new \Bitrix\Main\Result;
441 $error = new Error;
442
443 $siteRow = Site::getList([
444 'filter' => [
445 'ID' => $siteId
446 ]
447 ])->fetch();
448
449 if (!$siteRow)
450 {
451 $error->addError(
452 'SITE_NOT_FOUND',
453 Loc::getMessage('LANDING_COPY_ERROR_SITE_NOT_FOUND')
454 );
455 }
456 else
457 {
458 $result = Site::add([
459 'CODE' => $siteRow['CODE'],
460 'ACTIVE' => 'N',
461 'TITLE' => $siteRow['TITLE'],
462 'XML_ID' => $siteRow['XML_ID'],
463 'DESCRIPTION' => $siteRow['DESCRIPTION'],
464 'TYPE' => $siteRow['TYPE'],
465 'SMN_SITE_ID' => $siteRow['SMN_SITE_ID'],
466 'LANG' => $siteRow['LANG']
467 ]);
468
469 if ($result->isSuccess())
470 {
471 // copy hook data
472 Hook::copySite(
473 $siteId,
474 $result->getId()
475 );
476 // copy files
478 $siteId,
479 $result->getId()
480 );
481 }
482 }
483
484 if (!$error->isEmpty())
485 {
486 $result->addError($error->getFirstError());
487 }
488
489 return $result;
490 }
491
498 public static function fullExport($siteForExport, $params = array())
499 {
500 $version = 3;//used in demo/class.php
501 $siteForExport = intval($siteForExport);
502 $tplsXml = array();
503 $export = array();
504 $editMode = isset($params['edit_mode']) && $params['edit_mode'] === 'Y';
505
506 Landing::setEditMode($editMode);
507 Hook::setEditMode($editMode);
508
509 if (!is_array($params))
510 {
511 $params = array();
512 }
513 $params['hooks_files'] = Hook::HOOKS_CODES_FILES;
514
515 if (isset($params['scope']))
516 {
518 }
519
520 // check params
521 if (
522 !isset($params['hooks_disable']) ||
523 !is_array($params['hooks_disable'])
524 )
525 {
526 $params['hooks_disable'] = array();
527 }
528 if (
529 isset($params['code']) &&
530 preg_match('/[^a-z0-9]/i', $params['code'])
531 )
532 {
533 throw new \Bitrix\Main\Config\ConfigurationException(
534 Loc::getMessage('LANDING_EXPORT_ERROR')
535 );
536 }
537 // additional hooks for disable
538 $params['hooks_disable'][] = 'B24BUTTON_CODE';
539 $params['hooks_disable'][] = 'FAVICON_PICTURE';
540 // get all templates
541 $res = Template::getList(array(
542 'select' => array(
543 'ID', 'XML_ID'
544 )
545 ));
546 while ($row = $res->fetch())
547 {
548 $tplsXml[$row['ID']] = $row['XML_ID'];
549 }
550 // gets pages count
552 'select' => array(
553 'CNT'
554 ),
555 'filter' => array(
556 'SITE_ID' => $siteForExport
557 ),
558 'runtime' => array(
560 'CNT', 'COUNT(*)'
561 )
562 )
563 ));
564 if ($pagesCount = $res->fetch())
565 {
566 $pagesCount = $pagesCount['CNT'];
567 }
568 else
569 {
570 return array();
571 }
572 // get all pages from the site
574 'select' => array(
575 'ID',
576 'CODE',
577 'RULE',
578 'TITLE',
579 'DESCRIPTION',
580 'TPL_ID',
581 'FOLDER_ID',
582 'SITE_ID',
583 'SITE_CODE' => 'SITE.CODE',
584 'SITE_TYPE' => 'SITE.TYPE',
585 'SITE_TPL_ID' => 'SITE.TPL_ID',
586 'SITE_TITLE' => 'SITE.TITLE',
587 'SITE_DESCRIPTION' => 'SITE.DESCRIPTION',
588 'LANDING_ID_INDEX' => 'SITE.LANDING_ID_INDEX',
589 'LANDING_ID_404' => 'SITE.LANDING_ID_404'
590 ),
591 'filter' => array(
592 'SITE_ID' => $siteForExport,
593 //'=ACTIVE' => 'Y',
594 //'=SITE.ACTIVE' => 'Y'
595 ),
596 'order' => array(
597 'ID' => 'asc'
598 )
599 ));
600 if (!($row = $res->fetch()))
601 {
602 return array();
603 }
604 do
605 {
606 if (empty($export))
607 {
608 $export = array(
609 'charset' => SITE_CHARSET,
610 'code' => isset($params['code'])
611 ? $params['code']
612 : trim($row['SITE_CODE'], '/'),
613 'code_mainpage' => '',
614 'site_code' => $row['SITE_CODE'],
615 'name' => isset($params['name'])
616 ? $params['name']
617 : $row['SITE_TITLE'],
618 'description' => isset($params['description'])
619 ? $params['description']
620 : $row['SITE_DESCRIPTION'],
621 'preview' => isset($params['preview'])
622 ? $params['preview']
623 : '',
624 'preview2x' => isset($params['preview2x'])
625 ? $params['preview2x']
626 : '',
627 'preview3x' => isset($params['preview3x'])
628 ? $params['preview3x']
629 : '',
630 'preview_url' => isset($params['preview_url'])
631 ? $params['preview_url']
632 : '',
633 'show_in_list' => 'Y',
634 'type' => mb_strtolower($row['SITE_TYPE']),
635 'version' => $version,
636 'fields' => array(
637 'ADDITIONAL_FIELDS' => array(),
638 'TITLE' => isset($params['name'])
639 ? $params['name']
640 : $row['SITE_TITLE'],
641 'LANDING_ID_INDEX' => $row['LANDING_ID_INDEX'],
642 'LANDING_ID_404' => $row['LANDING_ID_404']
643 ),
644 'layout' => array(),
645 'folders' => array(),
646 'syspages' => array(),
647 'items' => array()
648 );
649 // site tpl
650 if ($row['SITE_TPL_ID'])
651 {
652 $export['layout'] = array(
653 'code' => $tplsXml[$row['SITE_TPL_ID']],
654 'ref' => TemplateRef::getForSite($row['SITE_ID'])
655 );
656 }
657 // sys pages
658 foreach (Syspage::get($siteForExport) as $syspage)
659 {
660 $export['syspages'][$syspage['TYPE']] = $syspage['LANDING_ID'];
661 }
662 // site hooks
663 $hookFields = &$export['fields']['ADDITIONAL_FIELDS'];
664 foreach (Hook::getForSite($row['SITE_ID']) as $hookCode => $hook)
665 {
666 if ($hookCode == 'SETTINGS')
667 {
668 continue;
669 }
670 foreach ($hook->getFields() as $fCode => $field)
671 {
672 $hookCodeFull = $hookCode . '_' . $fCode;
673 if (!in_array($hookCodeFull, $params['hooks_disable']))
674 {
675 $hookFields[$hookCodeFull] = $field->getValue();
676 if (!$hookFields[$hookCodeFull])
677 {
678 unset($hookFields[$hookCodeFull]);
679 }
680 else if (
681 in_array($hookCodeFull, $params['hooks_files']) &&
682 intval($hookFields[$hookCodeFull]) > 0
683 )
684 {
685 $hookFields['~' . $hookCodeFull] = $hookFields[$hookCodeFull];
686 $hookFields[$hookCodeFull] = File::getFilePath(
687 $hookFields[$hookCodeFull]
688 );
689 if ($hookFields[$hookCodeFull])
690 {
691 $hookFields[$hookCodeFull] = Manager::getUrlFromFile(
692 $hookFields[$hookCodeFull]
693 );
694 }
695 }
696 }
697 }
698 }
699 unset($hookFields);
700 }
701 // fill one page
702 $export['items'][$row['ID']] = array(
703 'old_id' => $row['ID'],
704 'code' => $pagesCount > 1
705 ? $export['code'] . '/' . $row['CODE']
706 : $export['code'],
707 'name' => (isset($params['name']) && $pagesCount == 1)
708 ? $params['name']
709 : $row['TITLE'],
710 'description' => (isset($params['description']) && $pagesCount == 1)
711 ? $params['description']
712 : $row['DESCRIPTION'],
713 'preview' => (isset($params['preview']) && $pagesCount == 1)
714 ? $params['preview']
715 : '',
716 'preview2x' => (isset($params['preview2x']) && $pagesCount == 1)
717 ? $params['preview2x']
718 : '',
719 'preview3x' => (isset($params['preview3x']) && $pagesCount == 1)
720 ? $params['preview3x']
721 : '',
722 'preview_url' => (isset($params['preview_url']) && $pagesCount == 1)
723 ? $params['preview_url']
724 : '',
725 'show_in_list' => ($pagesCount == 1) ? 'Y' : 'N',
726 'type' => mb_strtolower($row['SITE_TYPE']),
727 'version' => $version,
728 'fields' => array(
729 'TITLE' => (isset($params['name']) && $pagesCount == 1)
730 ? $params['name']
731 : $row['TITLE'],
732 'RULE' => $row['RULE'],
733 'ADDITIONAL_FIELDS' => array(),
734 ),
735 'layout' => $row['TPL_ID']
736 ? array(
737 'code' => $tplsXml[$row['TPL_ID']],
738 'ref' => TemplateRef::getForLanding($row['ID'])
739 )
740 : array(),
741 'items' => array()
742 );
743 // special code for index page
744 if (
745 $pagesCount > 1 &&
746 $row['LANDING_ID_INDEX'] == $row['ID']
747 )
748 {
749 $export['code_mainpage'] = $row['CODE'];
750 }
751 // special pages
752 if ($row['LANDING_ID_INDEX'] == $row['ID'])
753 {
754 $export['fields']['LANDING_ID_INDEX'] = $export['items'][$row['ID']]['code'];
755 }
756 if ($row['LANDING_ID_404'] == $row['ID'])
757 {
758 $export['fields']['LANDING_ID_404'] = $export['items'][$row['ID']]['code'];
759 }
760 // page hooks
761 $hookFields = &$export['items'][$row['ID']]['fields']['ADDITIONAL_FIELDS'];
762 foreach (Hook::getForLanding($row['ID']) as $hookCode => $hook)
763 {
764 if ($hookCode == 'SETTINGS')
765 {
766 continue;
767 }
768 foreach ($hook->getFields() as $fCode => $field)
769 {
770 $hookCodeFull = $hookCode . '_' . $fCode;
771 if (!in_array($hookCodeFull, $params['hooks_disable']))
772 {
773 $hookFields[$hookCodeFull] = $field->getValue();
774 if (!$hookFields[$hookCodeFull])
775 {
776 unset($hookFields[$hookCodeFull]);
777 }
778 else if (
779 in_array($hookCodeFull, $params['hooks_files']) &&
780 intval($hookFields[$hookCodeFull]) > 0
781 )
782 {
783 $hookFields['~' . $hookCodeFull] = $hookFields[$hookCodeFull];
784 $hookFields[$hookCodeFull] = File::getFilePath(
785 $hookFields[$hookCodeFull]
786 );
787 if ($hookFields[$hookCodeFull])
788 {
789 $hookFields[$hookCodeFull] = Manager::getUrlFromFile(
790 $hookFields[$hookCodeFull]
791 );
792 }
793 }
794 }
795 }
796 }
797 unset($hookFields);
798 // folders
799 if ($row['FOLDER_ID'])
800 {
801 if (!isset($export['folders'][$row['FOLDER_ID']]))
802 {
803 $export['folders'][$row['FOLDER_ID']] = array();
804 }
805 $export['folders'][$row['FOLDER_ID']][] = $row['ID'];
806 }
807 // fill page with blocks
808 $landing = Landing::createInstance($row['ID']);
809 if ($landing->exist())
810 {
811 foreach ($landing->getBlocks() as $block)
812 {
813 if (!$block->isActive())
814 {
815 continue;
816 }
817 // repo blocks
818 $repoBlock = array();
819 if ($block->getRepoId())
820 {
821 $repoBlock = Repo::getBlock(
822 $block->getRepoId()
823 );
824 if ($repoBlock)
825 {
826 $repoBlock = array(
827 'app_code' => $repoBlock['block']['app_code'],
828 'xml_id' => $repoBlock['block']['xml_id']
829 );
830 }
831 }
832 $exportBlock = $block->export();
833 $exportItem = array(
834 'old_id' => $block->getId(),
835 'code' => $block->getCode(),
836 'access' => $block->getAccess(),
837 'anchor' => $block->getLocalAnchor(),
838 'repo_block' => $repoBlock,
839 'cards' => $exportBlock['cards'],
840 'nodes' => $exportBlock['nodes'],
841 'menu' => $exportBlock['menu'],
842 'style' => array_map(static function ($style){
843 if (is_array($style) && isset($style['classList']))
844 {
845 $style = $style['classList'];
846 }
847 return $style;
848 }, $exportBlock['style']),
849 'attrs' => $exportBlock['attrs'],
850 'dynamic' => $exportBlock['dynamic']
851 );
852 foreach ($exportItem as $key => $item)
853 {
854 if (!$item)
855 {
856 unset($exportItem[$key]);
857 }
858 }
859 $export['items'][$row['ID']]['items']['#block' . $block->getId()] = $exportItem;
860 }
861 }
862 }
863 while ($row = $res->fetch());
864
865 if ($export['code_mainpage'])
866 {
867 $export['code'] = $export['code'] . '/' . $export['code_mainpage'];
868 }
869 unset($export['code_mainpage']);
870
871 $pages = $export['items'];
872 $export['items'] = array();
873
874 // prepare for export tpls
875 if (isset($export['layout']['ref']))
876 {
877 foreach ($export['layout']['ref'] as &$lid)
878 {
879 if (isset($pages[$lid]))
880 {
881 $lid = $pages[$lid]['code'];
882 }
883 }
884 unset($lid);
885 }
886 // ... folders
887 $nCount = 0;
888 foreach ($export['folders'] as $folderId => $folderPages)
889 {
890 $export['folders']['n' . $nCount] = [];
891 foreach ($folderPages as $pageId)
892 {
893 if (isset($pages[$pageId]))
894 {
895 $export['folders']['n' . $nCount][] = $pages[$pageId]['code'];
896 }
897 }
898 unset($export['folders'][$folderId]);
899 $nCount++;
900 }
901 foreach ($export['folders'] as $folderId => $folderPages)
902 {
903 $export['folders'][$folderPages[0]] = $folderPages;
904 unset($export['folders'][$folderId]);
905 }
906 // ... syspages
907 foreach ($export['syspages'] as &$lid)
908 {
909 if (isset($pages[$lid]))
910 {
911 $lid = $pages[$lid]['code'];
912 }
913 }
914 unset($lid);
915 // ... pages
916 foreach ($pages as $page)
917 {
918 if (isset($page['layout']['ref']))
919 {
920 foreach ($page['layout']['ref'] as &$lid)
921 {
922 if (isset($pages[$lid]))
923 {
924 $lid = $pages[$lid]['code'];
925 }
926 }
927 unset($lid);
928 }
929 $export['items'][$page['code']] = $page;
930 }
931
932 return $export;
933 }
934
941 public static function getPublicHash($id, $domain = null)
942 {
943 static $hashes = [];
944 static $domains = [];
945
946 if (isset($hashes[$id]))
947 {
948 return $hashes[$id];
949 }
950
951 $hash = [];
952
953 if (Manager::isB24())
954 {
956 }
957 else
958 {
959 // detect domain
960 if ($domain === null)
961 {
962 if (!isset($domains[$id]))
963 {
964 $domains[$id] = '';
965 $res = self::getList(array(
966 'select' => array(
967 'SITE_DOMAIN' => 'DOMAIN.DOMAIN'
968 ),
969 'filter' => array(
970 'ID' => $id
971 )
972 ));
973 if ($row = $res->fetch())
974 {
975 $domains[$id] = $row['SITE_DOMAIN'];
976 }
977 }
978 $domain = $domains[$id];
979 }
980 $hash[] = $domain;
981 }
982
983 if (Manager::isB24())
984 {
985 $hash[] = rtrim(Manager::getPublicationPath($id), '/');
986 }
987 else
988 {
989 $hash[] = $id;
990 $hash[] = LICENSE_KEY;
991 }
992
993 $hashes[$id] = md5(implode('', $hash));
994
995 return $hashes[$id];
996 }
997
1004 public static function switchDomain(int $siteId1, int $siteId2): bool
1005 {
1006 return \Bitrix\Landing\Internals\SiteTable::switchDomain($siteId1, $siteId2);
1007 }
1008
1014 public static function randomizeDomain(int $siteId): bool
1015 {
1016 return \Bitrix\Landing\Internals\SiteTable::randomizeDomain($siteId);
1017 }
1018
1026 public static function addByTemplate(string $code, string $type, $additional = null): \Bitrix\Main\Entity\AddResult
1027 {
1028 $result = new \Bitrix\Main\Entity\AddResult;
1029
1030 $componentName = 'bitrix:landing.demo';
1031 $className = \CBitrixComponent::includeComponentClass($componentName);
1033 $demoCmp = new $className;
1034 $demoCmp->initComponent($componentName);
1035 $demoCmp->arParams = [
1036 'TYPE' => $type,
1037 'DISABLE_REDIRECT' => 'Y'
1038 ];
1039 $res = $demoCmp->actionSelect($code, $additional);
1040
1041 if ($res)
1042 {
1043 $resSite = self::getList([
1044 'select' => [
1045 'ID'
1046 ],
1047 'filter' => [
1048 '=TYPE' => $type
1049 ],
1050 'order' => [
1051 'ID' => 'desc'
1052 ]
1053 ]);
1054 if ($rowSite = $resSite->fetch())
1055 {
1056 $result->setId($rowSite['ID']);
1057 }
1058 }
1059 else
1060 {
1061 foreach ($demoCmp->getErrors() as $code => $title)
1062 {
1063 $result->addError(new \Bitrix\Main\Error($title, $code));
1064 }
1065 }
1066
1067 return $result;
1068 }
1069
1077 public static function copyFolders(int $fromSite, int $toSite, array &$folderMap = []): \Bitrix\Main\Result
1078 {
1079 $result = new \Bitrix\Main\Result();
1080 $fromSiteAccess = Site::ping($fromSite) && Rights::hasAccessForSite($fromSite, Rights::ACCESS_TYPES['read']);
1081 $toSiteAccess = Site::ping($toSite) && Rights::hasAccessForSite($toSite, Rights::ACCESS_TYPES['edit']);
1082
1083 if ($fromSiteAccess && $toSiteAccess)
1084 {
1085 Landing::disableCheckUniqueAddress();
1086
1087 $childrenExist = false;
1088 $res = Folder::getList([
1089 'filter' => [
1090 'SITE_ID' => $fromSite
1091 ]
1092 ]);
1093 while ($row = $res->fetch())
1094 {
1095 $oldId = $row['ID'];
1096 unset($row['ID']);
1097
1098 if ($row['PARENT_ID'])
1099 {
1100 $childrenExist = true;
1101 }
1102 else
1103 {
1104 unset($row['PARENT_ID']);
1105 }
1106
1107 if ($row['INDEX_ID'])
1108 {
1109 unset($row['INDEX_ID']);
1110 }
1111
1112 $row['SITE_ID'] = $toSite;
1113 $resAdd = Folder::add($row);
1114 $folderMap[$oldId] = $resAdd->isSuccess() ? $resAdd->getId() : null;
1115 }
1116
1117 // update child-parent
1118 if ($childrenExist)
1119 {
1120 $res = Folder::getList([
1121 'select' => [
1122 'ID', 'PARENT_ID'
1123 ],
1124 'filter' => [
1125 'SITE_ID' => $toSite,
1126 '!PARENT_ID' => false
1127 ]
1128 ]);
1129 while ($row = $res->fetch())
1130 {
1131 Folder::update($row['ID'], [
1132 'PARENT_ID' => $folderMap[$row['PARENT_ID']] ?: null
1133 ]);
1134 }
1135 }
1136
1137 Landing::enableCheckUniqueAddress();
1138 }
1139 else
1140 {
1141 $result->addError(new \Bitrix\Main\Error(
1142 Loc::getMessage('LANDING_COPY_ERROR_SITE_NOT_FOUND'),
1143 'ACCESS_DENIED'
1144 ));
1145 }
1146 return $result;
1147 }
1148
1155 public static function addFolder(int $siteId, array $fields): \Bitrix\Main\Entity\AddResult
1156 {
1157 if (self::ping($siteId) && Rights::hasAccessForSite($siteId, Rights::ACCESS_TYPES['edit']))
1158 {
1159 $fields['SITE_ID'] = $siteId;
1160 $result = Folder::add($fields);
1161 }
1162 else
1163 {
1164 $result = new \Bitrix\Main\Entity\AddResult;
1165 $result->addError(new \Bitrix\Main\Error(
1166 Loc::getMessage('LANDING_COPY_ERROR_SITE_NOT_FOUND'),
1167 'ACCESS_DENIED'
1168 ));
1169 }
1170 return $result;
1171 }
1172
1180 public static function updateFolder(int $siteId, int $folderId, array $fields): \Bitrix\Main\Entity\UpdateResult
1181 {
1182 if (self::ping($siteId) && Rights::hasAccessForSite($siteId, Rights::ACCESS_TYPES['edit']))
1183 {
1184 $fields['SITE_ID'] = $siteId;
1185 $result = Folder::update($folderId, $fields);
1186 }
1187 else
1188 {
1189 $result = new \Bitrix\Main\Entity\UpdateResult;
1190 $result->addError(new \Bitrix\Main\Error(
1191 Loc::getMessage('LANDING_COPY_ERROR_SITE_NOT_FOUND'),
1192 'ACCESS_DENIED'
1193 ));
1194 }
1195
1196 return $result;
1197 }
1198
1205 public static function publicationFolder(int $folderId, bool $mark = true): \Bitrix\Main\Result
1206 {
1207 $wasPublic = false;
1208 $result = new \Bitrix\Main\Result;
1209 $siteId = self::getFolder($folderId)['SITE_ID'] ?? null;
1210
1211 if ($siteId && self::ping($siteId) && Rights::hasAccessForSite($siteId, Rights::ACCESS_TYPES['public']))
1212 {
1213 $wasPublic = true;
1214 $breadCrumbs = Folder::getBreadCrumbs($folderId);
1215 if (!$breadCrumbs)
1216 {
1217 $wasPublic = false;
1218 }
1219 $char = $mark ? 'Y' : 'N';
1220 foreach ($breadCrumbs as $folder)
1221 {
1222 if ($folder['ACTIVE'] === $char)
1223 {
1224 continue;
1225 }
1226 if ($folder['DELETED'] === 'Y')
1227 {
1228 $result->addError(new \Bitrix\Main\Error(
1229 Loc::getMessage('LANDING_COPY_ERROR_FOLDER_NOT_FOUND'),
1230 'ACCESS_DENIED'
1231 ));
1232 return $result;
1233 }
1234 $res = Folder::update($folder['ID'], [
1235 'ACTIVE' => $char
1236 ]);
1237 if (!$res->isSuccess())
1238 {
1239 $wasPublic = false;
1240 }
1241 }
1242 }
1243
1244 if (!$wasPublic)
1245 {
1246 $result->addError(new \Bitrix\Main\Error(
1247 Loc::getMessage('LANDING_COPY_ERROR_FOLDER_NOT_FOUND'),
1248 'ACCESS_DENIED'
1249 ));
1250 }
1251
1252 return $result;
1253 }
1254
1262 public static function moveFolder(int $folderId, ?int $toFolderId, ?int $toSiteId = null): \Bitrix\Main\Result
1263 {
1264 $returnError = function()
1265 {
1266 $result = new \Bitrix\Main\Result;
1267 $result->addError(new \Bitrix\Main\Error(
1268 Loc::getMessage('LANDING_COPY_ERROR_FOLDER_NOT_FOUND'),
1269 'ACCESS_DENIED'
1270 ));
1271 return $result;
1272 };
1273
1274 $folder = Folder::getList([
1275 'filter' => [
1276 'ID' => $folderId
1277 ]
1278 ])->fetch();
1279 if ($folder)
1280 {
1281 // move to another site
1282 if ($toSiteId && (int)$folder['SITE_ID'] !== $toSiteId)
1283 {
1284 // check access to another site
1285 $hasRightFrom = Rights::hasAccessForSite($folder['SITE_ID'], Rights::ACCESS_TYPES['delete']);
1286 $hasRightTo = Rights::hasAccessForSite($toSiteId, Rights::ACCESS_TYPES['edit']);
1287 if (!$hasRightFrom || !$hasRightTo)
1288 {
1289 return $returnError();
1290 }
1291
1292 // check another site folder if specified
1293 $toFolder = null;
1294 if ($toFolderId)
1295 {
1296 $toFolder = Folder::getList([
1297 'filter' => [
1298 'ID' => $toFolderId,
1299 'SITE_ID' => $toSiteId
1300 ]
1301 ])->fetch();
1302 if (!$toFolder)
1303 {
1304 return $returnError();
1305 }
1306 }
1307
1308 // move folder
1309 $res = Folder::update($folderId, [
1310 'SITE_ID' => $toSiteId,
1311 'PARENT_ID' => $toFolder['ID'] ?? null
1312 ]);
1313 if ($res->isSuccess())
1314 {
1315 Folder::changeSiteIdRecursive($folderId, $toSiteId);
1316 }
1317
1318 return $res;
1319 }
1320
1321 $willBeRoot = !$toFolderId;
1322
1323 // check destination folder
1324 $toFolder = null;
1325 if ($toFolderId)
1326 {
1327 $toFolder = Folder::getList([
1328 'filter' => [
1329 'ID' => $toFolderId
1330 ]
1331 ])->fetch();
1332 if (!$toFolder)
1333 {
1334 return $returnError();
1335 }
1336 }
1337 if (!$toFolder)
1338 {
1339 $toFolder = $folder;
1340 }
1341 // check restriction to move to itself
1342 if (!$willBeRoot)
1343 {
1344 $breadCrumbs = Folder::getBreadCrumbs($toFolder['ID'], $toFolder['SITE_ID']);
1345 for ($i = 0, $c = count($breadCrumbs); $i < $c; $i++)
1346 {
1347 if ($breadCrumbs[$i]['ID'] === $folder['ID'])
1348 {
1349 $result = new \Bitrix\Main\Result;
1350 $result->addError(new \Bitrix\Main\Error(
1351 Loc::getMessage('LANDING_COPY_ERROR_MOVE_RESTRICTION'),
1352 'MOVE_RESTRICTION'
1353 ));
1354 return $result;
1355 }
1356 }
1357 }
1358 // check access and update then
1359 $hasRightFrom = Rights::hasAccessForSite($folder['SITE_ID'], Rights::ACCESS_TYPES['delete']);
1360 $hasRightTo = Rights::hasAccessForSite($toFolder['SITE_ID'], Rights::ACCESS_TYPES['edit']);
1361 if ($hasRightFrom && $hasRightTo)
1362 {
1363 return Folder::update($folderId, [
1364 'SITE_ID' => $toFolder['SITE_ID'],
1365 'PARENT_ID' => !$willBeRoot ? $toFolder['ID'] : null
1366 ]);
1367 }
1368 }
1369
1370 return $returnError();
1371 }
1372
1379 public static function getFolders(int $siteId, array $filter = []): array
1380 {
1382 {
1383 return [];
1384 }
1385
1386 if (!isset($filter['DELETED']) && !isset($filter['=DELETED']))
1387 {
1388 $filter['=DELETED'] = 'N';
1389 }
1390
1391 $folders = [];
1392 $filter['SITE_ID'] = $siteId;
1393 $res = Folder::getList([
1394 'filter' => $filter,
1395 'order' => [
1396 'DATE_MODIFY' => 'desc'
1397 ]
1398 ]);
1399 while ($row = $res->fetch())
1400 {
1401 $folders[$row['ID']] = $row;
1402 }
1403 return $folders;
1404 }
1405
1412 public static function getFolder(int $folderId, string $accessLevel = Rights::ACCESS_TYPES['read']): ?array
1413 {
1414 $folder = Folder::getList([
1415 'filter' => [
1416 'ID' => $folderId
1417 ]
1418 ])->fetch();
1419
1420 if ($folder)
1421 {
1422 if (!Rights::hasAccessForSite($folder['SITE_ID'], $accessLevel))
1423 {
1424 return null;
1425 }
1426 }
1427
1428 return is_array($folder) ? $folder : null;
1429 }
1430
1436 public static function markFolderDelete(int $id): \Bitrix\Main\Result
1437 {
1438 $folder = self::getFolder($id);
1439
1440 if (!$folder || !Rights::hasAccessForSite($folder['SITE_ID'], Rights::ACCESS_TYPES['delete']))
1441 {
1442 $result = new \Bitrix\Main\Entity\AddResult;
1443 $result->addError(new \Bitrix\Main\Error(
1444 Loc::getMessage('LANDING_COPY_ERROR_FOLDER_NOT_FOUND'),
1445 'ACCESS_DENIED'
1446 ));
1447 return $result;
1448 }
1449
1450 // disable delete if folder (or aby sub folders) contains area
1452 'select' => ['ID'],
1453 'filter' => [
1454 'FOLDER_ID' => [$id, ...Folder::getSubFolderIds($id)],
1455 '!==AREAS.ID' => null,
1456 ],
1457 ]);
1458 if ($res->fetch())
1459 {
1460 $result = new \Bitrix\Main\Entity\AddResult;
1461 $result->addError(new \Bitrix\Main\Error(
1462 Loc::getMessage('LANDING_DELETE_FOLDER_ERROR_CONTAINS_AREAS'),
1463 'FOLDER_CONTAINS_AREAS'
1464 ));
1465 return $result;
1466 }
1467
1468 $event = new Event('landing', 'onBeforeFolderRecycle', [
1469 'id' => $id,
1470 'delete' => 'Y'
1471 ]);
1472 $event->send();
1473
1474 foreach ($event->getResults() as $result)
1475 {
1476 if ($result->getType() == EventResult::ERROR)
1477 {
1478 $return = new \Bitrix\Main\Result;
1479 foreach ($result->getErrors() as $error)
1480 {
1481 $return->addError(
1482 $error
1483 );
1484 }
1485 return $return;
1486 }
1487 }
1488
1489 if (($currentScope = Site\Type::getCurrentScopeId()))
1490 {
1491 Agent::addUniqueAgent('clearRecycleScope', [$currentScope]);
1492 }
1493
1494 $updateResult = Folder::update($id, [
1495 'DELETED' => 'Y'
1496 ]);
1497
1498 if ($updateResult->isSuccess())
1499 {
1500 self::setDeletedStatusForFolderLandings($id, 'Y');
1501 }
1502
1503 return $updateResult;
1504 }
1505
1511 public static function markFolderUnDelete(int $id): \Bitrix\Main\Result
1512 {
1513 $folder = self::getFolder($id);
1514
1515 if (!$folder || !Rights::hasAccessForSite($folder['SITE_ID'], Rights::ACCESS_TYPES['delete']))
1516 {
1517 $result = new \Bitrix\Main\Entity\AddResult;
1518 $result->addError(new \Bitrix\Main\Error(
1519 Loc::getMessage('LANDING_COPY_ERROR_FOLDER_NOT_FOUND'),
1520 'ACCESS_DENIED'
1521 ));
1522 return $result;
1523 }
1524
1525 $event = new Event('landing', 'onBeforeFolderRecycle', array(
1526 'id' => $id,
1527 'delete' => 'N'
1528 ));
1529 $event->send();
1530
1531 foreach ($event->getResults() as $result)
1532 {
1533 if ($result->getType() == EventResult::ERROR)
1534 {
1535 $return = new \Bitrix\Main\Result;
1536 foreach ($result->getErrors() as $error)
1537 {
1538 $return->addError(
1539 $error
1540 );
1541 }
1542 return $return;
1543 }
1544 }
1545
1546 $updateResult = Folder::update($id, array(
1547 'DELETED' => 'N'
1548 ));
1549
1550 if ($updateResult->isSuccess())
1551 {
1552 self::setDeletedStatusForFolderLandings($id, 'N');
1553 }
1554
1555 return $updateResult;
1556 }
1557
1566 private static function setDeletedStatusForFolderLandings(int $folderId, string $deletedValue): void
1567 {
1568 $folderIds = [$folderId];
1569 $subFolderIds = Folder::getSubFolderIds($folderId);
1570 if (!empty($subFolderIds))
1571 {
1572 $folderIds = array_merge($folderIds, $subFolderIds);
1573 }
1575 'select' => ['ID'],
1576 'filter' => [
1577 'FOLDER_ID' => $folderIds,
1578 '=DELETED' => $deletedValue === 'Y' ? 'N' : 'Y'
1579 ]
1580 ]);
1581 while ($row = $res->fetch())
1582 {
1583 Landing::update($row['ID'], [
1584 'DELETED' => $deletedValue
1585 ]);
1586 }
1587 }
1588
1596 public static function addLandingToMenu(int $siteId, array $data): void
1597 {
1598 Landing::setEditMode();
1600 'select' => [
1601 'ID'
1602 ],
1603 'filter' => [
1604 'SITE_ID' => $siteId,
1605 '!==AREAS.ID' => null
1606 ],
1607 ]);
1608 while ($row = $res->fetch())
1609 {
1610 $landing = Landing::createInstance($row['ID']);
1611 if ($landing->exist())
1612 {
1613 foreach ($landing->getBlocks() as $block)
1614 {
1615 $manifest = $block->getManifest();
1616 if (isset($manifest['menu']))
1617 {
1618 foreach ($manifest['menu'] as $menuSelector => $foo)
1619 {
1620 $block->updateNodes([
1621 $menuSelector => [
1622 [
1623 'text' => $data['TITLE'],
1624 'href' => '#landing' . $data['ID']
1625 ]
1626 ]
1627 ], ['appendMenu' => true]);
1628 $block->save();
1629 break 2;
1630 }
1631 }
1632 }
1633 }
1634 }
1635 }
1636
1642 public static function touch(int $id): void
1643 {
1644 static $touched = [];
1645
1646 if (isset($touched[$id]))
1647 {
1648 return;
1649 }
1650
1651 $touched[$id] = true;
1652
1653 self::update($id, [
1654 'TOUCH' => 'Y'
1655 ]);
1656 }
1657
1667 public static function publication(int $id, bool $mark = true, ?Metrika\FieldsDto $metrikaFields = null): \Bitrix\Main\Result
1668 {
1669 $return = new \Bitrix\Main\Result;
1670
1671 if ($mark)
1672 {
1673 $verificationError = new Error();
1674 if (!Mutator::checkSiteVerification($id, $verificationError))
1675 {
1676 $return->addError($verificationError->getFirstError());
1677 return $return;
1678 }
1679 }
1680
1681 // work with pages
1683 'select' => [
1684 'ID', 'ACTIVE', 'PUBLIC'
1685 ],
1686 'filter' => [
1687 'SITE_ID' => $id,
1688 [
1689 'LOGIC' => 'OR',
1690 ['FOLDER_ID' => null],
1691 ['!FOLDER_ID' => Folder::getFolderIdsForSite($id, ['=DELETED' => 'Y']) ?: [-1]]
1692 ]
1693 ]
1694 ]);
1695
1696 $metrikaType = Metrika\Types::template;
1697 if ((new Copilot\Generation())->initBySiteId($id, (new Copilot\Generation\Scenario\CreateSite())))
1698 {
1699 $metrikaType = Metrika\Types::ai;
1700 }
1701
1702 $metrikaParams =
1704 event: $mark ? Metrika\Events::publishSite : Metrika\Events::unpublishSite,
1705 type: $metrikaType,
1706 subSection: $metrikaFields?->subSection ?? 'from_list',
1707 element: $metrikaFields?->element ?? 'manual',
1708 )
1709 ;
1710
1711 while ($row = $res->fetch())
1712 {
1713 if ($row['ACTIVE'] != 'Y')
1714 {
1715 $row['PUBLIC'] = 'N';
1716 }
1717 if ($row['PUBLIC'] == 'Y')
1718 {
1719 continue;
1720 }
1721 $landing = Landing::createInstance($row['ID'], [
1722 'skip_blocks' => true
1723 ]);
1724
1725 if ($mark)
1726 {
1727 $resPublication = $landing->publication(null, $metrikaParams);
1728 }
1729 else
1730 {
1731 $resPublication = $landing->unpublic();
1732 }
1733
1734 if (
1735 !$resPublication
1736 && !$landing->getError()->isEmpty()
1737 )
1738 {
1739 $error =
1740 $landing->getError()->getFirstError()
1741 ?? new \Bitrix\Main\Error('some_error', 'SOME_ERROR')
1742 ;
1743 $return->addError($error);
1744
1745 $metrikaParams->error = $error;
1746 self::sendAnalytics($metrikaParams, $id);
1747
1748 return $return;
1749 }
1750 }
1751
1752 self::sendAnalytics($metrikaParams, $id);
1753
1754 $res = Folder::getList([
1755 'select' => [
1756 'ID'
1757 ],
1758 'filter' => [
1759 'SITE_ID' => $id,
1760 '=ACTIVE' => $mark ? 'N' : 'Y',
1761 '=DELETED' => 'N'
1762 ]
1763 ]);
1764 while ($row = $res->fetch())
1765 {
1766 Folder::update($row['ID'], [
1767 'ACTIVE' => $mark ? 'Y' : 'N'
1768 ]);
1769 }
1770
1771 return parent::update($id, [
1772 'ACTIVE' => $mark ? 'Y' : 'N'
1773 ]);
1774 }
1775
1781 public static function unpublic(int $id): \Bitrix\Main\Result
1782 {
1783 return self::publication($id, false);
1784 }
1785
1786 private static function sendAnalytics(Metrika\FieldsDto $params, int $siteId): void
1787 {
1788 if (!isset($params->event))
1789 {
1790 return;
1791 }
1792
1793 $site = self::getList([
1794 'select' => [
1795 'TYPE'
1796 ],
1797 'filter' => [
1798 '=ID' => $siteId,
1799 ]
1800 ])->fetch();
1801 if ($site)
1802 {
1803 $metrika = new Metrika\Metrika(
1804 Metrika\Categories::getBySiteType($site['TYPE']),
1805 $params->event
1806 );
1807 $metrika->setType($params->type);
1808 $metrika->setSubSection($params->subSection);
1809 $metrika->setElement($params->element);
1810 $metrika->setParam(3, 'siteId', $siteId);
1811 if ($params->error)
1812 {
1813 $metrika->setError($params->error);
1814 }
1815
1816 $metrika->send();
1817 }
1818 }
1819
1825 public static function getSiteIdByTemplate(string $tplCode): ?int
1826 {
1827 $site = \Bitrix\Landing\Site::getList([
1828 'select' => [
1829 'ID'
1830 ],
1831 'filter' => [
1832 '=TPL_CODE' => $tplCode
1833 ],
1834 'order' => [
1835 'ID' => 'desc'
1836 ]
1837 ])->fetch();
1838
1839 return $site['ID'] ?? null;
1840 }
1841
1847 public static function onBeforeMainSiteDelete($siteId)
1848 {
1850 'select' => array(
1851 'ID'
1852 ),
1853 'filter' => array(
1854 '=SITE.SMN_SITE_ID' => $siteId,
1855 'CHECK_PERMISSIONS' => 'N'
1856 )
1857 ));
1858
1859 if ($res->fetch())
1860 {
1861 Manager::getApplication()->throwException(
1862 Loc::getMessage('LANDING_CLB_ERROR_DELETE_SMN'),
1863 'ERROR_DELETE_SMN'
1864 );
1865 return false;
1866 }
1867
1868 return true;
1869 }
1870
1876 public static function onMainSiteDelete($siteId)
1877 {
1879
1880 $realSiteId = null;
1881 // delete pages
1883 'select' => array(
1884 'ID', 'SITE_ID'
1885 ),
1886 'filter' => array(
1887 '=SITE.SMN_SITE_ID' => $siteId,
1888 '=SITE.DELETED' => ['Y', 'N'],
1889 '=DELETED' => ['Y', 'N']
1890 )
1891 ));
1892 while ($row = $res->fetch())
1893 {
1894 $realSiteId = $row['SITE_ID'];
1895 Landing::delete($row['ID'], true);
1896 }
1897 // detect site
1898 if (!$realSiteId)
1899 {
1900 $res = self::getList(array(
1901 'select' => array(
1902 'ID'
1903 ),
1904 'filter' => array(
1905 '=SMN_SITE_ID' => $siteId,
1906 '=DELETED' => ['Y', 'N']
1907 )
1908 ));
1909 if ($row = $res->fetch())
1910 {
1911 $realSiteId = $row['ID'];
1912 }
1913 }
1914 // and delete site
1915 if ($realSiteId)
1916 {
1917 self::delete($realSiteId);
1918 }
1919
1920 Rights::setOn();
1921 }
1922
1929 public static function changeType(int $id, string $type): void
1930 {
1931 if (self::getTypes()[$type] ?? null)
1932 {
1933 parent::update($id, array(
1934 'TYPE' => $type
1935 ));
1936 }
1937 }
1938
1945 public static function changeCode(int $id, string $code): void
1946 {
1947 parent::update($id, array(
1948 'CODE' => $code
1949 ));
1950 }
1951}
$hash
Определения ajax_redirector.php:8
$type
Определения options.php:106
static addUniqueAgent(string $funcName, array $params=[], int $time=7200, ?int $nextExecDelay=null)
Определения agent.php:28
static copySiteFiles($from, $to)
Определения file.php:548
static getFilePath($fileId)
Определения file.php:600
static changeSiteIdRecursive(int $folderId, int $newSiteId)
Определения folder.php:39
static getBreadCrumbs(int $folderId, ?int $siteId=null)
Определения folder.php:134
static getSubFolderIds(int $folderId)
Определения folder.php:85
static getFolderIdsForSite(int $siteId, array $additionalFilter=[])
Определения folder.php:109
const PROTOCOL_HTTPS
Определения domain.php:32
static isB24()
Определения manager.php:1135
static getApplication()
Определения manager.php:71
static getPublicationPath($siteCode=null, $siteId=null, $createPubPath=false)
Определения manager.php:401
static isHttps()
Определения manager.php:1032
static getHttpHost()
Определения manager.php:1058
static isCloudDisable()
Определения manager.php:1244
static getUrlFromFile($file)
Определения manager.php:1082
static checkSiteVerification(int $_852491107, Error $_1491703301)
Определения mutator.php:1
static getBlock($id)
Определения repo.php:150
static setOff()
Определения rights.php:89
static setOn()
Определения rights.php:98
const ACCESS_TYPES
Определения rights.php:21
static hasAccessForSite($siteId, $accessType, $deleted=false)
Определения rights.php:546
static setScope($scope, array $params=[])
Определения type.php:88
static getKeyCode()
Определения type.php:160
static addFolder(int $siteId, array $fields)
Определения site.php:1155
static getHooks($id)
Определения site.php:203
static switchDomain(int $siteId1, int $siteId2)
Определения site.php:1004
static changeType(int $id, string $type)
Определения site.php:1929
static getFolders(int $siteId, array $filter=[])
Определения site.php:1379
static addLandingToMenu(int $siteId, array $data)
Определения site.php:1596
static updateFolder(int $siteId, int $folderId, array $fields)
Определения site.php:1180
static markUnDelete($id)
Определения site.php:401
static getSiteIdByTemplate(string $tplCode)
Определения site.php:1825
static getTypes()
Определения site.php:282
static getPreview(int $siteId, bool $skipCloud=false)
Определения site.php:177
static $internalClass
Определения site.php:18
static getPublicUrl($id, bool $full=true, bool $hostInclude=true, bool $previewForNotActive=false)
Определения site.php:79
static getAdditionalFields($id)
Определения site.php:253
static $pings
Определения site.php:24
static moveFolder(int $folderId, ?int $toFolderId, ?int $toSiteId=null)
Определения site.php:1262
static getDefaultType()
Определения site.php:307
static ping(int $id, bool $deleted=false)
Определения site.php:32
static unpublic(int $id)
Определения site.php:1781
static publication(int $id, bool $mark=true, ?Metrika\FieldsDto $metrikaFields=null)
Определения site.php:1667
static getPublicHash($id, $domain=null)
Определения site.php:941
static fullExport($siteForExport, $params=array())
Определения site.php:498
static touch(int $id)
Определения site.php:1642
static markDelete($id)
Определения site.php:360
static copyFolders(int $fromSite, int $toSite, array &$folderMap=[])
Определения site.php:1077
static changeCode(int $id, string $code)
Определения site.php:1945
static copy($siteId)
Определения site.php:437
static getFolder(int $folderId, string $accessLevel=Rights::ACCESS_TYPES['read'])
Определения site.php:1412
static randomizeDomain(int $siteId)
Определения site.php:1014
static saveAdditionalFields($id, array $data)
Определения site.php:272
static onBeforeMainSiteDelete($siteId)
Определения site.php:1847
static clearPing(int $id)
Определения site.php:63
static getVersion($siteId)
Определения site.php:218
static markFolderUnDelete(int $id)
Определения site.php:1511
static onMainSiteDelete($siteId)
Определения site.php:1876
static publicationFolder(int $folderId, bool $mark=true)
Определения site.php:1205
static markFolderDelete(int $id)
Определения site.php:1436
static get(int $id, bool $active=false, bool $force=false)
Определения syspage.php:100
static getForLanding($id)
Определения templateref.php:153
static getForSite($id)
Определения templateref.php:143
Определения result.php:20
fetch(\Bitrix\Main\Text\Converter $converter=null)
Определения result.php:179
Определения error.php:15
static update($primary, array $data)
Определения file.php:228
static getList(array $parameters=array())
Определения datamanager.php:431
$componentName
Определения component_props2.php:49
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
$result
Определения get_property_values.php:14
$pageId
Определения group_bizproc_log.php:3
$filter
Определения iblock_catalog_list.php:54
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
Определения options.php:195
const SITE_CHARSET
Определения include.php:62
$siteId
Определения ajax.php:8
const LICENSE_KEY($show_sql_stat=='Y')
Определения start.php:84
Определения cookies.php:2
Определения ufield.php:9
Определения buffer.php:3
$event
Определения prolog_after.php:141
if(empty($signedUserToken)) $key
Определения quickway.php:257
$i
Определения factura.php:643
$page
Определения order_form.php:33
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
$title
Определения pdf.php:123
$paths
Определения options.php:2080
$error
Определения subscription_card_product.php:20
$site
Определения yandex_run.php:614
$fields
Определения yandex_run.php:501