1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
font.php
См. документацию.
1
<?php
2
namespace
Bitrix\Landing\Assets\PreProcessing;
3
4
use \Bitrix\Landing\Block;
5
use \Bitrix\Landing\Internals\BlockTable;
6
7
class
Font
8
{
14
protected
static
function
saveAssets
(
Block
$block): void
15
{
16
$blockContent = $block->
getContent
();
17
if
(!$blockContent)
18
{
19
return
;
20
}
21
22
$fonts = [];
23
$found = preg_match_all(
24
'/[\s"](g-font-[^\s"]+)/s'
,
25
$blockContent,
26
$matches
27
);
28
if
($found)
29
{
30
foreach
(
$matches
[1] as $font)
31
{
32
if
(
33
strpos($font,
'g-font-size-'
) !== 0
34
&& strpos($font,
'g-font-weight-'
) !== 0
35
&& strpos($font,
'g-font-style-'
) !== 0
36
)
37
{
38
$fonts[] = $font;
39
}
40
}
41
}
42
$block->
saveAssets
([
43
'font'
=> array_unique($fonts)
44
]);
45
}
46
52
public
static
function
processing
(
Block
$block): void
53
{
54
self::saveAssets
($block);
55
}
56
62
public
static
function
processingLanding
(
int
$landingId): void
63
{
64
$res
= BlockTable::getList([
65
'select'
=> [
66
'ID'
67
],
68
'filter'
=> [
69
'LID'
=> $landingId,
70
'=DELETED'
=>
'N'
71
]
72
]);
73
while
($row =
$res
->fetch())
74
{
75
$block =
new
Block
($row[
'ID'
]);
76
self::processing
($block);
77
$block->save();
78
}
79
}
80
86
public
static
function
view
(
Block
$block): void
87
{
88
$blockAssets = $block->
getAssets
();
89
if
(isset($blockAssets[
'font'
]))
90
{
91
foreach
($blockAssets[
'font'
] as $fontCode)
92
{
93
\Bitrix\Landing\Hook\Page\Fonts::setFontCode
($fontCode);
94
}
95
}
96
}
97
}
Bitrix\Landing\Assets\PreProcessing\Font
Определения
font.php:8
Bitrix\Landing\Assets\PreProcessing\Font\saveAssets
static saveAssets(Block $block)
Определения
font.php:14
Bitrix\Landing\Assets\PreProcessing\Font\processingLanding
static processingLanding(int $landingId)
Определения
font.php:62
Bitrix\Landing\Assets\PreProcessing\Font\view
static view(Block $block)
Определения
font.php:86
Bitrix\Landing\Assets\PreProcessing\Font\processing
static processing(Block $block)
Определения
font.php:52
Bitrix\Landing\Block\saveAssets
saveAssets(array $assets)
Определения
block.php:2635
Bitrix\Landing\Block\getContent
getContent()
Определения
block.php:1421
Bitrix\Landing\Block\getAssets
getAssets()
Определения
block.php:2665
Bitrix\Landing\Hook\Page\Fonts\setFontCode
static setFontCode(string $fontCode)
Определения
fonts.php:102
$res
$res
Определения
filter_act.php:7
Bitrix\Landing\Block
Определения
blockrepo.php:3
$matches
$matches
Определения
index.php:22
bitrix
modules
landing
lib
assets
preprocessing
font.php
Создано системой
1.14.0