1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
Element.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Iblock\UI\Input
;
4
5
use
Bitrix\Iblock\Integration\UI\EntitySelector\IblockPropertyElementProvider
;
6
use
Bitrix\Iblock\PropertyTable
;
7
use
Bitrix\Main\Localization\Loc
;
8
use
Bitrix\Main\Type
;
9
use
Bitrix\Main\UI
;
10
use
Bitrix\Main\Web\Json
;
11
12
class
Element
13
{
14
public
static
function
renderSelector
(
array
$property,
array
|
int
|
string
|
null
$values,
array
$config
): string
15
{
16
$rowId = trim((
string
)(
$config
[
'ROW_ID'
] ??
''
));
17
$fieldName = trim((
string
)(
$config
[
'FIELD_NAME'
] ??
''
));
18
if
($fieldName ===
''
)
19
{
20
return
''
;
21
}
22
23
if
(($property[
'PROPERTY_TYPE'
] ??
''
) !==
PropertyTable::TYPE_ELEMENT
)
24
{
25
return
''
;
26
}
27
28
$containerId =
29
$rowId . ($rowId !==
''
?
'_'
:
''
)
30
. $fieldName .
'_container'
31
;
32
33
if
(!is_array($values))
34
{
35
$values = !empty($values) ? [$values] : [];
36
}
37
Type\Collection::normalizeArrayValuesByInt
($values,
false
);
38
39
$multiple = ($property[
'MULTIPLE'
] ??
'N'
) ===
'Y'
;
40
41
$config
[
'SEARCH_TITLE'
] = (string)(
$config
[
'SEARCH_TITLE'
] ??
''
);
42
if
(
$config
[
'SEARCH_TITLE'
] ===
''
)
43
{
44
$config
[
'SEARCH_TITLE'
] = Loc::getMessage(
'IBLOCK_UI_INPUT_ELEMENT_SELECTOR_SEARCH_TITLE'
);
45
}
46
$config
[
'SEARCH_SUBTITLE'
] = (string)(
$config
[
'SEARCH_SUBTITLE'
] ??
''
);
47
if
(
$config
[
'SEARCH_SUBTITLE'
] ===
''
)
48
{
49
$config
[
'SEARCH_SUBTITLE'
] = Loc::getMessage(
'IBLOCK_UI_INPUT_ELEMENT_SELECTOR_SEARCH_SUBTITLE'
);
50
}
51
52
$config
[
'ENTITY_ID'
] = (string)(
$config
[
'ENTITY_ID'
] ?? IblockPropertyElementProvider::ENTITY_ID);
53
54
$config
[
'CHANGE_EVENTS'
] ??= [];
55
if
(!is_array(
$config
[
'CHANGE_EVENTS'
]))
56
{
57
$config
[
'CHANGE_EVENTS'
] = is_string(
$config
[
'CHANGE_EVENTS'
]) ? [
$config
[
'CHANGE_EVENTS'
]] : [];
58
}
59
60
$config
= Json::encode([
61
'containerId'
=> $containerId,
62
'fieldName'
=> $fieldName . ($multiple ?
'[]'
:
''
),
63
'multiple'
=> $multiple,
64
'collectionType'
=>
'int'
,
65
'selectedItems'
=> $values,
66
'iblockId'
=> (
int
)($property[
'LINK_IBLOCK_ID'
] ?? 0),
67
'userType'
=> (
string
)($property[
'USER_TYPE'
] ??
''
),
68
'entityId'
=>
$config
[
'ENTITY_ID'
],
69
'searchMessages'
=> [
70
'title'
=>
$config
[
'SEARCH_TITLE'
],
71
'subtitle'
=>
$config
[
'SEARCH_SUBTITLE'
],
72
],
73
'changeEvents'
=>
$config
[
'CHANGE_EVENTS'
],
74
]);
75
76
UI\Extension::load
(
'iblock.field-selector'
);
77
78
return
<<<HTML
79
<div
id
=
"$containerId"
></div>
80
<script>
81
(
function
() {
82
const
selector =
new
BX.Iblock.FieldSelector({
$config
});
83
selector.render();
84
})();
85
</script>
86
HTML
87
;
88
}
89
}
Bitrix\Iblock\Integration\UI\EntitySelector\IblockPropertyElementProvider
Определения
IblockPropertyElementProvider.php:13
Bitrix\Iblock\PropertyTable
Определения
propertytable.php:61
Bitrix\Iblock\PropertyTable\TYPE_ELEMENT
const TYPE_ELEMENT
Определения
propertytable.php:68
Bitrix\Iblock\UI\Input\Element
Определения
Element.php:13
Bitrix\Iblock\UI\Input\Element\renderSelector
static renderSelector(array $property, array|int|string|null $values, array $config)
Определения
Element.php:14
Bitrix\Main\Localization\Loc
Определения
loc.php:12
Bitrix\Main\Type\Collection\normalizeArrayValuesByInt
static normalizeArrayValuesByInt(&$map, $sorted=true)
Определения
collection.php:150
Bitrix\Main\UI\Extension\load
static load($extNames)
Определения
extension.php:16
Bitrix\Main\Web\Json
Определения
json.php:9
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
Bitrix\Iblock\UI\Input
Определения
Element.php:3
Bitrix\Main\Type
Определения
collection.php:2
Bitrix\Main\UI
$config
$config
Определения
quickway.php:69
bitrix
modules
iblock
lib
UI
Input
Element.php
Создано системой
1.14.0