2namespace Bitrix\Landing\Node;
4use Bitrix\Landing\Block;
5use Bitrix\Landing\File;
6use Bitrix\Landing\Manager;
7use Bitrix\Landing\Node;
8use Bitrix\Main\Web\DOM;
23 '--bg-url' =>
"url('#url#')",
26 '--bg-url-2x' =>
"url('#url#')",
39 return 'BX.Landing.Block.Node.StyleImg';
51 if (!self::isCorrectNodeType($block, $selector))
60 foreach (
$data as $pos => $value)
62 $id = isset($value[
'id']) ? (int)$value[
'id'] : 0;
63 $id2x = isset($value[
'id2x']) ? (int)$value[
'id2x'] : 0;
72 if (!in_array($id,
$files))
76 if (!in_array($id2x,
$files))
82 if (isset($resultList[$pos]))
85 if ($resultList[$pos]->getTagName() !==
'IMG')
88 if (isset($styles[
'--bg-url']))
90 $styles[
'background-image'] =
'';
92 if (!isset($styles[
'background']))
96 $stylesChanged =
false;
97 $resultList[$pos]->setAttribute(
'data-fileid', $id);
98 foreach (self::STYLES_VARIABLES_WITH_FILES[
'1x'] as
$var =>
$pattern)
100 if (isset($styles[
$var]))
102 $fileArray = \CFile::GetFileArray($id);
103 $styles[
$var] = str_replace(
104 self::STYLES_URL_MARKER,
108 $stylesChanged =
true;
114 $resultList[$pos]->setAttribute(
'data-fileid2x', $id2x);
115 foreach (self::STYLES_VARIABLES_WITH_FILES[
'2x'] as
$var =>
$pattern)
117 if (isset($styles[
$var]))
119 $fileArray = \CFile::GetFileArray($id2x);
120 $styles[
$var] = str_replace(
121 self::STYLES_URL_MARKER,
125 $stylesChanged =
true;
132 $classList = $resultList[$pos]->getAttribute(
'class');
133 if (!stripos($classList, self::STYLES_NODE_CLASS))
135 $classList .=
' ' . self::STYLES_NODE_CLASS;
137 $resultList[$pos]->setAttribute(
'class', $classList);
138 $fileArray1x = \CFile::GetFileArray($id);
139 $src1x = $fileArray1x[
'SRC'];
140 $styles[
'--bg-url'] =
"url('{$src1x}');";
141 if ($id2x <= 0 && $id > 0)
145 $fileArray2x = \CFile::GetFileArray($id2x);
146 $src2x = $fileArray2x[
'SRC'];
147 $styles[
'--bg-url-2x'] =
"url('{$src2x}');";
148 $stylesChanged =
true;
158 foreach ([
'fileid',
'fileid2x'] as $dataCode)
160 $attribute =
'data-' . $dataCode;
161 $oldId = $resultList[$pos]->getAttribute($attribute);
186 if (!self::isCorrectNodeType($block, $selector))
195 foreach ($resultList as $pos =>
$res)
206 if (
$res->getTagName() !==
'IMG')
209 $res->getAttribute(
'data-lazy-styleimg')
210 &&
$res->getAttribute(
'data-lazy-styleimg') ===
'Y'
220 if (!in_array($nodeData[
'id'],
$files))
224 if ($nodeData[
'id2x'] && !in_array($nodeData[
'id'],
$files))
226 unset($nodeData[
'id2x'], $nodeData[
'src2x'], $nodeData[
'lazyOrigSrc2x']);
229 $data[$pos] = $nodeData;
244 (!isset($styles[
'background']) || $styles[
'background'] ===
'')
245 && (!isset($styles[
'background-image']) || $styles[
'background-image'] ===
'')
248 $fileId = (int)$node->getAttribute(
'data-fileid');
252 $data[
'id'] = $fileId;
255 $fileId2x = (int)$node->getAttribute(
'data-fileid2x');
258 $data[
'id2x'] = $fileId2x;
271 $styles = $node->getAttribute(
'data-style');
274 $stylesConverted = [];
275 foreach (explode(
';', $styles) as $style)
278 $separator = strpos( $style,
':');
279 $key = substr($style, 0, $separator);
280 $val = substr($style, $separator + 1);
281 $stylesConverted[
$key] = trim(
$val);
284 $fileId = (int)$node->getAttribute(
'data-fileid');
287 $data = [
'isLazy' =>
'Y'];
289 $data[
'id'] = $fileId;
292 $fileId2x = (int)$node->getAttribute(
'data-fileid2x');
295 $data[
'id2x'] = $fileId2x;
312 if (array_key_exists($resolution, self::STYLES_VARIABLES_WITH_FILES))
314 foreach (self::STYLES_VARIABLES_WITH_FILES[$resolution] as
$var =>
$pattern)
319 && preg_match(self::STYLES_URL_REGEXP, $styles[
$var],
$matches)
339 if (!self::isCorrectNodeType($block, $selector))
359 $pattern =
'/' . substr($selector, 1) .
'[^\"]*/i';
362 $pattern =
'/[\s]?' . self::STYLES_NODE_CLASS .
'[\s]?/i';
static getFilesFromBlock($blockId)
static deleteFromBlock($blockId, $fileId=array())
static getUrlFromFile($file)
static getSearchableNode($block, $selector)
static getNode(\Bitrix\Landing\Block $block, $selector)
static saveNode(\Bitrix\Landing\Block $block, $selector, array $data)
static getNodesBySelector(Block $block, string $selector)
static isCorrectNodeType(Block $block, string $selector)
static getSrcFromStyles(array $styles, string $resolution)
static getSearchableNode(Block $block, string $selector)
const STYLES_VARIABLES_WITH_FILES
static getNode(Block $block, $selector)
static getNodeDataLazy(DOM\Node $node)
static getNodeData(DOM\Node $node)
static saveNode(Block $block, $selector, array $data)
static setStyle(Element $node, $styleList, $append=false)
static getStyle(Element $node, $singleStyle=true)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(empty($signedUserToken)) $key
if(!Loader::includeModule('sale')) $pattern