Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
tags.php
1<?php
2
11
14
15class Tags
16{
17 public static function getValue(array $tags = [], array $params = []): array
18 {
19 $result = [
20 'items' => [],
21 ];
22
23 $group = ($params['GROUP'] ?? null);
24 if (!$group)
25 {
26 return $result;
27 }
28
29 $groupId = (int)$group->get('ID');
30 $gridId = (string)($params['GRID_ID'] ?? '');
31 $filterField = (string)($params['FILTER_FIELD'] ?? '');
32 $currentUserRelation = ($params['CURRENT_USER_RELATION'] ?? null);
33
34 if (
35 $groupId <= 0
36 || $gridId === ''
37 || $filterField === ''
38 )
39 {
40 return $result;
41 }
42
43 $accessManager = new AccessManager(
44 $group,
45 $currentUserRelation,
46 $currentUserRelation
47 );
48
49 if ($accessManager->canModify())
50 {
51 $result['addButton'] = [
52 'events' => [
53 'click' => '
54 BX.Socialnetwork.UI.Grid.TagController
55 .onTagAddClick.bind(BX.Socialnetwork.UI.Grid.TagController, ' . $groupId . ')',
56 ],
57 ];
58 }
59
60 foreach ($tags as $tag)
61 {
62 $encodedData = Json::encode(['TAG' => $tag]);
63
64 $selected = (
65 $filterField !== ''
66 && isset($params['FILTER_DATA'][$filterField])
67 && $params['FILTER_DATA'][$filterField] === $tag
68 );
69
70 $result['items'][] = [
71 'text' => $tag,
72 'active' => $selected,
73 'events' => [
74 'click' => '
75 BX.Socialnetwork.UI.Grid.TagController
76 .onTagClick.bind(BX.Socialnetwork.UI.Grid.TagController, ' . $encodedData . ')',
77 ],
78 ];
79 }
80
81 return $result;
82 }
83}
static encode($data, $options=null)
Definition json.php:24
static getValue(array $tags=[], array $params=[])
Definition tags.php:17