1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
internalselect.php
См. документацию.
1<?php
2
3namespace Bitrix\Bizproc\BaseType;
4
5use Bitrix\Bizproc\FieldType;
6use Bitrix\Main\Localization\Loc;
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 = [];
88 $fields = $documentService->getDocumentFields($fieldType->getDocumentType());
89 if (!is_array($fields))
90 {
91 return $result;
92 }
93
94 foreach ($fields as $key => $field)
95 {
96 if ($field['Type'] === 'select' && mb_substr($key, -10) !== '_PRINTABLE')
97 {
98 $result[$key] = $field;
99 if (isset($field['Alias']) && !$ignoreAliases)
100 {
101 $result[$field['Alias']] = $field;
102 }
103 }
104 }
105
106 return $result;
107 }
108
109 public static function convertPropertyToView(FieldType $fieldType, int $viewMode, array $property): array
110 {
111 if ($viewMode === FieldType::RENDER_MODE_JN_MOBILE)
112 {
113 $property['Type'] = FieldType::SELECT;
114 }
115
116 return parent::convertPropertyToView($fieldType, $viewMode, $property);
117 }
118}
static renderControlOptions(FieldType $fieldType, $callbackFunctionName, $value)
Определения internalselect.php:30
static getFieldOptions(FieldType $fieldType)
Определения internalselect.php:61
static convertPropertyToView(FieldType $fieldType, int $viewMode, array $property)
Определения internalselect.php:109
getOptions()
Определения fieldtype.php:246
const SELECT
Определения fieldtype.php:47
const INTERNALSELECT
Определения fieldtype.php:52
const RENDER_MODE_JN_MOBILE
Определения fieldtype.php:97
setOptions($options)
Определения fieldtype.php:255
getDocumentType()
Определения fieldtype.php:184
$options
Определения commerceml2.php:49
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
$name
Определения menu_edit.php:35
if(empty($signedUserToken)) $key
Определения quickway.php:257
$fields
Определения yandex_run.php:501