Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
urltype.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
UrlType
extends
StringType
15
{
16
public
const
17
USER_TYPE_ID
=
'url'
,
18
RENDER_COMPONENT
=
'bitrix:main.field.url'
;
19
20
public
static
function
getDescription
(): array
21
{
22
return
array(
23
'DESCRIPTION'
=> GetMessage(
'USER_TYPE_URL_DESCRIPTION'
),
24
'BASE_TYPE'
=> CUserTypeManager::BASE_TYPE_STRING
25
);
26
}
27
32
public
static
function
prepareSettings
(array $userField): array
33
{
34
$popup = (($userField[
'SETTINGS'
][
'POPUP'
] ??
'Y'
) ===
'N'
?
'N'
:
'Y'
);
35
$size = (int)($userField[
'SETTINGS'
][
'SIZE'
] ?? 0);
36
$min = (int)($userField[
'SETTINGS'
][
'MIN_LENGTH'
] ?? 0);
37
$max = (int)($userField[
'SETTINGS'
][
'MAX_LENGTH'
] ?? 0);
38
$defaultValue = $userField[
'SETTINGS'
][
'DEFAULT_VALUE'
] ??
''
;
39
40
return
[
41
'POPUP'
=> $popup,
42
'SIZE'
=> ($size <= 1 ? 20 : ($size > 255 ? 225 : $size)),
43
'MIN_LENGTH'
=> $min,
44
'MAX_LENGTH'
=> $max,
45
'DEFAULT_VALUE'
=> $defaultValue,
46
];
47
}
48
54
public
static
function
onBeforeSave
(?array $userField, $value)
55
{
56
$value = (string)$value;
57
return
($value !==
''
? trim($value) : $value);
58
}
59
}
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\UserField\Types\StringType
Definition
stringtype.php:16
Bitrix\Main\UserField\Types\UrlType
Definition
urltype.php:15
Bitrix\Main\UserField\Types\UrlType\USER_TYPE_ID
const USER_TYPE_ID
Definition
urltype.php:17
Bitrix\Main\UserField\Types\UrlType\onBeforeSave
static onBeforeSave(?array $userField, $value)
Definition
urltype.php:54
Bitrix\Main\UserField\Types\UrlType\getDescription
static getDescription()
Definition
urltype.php:20
Bitrix\Main\UserField\Types\UrlType\RENDER_COMPONENT
const RENDER_COMPONENT
Definition
urltype.php:18
Bitrix\Main\UserField\Types\UrlType\prepareSettings
static prepareSettings(array $userField)
Definition
urltype.php:32
Bitrix\Main\UserField\Types
Definition
basetype.php:3
modules
main
lib
userfield
types
urltype.php
Создано системой
1.10.0