Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
icon.php
1<?php
2namespace Bitrix\Landing\Node;
3
5
7{
12 public static function getHandlerJS()
13 {
14 return 'BX.Landing.Node.Icon';
15 }
16
17
25 public static function saveNode(\Bitrix\Landing\Block $block, $selector, array $data)
26 {
27 $doc = $block->getDom();
28 $resultList = $doc->querySelectorAll($selector);
29 $valueBefore = static::getNode($block, $selector);
30
31 foreach ($data as $pos => $value)
32 {
33 $classList = (isset($value['classList']) && is_array($value['classList']))
34 ? $value['classList']
35 : (array)$value;
36 $className = implode(' ', $classList);
37
38 if (isset($value['url']))
39 {
40 $url = is_array($value['url'])
41 ? json_encode($value['url'])
42 : $value['url'];
43 }
44 else
45 {
46 $url = '';
47 }
48
49 if ($classList)
50 {
51 if (isset($resultList[$pos]))
52 {
53 $resultList[$pos]->setAttribute('class', $className);
54 if ($url)
55 {
56 $resultList[$pos]->setAttribute('data-pseudo-url', $url);
57 }
58
60 {
61 $history = new History($block->getLandingId(), History::ENTITY_TYPE_LANDING);
62 $history->push('EDIT_ICON', [
63 'block' => $block,
64 'selector' => $selector,
65 'position' => (int)$pos,
66 'valueBefore' => $valueBefore[$pos],
67 'valueAfter' => $value,
68 ]);
69 }
70 }
71 }
72 }
73 }
74
81 public static function getNode(\Bitrix\Landing\Block $block, $selector)
82 {
83 $data = array();
84 $doc = $block->getDom();
85 $resultList = $doc->querySelectorAll($selector);
86
87 foreach ($resultList as $pos => $res)
88 {
89 $data[$pos] = array(
90 'classList' => [$res->getAttribute('class')]
91 );
92 $pseudoUrl = $res->getAttribute('data-pseudo-url');
93 if ($pseudoUrl)
94 {
95 $data[$pos]['data-pseudo-url'] = $pseudoUrl;
96 }
97 }
98
99 return $data;
100 }
101}
static getNode(\Bitrix\Landing\Block $block, $selector)
Definition icon.php:81
static getHandlerJS()
Definition icon.php:12
static saveNode(\Bitrix\Landing\Block $block, $selector, array $data)
Definition icon.php:25