Your IP : 3.135.192.192


Current Path : /var/www/www-root/data/www/monolith-realty.ru/bitrix/modules/aspro.allcorp3/lib/solution/
Upload File :
Current File : /var/www/www-root/data/www/monolith-realty.ru/bitrix/modules/aspro.allcorp3/lib/solution/detail.php

<?php

namespace Aspro\Allcorp3\Solution;

use Aspro\Allcorp3\Functions\CAsproAllcorp3 as Functions;

class Detail
{
	public static function onAsproCatalogElementModifyPropertiesHandler(array &$arResult, array $arParams, string $templateName)
	{
		/* layouts */
		if (
			isset($arResult['DISPLAY_PROPERTIES']['LAYOUTS']['VALUE']) 
			&& !empty($arResult['DISPLAY_PROPERTIES']['LAYOUTS']['VALUE'])
		) {
			foreach ($arResult['DISPLAY_PROPERTIES']['LAYOUTS']['VALUE'] as $img) {
				$arResult['LAYOUTS'][] = [
					'DETAIL'  => ($arPhoto = \CFile::GetFileArray($img)),
					'PREVIEW' => (\CFile::ResizeImageGet($img, array('width' => '740', 'height' => '560'), BX_RESIZE_IMAGE_PROPORTIONAL, true)),
					'TITLE' => (strlen($arPhoto['DESCRIPTION']) ? $arPhoto['DESCRIPTION'] : (strlen($arPhoto['TITLE']) ? $arPhoto['TITLE'] : $arResult["NAME"])),
					'ALT' => (strlen($arPhoto['DESCRIPTION']) ? $arPhoto['DESCRIPTION'] : (strlen($arPhoto['ALT']) ? $arPhoto['ALT'] : $arResult["NAME"])),
					'FILE_NAME' => (strlen($arPhoto['FILE_NAME']) ? $arPhoto['FILE_NAME'] : $arPhoto['FILE_NAME']),
				];
			}
		}

		/* interiors */
		if (
			isset($arResult['DISPLAY_PROPERTIES']['INTERIORS']['VALUE']) 
			&& !empty($arResult['DISPLAY_PROPERTIES']['INTERIORS']['VALUE'])
		) {
			foreach ($arResult['DISPLAY_PROPERTIES']['INTERIORS']['VALUE'] as $img) {
				$arResult['INTERIORS'][] = [
					'DETAIL'  => ($arPhoto = \CFile::GetFileArray($img)),
					'PREVIEW' => (\CFile::ResizeImageGet($img, array('width' => '740', 'height' => '560'), BX_RESIZE_IMAGE_PROPORTIONAL, true)),
					'TITLE' => (strlen($arPhoto['DESCRIPTION']) ? $arPhoto['DESCRIPTION'] : (strlen($arPhoto['TITLE']) ? $arPhoto['TITLE'] : $arResult["NAME"])),
					'ALT' => (strlen($arPhoto['DESCRIPTION']) ? $arPhoto['DESCRIPTION'] : (strlen($arPhoto['ALT']) ? $arPhoto['ALT'] : $arResult["NAME"])),
					'FILE_NAME' => (strlen($arPhoto['FILE_NAME']) ? $arPhoto['FILE_NAME'] : $arPhoto['FILE_NAME']),
				];
			}
		}

		/* facades */
		if (
			isset($arResult['DISPLAY_PROPERTIES']['FACADES']['VALUE'])
			&& !empty($arResult['DISPLAY_PROPERTIES']['FACADES']['VALUE'])
		) {
			foreach ($arResult['DISPLAY_PROPERTIES']['FACADES']['VALUE'] as $img) {
				$arResult['FACADES'][] = [
					'DETAIL'  => ($arPhoto = \CFile::GetFileArray($img)),
					'PREVIEW' => (\CFile::ResizeImageGet($img, array('width' => '740', 'height' => '560'), BX_RESIZE_IMAGE_PROPORTIONAL, true)),
					'TITLE' => (strlen($arPhoto['DESCRIPTION']) ? $arPhoto['DESCRIPTION'] : (strlen($arPhoto['TITLE']) ? $arPhoto['TITLE'] : $arResult["NAME"])),
					'ALT' => (strlen($arPhoto['DESCRIPTION']) ? $arPhoto['DESCRIPTION'] : (strlen($arPhoto['ALT']) ? $arPhoto['ALT'] : $arResult["NAME"])),
					'FILE_NAME' => (strlen($arPhoto['FILE_NAME']) ? $arPhoto['FILE_NAME'] : $arPhoto['FILE_NAME']),
				];
			}
		}
	}

	public static function onAsproCatalogElementTemplateDataHandler(array &$templateData, array $arResult, \CBitrixComponentTemplate $template)
	{
		/* layouts */
		if ($templateData['LAYOUTS'] = boolval($arResult['LAYOUTS'])) {
			$template->SetViewTarget('PRODUCT_LAYOUTS');
			Functions::showBlockHtml([
				'FILE' => 'detail/layouts.php',
				'PARAMS' => [
					'PHOTO' => $arResult['LAYOUTS'],
					'CONFIG' => [
						'DATA_NAME' => 'layouts',
					],
				],
			]);
			$template->EndViewTarget();
		}

		/* layouts */
		if ($templateData['INTERIORS'] = boolval($arResult['INTERIORS'])) {
			$template->SetViewTarget('PRODUCT_INTERIORS');
			Functions::showBlockHtml([
				'FILE' => 'detail/layouts.php',
				'PARAMS' => [
					'PHOTO' => $arResult['INTERIORS'],
					'CONFIG' => [
						'DATA_NAME' => 'interiors',
						'BORDERED' => false,
					],
				],
			]);
			$template->EndViewTarget();
		}

		/* facades */
		if ($templateData['FACADES'] = boolval($arResult['FACADES'])) {
			$template->SetViewTarget('PRODUCT_FACADES');
			Functions::showBlockHtml([
				'FILE' => 'detail/layouts.php',
				'PARAMS' => [
					'PHOTO' => $arResult['FACADES'],
					'CONFIG' => [
						'DATA_NAME' => 'facades',
					],
				],
			]);
			$template->EndViewTarget();
		}
	}

	public static function onBeforeAsproShowEpilogBlockHandler(array &$arBlocksStatic, array &$arBlocksExcluded, string $templateName)
	{
		// set static blocks
		switch ($templateName) {
			case 'main4':
				$arBlocksStatic = ['gallery_mosaic', 'tizers', 'floor_layout'];
				break;
			default:
				$arBlocksStatic = ['tizers', 'floor_layout'];
				break;
		}

		// set excluded blocks
		switch ($templateName) {
			case 'main1':
				$arBlocksExcluded = ['sale'];
				break;
		}
	}
}