Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
sectionselectcontrol.php
1<?php
2
4
7use CIBlockSection;
8
9trait SectionSelectControl
10{
11 private array $sectionTree;
12
13 abstract protected function getIblockId(): int;
14
15 protected function getSectionSelectControl(bool $withTopLevel): array
16 {
17 $dropdownSectionItems = [];
18
19 if ($withTopLevel)
20 {
21 $dropdownSectionItems[] = [
22 'NAME' => Loc::getMessage('IBLOCK_GRID_PANEL_UI_ACTIONS_ITEM_ELEMENT_GROUP_SECTION_TREE_TOP_LEVEL_NAME'),
23 'VALUE' => 0,
24 ];
25 }
26
27 if (!isset($this->sectionTree))
28 {
29 $this->sectionTree = [];
30
31 $rows = CIBlockSection::getTreeList(
32 ['IBLOCK_ID' => $this->getIblockId()],
33 ['ID', 'NAME', 'DEPTH_LEVEL']
34 );
35 while ($row = $rows->Fetch())
36 {
37 $this->sectionTree[] = [
38 'NAME' => str_repeat(' . ', $row['DEPTH_LEVEL']) . $row['NAME'],
39 'VALUE' => (int)$row['ID'],
40 ];
41 }
42 }
43
44 array_push($dropdownSectionItems, ...$this->sectionTree);
45
46 return [
47 'TYPE' => Types::DROPDOWN,
48 'ID' => 'section_id',
49 'NAME' => 'section_id',
50 'ITEMS' => $dropdownSectionItems,
51 ];
52 }
53}
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29