3namespace Bitrix\Landing\Assets\PreProcessing;
5use \Bitrix\Landing\Block;
6use \Bitrix\Landing\Node;
7use \Bitrix\Landing\File;
8use \Bitrix\Main\Web\DOM;
25 $this->manifest =
$block->getManifest();
26 $this->content =
$block->getContent();
34 $this->skipDynamic = $flag;
37 protected function parse(): void
39 if (!$this->content || !$this->manifest[
'nodes'])
44 if ($this->skipDynamic && !empty($this->block->getDynamicParams()))
50 foreach ($this->manifest[
'nodes'] as $selector => $node)
52 if ($node[
'type'] ===
'img')
57 if ($node[
'type'] ===
'img' || $node[
'type'] ===
'styleimg')
61 if ($node[
'type'] ===
'img')
63 foreach ($domElements as $domElement)
65 if ($domElement->getTagName() ===
'IMG')
71 $this->
parseBg($domElement, $selector);
76 elseif ($node[
'type'] ===
'styleimg')
78 foreach ($domElements as $domElement)
80 if ($domElement->getTagName() !==
'IMG')
92 $this->block->saveContent($this->block->getDom()->saveHTML());
99 $origSrc = $node->getAttribute(
'src');
107 ($fileId = $node->getAttribute(
'data-fileid'))
112 $width = $fileArray[
'WIDTH'];
113 $height = $fileArray[
'HEIGHT'];
117 [
$width, $height] = $manifestSize;
121 $width = $height = self::IMG_PLACEHOLDER_SIZE_DEFAULT;
126 $node->setAttribute(
'data-lazy-img',
'Y');
127 $node->setAttribute(
'data-src', $origSrc);
128 $node->setAttribute(
'src', $lazySrc);
129 $node->setAttribute(
'loading',
'lazy');
130 if ($srcset = $node->getAttribute(
'srcset'))
132 $node->removeAttribute(
'srcset');
133 $node->setAttribute(
'data-srcset', $srcset);
140 if (!$styles[
'background-image'])
144 $origBg = implode(
'|', $styles[
'background-image']);
148 ($fileId = $node->getAttribute(
'data-fileid'))
153 $width = $fileArray[
'WIDTH'];
154 $height = $fileArray[
'HEIGHT'];
158 [
$width, $height] = $manifestSize;
162 $width = $height = self::BG_PLACEHOLDER_SIZE_DEFAULT;
165 $node->setAttribute(
'data-lazy-bg',
'Y');
166 $node->setAttribute(
'data-bg', $origBg);
170 if ($origSrc = self::getSrcByBgStyle($origBg))
172 if (isset($origSrc[
'src']))
174 $node->setAttribute(
'data-src', $origSrc[
'src']);
176 if (isset($origSrc[
'src2x']))
178 $node->setAttribute(
'data-src2x', $origSrc[
'src2x']);
186 ($fileId = $node->getAttribute(
'data-fileid'))
191 $width = $fileArray[
'WIDTH'];
192 $height = $fileArray[
'HEIGHT'];
194 $node->setAttribute(
'data-lazy-styleimg',
'Y');
195 $styleAttrValue = $node->getAttribute(
'style');
196 if (!str_contains($styleAttrValue,
'data:image/svg+xml;'))
198 $node->setAttribute(
'data-style', $styleAttrValue);
200 $node->setAttribute(
'style',
"background-image:url({$lazySrc});");
209 if (!empty($dimensions = $this->manifest[
'nodes'][$selector][
'dimensions']))
211 foreach ($dimensions as
$key => $value)
213 if (mb_stripos(
$key,
'width') !==
false)
217 if (mb_stripos(
$key,
'height') !==
false)
223 if (isset(
$width, $height))
228 if (isset(
$width) || isset($height))
230 $size =
$width ?? $height;
232 return [$size, $size];
246 return "data:image/svg+xml;base64,".base64_encode(
'<svg xmlns="http://www.w3.org/2000/svg" width="'.
$width.
'" height="'.$height.
'"><rect id="backgroundrect" width="100%" height="100%" x="0" y="0" fill="#ddd" fill-opacity=".7" stroke="none"/></svg>');
258 '/url\(\'*([^\']+)\'*\)\s*([\d]*x*)/is',
292 $lazyload =
new self(
$block);
298 $lazyload =
new self(
$block);
299 $lazyload->setSkipDynamic(
false);
parseImgTag(DOM\Element $node, string $selector)
static processingDynamic(Block $block)
const IMG_PLACEHOLDER_SIZE_DEFAULT
createPlaceholderImage(int $width, int $height)
static processing(Block $block)
parseBg(DOM\Element $node, string $selector)
parseStyleImg(DOM\Element $node, string $selector)
static getSrcByBgStyle($style)
setSkipDynamic(bool $flag=true)
__construct(Block $block)
getPlaceholderSizeFromManifest(string $selector)
const BG_PLACEHOLDER_SIZE_DEFAULT
static getFileArray($fileId)
static changeNodeType(array $node, \Bitrix\Landing\Block $block)
static getNodesBySelector(Block $block, string $selector)
static setStyle(Element $node, $styleList, $append=false)
static getStyle(Element $node, $singleStyle=true)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
if(empty($signedUserToken)) $key
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"