19 public static function exportLanding(
int $landingId,
string $fileName): ?array
31 $landing[
'DATE_CREATE'] = (string)$landing[
'DATE_CREATE'];
32 $landing[
'DATE_MODIFY'] = (string)$landing[
'DATE_MODIFY'];
33 $landing[
'DATE_PUBLIC'] = (string)$landing[
'DATE_PUBLIC'];
40 if ($hookCode ==
'SETTINGS')
44 foreach ($hook->getFields() as $fCode => $field)
46 $hookCodeFull = $hookCode .
'_' . $fCode;
47 $hookFields[$hookCodeFull] = $field->getValue();
48 if (!$hookFields[$hookCodeFull])
50 unset($hookFields[$hookCodeFull]);
54 if ($hookFields[$hookCodeFull] > 0)
56 $files[] = [
'ID' => $hookFields[$hookCodeFull]];
61 $landing[
'ADDITIONAL_FIELDS'] = $hookFields;
64 $landing[
'TEMPLATE_REF'] = [];
65 if ($landing[
'TPL_ID'])
70 $landingInstance = LandingCore::createInstance($landingId);
73 if ($landing[
'TPL_CODE'])
75 $tplCode = $landing[
'TPL_CODE'];
76 if (strpos($tplCode,
'@'))
78 [, $tplCode] = explode(
'@', $tplCode);
80 foreach (Block::getFavorites($tplCode) as $row)
82 $landingInstance->addBlockToCollection(
new Block($row[
'ID']));
87 $landing[
'BLOCKS'] = [];
88 foreach ($landingInstance->getBlocks() as $block)
90 if (!$block->isActive())
97 if ($block->getRepoId())
105 'app_code' => $repoBlock[
'block'][
'app_code'],
106 'xml_id' => $repoBlock[
'block'][
'xml_id']
112 if ($block->getRepoId())
118 'NAME' => $repoInfo[
'NAME'],
119 'DESCRIPTION' => $repoInfo[
'DESCRIPTION'],
120 'SECTIONS' => $repoInfo[
'SECTIONS'],
121 'PREVIEW' => $repoInfo[
'PREVIEW'],
122 'MANIFEST' => $repoInfo[
'MANIFEST'],
123 'CONTENT' => $repoInfo[
'CONTENT']
132 $metaBlock = $block->getMeta();
133 $exportBlock = $block->export();
135 'code' => $block->getCode(),
136 'old_id' => $block->getId(),
137 'access' => $block->getAccess(),
138 'anchor' => $block->getLocalAnchor(),
139 'designed' => $block->isDesigned(),
140 'meta' => $metaBlock,
141 'full_content' => $block->isDesigned() ? $block->getContent() :
null,
142 'repo_block' => $repoBlock,
143 'repo_info' => $repoInfo,
144 'cards' => $exportBlock[
'cards'],
145 'nodes' => $exportBlock[
'nodes'],
146 'menu' => $exportBlock[
'menu'],
147 'style' => $exportBlock[
'style'],
148 'attrs' => $exportBlock[
'attrs'],
149 'dynamic' => $exportBlock[
'dynamic']
152 foreach ($exportItem as $key => $item)
156 unset($exportItem[$key]);
159 $landing[
'BLOCKS'][$block->getId()] = $exportItem;
165 foreach ($blockFiles as $fileId)
167 $files[] = [
'ID' => $fileId];
170 if (intval($metaBlock[
'FAVORITE_META'][
'preview'] ?? 0) > 0)
172 $files[] = [
'ID' => intval($metaBlock[
'FAVORITE_META'][
'preview'])];
177 'FILE_NAME' => str_replace(
178 [
'#site_id#',
'#landing_id#'],
179 [$landing[
'SITE_ID'], $landing[
'ID']],
182 'CONTENT' => $landing,