Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
AddCardAction.php
1<?php
2
4
7
9{
10 protected const JS_COMMAND = 'addCard';
11
12 public function execute(bool $undo = true): bool
13 {
14 $block = new Block((int)$this->params['block']);
15 $block->cloneCard($this->params['selector'], $this->params['position'] - 1, $this->params['content']);
16
17 return $block->save();
18 }
19
20 public static function enrichParams(array $params): array
21 {
25 $block = $params['block'];
26 $selector = $params['selector'] ?: '';
27 $position = (int)$params['position'] ?: 0;
28 $content = '';
29 if ($selector)
30 {
31 $doc = new DOM\Document();
32 $doc->loadHTML($block->getContent());
33 $resultList = $doc->querySelectorAll($selector);
34 if (isset($resultList[$position]))
35 {
36 $content = $resultList[$position]->getOuterHTML();
37 }
38 }
39
40 return [
41 'block' => $block->getId(),
42 'selector' => $selector,
43 'lid' => $block->getLandingId(),
44 'position' => $position,
45 'content' => $content,
46 ];
47 }
48}