Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
listfieldassembler.php
1<?php
2
4
9
11{
12 public function __construct(int $iblockId)
13 {
14 parent::__construct($iblockId, []);
15 }
16
17 protected function getPropertyFilter(): array
18 {
19 return [
20 '=PROPERTY_TYPE' => PropertyTable::TYPE_LIST,
21 '=USER_TYPE' => null,
22 ];
23 }
24
25 protected function validateProperty(array $property): ?array
26 {
27 return $property;
28 }
29
30 protected function prepareRow(array $row): array
31 {
32 if (!self::isElementRow($row))
33 {
34 return $row;
35 }
36
37 $columnIds = $this->getColumnIds();
38 if (empty($columnIds))
39 {
40 return $row;
41 }
42
43 $row['columns'] ??= [];
44
45 $columnToPropertyIds = ElementPropertyProvider::getPropertyIdsFromColumnsIds($columnIds);
46 foreach ($columnToPropertyIds as $columnId => $propertyId)
47 {
48 // edit
49 $value = $this->getColumnValues($row['data'][$columnId] ?? null, 'VALUE_ENUM_ID');
50 Main\Type\Collection::normalizeArrayValuesByInt($value, false);
51 if ($this->isMultipleColumn($columnId))
52 {
53 $row['data']['~' . $columnId] = $value;
54 }
55 else
56 {
57 $row['data']['~' . $columnId] = empty($value) ? '' : reset($value);
58 }
59
60 // view
61 $value = $this->getColumnValues($row['data'][$columnId] ?? null, 'VALUE');
62 $viewValue = '';
63 if (!empty($value))
64 {
65 $viewValue = join(' / ', $value);
66 }
67 $viewValue = Main\Text\HtmlFilter::encode($viewValue);
68 $row['columns'][$columnId] ??= $viewValue;
69 }
70
71 /*
72 $columnToPropertyIds = ElementPropertyProvider::getPropertyIdsFromColumnsIds($columnIds);
73 foreach ($columnToPropertyIds as $columnId => $propertyId)
74 {
75 if (isset($row['columns'][$columnId]))
76 {
77 continue;
78 }
79
80 $value = $row['data'][$columnId] ?? null;
81 if (is_array($value))
82 {
83 $tmp = [];
84 foreach ($value as $valueItem)
85 {
86 if (is_numeric($valueItem))
87 {
88 $tmp[] = $this->getEnumValue($propertyId, $valueItem);
89 }
90 else
91 {
92 $tmp[] = $valueItem;
93 }
94
95 }
96
97 $value = join(' / ', $tmp);
98 }
99 elseif (is_numeric($value))
100 {
101 $value = $this->getEnumValue($propertyId, $value);
102 }
103
104 $row['columns'][$columnId] = $value;
105 }
106
107 */
108
109 return $row;
110 }
111}
getColumnValues(mixed $rawValues, string $fieldName='VALUE')