12 parent::__construct();
20 $this->fieldTypeHandlers = [
21 'string' =>
'addStringValue',
22 'number' =>
'addNumberValue',
23 'date' =>
'addDateValue',
24 'list' =>
'addListValue',
25 'checkbox' =>
'addCheckboxValue',
27 'dest_selector' =>
'addDestSelectorValue',
28 'custom_entity' =>
'',
43 $operator =
'default';
45 if (!empty($field[
'operators']) && is_array($field[
'operators']))
47 if (isset($field[
'operators'][$operator]))
49 $result = $field[
'operators'][$operator];
51 elseif (isset($field[
'operators'][
'default']))
53 $result = $field[
'operators'][
'default'];
65 protected function addRows(array &$result, array $items, array $field)
72 $entity = (isset($field[
'entity']) ? $field[
'entity'] :
'master');
75 if (!isset($result[$entity]))
77 $result[$entity] = [];
79 $result[$entity] = array_merge($result[$entity], $items);
93 if (isset($value[
'VALUE']) && is_string($value[
'VALUE']))
95 $findValue = trim($value[
'VALUE']);
96 if ($findValue !==
'')
99 if (is_string($operator))
101 $fieldId = $operator.$fieldId;
104 $this->
addRows($filter, [$fieldId => $findValue], $field);
116 protected function addStringValue(array &$result, $fieldId, array $field, array $value)
118 if (isset($value[
'VALUE']) && is_string($value[
'VALUE']) && $value[
'VALUE'] !==
'')
121 if (is_string($operator))
123 $fieldId = $operator.$fieldId;
126 $this->
addRows($result, [$fieldId => $value[
'VALUE']], $field);
137 protected function addNumberValue(array &$result, $fieldId, array $field, array $value)
139 if (isset($value[
'SUB_TYPE'])
140 && isset($value[
'_from']) && is_string($value[
'_from'])
141 && isset($value[
'_to']) && is_string($value[
'_to'])
144 $minValue = trim($value[
'_from']);
145 $maxValue = trim($value[
'_to']);
146 if ($minValue ===
'' && $maxValue ===
'')
152 switch ($value[
'SUB_TYPE'])
155 if ($minValue !==
'')
158 if (is_string($operator))
160 $fieldId = $operator.$fieldId;
163 $items[$fieldId] = $minValue;
167 if ($minValue !==
'' && $maxValue !==
'')
170 if (is_string($operator))
172 $fieldId = $operator.$fieldId;
175 $items[$fieldId] = [$minValue, $maxValue];
179 if ($minValue !==
'')
182 if (is_string($operator))
184 $fieldId = $operator.$fieldId;
187 $items[$fieldId] = $minValue;
191 if ($maxValue !==
'')
194 if (is_string($operator))
196 $fieldId = $operator.$fieldId;
199 $items[$fieldId] = $maxValue;
203 unset($maxValue, $minValue);
205 $this->
addRows($result, $items, $field);
217 protected function addDateValue(array &$result, $fieldId, array $field, array $value)
219 if (isset($value[
'SUB_TYPE'])
220 && isset($value[
'_from']) && is_string($value[
'_from'])
221 && isset($value[
'_to']) && is_string($value[
'_to']))
223 $minValue = trim($value[
'_from']);
224 $maxValue = trim($value[
'_to']);
225 if ($minValue ===
'' && $maxValue ===
'')
231 switch ($value[
'SUB_TYPE'])
234 if ($minValue !==
'')
237 if (is_string($operator))
239 $fieldId = $operator.$fieldId;
242 $items[$fieldId] = $minValue;
247 if ($minValue !==
'' && $maxValue !==
'')
250 if (is_string($operator))
252 $fieldId = $operator.$fieldId;
255 $items[$fieldId] = [$minValue, $maxValue];
259 unset($maxValue, $minValue);
261 $this->
addRows($result, $items, $field);
273 protected function addListValue(array &$result, $fieldId, array $field, array $value)
277 $multiple = isset($field[
'params'][
'multiple']) && $field[
'params'][
'multiple'] ==
'Y';
279 $validRawValue = !empty($value);
281 $validRawValue = isset($value[
'VALUE']);
287 foreach ($value as $row)
289 if (is_array($row) && isset($row[
'VALUE']))
291 $id[] = $row[
'VALUE'];
295 $check = !empty($id);
299 $id = $value[
'VALUE'];
307 if (is_string($operator))
309 $fieldId = $operator.$fieldId;
312 $this->
addRows($result, [$fieldId => $id], $field);
327 isset($value[
'VALUE'])
328 && ($value[
'VALUE'] ===
'Y' || $value[
'VALUE'] ===
'N')
332 if (is_string($operator))
334 $fieldId = $operator.$fieldId;
337 $this->
addRows($result, [$fieldId => $value[
'VALUE']], $field);
350 if (isset($value[
'_value']))
352 $multiple = isset($field[
'params'][
'multiple']) && $field[
'params'][
'multiple'] ==
'Y';
354 $validRawValue = !empty($value[
'_value']) && is_array($value[
'_value']);
356 $validRawValue = is_string($value[
'_value']) || is_int($value[
'_value']);
360 if (is_string($operator))
362 $fieldId = $operator.$fieldId;
365 $this->
addRows($result, [$fieldId => $value[
'VALUE']], $field);
addNumberValue(array &$result, $fieldId, array $field, array $value)
addCheckboxValue(array &$result, $fieldId, array $field, array $value)
addDateValue(array &$result, $fieldId, array $field, array $value)
addQuickSearchValue(array &$filter, $fieldId, array $field, array $value)
addStringValue(array &$result, $fieldId, array $field, array $value)
addListValue(array &$result, $fieldId, array $field, array $value)
addRows(array &$result, array $items, array $field)
addDestSelectorValue(array &$result, $fieldId, array $field, array $value)
static getFilterOperator(array $field, $operator)