Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
numbertype.php
1<?
2
4
5
11{
12 const SINGLE = "exact"; // =
13 const RANGE = "range"; // <= =>
14 const MORE = "more"; // >
15 const LESS = "less"; // <
16
17
22 public static function getList()
23 {
24 $reflection = new \ReflectionClass(__CLASS__);
25 return $reflection->getConstants();
26 }
27
32 public static function getPostfix()
33 {
34 return "_numsel";
35 }
36
43 public static function getLogicFilter(array $data, array $filterFields)
44 {
45 $filter = [];
46 $keys = array_filter($data, function($key) { return (mb_substr($key, 0 - mb_strlen(self::getPostfix())) == self::getPostfix()); }, ARRAY_FILTER_USE_KEY);
47 foreach ($keys as $key => $val)
48 {
49 $id = mb_substr($key, 0, 0 - mb_strlen(self::getPostfix()));
50 switch($val)
51 {
52 case self::SINGLE:
53 if (array_key_exists($id."_from", $data))
54 $filter["=".$id] = $data[$id."_from"];
55 else if (array_key_exists($id."_to", $data))
56 $filter["=".$id] = $data[$id."_to"];
57 break;
58 case self::RANGE:
59 if (array_key_exists($id."_from", $data))
60 $filter[">=".$id] = $data[$id."_from"];
61 if (array_key_exists($id."_to", $data))
62 $filter["<=".$id] = $data[$id."_to"];
63 break;
64 case self::MORE:
65 if (array_key_exists($id."_from", $data))
66 $filter[">".$id] = $data[$id."_from"];
67 break;
68 case self::LESS:
69 if (array_key_exists($id."_to", $data))
70 $filter["<".$id] = $data[$id."_to"];
71 break;
72 }
73 }
74 return $filter;
75 }
76}
static getLogicFilter(array $data, array $filterFields)