1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
jsonconverter.php
См. документацию.
1<?
8namespace Bitrix\Fileman\Block\Content;
9
10use Bitrix\Main\Web\Json;
11use Bitrix\Main\ArgumentException;
12use Bitrix\Main\Localization\Loc;
13
14Loc::loadMessages(__FILE__);
15
16class JsonConverter implements IConverter
17{
24 public static function isValid($string)
25 {
26 $string = trim($string);
27 $char = mb_substr($string, 0, 1);
28 if(!in_array($char, array('{', '[')))
29 {
30 return false;
31 }
32 $char = mb_substr($string, -1);
33 if(!in_array($char, array('}', ']')))
34 {
35 return false;
36 }
37
38 try
39 {
40 $r = Json::decode($string);
41 return is_array($r);
42 }
43 catch (ArgumentException $exception)
44 {
45 return false;
46 }
47 }
48
55 public static function toArray($string)
56 {
57 $blockContent = new BlockContent();
58 try
59 {
60 $list = Json::decode($string);
61 if (!is_array($list))
62 {
63 return $blockContent;
64 }
65 }
66 catch (ArgumentException $exception)
67 {
68 return $blockContent;
69 }
70
71 foreach ($list as $item)
72 {
73 $type = trim($item['type']);
74 $place = trim($item['place']);
75 $value = trim($item['value']);
76 $blockContent->add($type, $place, $value);
77 }
78
79 return $blockContent;
80 }
81}
$type
Определения options.php:106
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804