3namespace Bitrix\Iblock\Integration\UI\EntitySelector;
5use Bitrix\Iblock\Component\Tools;
6use Bitrix\Iblock\PropertyTable;
7use Bitrix\UI\EntitySelector\BaseProvider;
8use Bitrix\UI\EntitySelector\Dialog;
9use Bitrix\UI\EntitySelector\Item;
10use Bitrix\UI\EntitySelector\SearchQuery;
19 parent::__construct();
26 return $GLOBALS[
'USER']->isAuthorized();
33 $filter = !empty($ids) ? [
'ID' => $ids] : [];
55 $recentItems = $dialog->
getRecentItems()->getEntityItems(self::ENTITY_ID);
56 $recentItemsCount =
count($recentItems);
58 if ($recentItemsCount < self::ELEMENTS_LIMIT)
60 $elements = $this->
getElements([], self::ELEMENTS_LIMIT);
61 foreach ($elements as $element)
79 if (
count($elements) === self::ELEMENTS_LIMIT)
83 foreach ($elements as $element)
96 private function getQueryFilter(
string $query):
array
99 '*SEARCHABLE_CONTENT' =>
$query,
107 $filter = $this->getDefaultFilter();
108 if (!empty($additionalFilter))
130 $elementData = \CIBlockElement::GetList(
137 while ($element = $elementData->fetch())
139 if (empty($element[
'PREVIEW_PICTURE']))
141 $element[
'PREVIEW_PICTURE'] = $this->getElementImage($element);
143 $elements[] = $element;
153 'id' => $element[
'ID'] ??
null,
154 'entityId' => self::ENTITY_ID,
155 'title' => $element[
'NAME'] ??
null,
156 'subtitle' => $element[
'ID'] ??
null,
157 'description' => $element[
'DETAIL_TEXT'] ??
null,
158 'avatar' => $element[
'PREVIEW_PICTURE'] ??
null,
160 'xmlId' => $element[
'XML_ID'] ??
null,
164 return new Item($itemParams);
167 private function getElementImage(
array $element): ?string
169 $iblockId = $element[
'IBLOCK_ID'] ??
null;
175 $photoPropertyId = $this->getMorePhotoPropertyId(
$iblockId);
176 if (!$photoPropertyId)
182 'ID' => $photoPropertyId,
184 $result = \CIBlockElement::GetProperty(
$iblockId, $element[
'ID'],
'sort',
'asc', $propertyFilter)->Fetch();
191 if (is_array(
$result[
'VALUE']))
193 $imageId = (int)
$result[
'VALUE'][0];
197 $imageId = (int)
$result[
'VALUE'];
200 return $this->getImageSource($imageId);
203 private function getDefaultFilter():
array
206 'CHECK_PERMISSIONS' =>
'Y',
207 'MIN_PERMISSION' =>
'R',
216 $activeFilter = $this->
getOption(
'activeFilter',
false);
225 private function getMorePhotoPropertyId(
int $iblockId): ?int
237 return (
int)$row[
'ID'];
243 private function getImageSource(
int $id): ?string
250 $file = \CFile::GetFileArray($id);
256 return Tools::getImageSrc($file,
false) ?:
null;
__construct(array $options=[])
fillDialog(Dialog $dialog)
getPreselectedItems(array $ids)
getElements(array $additionalFilter=[], ?int $limit=null)
doSearch(SearchQuery $searchQuery, Dialog $dialog)
static getList(array $parameters=array())
getOption(string $option, $defaultValue=null)
loadPreselectedItems($preselectedMode=true)
addRecentItem(Item $item)
setCacheable(bool $flag=true)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
$GLOBALS['____1690880296']
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"