Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
iblock.php
1<?php
3
4use \Bitrix\Landing\Internals\HookDataTable;
5
6class Iblock
7{
14 public static function getElementUrl($siteId, $elementId): string
15 {
16 $url = '';
17
18 \Bitrix\Landing\Rights::setGlobalOff();
19
20 if (is_string($siteId))
21 {
22 $res = \Bitrix\Landing\Site::getList([
23 'select' => ['ID'],
24 'filter' => ['=TPL_CODE' => $siteId],
25 'order' => ['ID' => 'desc']
26 ]);
27 if ($row = $res->fetch())
28 {
29 $siteId = $row['ID'];
30 }
31 }
32
33 $syspages = \Bitrix\Landing\Syspage::get($siteId);
34 if (isset($syspages['catalog']))
35 {
36 $landing = \Bitrix\Landing\Landing::createInstance(
37 $syspages['catalog']['LANDING_ID'],
38 ['skip_blocks' => true]
39 );
40 if ($landing->exist())
41 {
42 $url = \Bitrix\Landing\PublicAction\Utils::getIblockURL(
43 $elementId,
44 'detail'
45 );
46 $url = str_replace(
47 '#system_catalog',
48 $landing->getPublicUrl(),
49 $url
50 );
51 if (mb_substr($url, 0, 1) == '/')
52 {
53 $url = \Bitrix\Landing\Site::getPublicUrl(
54 $landing->getSiteId()
55 ) . $url;
56 }
57 }
58 }
59
60 \Bitrix\Landing\Rights::setGlobalOn();
61
62 return $url;
63 }
64
70 public static function onAfterIBlockSectionDelete(array $section): void
71 {
72 if ($section['ID'] ?? null)
73 {
74 $res = HookDataTable::getList([
75 'select' => [
76 'ID'
77 ],
78 'filter' => [
79 '=HOOK' => 'SETTINGS',
80 '=CODE' => 'SECTION_ID',
81 '=VALUE' => $section['ID']
82 ]
83 ]);
84 while ($row = $res->fetch())
85 {
86 HookDataTable::delete($row['ID'])->isSuccess();
87 }
88 }
89 }
90}
static getElementUrl($siteId, $elementId)
Definition iblock.php:14
static onAfterIBlockSectionDelete(array $section)
Definition iblock.php:70