1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
sliceconverter.php
См. документацию.
1<?
8namespace Bitrix\Fileman\Block\Content;
9
10use Bitrix\Main\Localization\Loc;
11use Bitrix\Fileman\Block;
12
13Loc::loadMessages(__FILE__);
14
15class 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}
static toString(BlockContent $content)
Определения sliceconverter.php:78
static clean($html)
Определения sanitizer.php:26
$content
Определения commerceml.php:144
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
$i
Определения factura.php:643
</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
if(!Loader::includeModule('sale')) $pattern
Определения index.php:20
$matches
Определения index.php:22