1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
EditAttributesAction.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Landing\History\Action;
4
5
use Bitrix\Landing\Block;
6
use Bitrix\Landing\Landing;
7
8
class
EditAttributesAction
extends
BaseAction
9
{
10
protected
const
JS_COMMAND
=
'editAttributes'
;
11
12
public
function
execute
(
bool
$undo =
true
): bool
13
{
14
$block =
new
Block
((
int
)$this->params[
'block'
]);
15
$selector = $this->params[
'selector'
];
16
$position = $this->params[
'position'
];
17
$attribute = $this->params[
'attribute'
];
18
$value = $undo ? $this->params[
'valueBefore'
] : $this->params[
'valueAfter'
];
19
20
// todo: what if wrapper node?
21
if
($selector && isset($value) && $attribute)
22
{
23
$landingModeBefore = Landing::getEditMode();
24
Landing::setEditMode();
25
$block->setAttributes([
26
$selector => [
27
$position => [
28
$attribute => $value,
29
],
30
],
31
]);
32
Landing::setEditMode($landingModeBefore);
33
34
return
$block->getError()->isEmpty() && $block->save();
35
}
36
37
return
false
;
38
}
39
40
public
static
function
enrichParams
(
array
$params
):
array
41
{
45
$block =
$params
[
'block'
];
46
47
return
[
48
'block'
=> $block->getId(),
49
'lid'
=> $block->getLandingId(),
50
'selector'
=>
$params
[
'selector'
] ?:
''
,
51
'position'
=>
$params
[
'position'
] ?? -1,
52
'attribute'
=>
$params
[
'attribute'
] ??
''
,
53
'isWrapper'
=>
$params
[
'isWrapper'
] ??
false
,
54
'valueBefore'
=>
$params
[
'valueBefore'
],
55
'valueAfter'
=>
$params
[
'valueAfter'
],
56
];
57
}
58
59
public
function
isNeedPush
(): bool
60
{
61
return
62
parent::isNeedPush()
63
&& $this->params[
'valueBefore'
] !== $this->params[
'valueAfter'
];
64
}
65
70
public
function
getJsCommand
(
bool
$undo =
true
):
array
71
{
72
$params
= parent::getJsCommand($undo);
73
74
$params
[
'params'
][
'value'
] =
75
$undo
76
?
$params
[
'params'
][
'valueBefore'
]
77
:
$params
[
'params'
][
'valueAfter'
];
78
79
unset(
80
$params
[
'params'
][
'valueAfter'
],
81
$params
[
'params'
][
'valueBefore'
],
82
);
83
84
return
$params
;
85
}
86
93
public
static
function
compareParams
(
array
$oldParams,
array
$newParams): bool
94
{
95
unset($oldParams[
'valueBefore'
], $newParams[
'valueBefore'
]);
96
97
return
$oldParams === $newParams;
98
}
99
}
Bitrix\Landing\History\Action\BaseAction
Определения
BaseAction.php:5
Bitrix\Landing\History\Action\BaseAction\$params
array $params
Определения
BaseAction.php:7
Bitrix\Landing\History\Action\BaseAction\enrichParams
static enrichParams(array $params)
Bitrix\Landing\History\Action\EditAttributesAction
Определения
EditAttributesAction.php:9
Bitrix\Landing\History\Action\EditAttributesAction\getJsCommand
getJsCommand(bool $undo=true)
Определения
EditAttributesAction.php:70
Bitrix\Landing\History\Action\EditAttributesAction\isNeedPush
isNeedPush()
Определения
EditAttributesAction.php:59
Bitrix\Landing\History\Action\EditAttributesAction\compareParams
static compareParams(array $oldParams, array $newParams)
Определения
EditAttributesAction.php:93
Bitrix\Landing\History\Action\EditAttributesAction\execute
execute(bool $undo=true)
Определения
EditAttributesAction.php:12
Bitrix\Landing\History\Action\EditAttributesAction\JS_COMMAND
const JS_COMMAND
Определения
EditAttributesAction.php:10
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
Bitrix\Landing\Block
Определения
blockrepo.php:3
$params
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения
template.php:799
bitrix
modules
landing
lib
History
Action
EditAttributesAction.php
Создано системой
1.14.0