1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
EditStyleAction.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Landing\History\Action;
4
5
use Bitrix\Landing\Block;
6
use \Bitrix\Main\Web\DOM;
7
8
class
EditStyleAction
extends
BaseAction
9
{
10
protected
const
JS_COMMAND
=
'updateStyle'
;
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
$isWrapper = $this->params[
'isWrapper'
];
18
$value = $undo ? $this->params[
'valueBefore'
] : $this->params[
'valueAfter'
];
19
20
if
($selector)
21
{
22
if
($position >= 0 && !$isWrapper)
23
{
24
$selector = $selector .
'@'
. $position;
25
}
26
$data
= [
27
$selector => [
28
'classList'
=> explode(
' '
, $value[
'className'
]),
29
'style'
=> $value[
'style'
],
30
'affect'
=> $this->params[
'affect'
],
31
],
32
];
33
34
return
$block->setClasses(
$data
) && $block->save();
35
}
36
37
return
false
;
38
}
39
40
public
static
function
enrichParams
(
array
$params
):
array
41
{
45
$block =
$params
[
'block'
];
46
47
$getValue =
static
function
(
$content
) {
48
$doc =
new
DOM\Document
();
49
$doc->loadHTML(
$content
);
50
$children
= $doc->getChildNodesArray();
51
$node = array_pop(
$children
);
52
53
return
$node
54
? [
55
'className'
=> $node->getClassName() ?:
''
,
56
'style'
=>
DOM\StyleInliner::getStyle
($node,
true
),
57
'styleString'
=> $node->getAttribute(
'style'
) ?:
''
,
58
]
59
: [];
60
};
61
62
return
[
63
'block'
=> $block->getId(),
64
'selector'
=>
$params
[
'selector'
] ?:
''
,
65
'isWrapper'
=>
$params
[
'isWrapper'
] ??
false
,
66
'position'
=>
$params
[
'position'
] ?? -1,
67
'affect'
=>
$params
[
'affect'
] ?: [],
68
'lid'
=> $block->getLandingId(),
69
'valueBefore'
=> $getValue(
$params
[
'contentBefore'
]),
70
'valueAfter'
=> $getValue(
$params
[
'contentAfter'
]),
71
];
72
}
73
74
public
function
isNeedPush
(): bool
75
{
76
// todo: move to another actions
77
return
78
parent::isNeedPush()
79
&& $this->params[
'valueBefore'
] !== $this->params[
'valueAfter'
];
80
}
81
86
public
function
getJsCommand
(
bool
$undo =
true
):
array
87
{
88
$params
= parent::getJsCommand($undo);
89
90
$params
[
'params'
][
'value'
] =
91
$undo
92
?
$params
[
'params'
][
'valueBefore'
]
93
:
$params
[
'params'
][
'valueAfter'
];
94
$params
[
'params'
][
'value'
][
'style'
] =
$params
[
'params'
][
'value'
][
'styleString'
];
95
96
unset(
97
$params
[
'params'
][
'valueAfter'
],
98
$params
[
'params'
][
'valueBefore'
],
99
$params
[
'params'
][
'value'
][
'styleString'
],
100
);
101
102
return
$params
;
103
}
104
111
public
static
function
compareParams
(
array
$oldParams,
array
$newParams): bool
112
{
113
unset($oldParams[
'valueBefore'
], $newParams[
'valueBefore'
]);
114
115
return
$oldParams === $newParams;
116
}
117
}
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\EditStyleAction
Определения
EditStyleAction.php:9
Bitrix\Landing\History\Action\EditStyleAction\getJsCommand
getJsCommand(bool $undo=true)
Определения
EditStyleAction.php:86
Bitrix\Landing\History\Action\EditStyleAction\isNeedPush
isNeedPush()
Определения
EditStyleAction.php:74
Bitrix\Landing\History\Action\EditStyleAction\compareParams
static compareParams(array $oldParams, array $newParams)
Определения
EditStyleAction.php:111
Bitrix\Landing\History\Action\EditStyleAction\execute
execute(bool $undo=true)
Определения
EditStyleAction.php:12
Bitrix\Landing\History\Action\EditStyleAction\JS_COMMAND
const JS_COMMAND
Определения
EditStyleAction.php:10
Bitrix\Main\Web\DOM\Document
Определения
document.php:6
Bitrix\Main\Web\DOM\StyleInliner\getStyle
static getStyle(Element $node, $singleStyle=true)
Определения
styleinliner.php:43
$children
$children
Определения
sync.php:12
$content
$content
Определения
commerceml.php:144
$data
$data['IS_AVAILABLE']
Определения
.description.php:13
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
EditStyleAction.php
Создано системой
1.14.0