13 private const ENTITY_ID =
'iblock-property-section';
14 private const ELEMENTS_LIMIT = 100;
18 parent::__construct();
25 return $GLOBALS[
'USER']->isAuthorized();
32 $filter = !empty($ids) ? [
'ID' => $ids] : [];
34 foreach ($this->getElements($filter) as $element)
36 $items[] = $this->makeItem($element);
54 $recentItems = $dialog->
getRecentItems()->getEntityItems(self::ENTITY_ID);
55 $recentItemsCount = count($recentItems);
57 if ($recentItemsCount < self::ELEMENTS_LIMIT)
59 $elements = $this->getElements([], self::ELEMENTS_LIMIT);
60 foreach ($elements as $element)
74 $filter = $this->getQueryFilter($query);
77 $elements = $this->getElements($filter, self::ELEMENTS_LIMIT);
78 if (count($elements) === self::ELEMENTS_LIMIT)
82 foreach ($elements as $element)
85 $this->makeItem($element)
95 private function getQueryFilter(
string $query): array
102 private function getElements(array $additionalFilter = [], ?
int $limit =
null): array
106 $filter = $this->getDefaultFilter();
107 if (!empty($additionalFilter))
109 $filter = array_merge($filter, $additionalFilter);
115 $navParams = [
'nTopCount' => $limit];
129 $elementData = \CIBlockSection::GetList(
136 while ($element = $elementData->fetch())
138 $element[
'PICTURE'] = $this->getImageSource((
int)$element[
'PICTURE']);
139 $elements[] = $element;
146 private function makeItem(array $element): Item
149 'id' => $element[
'ID'] ??
null,
150 'entityId' => self::ENTITY_ID,
151 'title' => $element[
'NAME'] ??
null,
152 'subtitle' => $element[
'ID'] ??
null,
153 'description' => $element[
'DESCRIPTION'] ??
null,
154 'avatar' => $element[
'PICTURE'] ??
null,
156 'xmlId' => $element[
'XML_ID'] ??
null,
160 return new Item($itemParams);
163 private function getDefaultFilter(): array
166 'CHECK_PERMISSIONS' =>
'Y',
167 'MIN_PERMISSION' =>
'R',
170 $iblockId = (int)($this->
getOption(
'iblockId', 0));
171 if (!empty($iblockId))
173 $filter[
'IBLOCK_ID'] = $iblockId;
179 private function getImageSource(
int $id): ?string
186 $file = \CFile::GetFileArray($id);
192 return Tools::getImageSrc($file,
false) ?:
null;
$GLOBALS['____1444769544']