1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
appconfiguration.php
См. документацию.
1<?php
3
4use \Bitrix\Landing\File;
5use \Bitrix\Landing\Rights;
6use \Bitrix\Landing\Landing;
7use \Bitrix\Landing\Site;
8use \Bitrix\Landing\Restriction;
9use \Bitrix\Landing\Site\Type;
10use \Bitrix\Main\Application;
11use \Bitrix\Main\Event;
12use \Bitrix\Main\Localization\Loc;
13use \Bitrix\Rest\Configuration;
14
15Loc::loadMessages(__FILE__);
16
22{
26 const SYSTEM_BLOCK_REST_PENDING = 'system.rest.pending';
27 const SYSTEM_COMPONENT_REST_PENDING = 'bitrix:landing.rest.pending';
28
32 const PREFIX_CODE = 'landing_';
33
38 protected static $processing = false;
39
44 private static $entityList = [
45 'LANDING' => 500,
46 ];
47
52 private static $accessManifest = [
53 'total',
54 'landing_page',
55 'landing_store',
56 'landing_knowledge',
57 'landing_mainpage',
58 ];
59
64 private static $contextSiteId = null;
65
70 public static function inProcess(): bool
71 {
72 return self::$processing;
73 }
74
79 public static function getEntityList(): array
80 {
81 return static::$entityList;
82 }
83
89 public static function getManifestList(Event $event): array
90 {
91 $request = Application::getInstance()->getContext()->getRequest();
92 $additional = $request->get('additional');
93 $siteId = $additional['siteId'] ?? null;
94 $manifestList = [];
95
96 foreach (self::$accessManifest as $code)
97 {
98 if ($code == 'total')
99 {
100 continue;
101 }
102 $langCode = mb_strtoupper(mb_substr($code, mb_strlen(self::PREFIX_CODE)));
103 $manifestList[] = [
104 'CODE' => $code,
105 'VERSION' => 1,
106 'ACTIVE' => 'Y',
107 'PLACEMENT' => [$code],
108 'USES' => [
109 $code,
110 'app',
111 ],
112 'DISABLE_CLEAR_FULL' => 'Y',
113 'DISABLE_NEED_START_BTN' => 'Y',
114 'COLOR' => '#ff799c',
115 'ICON' => '/bitrix/images/landing/landing_transfer.svg',
116 'TITLE' => Loc::getMessage('LANDING_TRANSFER_GROUP_TITLE_' . $langCode),
117 //'DESCRIPTION' => Loc::getMessage('LANDING_TRANSFER_GROUP_DESC'),
118 'EXPORT_TITLE_PAGE' => Loc::getMessage('LANDING_TRANSFER_EXPORT_ACTION_TITLE_BLOCK_' . $langCode),
119 'EXPORT_TITLE_BLOCK' => Loc::getMessage('LANDING_TRANSFER_EXPORT_ACTION_TITLE_BLOCK_' . $langCode),
120 'EXPORT_ACTION_DESCRIPTION' => Loc::getMessage('LANDING_TRANSFER_EXPORT_ACTION_DESCRIPTION_' . $langCode),
121 'IMPORT_TITLE_PAGE' => Loc::getMessage('LANDING_TRANSFER_IMPORT_ACTION_TITLE_BLOCK_' . $langCode),
122 'IMPORT_TITLE_BLOCK' => Loc::getMessage('LANDING_TRANSFER_IMPORT_ACTION_TITLE_BLOCK_' . $langCode),
123 'IMPORT_DESCRIPTION_UPLOAD' => Loc::getMessage('LANDING_TRANSFER_IMPORT_DESCRIPTION_UPLOAD_' . $langCode),
124 'IMPORT_DESCRIPTION_START' => ' ',
125 'INSTALL_STEP' => Loc::getMessage('LANDING_TRANSFER_IMPORT_DESCRIPTION_STEP_' . $langCode),
126 'IMPORT_INSTALL_FINISH_TEXT' => '',
127 'IMPORT_TITLE_PAGE_CREATE' => Loc::getMessage('LANDING_TRANSFER_IMPORT_ACTION_TITLE_BLOCK_CREATE_' . $langCode),
128 'REST_IMPORT_AVAILABLE' => 'Y',
129 'SITE_ID' => $siteId,
130 'ACCESS' => [
131 'MODULE_ID' => 'landing',
132 'CALLBACK' => [
133 '\Bitrix\Landing\Transfer\AppConfiguration',
134 'onCheckAccess',
135 ],
136 ],
137 ];
138 }
139
140 return $manifestList;
141 }
142
149 public static function onCheckAccess(string $type, array $manifest): array
150 {
151 if ($manifest['CODE'] ?? null)
152 {
153 $siteType = substr($manifest['CODE'], strlen(AppConfiguration::PREFIX_CODE));
155 }
156
157 $siteId = $manifest['SITE_ID'] ?? 0;
158 if ($type === 'export')
159 {
161 if ($access)
162 {
163 $access = !Rights::hasAdditionalRight(Rights::ADDITIONAL_RIGHTS['unexportable'], null, false, true);
164 }
165 }
166 else
167 {
170 }
171 return [
172 'result' => $access,
173 ];
174 }
175
181 public static function onInitManifest(Event $event): ?array
182 {
183 $code = $event->getParameter('CODE');
184 $type = $event->getParameter('TYPE');
185
186 self::$processing = true;
187
188 if (in_array($code, static::$accessManifest))
189 {
190 if ($type == 'EXPORT')
191 {
193 }
194 else if ($type == 'IMPORT')
195 {
197 }
198 }
199
200 return null;
201 }
202
208 public static function onEventExportController(Event $event): ?array
209 {
210 $code = $event->getParameter('CODE');
211 $manifest = $event->getParameter('MANIFEST');
212 $access = array_intersect($manifest['USES'], static::$accessManifest);
213
214 self::$processing = true;
215
216 if (Restriction\Manager::isAllowed('limit_sites_transfer'))
217 {
218 if ($access && isset(static::$entityList[$code]))
219 {
221 }
222 }
223
224 return null;
225 }
226
232 public static function onEventImportController(Event $event): ?array
233 {
234 self::$contextSiteId = $event->getParameter('RATIO')['LANDING']['SITE_ID'] ?? null;
235 $code = $event->getParameter('CODE');
236
237 self::$processing = true;
238
239 Landing::disableCheckUniqueAddress();
240
241 if (isset(static::$entityList[$code]))
242 {
244 }
245
246 Landing::enableCheckUniqueAddress();
247
248 return null;
249 }
250
256 public static function onFinish(Event $event): array
257 {
258 $type = $event->getParameter('TYPE');
259 $code = $event->getParameter('MANIFEST_CODE');
260
261 if (in_array($code, static::$accessManifest))
262 {
263 if ($type == 'EXPORT')
264 {
265 // rename file to download
266 $context = $event->getParameter('CONTEXT_USER');
267 $setting = new Configuration\Setting($context);
268 $manifest = $setting->get(Configuration\Setting::SETTING_MANIFEST);
269 if (!empty($manifest['SITE_ID']))
270 {
271 Type::setScope($manifest['SITE_TYPE']);
272 $res = Site::getList([
273 'select' => [
274 'TITLE',
275 ],
276 'filter' => [
277 'ID' => $manifest['SITE_ID'],
278 ],
279 ]);
280 if ($row = $res->fetch())
281 {
282 $structure = new Configuration\Structure($context);
283 $structure->setArchiveName(\CUtil::translit(
284 trim($row['TITLE']),
285 'ru',
286 [
287 'replace_space' => '_',
288 'replace_other' => '_',
289 ]
290 ));
291 }
292 }
294 }
295 else if ($type == 'IMPORT')
296 {
298 }
299 }
300
301 self::$processing = false;
302
303 return [];
304 }
305
311 public static function saveFile(array $file): ?int
312 {
313 $checkExternal = self::$contextSiteId && ($file['ID'] ?? null);
314 $externalId = $checkExternal ? self::$contextSiteId . '_' . $file['ID'] : null;
315
316 if ($externalId)
317 {
318 $res = \CFile::getList([], ['EXTERNAL_ID' => $externalId]);
319 if ($row = $res->fetch())
320 {
321 return $row['ID'];
322 }
323 }
324
325 $fileId = null;
326 $fileData = \CFile::makeFileArray(
327 $file['PATH']
328 );
329
330 if ($fileData)
331 {
332 $fileData['name'] = $file['NAME'];
333 $fileData['external_id'] = $externalId;
334
335 if (\CFile::checkImageFile($fileData, 0, 0, 0, array('IMAGE')) === null)
336 {
337 $fileData['MODULE_ID'] = 'landing';
338 $fileData['name'] = File::sanitizeFileName($fileData['name']);
339 $fileId = (int)\CFile::saveFile($fileData, $fileData['MODULE_ID']);
340 if (!$fileId)
341 {
342 $fileId = null;
343 }
344 }
345 }
346
347 return $fileId;
348 }
349}
$type
Определения options.php:106
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
Определения catalog_reindex.php:36
static sanitizeFileName(string $fileName)
Определения file.php:54
const ADDITIONAL_RIGHTS
Определения rights.php:33
static getOperationsForSite($siteId)
Определения rights.php:520
static hasAdditionalRight($code, $type=null, bool $checkExtraRights=false, bool $strict=false)
Определения rights.php:1027
const ACCESS_TYPES
Определения rights.php:21
static setScope($scope, array $params=[])
Определения type.php:88
static getManifestList(Event $event)
Определения appconfiguration.php:89
static onInitManifest(Event $event)
Определения appconfiguration.php:181
static onCheckAccess(string $type, array $manifest)
Определения appconfiguration.php:149
static onEventExportController(Event $event)
Определения appconfiguration.php:208
static onFinish(Event $event)
Определения appconfiguration.php:256
static saveFile(array $file)
Определения appconfiguration.php:311
static onEventImportController(Event $event)
Определения appconfiguration.php:232
static nextStep(Event $event)
Определения site.php:241
static getInitManifest(Event $event)
Определения site.php:79
static onFinish(Event $event)
Определения site.php:329
static nextStep(Event $event)
Определения site.php:169
static getInitManifest(Event $event)
Определения site.php:59
static onFinish(Event $event)
Определения site.php:569
setScope($scope)
Определения controller.php:373
const SETTING_MANIFEST
Определения setting.php:14
</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
$context
Определения csv_new_setup.php:223
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
Определения options.php:195
if(!is_array($deviceNotifyCodes)) $access
Определения options.php:174
$siteId
Определения ajax.php:8
Определения buffer.php:3
$event
Определения prolog_after.php:141