AnonSec Shell
Server IP : 85.193.89.191  /  Your IP : 3.145.104.137
Web Server : Apache
System : Linux 956367-cx40159.tmweb.ru 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64
User : bitrix ( 600)
PHP Version : 8.1.27
Disable Function : NONE
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/bitrix/www/bitrix/components/bitrix/catalog.image.input/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/bitrix/www/bitrix/components/bitrix/catalog.image.input/class.php
<?php

use Bitrix\Main\Errorable;
use Bitrix\Main\ErrorableImplementation;
use Bitrix\Main\ErrorCollection;
use Bitrix\Main\UI\FileInput;

if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true)
{
	die();
}

class CatalogImageInput extends \CBitrixComponent implements Errorable
{
	use ErrorableImplementation;

	public function __construct($component = null)
	{
		parent::__construct($component);
		$this->errorCollection = new ErrorCollection();
	}

	protected function showErrors(): void
	{
		foreach ($this->getErrors() as $error)
		{
			ShowError($error);
		}
	}

	public function onPrepareComponentParams($params): array
	{
		$params['ENABLE_AUTO_SAVING'] = $params['ENABLE_AUTO_SAVING'] ?? true;
		$params['FILE_VALUES'] = $params['FILE_VALUES'] ?? [];
		$params['FILE_SETTINGS'] = $params['FILE_SETTINGS'] ?? [];

		return parent::onPrepareComponentParams($params);
	}

	public function executeComponent(): void
	{
		if ($this->hasErrors())
		{
			$this->showErrors();

			return;
		}

		$entity = $this->arParams['PRODUCT_ENTITY'];

		$this->arResult['JS_PARAMS'] = ['saveable' => false];

		if ($entity instanceof \Bitrix\Catalog\v2\Product\BaseProduct)
		{
			$this->arResult['JS_PARAMS'] = [
				'saveable' => $this->arParams['ENABLE_AUTO_SAVING'],
				'iblockId' => $entity->getIblockId(),
				'productId' => $entity->getId(),
				'skuId' => $entity->getId(),
			];
		}
		elseif ($entity instanceof \Bitrix\Catalog\v2\Sku\BaseSku)
		{
			$product = $entity->getParent();
			if ($product instanceof \Bitrix\Catalog\v2\BaseIblockElementEntity)
			{
				$this->arResult['JS_PARAMS'] = [
					'saveable' => $this->arParams['ENABLE_AUTO_SAVING'],
					'iblockId' => $product->getIblockId(),
					'productId' => $product->getId(),
					'skuId' => $entity->getId(),
				];
			}
		}

		$this->arResult['JS_PARAMS']['inputId'] = $this->arParams['INPUT_ID'] ?? '';
		$this->arResult['JS_PARAMS']['values'] = $this->arParams['FILE_SIGNED_VALUES'] ?? [];
		if (isset($this->arParams['FILE_SETTINGS']['maxCount']) && $this->arParams['FILE_SETTINGS']['maxCount'] <= 1)
		{
			$this->arResult['JS_PARAMS']['hideAddButton'] = true;
		}

		$uiKeys = ['FILE_VALUES', 'FILE_SETTINGS', 'LOADER_PREVIEW', 'DISABLED'];
		$this->arResult['UI_PARAMS'] = array_intersect_key($this->arParams, array_flip($uiKeys));
		$this->arResult['BLOCK_ID'] = uniqid('catalog_image_editor_', false);

		$this->includeComponentTemplate();
	}
}

Anon7 - 2022
AnonSec Team