2namespace Bitrix\Landing\PublicAction;
4use Bitrix\Landing\Hook;
5use Bitrix\Landing\Manager;
6use Bitrix\Landing\File;
7use Bitrix\Landing\Folder;
8use Bitrix\Landing\Metrika;
9use Bitrix\Landing\Site;
10use Bitrix\Landing\Block as BlockCore;
11use Bitrix\Landing\TemplateRef;
12use Bitrix\Landing\Landing as LandingCore;
13use Bitrix\Landing\PublicActionResult;
14use Bitrix\Landing\Internals\HookDataTable;
15use Bitrix\Landing\History;
16use Bitrix\Main\Localization\Loc;
18Loc::loadMessages(__FILE__);
29 $disallow = [
'RULE',
'TPL_CODE',
'ACTIVE',
'INITIATOR_APP_CODE',
'VIEWS'];
35 if (in_array(
$k, $disallow))
53 $landing = LandingCore::createInstance($lid, [
57 if ($landing->exist())
59 $result->setResult($landing->getPreview());
61 $result->setError($landing->getError());
74 $landing = LandingCore::createInstance($lid, [
78 if ($landing->exist())
81 $landing->getPublicUrl()
84 $result->setError($landing->getError());
98 $result->setResult(LandingCore::resolveIdByPublicUrl($landingUrl,
$siteId));
110 $landing = LandingCore::createInstance($lid, [
111 'skip_blocks' =>
true
114 if ($landing->exist())
116 $fields = $landing->getAdditionalFields($landing->getId());
129 $result->setError($landing->getError());
142 $landing = LandingCore::createInstance($lid, [
143 'skip_blocks' =>
true
146 if ($landing->exist())
150 subSection:
'from_editor',
153 if ($landing->publication(
null, $metrikaParams))
159 $result->setError($landing->getError());
172 $landing = LandingCore::createInstance($lid, [
173 'skip_blocks' =>
true
176 if ($landing->exist())
183 $result->setError($landing->getError());
197 LandingCore::setEditMode();
198 Hook::setEditMode(
true);
201 $landing = LandingCore::createInstance($lid);
202 if ($landing->exist())
219 if (isset(
$fields[
'AFTER_ID']))
221 $blocks = $landing->getBlocks();
222 if (isset($blocks[
$fields[
'AFTER_ID']]))
224 $data[
'SORT'] = $blocks[
$fields[
'AFTER_ID']]->getSort() + 1;
231 $preventHistory ? History::deactivate() : History::activate();
232 $newBlockId = $landing->addBlock(
$fields[
'CODE'] ??
'',
$data,
true);
233 $landing->resortBlocks();
237 isset(
$fields[
'RETURN_CONTENT']) &&
238 $fields[
'RETURN_CONTENT'] ==
'Y'
241 $return = BlockCore::getBlockContent($newBlockId,
true);
245 $return = $newBlockId;
249 $result->setError($landing->getError());
261 LandingCore::setEditMode();
264 $landing = LandingCore::createInstance($lid);
265 if ($landing->exist())
267 $result->setResult($landing->deleteBlock($block));
268 $landing->resortBlocks();
270 $result->setError($landing->getError());
284 LandingCore::setEditMode();
287 $landing = LandingCore::createInstance($lid);
288 if ($landing->exist())
290 $preventHistory ? History::deactivate() : History::activate();
292 $landing->markDeletedBlock($block, $mark)
294 $landing->resortBlocks();
296 $result->setError($landing->getError());
309 return self::markDeletedBlock($lid, $block,
false, $preventHistory);
322 $landing = LandingCore::createInstance($lid);
323 if ($landing->exist())
327 $result->setResult($landing->upBlock($block));
331 $result->setResult($landing->downBlock($block));
333 if ($landing->getError()->isEmpty())
335 $landing->resortBlocks();
338 $result->setError($landing->getError());
352 LandingCore::setEditMode();
353 $preventHistory ? History::deactivate() : History::activate();
355 return self::sort($lid, $block,
'up');
367 LandingCore::setEditMode();
368 $preventHistory ? History::deactivate() : History::activate();
370 return self::sort($lid, $block,
'down');
383 LandingCore::setEditMode();
384 $landing = LandingCore::createInstance($lid);
385 if ($landing->exist())
387 $result->setResult($landing->favoriteBlock($block, $meta));
389 $result->setError($landing->getError());
401 LandingCore::setEditMode();
402 $landing = LandingCore::createInstance(0);
403 $delResult = $landing->unFavoriteBlock($blockId);
406 $result->setResult($delResult);
410 $result->setError($landing->getError());
422 private static function activate($lid, $block,
$action)
425 $landing = LandingCore::createInstance($lid);
426 if ($landing->exist())
430 $result->setResult($landing->showBlock($block));
434 $result->setResult($landing->hideBlock($block));
437 $result->setError($landing->getError());
449 LandingCore::setEditMode();
450 return self::activate($lid, $block,
'show');
461 LandingCore::setEditMode();
462 return self::activate($lid, $block,
'hide');
475 $landing = LandingCore::createInstance($lid);
476 $afterId = (int)(
$params[
'AFTER_ID'] ?? 0);
477 if ($landing->exist())
481 $res = $landing->moveBlock((
int)$block, $afterId);
485 $res = $landing->copyBlock((
int)$block, $afterId);
491 isset(
$params[
'RETURN_CONTENT']) &&
492 $params[
'RETURN_CONTENT'] ==
'Y'
496 'result' =>
$res > 0,
497 'content' => BlockCore::getBlockContent(
$res,
true)
506 $result->setError($landing->getError());
525 LandingCore::setEditMode();
526 return self::changeParentOfBlock($lid, $block,
$params);
543 LandingCore::setEditMode();
544 return self::changeParentOfBlock($lid, $block,
$params);
557 LandingCore::setEditMode();
558 $landing = LandingCore::createInstance($lid);
560 if ($landing->exist())
562 $blocks = $landing->getBlocks();
563 if (isset(
$data[
'blocks']) && is_array(
$data[
'blocks']))
565 foreach (
$data[
'blocks'] as $block)
567 self::deleteBlock($lid, $block);
568 unset($blocks[$block]);
571 if (isset(
$data[
'images']) && is_array(
$data[
'images']))
573 foreach (
$data[
'images'] as $item)
575 if (isset($blocks[$item[
'block']]))
584 $result->setError($landing->getError());
598 $landingFake = LandingCore::createInstance(0);
603 if (
$params[
'filter'][
'SITE_ID'] ??
null)
612 [
'FOLDER_ID' =>
null],
617 if (isset(
$params[
'get_preview']))
619 $getPreview = !!
$params[
'get_preview'];
623 if (isset(
$params[
'get_urls']))
625 $getUrls = !!
$params[
'get_urls'];
629 if (isset(
$params[
'check_area']))
631 $checkArea = !!
$params[
'check_area'];
635 if (isset(
$params[
'filter'][
'CHECK_PERMISSIONS']))
637 unset(
$params[
'filter'][
'CHECK_PERMISSIONS']);
645 $params[
'select'][
'DOMAIN_ID'] =
'SITE.DOMAIN_ID';
647 while ($row =
$res->fetch())
649 $rows[$row[
'ID']] = $row;
652 if ($getPreview || $getUrls)
654 $publicUrls = LandingCore::createInstance(0)->getPublicUrl(array_keys(
$rows));
657 foreach (
$rows as $row)
659 if (isset($row[
'DATE_CREATE']))
661 $row[
'DATE_CREATE'] = (string) $row[
'DATE_CREATE'];
663 if (isset($row[
'DATE_MODIFY']))
665 $row[
'DATE_MODIFY'] = (string) $row[
'DATE_MODIFY'];
667 if ($getUrls && isset($row[
'ID']))
669 $row[
'PUBLIC_URL'] = $publicUrls[$row[
'ID']];
671 if ($getPreview && isset($row[
'ID']))
673 if ($row[
'DOMAIN_ID'] == 0)
675 \Bitrix\Landing\Hook::setEditMode(
true);
677 $row[
'PREVIEW'] = $landingFake->getPreview(
679 $row[
'DOMAIN_ID'] == 0,
680 $publicUrls[$row[
'ID']]
683 if ($checkArea && isset($row[
'ID']))
685 $data[$row[
'ID']] = $row;
700 foreach ($areas as $lid => $isA)
702 $data[$lid][
'IS_AREA'] = $isA;
722 if (isset(
$fields[
'BLOCK_ID']))
724 $blockId = (int)
$fields[
'BLOCK_ID'];
727 if (isset(
$fields[
'MENU_CODE']))
729 $menuCode =
$fields[
'MENU_CODE'];
733 if (!$blockId || !$menuCode || !is_string($menuCode))
743 $primary =
$event->getParameter(
'primary');
748 $landingId = BlockCore::getLandingIdByBlockId($blockId);
755 'href' =>
'#landing' . $primary[
'ID']
763 [
'appendMenu' =>
true]
782 $error = new \Bitrix\Landing\Error;
791 if (
$res->isSuccess())
814 $error = new \Bitrix\Landing\Error;
822 if (
$res->isSuccess())
827 isset(
$fields[
'ADD_IN_MENU']) &&
832 Site::addLandingToMenu(
$siteId, [
833 'ID' =>
$res->getId(),
856 $error = new \Bitrix\Landing\Error;
862 if (
$res->isSuccess())
880 public static function delete($lid)
883 $error = new \Bitrix\Landing\Error;
887 if (
$res->isSuccess())
910 $landing = LandingCore::createInstance($lid);
911 $result->setResult($landing->move($toSiteId ?:
null, $toFolderId ?:
null));
912 $result->setError($landing->getError());
924 public static function copy(
int $lid, ?
int $toSiteId =
null, ?
int $toFolderId =
null,
bool $skipSystem =
false):
PublicActionResult
928 LandingCore::disableCheckDeleted();
929 $landing = LandingCore::createInstance($lid);
930 $result->setResult($landing->copy($toSiteId ?:
null, $toFolderId ?:
null,
false,
Utils::isTrue($skipSystem)));
931 $result->setError($landing->getError());
932 LandingCore::enableCheckDeleted();
946 $error = new \Bitrix\Landing\Error;
950 $res = LandingCore::markDelete($lid);
954 $res = LandingCore::markUnDelete($lid);
956 if (
$res->isSuccess())
976 return self::markDelete($lid,
false);
989 static $internal =
true;
990 static $mixedParams = [
'picture'];
993 $error = new \Bitrix\Landing\Error;
996 $landing = LandingCore::createInstance($lid, [
997 'skip_blocks' =>
true
1000 if ($landing->exist())
1007 'id' => $file[
'ID'],
1008 'src' => $file[
'SRC']
1015 Loc::getMessage(
'LANDING_FILE_ERROR')
1021 $result->setError($landing->getError());
1034 static $internal =
true;
1036 $lid = intval($lid);
1038 $landing = LandingCore::createInstance($lid, [
1039 'skip_blocks' =>
true
1043 if ($landing->exist())
1050 'ENTITY_ID' => $lid,
1062 if ($row =
$res->fetch())
1064 $existsContent = $row[
'VALUE'];
1067 $found = preg_match_all(
1068 '#(<noscript>.*?<style.*?data-id="([^"]+)"[^>]*>[^<]+</style>)#is',
1074 foreach ($newFonts[1] as
$i => $newFont)
1076 if (mb_strpos($existsContent,
'"' . $newFonts[2][
$i] .
'"') ===
false)
1078 $existsContent .= $newFont;
1083 if ($existsContent != $row[
'VALUE'])
1085 HookDataTable::update(
1087 [
'VALUE' => $existsContent]
1099 Hook::setEditMode();
1100 Hook::publicationLanding($landing->getId());
1106 $result->setError($landing->getError());
static addToLanding($lid, $fileId)
static deleteFromBlock($blockId, $fileId=array())
static getFolderIdsForSite(int $siteId, array $additionalFilter=[])
static callback($code, $callback)
static getOption($code, $default=null)
static sanitize($value, &$bad=false, $splitter=' ')
static savePicture($file, $ext=false, $params=array())
static updateNodes($lid, $block, array $data, array $additional=array(), bool $preventHistory=false)
static removeEntities($lid, array $data)
static copy(int $lid, ?int $toSiteId=null, ?int $toFolderId=null, bool $skipSystem=false)
static showBlock($lid, $block)
static updateHead($lid, $content)
static addByTemplate($siteId, $code, array $fields=[])
static copyBlock($lid, $block, array $params=array())
static update($lid, array $fields)
static markUnDeletedBlock(int $lid, int $block, bool $preventHistory=false)
static unFavoriteBlock(int $blockId)
static getPublicUrl($lid)
static checkAddingInMenu(array $fields, ?bool &$willAdded=null)
static getList(array $params=[])
static hideBlock($lid, $block)
static clearDisallowFields(array $fields)
static markDelete($lid, $mark=true)
static downBlock(int $lid, int $block, bool $preventHistory=false)
static addBlock($lid, array $fields, bool $preventHistory=false)
static uploadFile($lid, $picture, $ext=false, array $params=array())
static getAdditionalFields($lid)
static resolveIdByPublicUrl(string $landingUrl, int $siteId)
static upBlock(int $lid, int $block, bool $preventHistory=false)
static favoriteBlock(int $lid, int $block, array $meta=[])
static move(int $lid, ?int $toSiteId=null, ?int $toFolderId=null)
static add(array $fields)
static moveBlock($lid, $block, array $params=array())
static deleteBlock($lid, $block)
static markUnDelete($lid)
static markDeletedBlock(int $lid, int $block, bool $mark=true, bool $preventHistory=false)
static landingIsArea(int|array $lid)
static update($primary, array $data)
static getList(array $parameters=array())
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
if(empty($signedUserToken)) $key
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']