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;
44 private static $entityList = [
52 private static $accessManifest = [
63 private static $contextSiteId =
null;
80 return static::$entityList;
91 $additional = $request->get(
'additional');
92 $siteId = $additional[
'siteId'] ??
null;
95 foreach (self::$accessManifest as $code)
101 $langCode = mb_strtoupper(mb_substr($code, mb_strlen(self::PREFIX_CODE)));
106 'PLACEMENT' => [$code],
111 'DISABLE_CLEAR_FULL' =>
'Y',
112 'DISABLE_NEED_START_BTN' =>
'Y',
113 'COLOR' =>
'#ff799c',
114 'ICON' =>
'/bitrix/images/landing/landing_transfer.svg',
115 'TITLE' =>
Loc::getMessage(
'LANDING_TRANSFER_GROUP_TITLE_' . $langCode),
117 'EXPORT_TITLE_PAGE' =>
Loc::getMessage(
'LANDING_TRANSFER_EXPORT_ACTION_TITLE_BLOCK_' . $langCode),
118 'EXPORT_TITLE_BLOCK' =>
Loc::getMessage(
'LANDING_TRANSFER_EXPORT_ACTION_TITLE_BLOCK_' . $langCode),
119 'EXPORT_ACTION_DESCRIPTION' =>
Loc::getMessage(
'LANDING_TRANSFER_EXPORT_ACTION_DESCRIPTION_' . $langCode),
120 'IMPORT_TITLE_PAGE' =>
Loc::getMessage(
'LANDING_TRANSFER_IMPORT_ACTION_TITLE_BLOCK_' . $langCode),
121 'IMPORT_TITLE_BLOCK' =>
Loc::getMessage(
'LANDING_TRANSFER_IMPORT_ACTION_TITLE_BLOCK_' . $langCode),
122 'IMPORT_DESCRIPTION_UPLOAD' =>
Loc::getMessage(
'LANDING_TRANSFER_IMPORT_DESCRIPTION_UPLOAD_' . $langCode),
123 'IMPORT_DESCRIPTION_START' =>
' ',
124 'IMPORT_INSTALL_FINISH_TEXT' =>
'',
125 'IMPORT_TITLE_PAGE_CREATE' =>
Loc::getMessage(
'LANDING_TRANSFER_IMPORT_ACTION_TITLE_BLOCK_CREATE_' . $langCode),
126 'REST_IMPORT_AVAILABLE' =>
'Y',
127 'SITE_ID' => $siteId,
129 'MODULE_ID' =>
'landing',
131 '\Bitrix\Landing\Transfer\AppConfiguration',
138 return $manifestList;
149 if ($manifest[
'CODE'] ??
null)
152 \Bitrix\Landing\Site\Type::setScope($siteType);
155 $siteId = $manifest[
'SITE_ID'] ?? 0;
156 if ($type ===
'export')
184 self::$processing =
true;
186 if (in_array($code, static::$accessManifest))
188 if ($type ==
'EXPORT')
190 return Export\Site::getInitManifest($event);
192 else if ($type ==
'IMPORT')
194 return Import\Site::getInitManifest($event);
210 $access = array_intersect($manifest[
'USES'], static::$accessManifest);
212 self::$processing =
true;
214 if (Restriction\Manager::isAllowed(
'limit_sites_transfer'))
216 if ($access && isset(static::$entityList[$code]))
218 return Export\Site::nextStep($event);
232 self::$contextSiteId = $event->
getParameter(
'RATIO')[
'LANDING'][
'SITE_ID'] ??
null;
235 self::$processing =
true;
239 if (isset(static::$entityList[$code]))
241 return Import\Site::nextStep($event);
259 if (in_array($code, static::$accessManifest))
261 if ($type ==
'EXPORT')
265 $setting =
new Configuration\Setting($context);
267 if (!empty($manifest[
'SITE_ID']))
270 $res = Site::getList([
275 'ID' => $manifest[
'SITE_ID']
278 if ($row = $res->fetch())
280 $structure =
new Configuration\Structure($context);
281 $structure->setArchiveName(\CUtil::translit(
285 'replace_space' =>
'_',
286 'replace_other' =>
'_'
291 return Export\Site::onFinish($event);
293 else if ($type ==
'IMPORT')
295 return Import\Site::onFinish($event);
299 self::$processing =
false;
311 $checkExternal = self::$contextSiteId && ($file[
'ID'] ??
null);
312 $externalId = $checkExternal ? self::$contextSiteId .
'_' . $file[
'ID'] :
null;
316 $res = \CFile::getList([], [
'EXTERNAL_ID' => $externalId]);
317 if ($row = $res->fetch())
324 $fileData = \CFile::makeFileArray(
330 $fileData[
'name'] = $file[
'NAME'];
331 $fileData[
'external_id'] = $externalId;
333 if (\CFile::checkImageFile($fileData, 0, 0, 0, array(
'IMAGE')) ===
null)
335 $fileData[
'MODULE_ID'] =
'landing';
337 $fileId = (int)\CFile::saveFile($fileData, $fileData[
'MODULE_ID']);
static sanitizeFileName(string $fileName)
static disableCheckUniqueAddress()
static enableCheckUniqueAddress()
static getOperationsForSite($siteId)
static hasAdditionalRight($code, $type=null, bool $checkExtraRights=false, bool $strict=false)
static getManifestList(Event $event)
static onInitManifest(Event $event)
static onCheckAccess(string $type, array $manifest)
static onEventExportController(Event $event)
static onFinish(Event $event)
static saveFile(array $file)
const SYSTEM_BLOCK_REST_PENDING
const SYSTEM_COMPONENT_REST_PENDING
static onEventImportController(Event $event)
static loadMessages($file)
static getMessage($code, $replace=null, $language=null)