Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
stringformattedtype.php
1<?php
2
4
6use CUserTypeManager;
7
8Loc::loadMessages(__FILE__);
9
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}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static getPublicViewHtml(?array $userField, ?array $additionalParameters=[])