1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
integertype.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Main\UserField\Types;
4
5
use Bitrix\Main\Localization\Loc;
6
use Bitrix\Main\Text\HtmlFilter;
7
use CUserTypeManager;
8
9
Loc::loadMessages(__FILE__);
10
15
class
IntegerType
extends
BaseType
16
{
17
public
const
18
USER_TYPE_ID
=
'integer'
,
19
RENDER_COMPONENT
=
'bitrix:main.field.integer'
;
20
24
public
static
function
getDescription
():
array
25
{
26
return
[
27
'DESCRIPTION'
=>
GetMessage
(
'USER_TYPE_INTEGER_DESCRIPTION'
),
28
'BASE_TYPE'
=> CUserTypeManager::BASE_TYPE_INT
29
];
30
}
31
35
public
static
function
getDbColumnType
(): string
36
{
37
$connection
=
\Bitrix\Main\Application::getConnection
();
38
$helper =
$connection
->getSqlHelper();
39
return
$helper->getColumnTypeByField(
new
\
Bitrix
\
Main
\
ORM
\
Fields
\
IntegerField
(
'x'
));
40
}
41
46
public
static
function
prepareSettings
(
array
$userField):
array
47
{
48
$size = (int)($userField[
'SETTINGS'
][
'SIZE'
] ?? 0);
49
$min = (int)($userField[
'SETTINGS'
][
'MIN_VALUE'
] ?? 0);
50
$max
= (int)($userField[
'SETTINGS'
][
'MAX_VALUE'
] ?? 0);
51
$default = ($userField[
'SETTINGS'
][
'DEFAULT_VALUE'
] ??
''
) !==
''
52
? (
int
)$userField[
'SETTINGS'
][
'DEFAULT_VALUE'
]
53
: null
54
;
55
56
return
[
57
'SIZE'
=> ($size <= 1 ? 20 : ($size > 255 ? 225 : $size)),
58
'MIN_VALUE'
=> $min,
59
'MAX_VALUE'
=>
$max
,
60
'DEFAULT_VALUE'
=> $default
61
];
62
}
63
69
public
static
function
getFilterData
(?
array
$userField,
array
$additionalSettings):
array
70
{
71
return
[
72
'id'
=> $additionalSettings[
'ID'
],
73
'name'
=> $additionalSettings[
'NAME'
],
74
'type'
=>
'number'
,
75
'filterable'
=>
''
76
];
77
}
78
84
public
static
function
checkFields
(
array
$userField, $value):
array
85
{
86
$fieldName = HtmlFilter::encode(
87
$userField[
'EDIT_FORM_LABEL'
] <>
''
88
? $userField[
'EDIT_FORM_LABEL'
] : $userField[
'FIELD_NAME'
]
89
);
90
91
$msg = [];
92
if
(
93
$value !==
''
94
&& $userField[
'SETTINGS'
][
'MIN_VALUE'
] != 0
95
&& (
int
)$value < $userField[
'SETTINGS'
][
'MIN_VALUE'
]
96
)
97
{
98
$msg[] = [
99
'id'
=> $userField[
'FIELD_NAME'
],
100
'text'
=> Loc::getMessage(
'USER_TYPE_INTEGER_MIN_VALUE_ERROR'
,
101
[
102
'#FIELD_NAME#'
=> $fieldName,
103
'#MIN_VALUE#'
=> $userField[
'SETTINGS'
][
'MIN_VALUE'
]
104
]
105
),
106
];
107
}
108
if
(
109
$value !==
''
110
&& $userField[
'SETTINGS'
][
'MAX_VALUE'
] != 0
111
&& (
int
)$value > $userField[
'SETTINGS'
][
'MAX_VALUE'
]
112
)
113
{
114
$msg[] = [
115
'id'
=> $userField[
'FIELD_NAME'
],
116
'text'
=> Loc::getMessage(
'USER_TYPE_INTEGER_MAX_VALUE_ERROR'
,
117
[
118
'#FIELD_NAME#'
=> $fieldName,
119
'#MAX_VALUE#'
=> $userField[
'SETTINGS'
][
'MAX_VALUE'
]
120
]
121
),
122
];
123
}
124
if
(
125
$value !=
''
126
&& !preg_match(
'/^[-+]?\d+$/'
, $value)
127
)
128
{
129
$msg[] = [
130
'id'
=> $userField[
'FIELD_NAME'
],
131
'text'
=> Loc::getMessage(
'USER_TYPE_INTEGER_TYPE_ERROR'
,
132
[
133
'#FIELD_NAME#'
=> $fieldName
134
]
135
),
136
];
137
}
138
139
return
$msg;
140
}
141
146
public
static
function
onSearchIndex
(
array
$userField): ?string
147
{
148
if
(is_array($userField[
'VALUE'
]))
149
{
150
$result
= implode(
'\r\n'
, $userField[
'VALUE'
]);
151
}
152
else
153
{
154
$result
= $userField[
'VALUE'
];
155
}
156
return
$result
;
157
}
158
}
$connection
$connection
Определения
actionsdefinitions.php:38
Bitrix\Main\Application\getConnection
static getConnection($name="")
Определения
application.php:638
Bitrix\Main\ORM\Fields\IntegerField
Определения
integerfield.php:20
Bitrix\Main\UserField\Types\BaseType
Определения
basetype.php:6
Bitrix\Main\UserField\Types\IntegerType
Определения
integertype.php:16
Bitrix\Main\UserField\Types\IntegerType\USER_TYPE_ID
const USER_TYPE_ID
Определения
integertype.php:18
Bitrix\Main\UserField\Types\IntegerType\getFilterData
static getFilterData(?array $userField, array $additionalSettings)
Определения
integertype.php:69
Bitrix\Main\UserField\Types\IntegerType\getDescription
static getDescription()
Определения
integertype.php:24
Bitrix\Main\UserField\Types\IntegerType\onSearchIndex
static onSearchIndex(array $userField)
Определения
integertype.php:146
Bitrix\Main\UserField\Types\IntegerType\RENDER_COMPONENT
const RENDER_COMPONENT
Определения
integertype.php:19
Bitrix\Main\UserField\Types\IntegerType\getDbColumnType
static getDbColumnType()
Определения
integertype.php:35
Bitrix\Main\UserField\Types\IntegerType\checkFields
static checkFields(array $userField, $value)
Определения
integertype.php:84
Bitrix\Main\UserField\Types\IntegerType\prepareSettings
static prepareSettings(array $userField)
Определения
integertype.php:46
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$result
$result
Определения
get_property_values.php:14
GetMessage
GetMessage($name, $aReplace=null)
Определения
tools.php:3397
Bitrix\Main\ORM\Fields
Определения
arrayfield.php:9
Bitrix\Main\ORM
Bitrix\Main
Bitrix
$max
$max
Определения
template_copy.php:262
bitrix
modules
main
lib
userfield
types
integertype.php
Создано системой
1.14.0