1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
intranet.php
См. документацию.
1<?php
2namespace Bitrix\Landing\Connector;
3
4use \Bitrix\Landing\Rights;
5use \Bitrix\Main\Loader;
6use \Bitrix\Main\Localization\Loc;
7use \Bitrix\Landing\Binding;
8use \Bitrix\Landing\Restriction;
9use \Bitrix\Intranet\Binding\Menu;
10
11Loc::loadMessages(__FILE__);
12
14{
18 const PATH_SERVICE_LIST = 'kb/binding/menu/';
19
25 protected static function getMenuItemBind(string $bindCode): array
26 {
27 $setItems = [];
28 if (
29 Rights::hasAdditionalRight('extension', null, false, true)
30 && (
31 !Loader::includeModule('intranet')
32 || Restriction\ToolAvailabilityManager::getInstance()->check('knowledge_base')
33 )
34 )
35 {
36 $setItems[] = [
37 'id' => 'landing_bind',
38 'system' => true,
39 'text' => Loc::getMessage('LANDING_CONNECTOR_INTRANET_MENU_BIND_TITLE'),
40 'onclick' => 'BX.SidePanel.Instance.open(\'' . SITE_DIR . self::PATH_SERVICE_LIST .
41 '?menuId=' . $bindCode . '\', {allowChangeHistory: false});',
42 'sectionCode' => Menu::SECTIONS['knowledge']
43 ];
44 if (Rights::hasAdditionalRight('create', null, false, true))
45 {
46 $setItems[] = [
47 'id' => 'landing_create',
48 'system' => true,
49 'text' => Loc::getMessage('LANDING_CONNECTOR_INTRANET_MENU_BIND_CREATE_TITLE'),
50 'onclick' => 'BX.SidePanel.Instance.open(\'' . SITE_DIR . self::PATH_SERVICE_LIST .
51 '?menuId=' . $bindCode . '&create=Y\', {allowChangeHistory: false});',
52 'sectionCode' => Menu::SECTIONS['knowledge']
53 ];
54 }
55 }
56 return $setItems;
57 }
58
66 protected static function getMenuItemUnbind(string $bindCode, string $entityId, string $title): array
67 {
68 return [
69 'id' => 'landing_unbind_' . $entityId,
70 'system' => true,
71 'text' => $title,
72 'onclick' => 'BX.Landing.Connector.Intranet.unbindMenuItem("' . $bindCode . '", "' . $entityId . '", "' . \CUtil::JSEscape($title) . '");'
73 ];
74 }
75
81 public static function onBuildBindingMenu(\Bitrix\Main\Event $event): array
82 {
83 \CJSCore::init('sidepanel');
85 \Bitrix\Landing\Site\Type::SCOPE_CODE_KNOWLEDGE
86 );
87
88 $bindings = Binding\Menu::getList(null);
89
90 // associate different bindings
91 $bindingsAssoc = [];
92 foreach ($bindings as $binding)
93 {
94 if (!isset($bindingsAssoc[$binding['BINDING_ID']]))
95 {
96 $bindingsAssoc[$binding['BINDING_ID']] = [];
97 }
98 $bindingsAssoc[$binding['BINDING_ID']][] = $binding;
99 }
100 $bindings = $bindingsAssoc;
101 unset($bindingsAssoc);
102
103 // init vars
104 $items = [];
105 $bindingMap = Menu::getMap();
106
107 // build binding map
108 foreach ($bindingMap as $sectionCode => $bindingSection)
109 {
110 foreach ($bindingSection['items'] as $itemCode => $foo)
111 {
112 $menuItems = [];
113 $unbindItems = [];
114 $bindingCode = $sectionCode . ':' . $itemCode;
115 if (isset($bindings[$bindingCode]))
116 {
117 foreach ($bindings[$bindingCode] as $bindingItem)
118 {
119 $menuItems[] = [
120 'id' => 'landing_' . $bindingItem['ENTITY_TYPE'] . $bindingItem['ENTITY_ID'],
121 'text' => \htmlspecialcharsbx($bindingItem['TITLE']),
122 'href' => $bindingItem['PUBLIC_URL'],
123 'sectionCode' => Menu::SECTIONS['knowledge']
124 ];
125 $unbindItems[] = self::getMenuItemUnbind(
126 $bindingCode,
127 $bindingItem['ENTITY_TYPE'] . '_' . $bindingItem['ENTITY_ID'],
128 $bindingItem['TITLE']
129 );
130 }
131 }
132 $menuItems = array_merge(
133 $menuItems,
134 self::getMenuItemBind($bindingCode)
135 );
136 if (isset($bindings[$bindingCode]) && Rights::hasAdditionalRight('extension', null, false, true))
137 {
138 $menuItems[] = [
139 'id' => 'landing_unbind',
140 'extension' => 'landing.connector.intranet',
141 'text' => Loc::getMessage('LANDING_CONNECTOR_INTRANET_MENU_HIDE_TITLE'),
142 'items' => $unbindItems,
143 'sectionCode' => Menu::SECTIONS['knowledge']
144 ];
145 }
146 $items[] = [
147 'bindings' => [
148 $sectionCode => [
149 'include' => [
150 $itemCode
151 ]
152 ]
153 ],
154 'items' => $menuItems
155 ];
156 }
157 }
158
160
161 return $items;
162 }
163}
const PATH_SERVICE_LIST
Определения intranet.php:18
static onBuildBindingMenu(\Bitrix\Main\Event $event)
Определения intranet.php:81
static getMenuItemUnbind(string $bindCode, string $entityId, string $title)
Определения intranet.php:66
static getMenuItemBind(string $bindCode)
Определения intranet.php:25
static hasAdditionalRight($code, $type=null, bool $checkExtraRights=false, bool $strict=false)
Определения rights.php:1027
static clearScope()
Определения type.php:109
static setScope($scope, array $params=[])
Определения type.php:88
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
const SITE_DIR(!defined('LANG'))
Определения include.php:72
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
Определения cookies.php:2
Определения agent.php:3
Определения buffer.php:3
$entityId
Определения payment.php:4
$event
Определения prolog_after.php:141
$items
Определения template.php:224
$title
Определения pdf.php:123