Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
uifilterpreset.php
1<?php
3
4class UiFilterPreset extends Filter
5{
10 public function __construct()
11 {
12 parent::__construct();
13 }
14
19 public function create(array $sourceFilter)
20 {
21 $result = parent::create($sourceFilter);
22
23 if (!empty($this->fields) && !empty($sourceFilter))
24 {
25 if ($this->getQuickSearchField() !== null && !isset($result['FIND']))
26 {
27 $result['FIND'] = '';
28 }
29 }
30
31 return $result;
32 }
33
37 protected function initFieldTypeHandlers()
38 {
39 $this->fieldTypeHandlers = [
40 'string' => 'addStringValue',
41 'number' => 'addNumberValue',
42 'date' => 'addDateValue',
43 'custom_date' => 'addCustomDateValue',
44 'list' => 'addListValue',
45 'checkbox' => 'addCheckboxValue',
46 'dest_selector' => 'addDestSelectorValue',
47 'custom_entity' => '',
48 'custom' => ''
49 ];
50 }
51
59 protected function addQuickSearchValue(array &$result, $fieldId, array $field, array $value)
60 {
61 if (isset($value['VALUE']) && is_string($value['VALUE']) && $value['VALUE'] !== '')
62 {
63 $result['FIND'] = $value['VALUE'];
64 }
65 }
66
74 protected function addStringValue(array &$result, $fieldId, array $field, array $value)
75 {
76 if (isset($value['VALUE']) && is_string($value['VALUE']) && $value['VALUE'] !== '')
77 {
78 $result[$fieldId] = $value['VALUE'];
79 }
80 }
81
89 protected function addNumberValue(array &$result, $fieldId, array $field, array $value)
90 {
91 if (isset($value['SUB_TYPE']))
92 {
93 $result[$fieldId.'_numsel'] = $value['SUB_TYPE'];
94 $result[$fieldId.'_from'] = (isset($value['_from']) ? $value['_from'] : '');
95 $result[$fieldId.'_to'] = (isset($value['_to']) ? $value['_to'] : '');
96 }
97 }
98
106 protected function addDateValue(array &$result, $fieldId, array $field, array $value)
107 {
108 if (isset($value['SUB_TYPE']))
109 {
110 $result[$fieldId.'_datesel'] = $value['SUB_TYPE'];
111 $result[$fieldId.'_from'] = (isset($value['_from']) ? $value['_from'] : '');
112 $result[$fieldId.'_to'] = (isset($value['_to']) ? $value['_to'] : '');
113 $result[$fieldId.'_days'] = (isset($value['_days']) ? $value['_days'] : '');
114 $result[$fieldId.'_month'] = (isset($value['_month']) ? $value['_month'] : '');
115 $result[$fieldId.'_quarter'] = (isset($value['_quarter']) ? $value['_quarter'] : '');
116 $result[$fieldId.'_year'] = (isset($value['_year']) ? $value['_year'] : '');
117 $result[$fieldId.'_allow_year'] = (isset($value['_allow_year']) ? $value['_allow_year'] : '');
118 }
119 }
120
128 protected function addCustomDateValue(array &$result, $fieldId, array $field, array $value)
129 {
130 if (isset($value['days']) || isset($value['months']) || isset($value['years']))
131 {
132 $result[$fieldId.'days'] = (isset($value['days']) ? $value['days'] : '');
133 $result[$fieldId.'months'] = (isset($value['months']) ? $value['months'] : '');
134 $result[$fieldId.'years'] = (isset($value['years']) ? $value['years'] : '');
135 }
136 }
137
145 protected function addListValue(array &$result, $fieldId, array $field, array $value)
146 {
147 if (isset($field['params']['multiple']) && $field['params']['multiple'] = 'Y')
148 {
149 $list = [];
150
151 foreach ($value as $row)
152 {
153 if (!empty($row) && is_array($row) && isset($row['VALUE']))
154 {
155 $list[] = $row['VALUE'];
156 }
157 }
158 unset($row);
159
160 if (!empty($list))
161 {
162 $result[$fieldId] = $list;
163 }
164 unset($list);
165 }
166 else
167 {
168 if (isset($value['VALUE']))
169 {
170 $result[$fieldId] = $value['VALUE'];
171 }
172 }
173 }
174
182 protected function addCheckboxValue(array &$result, $fieldId, array $field, array $value)
183 {
184 if (
185 isset($value['VALUE'])
186 && ($value['VALUE'] === 'Y' || $value['VALUE'] === 'N')
187 )
188 {
189 $result[$fieldId] = $value['VALUE'];
190 }
191 }
192
200 protected function addDestSelectorValue(array &$result, $fieldId, array $field, array $value)
201 {
202 if (
203 isset($value['_value'])
204 && (isset($value['_label']))
205 )
206 {
207 $result[$fieldId] = $value['_value'];
208 $result[$fieldId.'_label'] = $value['_label'];
209 }
210 }
211}
addNumberValue(array &$result, $fieldId, array $field, array $value)
addCheckboxValue(array &$result, $fieldId, array $field, array $value)
addDateValue(array &$result, $fieldId, array $field, array $value)
addCustomDateValue(array &$result, $fieldId, array $field, array $value)
addStringValue(array &$result, $fieldId, array $field, array $value)
addListValue(array &$result, $fieldId, array $field, array $value)
addDestSelectorValue(array &$result, $fieldId, array $field, array $value)
addQuickSearchValue(array &$result, $fieldId, array $field, array $value)