Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
chat.php
1<?php
3
4use \Bitrix\Main\Localization\Loc;
5
6Loc::loadMessages(__FILE__);
7
8class Chat
9{
17 public static function prepareManifest(array $manifest, \Bitrix\Landing\Block $block = NULL, array $params = []): array
18 {
19 if (!\Bitrix\Main\ModuleManager::isModuleInstalled('im'))
20 {
21 $manifest['requiredUserAction'] = array(
22 'header' => Loc::getMessage('LANDING_BLOCK_IM_NOT_INSTALLED_HEADER'),
23 'description' => Loc::getMessage('LANDING_BLOCK_IM_NOT_INSTALLED_TEXT'),
24 'text' => Loc::getMessage('LANDING_BLOCK_IM_NOT_INSTALLED_LINK'),
25 'href' => '/bitrix/admin/module_admin.php?lang=' . LANGUAGE_ID,
26 'className' => 'landing-required-link'
27 );
28 }
29 $manifest['callbacks'] = array(
30 'afterAdd' => function (\Bitrix\Landing\Block &$block) use($params)
31 {
32 $block->saveDynamicParams(
33 self::getSourceParams($params)
34 );
35 },
36 );
37
38 return $manifest;
39 }
40
46 protected static function buildReferences(array $references): array
47 {
48 $return = [];
49
50 foreach ($references as $fieldCode => $selector)
51 {
52 if (is_string($selector))
53 {
54 $return[$selector] = [
55 'id' => $fieldCode,
56 'link' => false
57 ];
58 }
59 }
60
61 return $return;
62 }
63
69 protected static function getSourceParams(array $params): array
70 {
71 $return = [];
72
73 if (
74 isset($params['type']) && is_string($params['type']) &&
75 isset($params['card']) && is_string($params['card']) &&
76 isset($params['attributeData']) && is_string($params['attributeData']) &&
77 isset($params['references']) && is_array($params['references'])
78 )
79 {
80 $return[$params['card']] = [
81 'source' => 'landing:chat',
82 'references' => self::buildReferences($params['references']),
83 'settings' => [
84 'source' => [
85 'source' => 'landing:chat',
86 'additional' => [
87 'type' => $params['type'],
88 'attributeData' => $params['attributeData'],
89 'attributeButton' => isset($params['attributeButton'])
90 ? $params['attributeButton']
91 : null
92 ]
93 ],
94 'pagesCount' => isset($params['references'])
95 ? $params['references']
96 : 10
97 ]
98 ];
99 }
100
101 return $return;
102 }
103}
static getSourceParams(array $params)
Definition chat.php:69
static buildReferences(array $references)
Definition chat.php:46
static prepareManifest(array $manifest, \Bitrix\Landing\Block $block=NULL, array $params=[])
Definition chat.php:17
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29