Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
internalselect.php
1<?php
2
4
7
8Loc::loadMessages(__FILE__);
9
15{
19 public static function getType()
20 {
22 }
23
30 public static function renderControlOptions(FieldType $fieldType, $callbackFunctionName, $value)
31 {
32 $result = '';
33 $selectedField = $fieldType->getOptions();
34
35 $fields = self::getDocumentSelectFields($fieldType, true);
36 if (!empty($fields))
37 {
38 $result .= '<select onchange="'.htmlspecialcharsbx($callbackFunctionName).'(this.options[this.selectedIndex].value)">';
39
40 $fieldsNames = array_keys($fields);
41 if (!in_array($selectedField, $fieldsNames))
42 $selectedField = isset($fieldsNames[0]) ? $fieldsNames[0] : '';
43
44 foreach ($fields as $name => $field)
45 {
46 $result .= '<option value="'.htmlspecialcharsbx($name).'"'.(($selectedField == $name) ? " selected" : "").'>'
47 .htmlspecialcharsbx($field["Name"]).'</option>';
48 }
49 $result .= '</select>';
50 }
51 $result .= '<!--__defaultOptionsValue:'.$selectedField.'--><!--__modifyOptionsPromt:'.Loc::getMessage('BPDT_INTERNALSELECT_OPT_LABEL').'-->';
52 $fieldType->setOptions($selectedField);
53
54 return $result;
55 }
56
61 protected static function getFieldOptions(FieldType $fieldType)
62 {
63 $optionsValue = $fieldType->getOptions();
64
65 $fields = self::getDocumentSelectFields($fieldType);
66 $options = array();
67
68 if (isset($fields[$optionsValue]['Options']))
69 {
70 $options = $fields[$optionsValue]['Options'];
71 }
72
73 return static::normalizeOptions($options);
74 }
75
81 private static function getDocumentSelectFields(FieldType $fieldType, $ignoreAliases = false)
82 {
83 $runtime = \CBPRuntime::getRuntime();
84 $runtime->startRuntime();
85 $documentService = $runtime->getService("DocumentService");
86
87 $result = array();
88 $fields = $documentService->getDocumentFields($fieldType->getDocumentType());
89 foreach ($fields as $key => $field)
90 {
91 if ($field['Type'] == 'select' && mb_substr($key, -10) != '_PRINTABLE')
92 {
93 $result[$key] = $field;
94 if (isset($field['Alias']) && !$ignoreAliases)
95 $result[$field['Alias']] = $field;
96 }
97 }
98 return $result;
99 }
100
101 public static function convertPropertyToView(FieldType $fieldType, int $viewMode, array $property): array
102 {
103 if ($viewMode === FieldType::RENDER_MODE_JN_MOBILE)
104 {
105 $property['Type'] = FieldType::SELECT;
106 }
107
108 return parent::convertPropertyToView($fieldType, $viewMode, $property);
109 }
110}
static renderControlOptions(FieldType $fieldType, $callbackFunctionName, $value)
static getFieldOptions(FieldType $fieldType)
static convertPropertyToView(FieldType $fieldType, int $viewMode, array $property)
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29