1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
multiplefieldassembler.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Iblock\Grid\Row\Assembler\Property;
4
5
use Bitrix\Main;
6
use Bitrix\Iblock\Grid\Column\ElementPropertyProvider;
7
use Bitrix\Iblock\PropertyTable;
8
use Bitrix\Main\Grid\Row\FieldAssembler;
9
10
final
class
MultipleFieldAssembler
extends
FieldAssembler
11
{
12
private
int
$iblockId;
13
14
public
function
__construct
(
int
$iblockId,
array
$excludeColumnsIds)
15
{
16
$this->iblockId = $iblockId;
17
18
parent::__construct(
19
$this->getPropertyColumnsIds($excludeColumnsIds)
20
);
21
}
22
23
private
function
getPropertyColumnsIds(
array
$excludeColumnsIds):
array
24
{
25
$result
= [];
26
27
$rows
=
PropertyTable::getList
([
28
'select'
=> [
29
'ID'
,
30
],
31
'filter'
=> [
32
'=IBLOCK_ID'
=> $this->iblockId,
33
'=MULTIPLE'
=>
'Y'
,
34
'USER_TYPE'
=>
null
,
35
],
36
]);
37
foreach
(
$rows
as $row)
38
{
39
$columnId = ElementPropertyProvider::getColumnIdByPropertyId((
int
)$row[
'ID'
]);
40
if
(!in_array($columnId, $excludeColumnsIds,
true
))
41
{
42
$result
[] = $columnId;
43
}
44
}
45
46
return
$result
;
47
}
48
49
protected
function
prepareRow
(
array
$row):
array
50
{
51
$columnIds = $this->
getColumnIds
();
52
if
(empty($columnIds))
53
{
54
return
$row;
55
}
56
57
$row[
'columns'
] ??= [];
58
59
foreach
($columnIds as $columnId)
60
{
61
$value = $this->getFlatColumnValues($row[
'data'
][$columnId] ??
null
);
62
if
(is_array($value))
63
{
64
$value = join(
' / '
, $value);
65
}
66
$value =
Main\Text\HtmlFilter::encode
((
string
)$value);
67
68
$row[
'columns'
][$columnId] ??= $value;
69
$row[
'data'
][
'~'
. $columnId] ??= $value;
70
}
71
72
return
$row;
73
}
74
75
private
static
function
getFlatColumnValues(mixed $rawValues)
76
{
77
if
(!is_array($rawValues))
78
{
79
return
null
;
80
}
81
if
(array_key_exists(
'VALUE'
, $rawValues))
82
{
83
return
$rawValues[
'VALUE'
];
84
}
85
else
86
{
87
$result
= [];
88
foreach
($rawValues as $row)
89
{
90
if
(is_array($row) && array_key_exists(
'VALUE'
, $row))
91
{
92
$result
[] = $row[
'VALUE'
];
93
}
94
}
95
96
return
$result
;
97
}
98
}
99
}
Bitrix\Iblock\Grid\Row\Assembler\Property\MultipleFieldAssembler
Определения
multiplefieldassembler.php:11
Bitrix\Iblock\Grid\Row\Assembler\Property\MultipleFieldAssembler\__construct
__construct(int $iblockId, array $excludeColumnsIds)
Определения
multiplefieldassembler.php:14
Bitrix\Iblock\Grid\Row\Assembler\Property\MultipleFieldAssembler\prepareRow
prepareRow(array $row)
Определения
multiplefieldassembler.php:49
Bitrix\Main\Grid\Row\FieldAssembler
Определения
fieldassembler.php:25
Bitrix\Main\Grid\Row\FieldAssembler\getColumnIds
getColumnIds()
Определения
fieldassembler.php:47
Bitrix\Main\ORM\Data\DataManager\getList
static getList(array $parameters=array())
Определения
datamanager.php:431
Bitrix\Main\Text\HtmlFilter\encode
static encode($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения
htmlfilter.php:12
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$result
$result
Определения
get_property_values.php:14
$rows
$rows
Определения
options.php:264
bitrix
modules
iblock
lib
grid
row
assembler
property
multiplefieldassembler.php
Создано системой
1.14.0