Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
map.php
1<?php
2namespace Bitrix\Landing\Node;
3
5
7{
8 protected const ATTR_MAP = 'data-map';
9
14 public static function getHandlerJS()
15 {
16 return 'BX.Landing.Node.Map';
17 }
18
26 public static function saveNode(\Bitrix\Landing\Block $block, $selector, array $data)
27 {
28 $doc = $block->getDom();
29 $resultList = $doc->querySelectorAll($selector);
30
31 foreach ($data as $pos => $value)
32 {
33 if (isset($resultList[$pos]) && $value)
34 {
36 {
37 $history = new History($block->getLandingId(), History::ENTITY_TYPE_LANDING);
38 $history->push('EDIT_MAP', [
39 'block' => $block,
40 'selector' => $selector,
41 'position' => (int)$pos,
42 'valueBefore' => $resultList[$pos]->getAttributes()[self::ATTR_MAP]->getValue(),
43 'valueAfter' => $value,
44 ]);
45 }
46
47 $resultList[$pos]->setAttribute(
48 self::ATTR_MAP,
49 $value
50 );
51 }
52 }
53 }
54
61 public static function getNode(\Bitrix\Landing\Block $block, $selector)
62 {
63 $data = array();
64 $doc = $block->getDom();
65 $resultList = $doc->querySelectorAll($selector);
66
67 foreach ($resultList as $pos => $res)
68 {
69 $data[$pos] = $res->getAttribute(self::ATTR_MAP);
70 }
71
72 return $data;
73 }
74}
static getNode(\Bitrix\Landing\Block $block, $selector)
Definition map.php:61
static getHandlerJS()
Definition map.php:14
static saveNode(\Bitrix\Landing\Block $block, $selector, array $data)
Definition map.php:26