Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
urltype.php
1<?php
2
4
6use CUserTypeManager;
7
8Loc::loadMessages(__FILE__);
9
14class 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}
static loadMessages($file)
Definition loc.php:64
static onBeforeSave(?array $userField, $value)
Definition urltype.php:54
static prepareSettings(array $userField)
Definition urltype.php:32