1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
mainpage.php
См. документацию.
1<?php
2namespace Bitrix\Landing\Site\Scope;
3
4use Bitrix\Landing\Block\BlockRepo;
5use Bitrix\Landing\Role;
6use Bitrix\Landing\Manager;
7use Bitrix\Landing\Domain;
8use Bitrix\Landing\Site\Scope;
9use Bitrix\Main\Entity;
10use Bitrix\Main\Event;
11use Bitrix\Main\EventManager;
12
16class Mainpage extends Scope
17{
23 public static function init(array $params = [])
24 {
25 parent::init($params);
26 Role::setExpectedType(self::$currentScopeId);
27
28 $eventManager = EventManager::getInstance();
29 $eventManager->addEventHandler(
30 'landing',
31 'onBlockRepoSetFilters',
32 function(Event $event)
33 {
34 $result = new Entity\EventResult();
35 $result->modifyFields([
36 'ENABLE' => BlockRepo::FILTER_SKIP_COMMON_BLOCKS,
37 'DISABLE' => BlockRepo::FILTER_SKIP_HIDDEN_BLOCKS,
38 ]);
39
40 return $result;
41 }
42 );
43 }
44
49 public static function getPublicationPath()
50 {
51 return '/vibe/';
52 }
53
58 public static function getKeyCode()
59 {
60 return 'CODE';
61 }
62
67 public static function getDomainId()
68 {
69 if (!Manager::isB24())
70 {
71 return Domain::getCurrentId();
72 }
73
74 return 0;
75 }
76
81 public static function getFilterType()
82 {
83 return self::getCurrentScopeId();
84 }
85
90 public static function getExcludedHooks(): array
91 {
92 return [
93 'B24BUTTON',
94 'COPYRIGHT',
95 'CSSBLOCK',
96 'COOKIES',
97 'FAVICON',
98 'GACOUNTER',
99 'GTM',
100 'HEADBLOCK',
101 'METAGOOGLEVERIFICATION',
102 'METAMAIN',
103 'METAROBOTS',
104 'METAYANDEXVERIFICATION',
105 'PIXELFB',
106 'PIXELVK',
107 'ROBOTS',
108 'SETTINGS',
109 'SPEED',
110 'TRANSITION',
111 'THEMEFONTS',
112 'UP',
113 'YACOUNTER',
114 ];
115 }
116
122 public static function prepareBlockManifest(array $manifest): array
123 {
124 $allowedManifestKeys = [
125 'block',
126 'cards',
127 'nodes',
128 'style',
129 'assets',
130 'callbacks',
131 ];
132 $manifest = array_filter(
133 $manifest,
134 function ($key) use ($allowedManifestKeys) {
135 return in_array(mb_strtolower($key), $allowedManifestKeys);
136 },
137 ARRAY_FILTER_USE_KEY
138 );
139
140 $manifest['block']['type'] = (array)$manifest['block']['type'];
141
142 // not all assets allowed
143 if (isset($manifest['assets']))
144 {
145 $allowedExt = [
146 'landing.widgetvue',
147 'landing_inline_video',
148 'landing_carousel',
149 ];
150 $manifest['assets'] = [
151 'ext' => array_filter(
152 (array)$manifest['assets']['ext'],
153 function ($item) use ($allowedExt)
154 {
155 return in_array(mb_strtolower($item), $allowedExt);
156 }
157 ),
158 ];
159
160 if (empty($manifest['assets']['ext']))
161 {
162 unset($manifest['assets']);
163 }
164 }
165
166 // unset not allowed subtypes
167 if (isset($manifest['block']['subtype']))
168 {
169 $allowedSubtypes = [
170 'widgetvue',
171 ];
172 $manifest['block']['subtype'] = array_filter(
173 (array)$manifest['block']['subtype'],
174 function ($item) use ($allowedSubtypes) {
175 return in_array(mb_strtolower($item), $allowedSubtypes);
176 }
177 );
178 }
179 if (empty($manifest['block']['subtype']))
180 {
181 unset($manifest['block']['subtype'], $manifest['block']['subtype_params']);
182 }
183
184 // unset not allowed callbacks
185 if (isset($manifest['callbacks']))
186 {
187 $allowedCallbacks = [
188 'afteradd',
189 'beforeview',
190 ];
191 $manifest['callbacks'] = array_filter(
192 (array)$manifest['callbacks'],
193 function ($item) use ($allowedCallbacks) {
194 return in_array(mb_strtolower($item), $allowedCallbacks);
195 },
196 ARRAY_FILTER_USE_KEY
197 );
198
199 if (empty($manifest['callbacks']))
200 {
201 unset($manifest['callbacks']);
202 }
203 }
204
205 //unset not allowed style
206 $allowedStyles = [
207 //for landing block
208 'background',
209 'color',
210 'background-color',
211 'padding-top',
212 'padding-bottom',
213 'padding-left',
214 'padding-right',
215 'margin-top',
216 'margin-bottom',
217 'margin-left',
218 'margin-right',
219 'text-align',
220 'font-family',
221 //for widget
222 'widget',
223 'widget-type',
224 //for separators
225 'fill-first',
226 'fill-second',
227 'height-increased--md',
228 ];
229
230 if (isset($manifest['style']['block']['type']))
231 {
232 $manifest['style']['block']['type'] = (array)$manifest['style']['block']['type'];
233 $manifest['block']['section'] = (array)$manifest['block']['section'];
234 $filtered = array_intersect($manifest['style']['block']['type'], $allowedStyles);
235 $manifest['style']['block']['type'] = array_values($filtered);
236 if (
237 !in_array('widget-type', $manifest['style']['block']['type'], true)
238 && !in_array('widgets_separators', $manifest['block']['section'], true)
239 )
240 {
241 $manifest['style']['block']['type'][] = 'widget-type';
242 }
243 }
244
245 foreach (($manifest['style']['nodes'] ?? []) as &$node)
246 {
247 $node['type'] = (array)$node['type'];
248 $node['type'] = array_values(array_intersect($node['type'], $allowedStyles));
249 }
250 unset($node);
251
252 // if manifest not exist in style sections block and nodes
253 if (
254 isset($manifest['style'])
255 && !isset($manifest['style']['block'])
256 && !isset($manifest['style']['nodes'])
257 )
258 {
259 foreach ($manifest['style'] as &$node)
260 {
261 $node['type'] = (array)$node['type'];
262 $node['type'] = array_values(array_intersect($node['type'], $allowedStyles));
263 }
264 unset($node);
265 }
266
267 return $manifest;
268 }
269}
static isB24()
Определения manager.php:1135
static setExpectedType($type)
Определения role.php:537
static getPublicationPath()
Определения mainpage.php:49
static getExcludedHooks()
Определения mainpage.php:90
static init(array $params=[])
Определения mainpage.php:23
static getFilterType()
Определения mainpage.php:81
static getKeyCode()
Определения mainpage.php:58
static getDomainId()
Определения mainpage.php:67
static prepareBlockManifest(array $manifest)
Определения mainpage.php:122
Определения event.php:5
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
$event
Определения prolog_after.php:141
if(empty($signedUserToken)) $key
Определения quickway.php:257
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
$eventManager
Определения include.php:412