• Модуль: iblock
  • Путь к файлу: ~/bitrix/modules/iblock/classes/general/comp_pricetools.php
  • Класс: CIBlockPriceTools
  • Вызов: CIBlockPriceTools::getSliderForItem
static function getSliderForItem(&$item, $propertyCode, $addDetailToSlider, $encode = true)
{
	$encode = ($encode === true);
	$result = array();

	if (!empty($item) && is_array($item))
	{
		if (
			'' != $propertyCode &&
			isset($item['PROPERTIES'][$propertyCode]) &&
			'F' == $item['PROPERTIES'][$propertyCode]['PROPERTY_TYPE']
		)
		{
			if ('MORE_PHOTO' == $propertyCode && isset($item['MORE_PHOTO']) && !empty($item['MORE_PHOTO']))
			{
				foreach ($item['MORE_PHOTO'] as $onePhoto)
				{
					$result[] = array(
						'ID' => (int)$onePhoto['ID'],
						'SRC' => IblockComponentTools::getImageSrc($onePhoto, $encode),
						'WIDTH' => (int)$onePhoto['WIDTH'],
						'HEIGHT' => (int)$onePhoto['HEIGHT']
					);
				}
				unset($onePhoto);
			}
			else
			{
				if (
					isset($item['DISPLAY_PROPERTIES'][$propertyCode]['FILE_VALUE']) &&
					!empty($item['DISPLAY_PROPERTIES'][$propertyCode]['FILE_VALUE'])
				)
				{
					$fileValues = (
						isset($item['DISPLAY_PROPERTIES'][$propertyCode]['FILE_VALUE']['ID']) ?
						array(0 => $item['DISPLAY_PROPERTIES'][$propertyCode]['FILE_VALUE']) :
						$item['DISPLAY_PROPERTIES'][$propertyCode]['FILE_VALUE']
					);
					foreach ($fileValues as $oneFileValue)
					{
						$result[] = array(
							'ID' => (int)$oneFileValue['ID'],
							'SRC' => IblockComponentTools::getImageSrc($oneFileValue, $encode),
							'WIDTH' => (int)$oneFileValue['WIDTH'],
							'HEIGHT' => (int)$oneFileValue['HEIGHT']
						);
					}
					if (isset($oneFileValue))
						unset($oneFileValue);
				}
				else
				{
					$propValues = $item['PROPERTIES'][$propertyCode]['VALUE'];
					if (!is_array($propValues))
						$propValues = array($propValues);

					foreach ($propValues as $oneValue)
					{
						$oneFileValue = CFile::GetFileArray($oneValue);
						if (isset($oneFileValue['ID']))
						{
							$result[] = array(
								'ID' => (int)$oneFileValue['ID'],
								'SRC' => IblockComponentTools::getImageSrc($oneFileValue, $encode),
								'WIDTH' => (int)$oneFileValue['WIDTH'],
								'HEIGHT' => (int)$oneFileValue['HEIGHT']
							);
						}
					}
					if (isset($oneValue))
						unset($oneValue);
				}
			}
		}
		if ($addDetailToSlider || empty($result))
		{
			if (!empty($item['DETAIL_PICTURE']))
			{
				if (!is_array($item['DETAIL_PICTURE']))
					$item['DETAIL_PICTURE'] = CFile::GetFileArray($item['DETAIL_PICTURE']);
				if (isset($item['DETAIL_PICTURE']['ID']))
				{
					array_unshift(
						$result,
						array(
							'ID' => (int)$item['DETAIL_PICTURE']['ID'],
							'SRC' => IblockComponentTools::getImageSrc($item['DETAIL_PICTURE'], $encode),
							'WIDTH' => (int)$item['DETAIL_PICTURE']['WIDTH'],
							'HEIGHT' => (int)$item['DETAIL_PICTURE']['HEIGHT']
						)
					);
				}
			}
		}
	}
	return $result;
}