Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
sectionnamefieldassembler.php
1<?php
2
4
10
12{
13 private ?BaseBuilder $urlBuilder;
14
15 public function __construct(array $columnIds, ?BaseBuilder $urlBuilder = null)
16 {
17 parent::__construct($columnIds);
18
19 $this->urlBuilder = $urlBuilder;
20 $this->preloadResources();
21 }
22
33 private function preloadResources(): void
34 {
35 Extension::load([
36 'ui.icons.disk',
37 ]);
38 }
39
40 protected function prepareRow(array $row): array
41 {
42 $rowType = $row['data']['ROW_TYPE'] ?? null;
43 if ($rowType !== RowType::SECTION)
44 {
45 return $row;
46 }
47
48 $sectionId = (int)($row['data']['ID'] ?? 0);
49 $sectionName = (string)($row['data']['NAME'] ?? '');
50 if ($sectionId > 0 && !empty($sectionName))
51 {
52 $prefix = '<span class="ui-icon ui-icon-xs ui-icon-file-folder"><i></i></span>';
53 $name = '<span class="element-field-grid-section-cell-name">' . htmlspecialcharsbx($sectionName) . '</span>';
54
55 if (isset($this->urlBuilder))
56 {
57 $link = new Uri($this->urlBuilder->getSectionListUrl($sectionId));
58
59 $columnValue =
60 '<a class="element-field-grid-section-cell" href="' . htmlspecialcharsbx($link->toAbsolute()) . '">'
61 . $prefix
62 . $name
63 . '</a>'
64 ;
65 }
66 else
67 {
68 $columnValue =
69 '<div class="element-field-grid-section-cell">'
70 . $prefix
71 . $name
72 . '</div>'
73 ;
74 }
75
76 $row['columns'] ??= [];
77 foreach ($this->getColumnIds() as $columnId)
78 {
79 $row['columns'][$columnId] = $columnValue;
80 }
81 }
82
83 return $row;
84 }
85}
__construct(array $columnIds, ?BaseBuilder $urlBuilder=null)