Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
marketplaceactions.php
1
<?php
2
3
4
namespace
Bitrix\Rest\Marketplace
;
5
6
7
use
Bitrix\Main\ArgumentException
;
8
use
Bitrix\Main\Web\HttpClient
;
9
use
Bitrix\Main\Web
;
10
use
Bitrix\Main\ModuleManager
;
11
12
class
MarketplaceActions
13
{
14
public
static
function
getItems
($placement, $userLang)
15
{
16
$response = [];
17
$items = [];
18
$params =
'placement='
.$placement.
'&lang='
.$userLang;
19
if
(
ModuleManager::isModuleInstalled
(
'bitrix24'
))
20
{
21
$zone = mb_strtolower(\CBitrix24::getPortalZone());
22
$params .=
'&zone='
.$zone;
23
}
24
else
25
{
26
$hash = \Bitrix\Main\Analytics\Counter::getAccountId();
27
$params .=
'&hash='
.$hash;
28
}
29
30
$client =
new
HttpClient
();
31
$client->query(Web\HttpClient::HTTP_GET,
'https://util.1c-bitrix.ru/b24/buttons.php?'
.$params);
32
33
if
($client->getStatus() == 200)
34
{
35
$resp = $client->getResult();
36
try
37
{
38
$response = Web\Json::decode($resp);
39
}
40
catch
(
ArgumentException
$e)
41
{
42
}
43
}
44
45
if
(is_array($response) && !empty($response))
46
{
47
foreach
($response as $item)
48
{
49
$items[$item[
'id'
]] = [
50
'NAME'
=> $item[
'name'
],
51
'COLOR'
=> $item[
'color'
],
52
'HANDLER'
=> $item[
'link'
],
53
'IMAGE'
=> $item[
'image'
],
54
'SLIDER'
=> $item[
'slider'
],
55
];
56
}
57
}
58
59
return
$items;
60
}
61
}
Bitrix\Main\ArgumentException
Definition
exception.php:34
Bitrix\Main\ModuleManager
Definition
modulemanager.php:5
Bitrix\Main\ModuleManager\isModuleInstalled
static isModuleInstalled($moduleName)
Definition
modulemanager.php:67
Bitrix\Main\Web\HttpClient
Definition
httpclient.php:24
Bitrix\Rest\Marketplace\MarketplaceActions
Definition
marketplaceactions.php:13
Bitrix\Rest\Marketplace\MarketplaceActions\getItems
static getItems($placement, $userLang)
Definition
marketplaceactions.php:14
Bitrix\Main\Web
Definition
cookie.php:3
Bitrix\Rest\Marketplace
Definition
application.php:3
modules
rest
lib
marketplace
marketplaceactions.php
Создано системой
1.10.0