1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
jsonconverter.php
См. документацию.
1
<?
8
namespace
Bitrix\Fileman\Block\Content;
9
10
use Bitrix\Main\Web\Json;
11
use Bitrix\Main\ArgumentException;
12
use Bitrix\Main\Localization\Loc;
13
14
Loc::loadMessages(__FILE__);
15
16
class
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
$type
Определения
options.php:106
Bitrix\Fileman\Block\Content\BlockContent
Определения
blockcontent.php:15
Bitrix\Fileman\Block\Content\JsonConverter
Определения
jsonconverter.php:17
Bitrix\Fileman\Block\Content\JsonConverter\isValid
static isValid($string)
Определения
jsonconverter.php:24
Bitrix\Fileman\Block\Content\JsonConverter\toArray
static toArray($string)
Определения
jsonconverter.php:55
Bitrix\Main\ArgumentException
Определения
ArgumentException.php:9
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
Bitrix\Fileman\Block\Content\IConverter
Определения
iconverter.php:19
bitrix
modules
fileman
lib
block
content
jsonconverter.php
Создано системой
1.14.0