1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
EditMapAction.php
См. документацию.
1<?php
2
3namespace Bitrix\Landing\History\Action;
4
5use Bitrix\Landing\Block;
6use Bitrix\Landing\Node;
7use Bitrix\Main\Web\Json;
8
10{
11 protected const JS_COMMAND = 'editMap';
12
13 public function execute(bool $undo = true): bool
14 {
15 $block = new Block((int)$this->params['block']);
16 $selector = $this->params['selector'] ?: '';
17 $position = (int)($this->params['position'] ?: 0);
18 $value = $undo ? $this->params['valueBefore'] : $this->params['valueAfter'];
19
20 if ($selector)
21 {
22 $doc = $block->getDom();
23 $resultList = $doc->querySelectorAll($selector);
24 if (isset($resultList[$position]))
25 {
26 Node\Map::saveNode($block, $selector, [
27 $position => $value
28 ]);
29
30 $block->saveContent($doc->saveHTML());
31
32 return $block->save();
33 }
34 }
35
36 return false;
37 }
38
39 public static function enrichParams(array $params): array
40 {
44 $block = $params['block'];
45
46 return [
47 'block' => $block->getId(),
48 'selector' => $params['selector'] ?: '',
49 'position' => $params['position'] ?: 0,
50 'lid' => $block->getLandingId(),
51 'valueAfter' => $params['valueAfter'] ?: '',
52 'valueBefore' => $params['valueBefore'] ?: '',
53 ];
54 }
55
60 public function getJsCommand(bool $undo = true): array
61 {
62 $params = parent::getJsCommand($undo);
63
64 $params['params']['selector'] .= '@' . $params['params']['position'];
65 $params['params']['value'] =
66 $undo
67 ? $params['params']['valueBefore']
68 : $params['params']['valueAfter']
69 ;
70 $params['params']['value'] = Json::decode($params['params']['value']);
71
72 unset(
73 $params['params']['valueAfter'],
74 $params['params']['valueBefore'],
75 $params['params']['position'],
76 );
77
78 return $params;
79 }
80
87 public static function compareParams(array $oldParams, array $newParams): bool
88 {
89 unset($oldParams['valueBefore'], $newParams['valueBefore']);
90
91 return $oldParams === $newParams;
92 }
93}
getJsCommand(bool $undo=true)
Определения EditMapAction.php:60
static compareParams(array $oldParams, array $newParams)
Определения EditMapAction.php:87
static saveNode(\Bitrix\Landing\Block $block, $selector, array $data)
Определения map.php:26
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799