Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
numbertype.php
1
<?
2
3
namespace
Bitrix\Main\UI\Filter
;
4
5
10
class
NumberType
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
}
Bitrix\Main\UI\Filter\NumberType
Definition
numbertype.php:11
Bitrix\Main\UI\Filter\NumberType\LESS
const LESS
Definition
numbertype.php:15
Bitrix\Main\UI\Filter\NumberType\MORE
const MORE
Definition
numbertype.php:14
Bitrix\Main\UI\Filter\NumberType\getLogicFilter
static getLogicFilter(array $data, array $filterFields)
Definition
numbertype.php:43
Bitrix\Main\UI\Filter\NumberType\getPostfix
static getPostfix()
Definition
numbertype.php:32
Bitrix\Main\UI\Filter\NumberType\getList
static getList()
Definition
numbertype.php:22
Bitrix\Main\UI\Filter\NumberType\SINGLE
const SINGLE
Definition
numbertype.php:12
Bitrix\Main\UI\Filter\NumberType\RANGE
const RANGE
Definition
numbertype.php:13
Bitrix\Main\UI\Filter
Definition
actions.php:3
modules
main
lib
ui
filter
numbertype.php
Создано системой
1.10.0