1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
smile.php
См. документацию.
1
<?php
2
namespace
Bitrix\Main\Rest;
3
4
class
Smile
extends
\IRestService
5
{
6
public
static
function
getList
(
$arParams
,
$n
, \CRestServer $server)
7
{
8
$options
= [];
9
if
(isset(
$arParams
[
'FULL_TYPINGS'
]) &&
$arParams
[
'FULL_TYPINGS'
] ===
'Y'
)
10
{
11
$options
[
'FULL_TYPINGS'
] =
'Y'
;
12
}
13
14
$smiles = \CSmileGallery::getSmilesWithSets(\CSmileGallery::GALLERY_DEFAULT,
$options
);
15
16
return
self::objectEncode
([
17
'SETS'
=> $smiles[
'SMILE_SET'
],
18
'SMILES'
=> $smiles[
'SMILE'
],
19
], [
20
'IMAGE_FIELD'
=> [
'IMAGE'
]
21
]);
22
}
23
24
/* Utils */
25
public
static
function
objectEncode
(
$data
,
$options
= [])
26
{
27
if
(!is_array(
$options
[
'IMAGE_FIELD'
]))
28
{
29
$options
[
'IMAGE_FIELD'
] = [
'AVATAR'
,
'AVATAR_HR'
];
30
}
31
32
if
(is_array(
$data
))
33
{
34
$result
= [];
35
foreach
(
$data
as
$key
=> $value)
36
{
37
if
(is_array($value))
38
{
39
$value =
self::objectEncode
($value,
$options
);
40
}
41
else
if
($value instanceof \
Bitrix
\
Main
\
Type
\
DateTime
)
42
{
43
$value = date(
'c'
, $value->getTimestamp());
44
}
45
else
if
(is_string(
$key
) && in_array(
$key
,
$options
[
'IMAGE_FIELD'
]) && is_string($value) && $value && !str_starts_with($value,
'http'
))
46
{
47
$value =
self::getServerAddress
().$value;
48
}
49
50
$key
= str_replace(
'_'
,
''
, lcfirst(ucwords(mb_strtolower(
$key
),
'_'
)));
51
52
$result
[
$key
] = $value;
53
}
54
$data
=
$result
;
55
}
56
57
return
$data
;
58
}
59
60
public
static
function
getServerAddress
()
61
{
62
$publicUrl =
\Bitrix\Main\Config\Option::get
(
'main'
,
'last_site_url'
,
''
);
63
64
if
($publicUrl)
65
{
66
return
$publicUrl;
67
}
68
else
69
{
70
return
(\
Bitrix
\
Main
\Context::getCurrent()->getRequest()->isHttps() ?
"https"
:
"http"
).
"://"
.
$_SERVER
[
'SERVER_NAME'
].(in_array(
$_SERVER
[
'SERVER_PORT'
], Array(80, 443))?
''
:
':'
.
$_SERVER
[
'SERVER_PORT'
]);
71
}
72
}
73
}
$arParams
$arParams
Определения
access_dialog.php:21
Bitrix\Main\Config\Option\get
static get($moduleId, $name, $default="", $siteId=false)
Определения
option.php:30
Bitrix\Main\Rest\Smile
Определения
smile.php:5
Bitrix\Main\Rest\Smile\getServerAddress
static getServerAddress()
Определения
smile.php:60
Bitrix\Main\Rest\Smile\getList
static getList($arParams, $n, \CRestServer $server)
Определения
smile.php:6
Bitrix\Main\Rest\Smile\objectEncode
static objectEncode($data, $options=[])
Определения
smile.php:25
Bitrix\Main\Type\DateTime
Определения
datetime.php:9
IRestService
Определения
rest.php:896
$options
$options
Определения
commerceml2.php:49
$data
$data['IS_AVAILABLE']
Определения
.description.php:13
$result
$result
Определения
get_property_values.php:14
$_SERVER
$_SERVER["DOCUMENT_ROOT"]
Определения
cron_frame.php:9
Bitrix\Main\Type
Определения
collection.php:2
Bitrix\Main
Bitrix
$key
if(empty($signedUserToken)) $key
Определения
quickway.php:257
$n
$n
Определения
update_log.php:107
bitrix
modules
main
lib
rest
smile.php
Создано системой
1.14.0