Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
stringformattedtype.php
1
<?php
2
3
namespace
Bitrix\Main\UserField\Types
;
4
5
use
Bitrix\Main\Localization\Loc
;
6
use CUserTypeManager;
7
8
Loc::loadMessages
(__FILE__);
9
14
class
StringFormattedType
extends
StringType
15
{
16
public
const
17
USER_TYPE_ID
=
'string_formatted'
,
18
RENDER_COMPONENT
=
'bitrix:main.field.stringformatted'
;
19
20
public
static
function
getDescription
(): array
21
{
22
return
[
23
'DESCRIPTION'
=>
Loc::getMessage
(
'USER_TYPE_STRINGFMT_DESCRIPTION'
),
24
'BASE_TYPE'
=> CUserTypeManager::BASE_TYPE_STRING,
25
];
26
}
27
32
public
static
function
prepareSettings
(array $userField): array
33
{
34
$size = (int)$userField[
'SETTINGS'
][
'SIZE'
];
35
$rows = (int)$userField[
'SETTINGS'
][
'ROWS'
];
36
$min = (int)$userField[
'SETTINGS'
][
'MIN_LENGTH'
];
37
$max = (int)$userField[
'SETTINGS'
][
'MAX_LENGTH'
];
38
39
return
[
40
'SIZE'
=> ($size <= 1 ? 20 : ($size > 255 ? 225 : $size)),
41
'ROWS'
=> ($rows <= 1 ? 1 : ($rows > 50 ? 50 : $rows)),
42
'REGEXP'
=> $userField[
'SETTINGS'
][
'REGEXP'
],
43
'MIN_LENGTH'
=> $min,
44
'MAX_LENGTH'
=> $max,
45
'DEFAULT_VALUE'
=> $userField[
'SETTINGS'
][
'DEFAULT_VALUE'
],
46
'PATTERN'
=> $userField[
'SETTINGS'
][
'PATTERN'
],
47
];
48
}
49
55
public
static
function
getPublicViewHtml
(?array $userField, ?array $additionalParameters = []): ?string
56
{
57
$val = $additionalParameters[
'VALUE'
];
58
if
(trim($val) ===
''
)
59
{
60
return
null
;
61
}
62
63
return
htmlspecialcharsEx($val);
64
}
65
}
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\UserField\Types\StringFormattedType
Definition
stringformattedtype.php:15
Bitrix\Main\UserField\Types\StringFormattedType\USER_TYPE_ID
const USER_TYPE_ID
Definition
stringformattedtype.php:17
Bitrix\Main\UserField\Types\StringFormattedType\getPublicViewHtml
static getPublicViewHtml(?array $userField, ?array $additionalParameters=[])
Definition
stringformattedtype.php:55
Bitrix\Main\UserField\Types\StringFormattedType\getDescription
static getDescription()
Definition
stringformattedtype.php:20
Bitrix\Main\UserField\Types\StringFormattedType\RENDER_COMPONENT
const RENDER_COMPONENT
Definition
stringformattedtype.php:18
Bitrix\Main\UserField\Types\StringFormattedType\prepareSettings
static prepareSettings(array $userField)
Definition
stringformattedtype.php:32
Bitrix\Main\UserField\Types\StringType
Definition
stringtype.php:16
Bitrix\Main\UserField\Types
Definition
basetype.php:3
modules
main
lib
userfield
types
stringformattedtype.php
Создано системой
1.10.0