1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
sliceconverter.php
См. документацию.
1
<?
8
namespace
Bitrix\Fileman\Block\Content;
9
10
use Bitrix\Main\Localization\Loc;
11
use Bitrix\Fileman\Block;
12
13
Loc::loadMessages(__FILE__);
14
15
class
SliceConverter
implements
IConverter
16
{
17
CONST
SLICE_SECTION_ID
=
'BX_BLOCK_EDITOR_EDITABLE_SECTION'
;
18
25
public
static
function
isValid
($string)
26
{
27
$result
=
true
;
28
$string = mb_strtoupper($string);
29
if
(mb_strpos($string,
'<!--START '
.static::SLICE_SECTION_ID.
'/'
) ===
false
)
30
{
31
$result
=
false
;
32
}
33
if
(mb_strpos($string,
'<!--END '
.static::SLICE_SECTION_ID.
'/'
) ===
false
)
34
{
35
$result
=
false
;
36
}
37
38
return
$result
;
39
}
40
47
public
static
function
toArray
($string)
48
{
49
$blockContent =
new
BlockContent
();
50
$pattern
=
'#<!--START '
51
. static::SLICE_SECTION_ID .
'/([\w]+?)/([\w]+?)/-->'
52
.
'([\s\S,\n]*?)'
53
.
'<!--END '
. static::SLICE_SECTION_ID .
'[/\w]+?-->#'
;
54
55
$matches
=
array
();
56
if
(preg_match_all(
$pattern
, $string,
$matches
))
57
{
58
$matchesCount =
count
(
$matches
[0]);
59
for
(
$i
= 0;
$i
< $matchesCount;
$i
++)
60
{
61
$section = trim(
$matches
[1][
$i
]);
62
$place = trim(
$matches
[2][
$i
]);
63
$value = trim(
$matches
[3][
$i
]);
64
65
$blockContent->add($section, $place, $value);
66
}
67
}
68
69
return
$blockContent;
70
}
71
78
public
static
function
toString
(
BlockContent
$content
)
79
{
80
$result
=
''
;
81
foreach
(
$content
->getList() as $item)
82
{
83
$result
.=
'<!--START '
84
. static::SLICE_SECTION_ID .
"/{$item['type']}/{$item['place']}/-->\n"
85
. $item[
'value'
] .
"\n"
86
.
'<!--END '
87
. static::SLICE_SECTION_ID .
"/{$item['type']}/{$item['place']}/-->\n"
;
88
}
89
90
return
trim(
$result
);
91
}
92
99
public
static
function
sanitize
($string)
100
{
101
if
(!self::isValid($string))
102
{
103
return
Block\Sanitizer::clean
($string);
104
}
105
106
$content
=
self::toArray
($string);
107
$list =
$content
->getList();
108
foreach
($list as $index => $item)
109
{
110
if
($item[
'type'
] !==
BlockContent::TYPE_BLOCKS
)
111
{
112
continue
;
113
}
114
115
$item[
'value'
] =
Block\Sanitizer::clean
($item[
'value'
]);
116
$list[$index] = $item;
117
}
118
119
$content
->setList($list);
120
return
self::toString
(
$content
);
121
}
122
}
Bitrix\Fileman\Block\Content\BlockContent
Определения
blockcontent.php:15
Bitrix\Fileman\Block\Content\BlockContent\TYPE_BLOCKS
CONST TYPE_BLOCKS
Определения
blockcontent.php:17
Bitrix\Fileman\Block\Content\SliceConverter
Определения
sliceconverter.php:16
Bitrix\Fileman\Block\Content\SliceConverter\toString
static toString(BlockContent $content)
Определения
sliceconverter.php:78
Bitrix\Fileman\Block\Content\SliceConverter\SLICE_SECTION_ID
CONST SLICE_SECTION_ID
Определения
sliceconverter.php:17
Bitrix\Fileman\Block\Content\SliceConverter\isValid
static isValid($string)
Определения
sliceconverter.php:25
Bitrix\Fileman\Block\Content\SliceConverter\toArray
static toArray($string)
Определения
sliceconverter.php:47
Bitrix\Fileman\Block\Content\SliceConverter\sanitize
static sanitize($string)
Определения
sliceconverter.php:99
Bitrix\Fileman\Block\Sanitizer\clean
static clean($html)
Определения
sanitizer.php:26
$content
$content
Определения
commerceml.php:144
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$result
$result
Определения
get_property_values.php:14
Bitrix\Fileman\Block\Content\IConverter
Определения
iconverter.php:19
$i
$i
Определения
factura.php:643
count
</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."%"
Определения
waybill.php:936
$pattern
if(!Loader::includeModule('sale')) $pattern
Определения
index.php:20
$matches
$matches
Определения
index.php:22
bitrix
modules
fileman
lib
block
content
sliceconverter.php
Создано системой
1.14.0