3namespace Bitrix\Catalog\UI\FileUploader;
5use Bitrix\Catalog\Access\AccessController;
6use Bitrix\Catalog\Access\ActionDictionary;
7use Bitrix\Catalog\v2\Image\MorePhotoImage;
8use Bitrix\Catalog\v2\IoC\ServiceContainer;
9use Bitrix\Iblock\PropertyTable;
10use Bitrix\Main\ArgumentException;
11use Bitrix\Main\Engine\CurrentUser;
12use Bitrix\UI\FileUploader\FileOwnershipCollection;
13use Bitrix\UI\FileUploader\Configuration;
14use Bitrix\UI\FileUploader\UploaderController;
18 private ?
array $property;
30 $options[
'iblockId'] = (int)\CIBlockElement::GetIBlockByID(
$options[
'productId']);
38 $iblockInfo = ServiceContainer::getIblockInfo(
$options[
'iblockId']);
44 $options[
'fieldName'] ??= MorePhotoImage::CODE;
52 $this->
property = $this->loadProperty(
$options[
'iblockId'],
$options[
'fieldName']);
57 private function loadProperty(
int $iblockId,
string $fieldName): ?
array
59 return PropertyTable::getRow([
60 'select' => [
'ID',
'FILE_TYPE'],
65 '=CODE' => $fieldName,
72 return AccessController::getCurrent()->check(ActionDictionary::ACTION_CATALOG_READ);
79 $acceptedFileTypes = [];
81 if (!empty($this->property[
'FILE_TYPE']))
83 $propertyFileTypes = $this->prepareAcceptedFileTypes($this->property[
'FILE_TYPE']);
84 if (!empty($propertyFileTypes))
86 $acceptedFileTypes = array_intersect(Configuration::getImageExtensions(), $propertyFileTypes);
90 if (!empty($acceptedFileTypes))
92 $configuration->setAcceptedFileTypes($acceptedFileTypes);
96 $configuration->acceptOnlyImages();
99 return $configuration;
102 private function prepareAcceptedFileTypes(
string $fileTypes):
array
104 $imageExtensions = explode(
',', $fileTypes);
106 return array_map(
static fn ($extension) =>
'.' . trim($extension), $imageExtensions);
111 return CurrentUser::get()->canDoOperation(ActionDictionary::ACTION_STORE_VIEW);
__construct(array $options=[])
verifyFileOwner(FileOwnershipCollection $files)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)