Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
site.php
1<?php
2namespace Bitrix\Landing;
3
4use \Bitrix\Main\Localization\Loc;
5use \Bitrix\Main\Event;
6use \Bitrix\Main\EventResult;
7
8Loc::loadMessages(__FILE__);
9
11{
16 public static $internalClass = 'SiteTable';
17
22 protected static $pings = [];
23
30 public static function ping(int $id, bool $deleted = false): bool
31 {
32 if (array_key_exists($id, self::$pings))
33 {
34 return self::$pings[$id];
35 }
36
37 $filter = [
38 'ID' => $id
39 ];
40 if ($deleted)
41 {
42 $filter['=DELETED'] = ['Y', 'N'];
43 }
44
45 $check = Site::getList([
46 'select' => [
47 'ID'
48 ],
49 'filter' => $filter
50 ]);
51 self::$pings[$id] = (boolean) $check->fetch();
52
53 return self::$pings[$id];
54 }
55
61 protected static function clearPing(int $id): void
62 {
63 if (array_key_exists($id, self::$pings))
64 {
65 unset(self::$pings[$id]);
66 }
67 }
68
77 public static function getPublicUrl($id, bool $full = true, bool $hostInclude = true, bool $previewForNotActive = false)
78 {
79 $paths = [];
80 $isB24 = Manager::isB24();
81
82 $siteKeyCode = Site\Type::getKeyCode();
83 $defaultPubPath = rtrim(Manager::getPublicationPath(), '/');
84 $hostUrl = Domain::getHostUrl();
85 $disableCloud = Manager::isCloudDisable();
86 $res = self::getList(array(
87 'select' => array(
88 'DOMAIN_PROTOCOL' => 'DOMAIN.PROTOCOL',
89 'DOMAIN_NAME' => 'DOMAIN.DOMAIN',
90 'DOMAIN_ID',
91 'SMN_SITE_ID',
92 'CODE',
93 'TYPE',
94 'ACTIVE',
95 'DELETED',
96 'ID'
97 ),
98 'filter' => array(
99 'ID' => $id,
100 '=DELETED' => ['Y', 'N'],
101 'CHECK_PERMISSIONS' => 'N'
102 )
103 ));
104 while ($row = $res->fetch())
105 {
106 $pubPath = '';
107 $isB24localVar = $isB24;
108
109 if ($row['TYPE'] == 'SMN')
110 {
111 $isB24localVar = false;
112 }
113
114 if (!$isB24localVar || $disableCloud)
115 {
117 null,
118 $row['SMN_SITE_ID'] ? $row['SMN_SITE_ID'] : null
119 );
120 $pubPath = rtrim($pubPath, '/');
121 }
122
123 if ($siteKeyCode == 'ID')
124 {
125 $row['CODE'] = '/' . $row['ID'] . '/';
126 }
127
128 // force https
129 if (Manager::isHttps())
130 {
131 $row['DOMAIN_PROTOCOL'] = \Bitrix\Landing\Internals\DomainTable::PROTOCOL_HTTPS;
132 }
133
134 if ($row['DOMAIN_ID'])
135 {
136 $paths[$row['ID']] = ($hostInclude ? ($disableCloud ? $hostUrl : $row['DOMAIN_PROTOCOL'] . '://' . $row['DOMAIN_NAME']) : '') . $pubPath;
137 if ($full)
138 {
139 if ($disableCloud && $isB24localVar)
140 {
141 $paths[$row['ID']] .= $row['CODE'];
142 }
143 else if (!$isB24localVar)
144 {
145 $paths[$row['ID']] .= '/';
146 }
147 }
148 }
149 else
150 {
151 $paths[$row['ID']] = ($hostInclude ? $hostUrl : '') . $defaultPubPath . ($full ? $row['CODE'] : '');
152 }
153 if ($previewForNotActive && ($row['ACTIVE'] === 'N' || $row['DELETED'] === 'Y'))
154 {
155 $paths[$row['ID']] .= 'preview/' . self::getPublicHash($row['ID'], $row['DOMAIN_NAME']) . '/';
156 }
157 }
158
159 if (is_array($id))
160 {
161 return $paths;
162 }
163 else
164 {
165 return isset($paths[$id]) ? $paths[$id] : '';
166 }
167 }
168
174 public static function getPreview(int $siteId): string
175 {
176 $res = self::getList([
177 'select' => [
178 'LANDING_ID_INDEX'
179 ],
180 'filter' => [
181 'ID' => $siteId
182 ],
183 ]);
184 if ($row = $res->fetch())
185 {
186 if ($row['LANDING_ID_INDEX'])
187 {
188 return Landing::createInstance(0)->getPreview($row['LANDING_ID_INDEX']);
189 }
190 }
191
192 return Manager::getUrlFromFile('/bitrix/images/landing/nopreview.jpg');
193 }
194
200 public static function getHooks($id)
201 {
203 {
204 return [];
205 }
206
207 return Hook::getForSite($id);
208 }
209
215 public static function getVersion($siteId): int
216 {
217 static $versions;
218
219 if (isset($versions[$siteId]))
220 {
221 return $versions[$siteId];
222 }
223
224 $resSite = self::getList([
225 'select' => [
226 'VERSION'
227 ],
228 'filter' => [
229 '=ID' => $siteId
230 ]
231 ]);
232 if ($site = $resSite->fetch())
233 {
234 $versions[$siteId] = (int)$site['VERSION'];
235 }
236 else
237 {
238 $versions[$siteId] = 0;
239 }
240
241 return $versions[$siteId];
242 }
243
244
250 public static function getAdditionalFields($id)
251 {
252 $fields = array();
253
254 // now we can get additional fields only from hooks
255 foreach (self::getHooks($id) as $hook)
256 {
257 $fields += $hook->getPageFields();
258 }
259
260 return $fields;
261 }
262
269 public static function saveAdditionalFields($id, array $data)
270 {
271 // now we can get additional fields only from hooks
272 Hook::saveForSite($id, $data);
273 }
274
279 public static function getTypes()
280 {
281 static $types = null;
282
283 if ($types !== null)
284 {
285 return $types;
286 }
287
288 $types = array(
289 'PAGE' => Loc::getMessage('LANDING_TYPE_PAGE'),
290 'STORE' => Loc::getMessage('LANDING_TYPE_STORE'),
291 'SMN' => Loc::getMessage('LANDING_TYPE_SMN'),
292 'KNOWLEDGE' => Loc::getMessage('LANDING_TYPE_KNOWLEDGE'),
293 'GROUP' => Loc::getMessage('LANDING_TYPE_GROUP')
294 );
295
296 return $types;
297 }
298
303 public static function getDefaultType()
304 {
305 return 'PAGE';
306 }
307
314 public static function delete($id, $pagesDelete = false)
315 {
316 // first delete all pages if you want
317 if ($pagesDelete)
318 {
319 $res = Landing::getList([
320 'select' => [
321 'ID', 'FOLDER_ID'
322 ],
323 'filter' => [
324 'SITE_ID' => $id,
325 '=DELETED' => ['Y', 'N']
326 ]
327 ]);
328 while ($row = $res->fetch())
329 {
330 if ($row['FOLDER_ID'])
331 {
332 Landing::update($row['ID'], [
333 'FOLDER_ID' => 0
334 ]);
335 }
336 $resDel = Landing::delete($row['ID'], true);
337 if (!$resDel->isSuccess())
338 {
339 return $resDel;
340 }
341 }
342 }
343
344 // delete site
345 $result = parent::delete($id);
346 self::clearPing($id);
347
348 return $result;
349 }
350
356 public static function markDelete($id)
357 {
358 $event = new Event('landing', 'onBeforeSiteRecycle', array(
359 'id' => $id,
360 'delete' => 'Y'
361 ));
362 $event->send();
363
364 foreach ($event->getResults() as $result)
365 {
366 if ($result->getType() == EventResult::ERROR)
367 {
368 $return = new \Bitrix\Main\Result;
369 foreach ($result->getErrors() as $error)
370 {
371 $return->addError(
372 $error
373 );
374 }
375 return $return;
376 }
377 }
378
379 if (($currentScope = Site\Type::getCurrentScopeId()))
380 {
381 Agent::addUniqueAgent('clearRecycleScope', [$currentScope]);
382 }
383
384 $res = parent::update($id, array(
385 'DELETED' => 'Y'
386 ));
387 self::clearPing($id);
388
389 return $res;
390 }
391
397 public static function markUnDelete($id)
398 {
399 $event = new Event('landing', 'onBeforeSiteRecycle', array(
400 'id' => $id,
401 'delete' => 'N'
402 ));
403 $event->send();
404
405 foreach ($event->getResults() as $result)
406 {
407 if ($result->getType() == EventResult::ERROR)
408 {
409 $return = new \Bitrix\Main\Result;
410 foreach ($result->getErrors() as $error)
411 {
412 $return->addError(
413 $error
414 );
415 }
416 return $return;
417 }
418 }
419
420 $res = parent::update($id, array(
421 'DELETED' => 'N'
422 ));
423 self::clearPing($id);
424
425 return $res;
426 }
427
433 public static function copy($siteId)
434 {
435 $siteId = intval($siteId);
436 $result = new \Bitrix\Main\Result;
437 $error = new Error;
438
439 $siteRow = Site::getList([
440 'filter' => [
441 'ID' => $siteId
442 ]
443 ])->fetch();
444
445 if (!$siteRow)
446 {
447 $error->addError(
448 'SITE_NOT_FOUND',
449 Loc::getMessage('LANDING_COPY_ERROR_SITE_NOT_FOUND')
450 );
451 }
452 else
453 {
454 $result = Site::add([
455 'CODE' => $siteRow['CODE'],
456 'ACTIVE' => 'N',
457 'TITLE' => $siteRow['TITLE'],
458 'XML_ID' => $siteRow['XML_ID'],
459 'DESCRIPTION' => $siteRow['DESCRIPTION'],
460 'TYPE' => $siteRow['TYPE'],
461 'SMN_SITE_ID' => $siteRow['SMN_SITE_ID'],
462 'LANG' => $siteRow['LANG']
463 ]);
464
465 if ($result->isSuccess())
466 {
467 // copy hook data
469 $siteId,
470 $result->getId()
471 );
472 // copy files
474 $siteId,
475 $result->getId()
476 );
477 }
478 }
479
480 if (!$error->isEmpty())
481 {
482 $result->addError($error->getFirstError());
483 }
484
485 return $result;
486 }
487
494 public static function fullExport($siteForExport, $params = array())
495 {
496 $version = 3;//used in demo/class.php
497 $siteForExport = intval($siteForExport);
498 $tplsXml = array();
499 $export = array();
500 $editMode = isset($params['edit_mode']) && $params['edit_mode'] === 'Y';
501
502 Landing::setEditMode($editMode);
503 Hook::setEditMode($editMode);
504
505 if (!is_array($params))
506 {
507 $params = array();
508 }
509 $params['hooks_files'] = Hook::HOOKS_CODES_FILES;
510
511 if (isset($params['scope']))
512 {
513 Site\Type::setScope($params['scope']);
514 }
515
516 // check params
517 if (
518 !isset($params['hooks_disable']) ||
519 !is_array($params['hooks_disable'])
520 )
521 {
522 $params['hooks_disable'] = array();
523 }
524 if (
525 isset($params['code']) &&
526 preg_match('/[^a-z0-9]/i', $params['code'])
527 )
528 {
529 throw new \Bitrix\Main\Config\ConfigurationException(
530 Loc::getMessage('LANDING_EXPORT_ERROR')
531 );
532 }
533 // additional hooks for disable
534 $params['hooks_disable'][] = 'B24BUTTON_CODE';
535 $params['hooks_disable'][] = 'FAVICON_PICTURE';
536 // get all templates
537 $res = Template::getList(array(
538 'select' => array(
539 'ID', 'XML_ID'
540 )
541 ));
542 while ($row = $res->fetch())
543 {
544 $tplsXml[$row['ID']] = $row['XML_ID'];
545 }
546 // gets pages count
547 $res = Landing::getList(array(
548 'select' => array(
549 'CNT'
550 ),
551 'filter' => array(
552 'SITE_ID' => $siteForExport
553 ),
554 'runtime' => array(
555 new \Bitrix\Main\Entity\ExpressionField(
556 'CNT', 'COUNT(*)'
557 )
558 )
559 ));
560 if ($pagesCount = $res->fetch())
561 {
562 $pagesCount = $pagesCount['CNT'];
563 }
564 else
565 {
566 return array();
567 }
568 // get all pages from the site
569 $res = Landing::getList(array(
570 'select' => array(
571 'ID',
572 'CODE',
573 'RULE',
574 'TITLE',
575 'DESCRIPTION',
576 'TPL_ID',
577 'FOLDER_ID',
578 'SITE_ID',
579 'SITE_CODE' => 'SITE.CODE',
580 'SITE_TYPE' => 'SITE.TYPE',
581 'SITE_TPL_ID' => 'SITE.TPL_ID',
582 'SITE_TITLE' => 'SITE.TITLE',
583 'SITE_DESCRIPTION' => 'SITE.DESCRIPTION',
584 'LANDING_ID_INDEX' => 'SITE.LANDING_ID_INDEX',
585 'LANDING_ID_404' => 'SITE.LANDING_ID_404'
586 ),
587 'filter' => array(
588 'SITE_ID' => $siteForExport,
589 //'=ACTIVE' => 'Y',
590 //'=SITE.ACTIVE' => 'Y'
591 ),
592 'order' => array(
593 'ID' => 'asc'
594 )
595 ));
596 if (!($row = $res->fetch()))
597 {
598 return array();
599 }
600 do
601 {
602 if (empty($export))
603 {
604 $export = array(
605 'charset' => SITE_CHARSET,
606 'code' => isset($params['code'])
607 ? $params['code']
608 : trim($row['SITE_CODE'], '/'),
609 'code_mainpage' => '',
610 'site_code' => $row['SITE_CODE'],
611 'name' => isset($params['name'])
612 ? $params['name']
613 : $row['SITE_TITLE'],
614 'description' => isset($params['description'])
615 ? $params['description']
616 : $row['SITE_DESCRIPTION'],
617 'preview' => isset($params['preview'])
618 ? $params['preview']
619 : '',
620 'preview2x' => isset($params['preview2x'])
621 ? $params['preview2x']
622 : '',
623 'preview3x' => isset($params['preview3x'])
624 ? $params['preview3x']
625 : '',
626 'preview_url' => isset($params['preview_url'])
627 ? $params['preview_url']
628 : '',
629 'show_in_list' => 'Y',
630 'type' => mb_strtolower($row['SITE_TYPE']),
631 'version' => $version,
632 'fields' => array(
633 'ADDITIONAL_FIELDS' => array(),
634 'TITLE' => isset($params['name'])
635 ? $params['name']
636 : $row['SITE_TITLE'],
637 'LANDING_ID_INDEX' => $row['LANDING_ID_INDEX'],
638 'LANDING_ID_404' => $row['LANDING_ID_404']
639 ),
640 'layout' => array(),
641 'folders' => array(),
642 'syspages' => array(),
643 'items' => array()
644 );
645 // site tpl
646 if ($row['SITE_TPL_ID'])
647 {
648 $export['layout'] = array(
649 'code' => $tplsXml[$row['SITE_TPL_ID']],
650 'ref' => TemplateRef::getForSite($row['SITE_ID'])
651 );
652 }
653 // sys pages
654 foreach (Syspage::get($siteForExport) as $syspage)
655 {
656 $export['syspages'][$syspage['TYPE']] = $syspage['LANDING_ID'];
657 }
658 // site hooks
659 $hookFields = &$export['fields']['ADDITIONAL_FIELDS'];
660 foreach (Hook::getForSite($row['SITE_ID']) as $hookCode => $hook)
661 {
662 if ($hookCode == 'SETTINGS')
663 {
664 continue;
665 }
666 foreach ($hook->getFields() as $fCode => $field)
667 {
668 $hookCodeFull = $hookCode . '_' . $fCode;
669 if (!in_array($hookCodeFull, $params['hooks_disable']))
670 {
671 $hookFields[$hookCodeFull] = $field->getValue();
672 if (!$hookFields[$hookCodeFull])
673 {
674 unset($hookFields[$hookCodeFull]);
675 }
676 else if (
677 in_array($hookCodeFull, $params['hooks_files']) &&
678 intval($hookFields[$hookCodeFull]) > 0
679 )
680 {
681 $hookFields['~' . $hookCodeFull] = $hookFields[$hookCodeFull];
682 $hookFields[$hookCodeFull] = File::getFilePath(
683 $hookFields[$hookCodeFull]
684 );
685 if ($hookFields[$hookCodeFull])
686 {
687 $hookFields[$hookCodeFull] = Manager::getUrlFromFile(
688 $hookFields[$hookCodeFull]
689 );
690 }
691 }
692 }
693 }
694 }
695 unset($hookFields);
696 }
697 // fill one page
698 $export['items'][$row['ID']] = array(
699 'old_id' => $row['ID'],
700 'code' => $pagesCount > 1
701 ? $export['code'] . '/' . $row['CODE']
702 : $export['code'],
703 'name' => (isset($params['name']) && $pagesCount == 1)
704 ? $params['name']
705 : $row['TITLE'],
706 'description' => (isset($params['description']) && $pagesCount == 1)
707 ? $params['description']
708 : $row['DESCRIPTION'],
709 'preview' => (isset($params['preview']) && $pagesCount == 1)
710 ? $params['preview']
711 : '',
712 'preview2x' => (isset($params['preview2x']) && $pagesCount == 1)
713 ? $params['preview2x']
714 : '',
715 'preview3x' => (isset($params['preview3x']) && $pagesCount == 1)
716 ? $params['preview3x']
717 : '',
718 'preview_url' => (isset($params['preview_url']) && $pagesCount == 1)
719 ? $params['preview_url']
720 : '',
721 'show_in_list' => ($pagesCount == 1) ? 'Y' : 'N',
722 'type' => mb_strtolower($row['SITE_TYPE']),
723 'version' => $version,
724 'fields' => array(
725 'TITLE' => (isset($params['name']) && $pagesCount == 1)
726 ? $params['name']
727 : $row['TITLE'],
728 'RULE' => $row['RULE'],
729 'ADDITIONAL_FIELDS' => array(),
730 ),
731 'layout' => $row['TPL_ID']
732 ? array(
733 'code' => $tplsXml[$row['TPL_ID']],
734 'ref' => TemplateRef::getForLanding($row['ID'])
735 )
736 : array(),
737 'items' => array()
738 );
739 // special code for index page
740 if (
741 $pagesCount > 1 &&
742 $row['LANDING_ID_INDEX'] == $row['ID']
743 )
744 {
745 $export['code_mainpage'] = $row['CODE'];
746 }
747 // special pages
748 if ($row['LANDING_ID_INDEX'] == $row['ID'])
749 {
750 $export['fields']['LANDING_ID_INDEX'] = $export['items'][$row['ID']]['code'];
751 }
752 if ($row['LANDING_ID_404'] == $row['ID'])
753 {
754 $export['fields']['LANDING_ID_404'] = $export['items'][$row['ID']]['code'];
755 }
756 // page hooks
757 $hookFields = &$export['items'][$row['ID']]['fields']['ADDITIONAL_FIELDS'];
758 foreach (Hook::getForLanding($row['ID']) as $hookCode => $hook)
759 {
760 if ($hookCode == 'SETTINGS')
761 {
762 continue;
763 }
764 foreach ($hook->getFields() as $fCode => $field)
765 {
766 $hookCodeFull = $hookCode . '_' . $fCode;
767 if (!in_array($hookCodeFull, $params['hooks_disable']))
768 {
769 $hookFields[$hookCodeFull] = $field->getValue();
770 if (!$hookFields[$hookCodeFull])
771 {
772 unset($hookFields[$hookCodeFull]);
773 }
774 else if (
775 in_array($hookCodeFull, $params['hooks_files']) &&
776 intval($hookFields[$hookCodeFull]) > 0
777 )
778 {
779 $hookFields['~' . $hookCodeFull] = $hookFields[$hookCodeFull];
780 $hookFields[$hookCodeFull] = File::getFilePath(
781 $hookFields[$hookCodeFull]
782 );
783 if ($hookFields[$hookCodeFull])
784 {
785 $hookFields[$hookCodeFull] = Manager::getUrlFromFile(
786 $hookFields[$hookCodeFull]
787 );
788 }
789 }
790 }
791 }
792 }
793 unset($hookFields);
794 // folders
795 if ($row['FOLDER_ID'])
796 {
797 if (!isset($export['folders'][$row['FOLDER_ID']]))
798 {
799 $export['folders'][$row['FOLDER_ID']] = array();
800 }
801 $export['folders'][$row['FOLDER_ID']][] = $row['ID'];
802 }
803 // fill page with blocks
804 $landing = Landing::createInstance($row['ID']);
805 if ($landing->exist())
806 {
807 foreach ($landing->getBlocks() as $block)
808 {
809 if (!$block->isActive())
810 {
811 continue;
812 }
813 // repo blocks
814 $repoBlock = array();
815 if ($block->getRepoId())
816 {
817 $repoBlock = Repo::getBlock(
818 $block->getRepoId()
819 );
820 if ($repoBlock)
821 {
822 $repoBlock = array(
823 'app_code' => $repoBlock['block']['app_code'],
824 'xml_id' => $repoBlock['block']['xml_id']
825 );
826 }
827 }
828 $exportBlock = $block->export();
829 $exportItem = array(
830 'old_id' => $block->getId(),
831 'code' => $block->getCode(),
832 'access' => $block->getAccess(),
833 'anchor' => $block->getLocalAnchor(),
834 'repo_block' => $repoBlock,
835 'cards' => $exportBlock['cards'],
836 'nodes' => $exportBlock['nodes'],
837 'menu' => $exportBlock['menu'],
838 'style' => array_map(static function ($style){
839 if (is_array($style) && isset($style['classList']))
840 {
841 $style = $style['classList'];
842 }
843 return $style;
844 }, $exportBlock['style']),
845 'attrs' => $exportBlock['attrs'],
846 'dynamic' => $exportBlock['dynamic']
847 );
848 foreach ($exportItem as $key => $item)
849 {
850 if (!$item)
851 {
852 unset($exportItem[$key]);
853 }
854 }
855 $export['items'][$row['ID']]['items']['#block' . $block->getId()] = $exportItem;
856 }
857 }
858 }
859 while ($row = $res->fetch());
860
861 if ($export['code_mainpage'])
862 {
863 $export['code'] = $export['code'] . '/' . $export['code_mainpage'];
864 }
865 unset($export['code_mainpage']);
866
867 $pages = $export['items'];
868 $export['items'] = array();
869
870 // prepare for export tpls
871 if (isset($export['layout']['ref']))
872 {
873 foreach ($export['layout']['ref'] as &$lid)
874 {
875 if (isset($pages[$lid]))
876 {
877 $lid = $pages[$lid]['code'];
878 }
879 }
880 unset($lid);
881 }
882 // ... folders
883 $nCount = 0;
884 foreach ($export['folders'] as $folderId => $folderPages)
885 {
886 $export['folders']['n' . $nCount] = [];
887 foreach ($folderPages as $pageId)
888 {
889 if (isset($pages[$pageId]))
890 {
891 $export['folders']['n' . $nCount][] = $pages[$pageId]['code'];
892 }
893 }
894 unset($export['folders'][$folderId]);
895 $nCount++;
896 }
897 foreach ($export['folders'] as $folderId => $folderPages)
898 {
899 $export['folders'][$folderPages[0]] = $folderPages;
900 unset($export['folders'][$folderId]);
901 }
902 // ... syspages
903 foreach ($export['syspages'] as &$lid)
904 {
905 if (isset($pages[$lid]))
906 {
907 $lid = $pages[$lid]['code'];
908 }
909 }
910 unset($lid);
911 // ... pages
912 foreach ($pages as $page)
913 {
914 if (isset($page['layout']['ref']))
915 {
916 foreach ($page['layout']['ref'] as &$lid)
917 {
918 if (isset($pages[$lid]))
919 {
920 $lid = $pages[$lid]['code'];
921 }
922 }
923 unset($lid);
924 }
925 $export['items'][$page['code']] = $page;
926 }
927
928 return $export;
929 }
930
937 public static function getPublicHash($id, $domain = null)
938 {
939 static $hashes = [];
940 static $domains = [];
941
942 if (isset($hashes[$id]))
943 {
944 return $hashes[$id];
945 }
946
947 $hash = [];
948
949 if (Manager::isB24())
950 {
951 $hash[] = Manager::getHttpHost();
952 }
953 else
954 {
955 // detect domain
956 if ($domain === null)
957 {
958 if (!isset($domains[$id]))
959 {
960 $domains[$id] = '';
961 $res = self::getList(array(
962 'select' => array(
963 'SITE_DOMAIN' => 'DOMAIN.DOMAIN'
964 ),
965 'filter' => array(
966 'ID' => $id
967 )
968 ));
969 if ($row = $res->fetch())
970 {
971 $domains[$id] = $row['SITE_DOMAIN'];
972 }
973 }
974 $domain = $domains[$id];
975 }
976 $hash[] = $domain;
977 }
978
979 if (Manager::isB24())
980 {
981 $hash[] = rtrim(Manager::getPublicationPath($id), '/');
982 }
983 else
984 {
985 $hash[] = $id;
986 $hash[] = LICENSE_KEY;
987 }
988
989 $hashes[$id] = md5(implode('', $hash));
990
991 return $hashes[$id];
992 }
993
1000 public static function switchDomain(int $siteId1, int $siteId2): bool
1001 {
1002 return \Bitrix\Landing\Internals\SiteTable::switchDomain($siteId1, $siteId2);
1003 }
1004
1010 public static function randomizeDomain(int $siteId): bool
1011 {
1012 return \Bitrix\Landing\Internals\SiteTable::randomizeDomain($siteId);
1013 }
1014
1022 public static function addByTemplate(string $code, string $type, $additional = null): \Bitrix\Main\Entity\AddResult
1023 {
1024 $result = new \Bitrix\Main\Entity\AddResult;
1025
1026 $componentName = 'bitrix:landing.demo';
1027 $className = \CBitrixComponent::includeComponentClass($componentName);
1029 $demoCmp = new $className;
1030 $demoCmp->initComponent($componentName);
1031 $demoCmp->arParams = [
1032 'TYPE' => $type,
1033 'DISABLE_REDIRECT' => 'Y'
1034 ];
1035 $res = $demoCmp->actionSelect($code, $additional);
1036
1037 if ($res)
1038 {
1039 $resSite = self::getList([
1040 'select' => [
1041 'ID'
1042 ],
1043 'filter' => [
1044 '=TYPE' => $type
1045 ],
1046 'order' => [
1047 'ID' => 'desc'
1048 ]
1049 ]);
1050 if ($rowSite = $resSite->fetch())
1051 {
1052 $result->setId($rowSite['ID']);
1053 }
1054 }
1055 else
1056 {
1057 foreach ($demoCmp->getErrors() as $code => $title)
1058 {
1059 $result->addError(new \Bitrix\Main\Error($title, $code));
1060 }
1061 }
1062
1063 return $result;
1064 }
1065
1073 public static function copyFolders(int $fromSite, int $toSite, array &$folderMap = []): \Bitrix\Main\Result
1074 {
1075 $result = new \Bitrix\Main\Result();
1076 $fromSiteAccess = Site::ping($fromSite) && Rights::hasAccessForSite($fromSite, Rights::ACCESS_TYPES['read']);
1077 $toSiteAccess = Site::ping($toSite) && Rights::hasAccessForSite($toSite, Rights::ACCESS_TYPES['edit']);
1078
1079 if ($fromSiteAccess && $toSiteAccess)
1080 {
1081 Landing::disableCheckUniqueAddress();
1082
1083 $childrenExist = false;
1084 $res = Folder::getList([
1085 'filter' => [
1086 'SITE_ID' => $fromSite
1087 ]
1088 ]);
1089 while ($row = $res->fetch())
1090 {
1091 $oldId = $row['ID'];
1092 unset($row['ID']);
1093
1094 if ($row['PARENT_ID'])
1095 {
1096 $childrenExist = true;
1097 }
1098 else
1099 {
1100 unset($row['PARENT_ID']);
1101 }
1102
1103 if ($row['INDEX_ID'])
1104 {
1105 unset($row['INDEX_ID']);
1106 }
1107
1108 $row['SITE_ID'] = $toSite;
1109 $resAdd = Folder::add($row);
1110 $folderMap[$oldId] = $resAdd->isSuccess() ? $resAdd->getId() : null;
1111 }
1112
1113 // update child-parent
1114 if ($childrenExist)
1115 {
1116 $res = Folder::getList([
1117 'select' => [
1118 'ID', 'PARENT_ID'
1119 ],
1120 'filter' => [
1121 'SITE_ID' => $toSite,
1122 '!PARENT_ID' => false
1123 ]
1124 ]);
1125 while ($row = $res->fetch())
1126 {
1127 Folder::update($row['ID'], [
1128 'PARENT_ID' => $folderMap[$row['PARENT_ID']] ?: null
1129 ]);
1130 }
1131 }
1132
1133 Landing::enableCheckUniqueAddress();
1134 }
1135 else
1136 {
1137 $result->addError(new \Bitrix\Main\Error(
1138 Loc::getMessage('LANDING_COPY_ERROR_SITE_NOT_FOUND'),
1139 'ACCESS_DENIED'
1140 ));
1141 }
1142 return $result;
1143 }
1144
1151 public static function addFolder(int $siteId, array $fields): \Bitrix\Main\Entity\AddResult
1152 {
1153 if (self::ping($siteId) && Rights::hasAccessForSite($siteId, Rights::ACCESS_TYPES['edit']))
1154 {
1155 $fields['SITE_ID'] = $siteId;
1156 $result = Folder::add($fields);
1157 }
1158 else
1159 {
1160 $result = new \Bitrix\Main\Entity\AddResult;
1161 $result->addError(new \Bitrix\Main\Error(
1162 Loc::getMessage('LANDING_COPY_ERROR_SITE_NOT_FOUND'),
1163 'ACCESS_DENIED'
1164 ));
1165 }
1166 return $result;
1167 }
1168
1176 public static function updateFolder(int $siteId, int $folderId, array $fields): \Bitrix\Main\Entity\UpdateResult
1177 {
1178 if (self::ping($siteId) && Rights::hasAccessForSite($siteId, Rights::ACCESS_TYPES['edit']))
1179 {
1180 $fields['SITE_ID'] = $siteId;
1181 $result = Folder::update($folderId, $fields);
1182 }
1183 else
1184 {
1185 $result = new \Bitrix\Main\Entity\UpdateResult;
1186 $result->addError(new \Bitrix\Main\Error(
1187 Loc::getMessage('LANDING_COPY_ERROR_SITE_NOT_FOUND'),
1188 'ACCESS_DENIED'
1189 ));
1190 }
1191
1192 return $result;
1193 }
1194
1201 public static function publicationFolder(int $folderId, bool $mark = true): \Bitrix\Main\Result
1202 {
1203 $wasPublic = false;
1204 $result = new \Bitrix\Main\Result;
1205 $siteId = self::getFolder($folderId)['SITE_ID'] ?? null;
1206
1207 if ($siteId && self::ping($siteId) && Rights::hasAccessForSite($siteId, Rights::ACCESS_TYPES['public']))
1208 {
1209 $wasPublic = true;
1210 $breadCrumbs = Folder::getBreadCrumbs($folderId);
1211 if (!$breadCrumbs)
1212 {
1213 $wasPublic = false;
1214 }
1215 $char = $mark ? 'Y' : 'N';
1216 foreach ($breadCrumbs as $folder)
1217 {
1218 if ($folder['ACTIVE'] === $char)
1219 {
1220 continue;
1221 }
1222 if ($folder['DELETED'] === 'Y')
1223 {
1224 $result->addError(new \Bitrix\Main\Error(
1225 Loc::getMessage('LANDING_COPY_ERROR_FOLDER_NOT_FOUND'),
1226 'ACCESS_DENIED'
1227 ));
1228 return $result;
1229 }
1230 $res = Folder::update($folder['ID'], [
1231 'ACTIVE' => $char
1232 ]);
1233 if (!$res->isSuccess())
1234 {
1235 $wasPublic = false;
1236 }
1237 }
1238 }
1239
1240 if (!$wasPublic)
1241 {
1242 $result->addError(new \Bitrix\Main\Error(
1243 Loc::getMessage('LANDING_COPY_ERROR_FOLDER_NOT_FOUND'),
1244 'ACCESS_DENIED'
1245 ));
1246 }
1247
1248 return $result;
1249 }
1250
1258 public static function moveFolder(int $folderId, ?int $toFolderId, ?int $toSiteId = null): \Bitrix\Main\Result
1259 {
1260 $returnError = function()
1261 {
1262 $result = new \Bitrix\Main\Result;
1263 $result->addError(new \Bitrix\Main\Error(
1264 Loc::getMessage('LANDING_COPY_ERROR_FOLDER_NOT_FOUND'),
1265 'ACCESS_DENIED'
1266 ));
1267 return $result;
1268 };
1269
1270 $folder = Folder::getList([
1271 'filter' => [
1272 'ID' => $folderId
1273 ]
1274 ])->fetch();
1275 if ($folder)
1276 {
1277 // move to another site
1278 if ($toSiteId && (int)$folder['SITE_ID'] !== $toSiteId)
1279 {
1280 // check access to another site
1281 $hasRightFrom = Rights::hasAccessForSite($folder['SITE_ID'], Rights::ACCESS_TYPES['delete']);
1282 $hasRightTo = Rights::hasAccessForSite($toSiteId, Rights::ACCESS_TYPES['edit']);
1283 if (!$hasRightFrom || !$hasRightTo)
1284 {
1285 return $returnError();
1286 }
1287
1288 // check another site folder if specified
1289 $toFolder = null;
1290 if ($toFolderId)
1291 {
1292 $toFolder = Folder::getList([
1293 'filter' => [
1294 'ID' => $toFolderId,
1295 'SITE_ID' => $toSiteId
1296 ]
1297 ])->fetch();
1298 if (!$toFolder)
1299 {
1300 return $returnError();
1301 }
1302 }
1303
1304 // move folder
1305 $res = Folder::update($folderId, [
1306 'SITE_ID' => $toSiteId,
1307 'PARENT_ID' => $toFolder['ID'] ?? null
1308 ]);
1309 if ($res->isSuccess())
1310 {
1311 Folder::changeSiteIdRecursive($folderId, $toSiteId);
1312 }
1313
1314 return $res;
1315 }
1316
1317 $willBeRoot = !$toFolderId;
1318
1319 // check destination folder
1320 $toFolder = null;
1321 if ($toFolderId)
1322 {
1323 $toFolder = Folder::getList([
1324 'filter' => [
1325 'ID' => $toFolderId
1326 ]
1327 ])->fetch();
1328 if (!$toFolder)
1329 {
1330 return $returnError();
1331 }
1332 }
1333 if (!$toFolder)
1334 {
1335 $toFolder = $folder;
1336 }
1337 // check restriction to move to itself
1338 if (!$willBeRoot)
1339 {
1340 $breadCrumbs = Folder::getBreadCrumbs($toFolder['ID'], $toFolder['SITE_ID']);
1341 for ($i = 0, $c = count($breadCrumbs); $i < $c; $i++)
1342 {
1343 if ($breadCrumbs[$i]['ID'] === $folder['ID'])
1344 {
1345 $result = new \Bitrix\Main\Result;
1346 $result->addError(new \Bitrix\Main\Error(
1347 Loc::getMessage('LANDING_COPY_ERROR_MOVE_RESTRICTION'),
1348 'MOVE_RESTRICTION'
1349 ));
1350 return $result;
1351 }
1352 }
1353 }
1354 // check access and update then
1355 $hasRightFrom = Rights::hasAccessForSite($folder['SITE_ID'], Rights::ACCESS_TYPES['delete']);
1356 $hasRightTo = Rights::hasAccessForSite($toFolder['SITE_ID'], Rights::ACCESS_TYPES['edit']);
1357 if ($hasRightFrom && $hasRightTo)
1358 {
1359 return Folder::update($folderId, [
1360 'SITE_ID' => $toFolder['SITE_ID'],
1361 'PARENT_ID' => !$willBeRoot ? $toFolder['ID'] : null
1362 ]);
1363 }
1364 }
1365
1366 return $returnError();
1367 }
1368
1375 public static function getFolders(int $siteId, array $filter = []): array
1376 {
1377 if (!Rights::hasAccessForSite($siteId, Rights::ACCESS_TYPES['read']))
1378 {
1379 return [];
1380 }
1381
1382 if (!isset($filter['DELETED']) && !isset($filter['=DELETED']))
1383 {
1384 $filter['=DELETED'] = 'N';
1385 }
1386
1387 $folders = [];
1388 $filter['SITE_ID'] = $siteId;
1389 $res = Folder::getList([
1390 'filter' => $filter,
1391 'order' => [
1392 'DATE_MODIFY' => 'desc'
1393 ]
1394 ]);
1395 while ($row = $res->fetch())
1396 {
1397 $folders[$row['ID']] = $row;
1398 }
1399 return $folders;
1400 }
1401
1408 public static function getFolder(int $folderId, string $accessLevel = Rights::ACCESS_TYPES['read']): ?array
1409 {
1410 $folder = Folder::getList([
1411 'filter' => [
1412 'ID' => $folderId
1413 ]
1414 ])->fetch();
1415
1416 if ($folder)
1417 {
1418 if (!Rights::hasAccessForSite($folder['SITE_ID'], $accessLevel))
1419 {
1420 return null;
1421 }
1422 }
1423
1424 return is_array($folder) ? $folder : null;
1425 }
1426
1432 public static function markFolderDelete(int $id): \Bitrix\Main\Result
1433 {
1434 $folder = self::getFolder($id);
1435
1436 if (!$folder || !Rights::hasAccessForSite($folder['SITE_ID'], Rights::ACCESS_TYPES['delete']))
1437 {
1438 $result = new \Bitrix\Main\Entity\AddResult;
1439 $result->addError(new \Bitrix\Main\Error(
1440 Loc::getMessage('LANDING_COPY_ERROR_FOLDER_NOT_FOUND'),
1441 'ACCESS_DENIED'
1442 ));
1443 return $result;
1444 }
1445
1446 // disable delete if folder (or aby sub folders) contains area
1447 $res = Landing::getList([
1448 'select' => ['ID'],
1449 'filter' => [
1450 'FOLDER_ID' => [$id, ...Folder::getSubFolderIds($id)],
1451 '!==AREAS.ID' => null,
1452 ],
1453 ]);
1454 if ($res->fetch())
1455 {
1456 $result = new \Bitrix\Main\Entity\AddResult;
1457 $result->addError(new \Bitrix\Main\Error(
1458 Loc::getMessage('LANDING_DELETE_FOLDER_ERROR_CONTAINS_AREAS'),
1459 'FOLDER_CONTAINS_AREAS'
1460 ));
1461 return $result;
1462 }
1463
1464 $event = new Event('landing', 'onBeforeFolderRecycle', [
1465 'id' => $id,
1466 'delete' => 'Y'
1467 ]);
1468 $event->send();
1469
1470 foreach ($event->getResults() as $result)
1471 {
1472 if ($result->getType() == EventResult::ERROR)
1473 {
1474 $return = new \Bitrix\Main\Result;
1475 foreach ($result->getErrors() as $error)
1476 {
1477 $return->addError(
1478 $error
1479 );
1480 }
1481 return $return;
1482 }
1483 }
1484
1485 if (($currentScope = Site\Type::getCurrentScopeId()))
1486 {
1487 Agent::addUniqueAgent('clearRecycleScope', [$currentScope]);
1488 }
1489
1490 return Folder::update($id, [
1491 'DELETED' => 'Y'
1492 ]);
1493 }
1494
1500 public static function markFolderUnDelete(int $id): \Bitrix\Main\Result
1501 {
1502 $folder = self::getFolder($id);
1503
1504 if (!$folder || !Rights::hasAccessForSite($folder['SITE_ID'], Rights::ACCESS_TYPES['delete']))
1505 {
1506 $result = new \Bitrix\Main\Entity\AddResult;
1507 $result->addError(new \Bitrix\Main\Error(
1508 Loc::getMessage('LANDING_COPY_ERROR_FOLDER_NOT_FOUND'),
1509 'ACCESS_DENIED'
1510 ));
1511 return $result;
1512 }
1513
1514 $event = new Event('landing', 'onBeforeFolderRecycle', array(
1515 'id' => $id,
1516 'delete' => 'N'
1517 ));
1518 $event->send();
1519
1520 foreach ($event->getResults() as $result)
1521 {
1522 if ($result->getType() == EventResult::ERROR)
1523 {
1524 $return = new \Bitrix\Main\Result;
1525 foreach ($result->getErrors() as $error)
1526 {
1527 $return->addError(
1528 $error
1529 );
1530 }
1531 return $return;
1532 }
1533 }
1534
1535 return Folder::update($id, array(
1536 'DELETED' => 'N'
1537 ));
1538 }
1539
1547 public static function addLandingToMenu(int $siteId, array $data): void
1548 {
1549 Landing::setEditMode();
1550 $res = Landing::getList([
1551 'select' => [
1552 'ID'
1553 ],
1554 'filter' => [
1555 'SITE_ID' => $siteId,
1556 '!==AREAS.ID' => null
1557 ],
1558 ]);
1559 while ($row = $res->fetch())
1560 {
1561 $landing = Landing::createInstance($row['ID']);
1562 if ($landing->exist())
1563 {
1564 foreach ($landing->getBlocks() as $block)
1565 {
1566 $manifest = $block->getManifest();
1567 if (isset($manifest['menu']))
1568 {
1569 foreach ($manifest['menu'] as $menuSelector => $foo)
1570 {
1571 $block->updateNodes([
1572 $menuSelector => [
1573 [
1574 'text' => $data['TITLE'],
1575 'href' => '#landing' . $data['ID']
1576 ]
1577 ]
1578 ], ['appendMenu' => true]);
1579 $block->save();
1580 break 2;
1581 }
1582 }
1583 }
1584 }
1585 }
1586 }
1587
1593 public static function touch(int $id): void
1594 {
1595 static $touched = [];
1596
1597 if (isset($touched[$id]))
1598 {
1599 return;
1600 }
1601
1602 $touched[$id] = true;
1603
1604 self::update($id, [
1605 'TOUCH' => 'Y'
1606 ]);
1607 }
1608
1615 public static function publication(int $id, bool $mark = true): \Bitrix\Main\Result
1616 {
1617 $return = new \Bitrix\Main\Result;
1618
1619 if ($mark)
1620 {
1621 $verificationError = new Error();
1622 if (!Mutator::checkSiteVerification($id, $verificationError))
1623 {
1624 $return->addError($verificationError->getFirstError());
1625 return $return;
1626 }
1627 }
1628
1629 // work with pages
1630 $res = Landing::getList([
1631 'select' => [
1632 'ID', 'ACTIVE', 'PUBLIC'
1633 ],
1634 'filter' => [
1635 'SITE_ID' => $id,
1636 [
1637 'LOGIC' => 'OR',
1638 ['FOLDER_ID' => null],
1639 ['!FOLDER_ID' => Folder::getFolderIdsForSite($id, ['=DELETED' => 'Y']) ?: [-1]]
1640 ]
1641 ]
1642 ]);
1643 while ($row = $res->fetch())
1644 {
1645 if ($row['ACTIVE'] != 'Y')
1646 {
1647 $row['PUBLIC'] = 'N';
1648 }
1649 if ($row['PUBLIC'] == 'Y')
1650 {
1651 continue;
1652 }
1653 $landing = Landing::createInstance($row['ID'], [
1654 'skip_blocks' => true
1655 ]);
1656
1657 if ($mark)
1658 {
1659 $resPublication = $landing->publication();
1660 }
1661 else
1662 {
1663 $resPublication = $landing->unpublic();
1664 }
1665
1666 if (!$resPublication)
1667 {
1668 if (!$landing->getError()->isEmpty())
1669 {
1670 $error = $landing->getError()->getFirstError();
1671 $return->addError(new \Bitrix\Main\Error(
1672 $error->getMessage(),
1673 $error->getCode()
1674 ));
1675 return $return;
1676 }
1677 }
1678 }
1679
1680 $res = Folder::getList([
1681 'select' => [
1682 'ID'
1683 ],
1684 'filter' => [
1685 'SITE_ID' => $id,
1686 '=ACTIVE' => $mark ? 'N' : 'Y',
1687 '=DELETED' => 'N'
1688 ]
1689 ]);
1690 while ($row = $res->fetch())
1691 {
1692 Folder::update($row['ID'], [
1693 'ACTIVE' => $mark ? 'Y' : 'N'
1694 ]);
1695 }
1696
1697 return parent::update($id, [
1698 'ACTIVE' => $mark ? 'Y' : 'N'
1699 ]);
1700 }
1701
1707 public static function unpublic(int $id): \Bitrix\Main\Result
1708 {
1709 return self::publication($id, false);
1710 }
1711
1717 public static function getSiteIdByTemplate(string $tplCode): ?int
1718 {
1719 $site = \Bitrix\Landing\Site::getList([
1720 'select' => [
1721 'ID'
1722 ],
1723 'filter' => [
1724 '=TPL_CODE' => $tplCode
1725 ],
1726 'order' => [
1727 'ID' => 'desc'
1728 ]
1729 ])->fetch();
1730
1731 return $site['ID'] ?? null;
1732 }
1733
1739 public static function onBeforeMainSiteDelete($siteId)
1740 {
1741 $res = Landing::getList(array(
1742 'select' => array(
1743 'ID'
1744 ),
1745 'filter' => array(
1746 '=SITE.SMN_SITE_ID' => $siteId,
1747 'CHECK_PERMISSIONS' => 'N'
1748 )
1749 ));
1750
1751 if ($res->fetch())
1752 {
1753 Manager::getApplication()->throwException(
1754 Loc::getMessage('LANDING_CLB_ERROR_DELETE_SMN'),
1755 'ERROR_DELETE_SMN'
1756 );
1757 return false;
1758 }
1759
1760 return true;
1761 }
1762
1768 public static function onMainSiteDelete($siteId)
1769 {
1771
1772 $realSiteId = null;
1773 // delete pages
1774 $res = Landing::getList(array(
1775 'select' => array(
1776 'ID', 'SITE_ID'
1777 ),
1778 'filter' => array(
1779 '=SITE.SMN_SITE_ID' => $siteId,
1780 '=SITE.DELETED' => ['Y', 'N'],
1781 '=DELETED' => ['Y', 'N']
1782 )
1783 ));
1784 while ($row = $res->fetch())
1785 {
1786 $realSiteId = $row['SITE_ID'];
1787 Landing::delete($row['ID'], true);
1788 }
1789 // detect site
1790 if (!$realSiteId)
1791 {
1792 $res = self::getList(array(
1793 'select' => array(
1794 'ID'
1795 ),
1796 'filter' => array(
1797 '=SMN_SITE_ID' => $siteId,
1798 '=DELETED' => ['Y', 'N']
1799 )
1800 ));
1801 if ($row = $res->fetch())
1802 {
1803 $realSiteId = $row['ID'];
1804 }
1805 }
1806 // and delete site
1807 if ($realSiteId)
1808 {
1809 self::delete($realSiteId);
1810 }
1811
1812 Rights::setOn();
1813 }
1814
1821 public static function changeType(int $id, string $type): void
1822 {
1823 if (self::getTypes()[$type] ?? null)
1824 {
1825 parent::update($id, array(
1826 'TYPE' => $type
1827 ));
1828 }
1829 }
1830
1837 public static function changeCode(int $id, string $code): void
1838 {
1839 parent::update($id, array(
1840 'CODE' => $code
1841 ));
1842 }
1843}
static addUniqueAgent(string $funcName, array $params=[], int $time=7200, ?int $nextExecDelay=null)
Definition agent.php:27
addError($code, $message='')
Definition error.php:18
static copySiteFiles($from, $to)
Definition file.php:548
static getFilePath($fileId)
Definition file.php:600
static changeSiteIdRecursive(int $folderId, int $newSiteId)
Definition folder.php:39
static getBreadCrumbs(int $folderId, ?int $siteId=null)
Definition folder.php:134
static getSubFolderIds(int $folderId)
Definition folder.php:85
static getFolderIdsForSite(int $siteId, array $additionalFilter=[])
Definition folder.php:109
static copySite($from, $to)
Definition hook.php:410
static getForLanding($id)
Definition hook.php:275
const HOOKS_CODES_FILES
Definition hook.php:45
static getForSite($id)
Definition hook.php:251
static setEditMode(bool $mode=true)
Definition hook.php:232
static saveForSite(int $id, array $data)
Definition hook.php:764
static getApplication()
Definition manager.php:71
static getPublicationPath($siteCode=null, $siteId=null, $createPubPath=false)
Definition manager.php:396
static getUrlFromFile($file)
Definition manager.php:1067
static checkSiteVerification(int $_1798975350, Error $_268582848)
Definition mutator.php:1
static getBlock($id)
Definition repo.php:144
static hasAccessForSite($siteId, $accessType, $deleted=false)
Definition rights.php:544
static addFolder(int $siteId, array $fields)
Definition site.php:1151
static getHooks($id)
Definition site.php:200
static switchDomain(int $siteId1, int $siteId2)
Definition site.php:1000
static changeType(int $id, string $type)
Definition site.php:1821
static getFolders(int $siteId, array $filter=[])
Definition site.php:1375
static addLandingToMenu(int $siteId, array $data)
Definition site.php:1547
static updateFolder(int $siteId, int $folderId, array $fields)
Definition site.php:1176
static markUnDelete($id)
Definition site.php:397
static getSiteIdByTemplate(string $tplCode)
Definition site.php:1717
static getTypes()
Definition site.php:279
static $internalClass
Definition site.php:16
static getPreview(int $siteId)
Definition site.php:174
static getPublicUrl($id, bool $full=true, bool $hostInclude=true, bool $previewForNotActive=false)
Definition site.php:77
static getAdditionalFields($id)
Definition site.php:250
static moveFolder(int $folderId, ?int $toFolderId, ?int $toSiteId=null)
Definition site.php:1258
static getDefaultType()
Definition site.php:303
static ping(int $id, bool $deleted=false)
Definition site.php:30
static unpublic(int $id)
Definition site.php:1707
static publication(int $id, bool $mark=true)
Definition site.php:1615
static getPublicHash($id, $domain=null)
Definition site.php:937
static fullExport($siteForExport, $params=array())
Definition site.php:494
static touch(int $id)
Definition site.php:1593
static markDelete($id)
Definition site.php:356
static copyFolders(int $fromSite, int $toSite, array &$folderMap=[])
Definition site.php:1073
static changeCode(int $id, string $code)
Definition site.php:1837
static copy($siteId)
Definition site.php:433
static getFolder(int $folderId, string $accessLevel=Rights::ACCESS_TYPES['read'])
Definition site.php:1408
static randomizeDomain(int $siteId)
Definition site.php:1010
static saveAdditionalFields($id, array $data)
Definition site.php:269
static onBeforeMainSiteDelete($siteId)
Definition site.php:1739
static clearPing(int $id)
Definition site.php:61
static getVersion($siteId)
Definition site.php:215
static markFolderUnDelete(int $id)
Definition site.php:1500
static onMainSiteDelete($siteId)
Definition site.php:1768
static publicationFolder(int $folderId, bool $mark=true)
Definition site.php:1201
static markFolderDelete(int $id)
Definition site.php:1432
static get(int $id, bool $active=false, bool $force=false)
Definition syspage.php:100
static update($primary, array $data)
Definition file.php:228
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static getList(array $parameters=array())
addError(Error $error)
Definition result.php:50