Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
numberfield.php
1
<?php
8
namespace
Bitrix\Sender\Connector\Filter
;
9
10
use
Bitrix\Main\UI\Filter\NumberType
as FilterNumberType;
11
16
class
NumberField
extends
AbstractField
17
{
24
public
function
applyFilter
(array &$filter = array())
25
{
26
$filterKey = $this->
getFilterKey
();
27
$data
= $this->calcNumbers();
28
29
switch
(
$data
[
'op'
])
30
{
31
case
FilterNumberType::SINGLE
:
32
if
(is_numeric(
$data
[
'from'
]))
33
{
34
$filter[
"=$filterKey"
] =
$data
[
'from'
];
35
}
36
return
;
37
38
case
FilterNumberType::MORE
:
39
case
FilterNumberType::LESS
:
40
$opMore =
'>'
;
41
$opLess =
'<'
;
42
break
;
43
44
default
:
45
$opMore =
'>='
;
46
$opLess =
'<='
;
47
break
;
48
49
}
50
51
if
(is_numeric(
$data
[
'from'
]))
52
{
53
$filter[
"{$opMore}$filterKey"
] =
$data
[
'from'
];
54
}
55
if
(is_numeric(
$data
[
'to'
]))
56
{
57
$filter[
"{$opLess}$filterKey"
] =
$data
[
'to'
];
58
}
59
}
60
61
private
function
calcNumbers()
62
{
63
$result = array(
64
'op'
=>
FilterNumberType::SINGLE
,
65
'from'
=>
null
,
66
'to'
=>
null
,
67
);
68
$value = $this->
getValue
();
69
if
(!is_array($value) || count($value) === 0)
70
{
71
return
$result;
72
}
73
74
$id = $this->
getId
();
75
if
(isset($value[
"{$id}_numsel"
]) && in_array($value[
"{$id}_numsel"
],
FilterNumberType::getList
()))
76
{
77
$result[
'op'
] = $value[
"{$id}_numsel"
];
78
}
79
80
if
(isset($value[
"{$id}_from"
]))
81
{
82
$result[
'from'
] = $value[
"{$id}_from"
];
83
}
84
85
if
(isset($value[
"{$id}_to"
]))
86
{
87
$result[
'to'
] = $value[
"{$id}_to"
];
88
}
89
90
return
$result;
91
}
92
}
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\getList
static getList()
Definition
numbertype.php:22
Bitrix\Main\UI\Filter\NumberType\SINGLE
const SINGLE
Definition
numbertype.php:12
Bitrix\Sender\Connector\Filter\AbstractField
Definition
abstractfield.php:17
Bitrix\Sender\Connector\Filter\AbstractField\getId
getId()
Definition
abstractfield.php:47
Bitrix\Sender\Connector\Filter\AbstractField\$data
$data
Definition
abstractfield.php:19
Bitrix\Sender\Connector\Filter\AbstractField\getValue
getValue($defaultValue=null)
Definition
abstractfield.php:68
Bitrix\Sender\Connector\Filter\AbstractField\getFilterKey
getFilterKey()
Definition
abstractfield.php:57
Bitrix\Sender\Connector\Filter\NumberField
Definition
numberfield.php:17
Bitrix\Sender\Connector\Filter\NumberField\applyFilter
applyFilter(array &$filter=array())
Definition
numberfield.php:24
Bitrix\Sender\Connector\Filter
Definition
abstractfield.php:8
modules
sender
lib
connector
filter
numberfield.php
Создано системой
1.10.0