• Модуль: catalog
  • Путь к файлу: ~/bitrix/modules/catalog/lib/ebay/exportoffer.php
  • Класс: BitrixCatalogEbayExportOffer
  • Вызов: ExportOffer::getValue
protected function getValue($arOffer, $param, $PROPERTY, $arProperties, $arUserTypeFormat)
{
	$result = array();

	$bParam = (strncmp($param, 'PARAM_', 6) == 0);

	if (isset($arProperties[$PROPERTY]) && !empty($arProperties[$PROPERTY]))
	{
		$PROPERTY_CODE = $arProperties[$PROPERTY]['CODE'];
		$arProperty = (
		isset($arOffer['PROPERTIES'][$PROPERTY_CODE])
			? $arOffer['PROPERTIES'][$PROPERTY_CODE]
			: $arOffer['PROPERTIES'][$PROPERTY]
		);

		$value = array();

		if(!is_array($arProperty["VALUE"]))
			$arProperty["VALUE"] = array($arProperty["VALUE"]);

		switch ($arProperties[$PROPERTY]['PROPERTY_TYPE'])
		{
			case 'USER_TYPE':
				foreach($arProperty["VALUE"] as $oneValue)
				{
					$value[] = call_user_func_array($arUserTypeFormat[$PROPERTY],
						array(
							$arProperty,
							array("VALUE" => $oneValue),
							array('MODE' => 'SIMPLE_TEXT'),
						));
				}
				break;

			case 'E':
				$arCheckValue = array();

				foreach ($arProperty['VALUE'] as &$intValue)
				{
					$intValue = (int)$intValue;
					if (0 < $intValue)
						$arCheckValue[] = $intValue;
				}

				if (isset($intValue))
					unset($intValue);

				if (!empty($arCheckValue))
				{
					$dbRes = CIBlockElement::GetList(array(), array('IBLOCK_ID' => $arProperties[$PROPERTY]['LINK_IBLOCK_ID'], 'ID' => $arCheckValue), false, false, array('NAME'));
					while ($arRes = $dbRes->Fetch())
					{
						$value[] = $arRes['NAME'];
					}
				}
				break;

			case 'G':
				$arCheckValue = array();

				foreach ($arProperty['VALUE'] as &$intValue)
				{
					$intValue = (int)$intValue;
					if (0 < $intValue)
						$arCheckValue[] = $intValue;
				}

				if (isset($intValue))
					unset($intValue);

				if (!empty($arCheckValue))
				{
					$dbRes = CIBlockSection::GetList(array(), array('IBLOCK_ID' => $arProperty['LINK_IBLOCK_ID'], 'ID' => $arCheckValue), false, array('NAME'));
					while ($arRes = $dbRes->Fetch())
					{
						$value[] = $arRes['NAME'];
					}
				}
				break;

			case 'L':
				$value .= $arProperty['VALUE'];
				break;

			case 'F':
				foreach ($arProperty['VALUE'] as &$intValue)
				{
					$intValue = (int)$intValue;
					if ($intValue > 0)
					{
						if ($ar_file = CFile::GetFileArray($intValue))
						{
							if(mb_substr($ar_file["SRC"], 0, 1) == "/")
								$strFile = "http://".$this->arIblock["SERVER_NAME"].implode("/", array_map("rawurlencode", explode("/", $ar_file["SRC"])));
							elseif(preg_match("/^(http|https):\/\/(.*?)\/(.*)$/", $ar_file["SRC"], $match))
								$strFile = "http://".$match[2].'/'.implode("/", array_map("rawurlencode", explode("/", $match[3])));
							else
								$strFile = $ar_file["SRC"];
							$value[] = $strFile;
						}
					}
				}

				if (isset($intValue))
					unset($intValue);
				break;

			default:
				$value = $arProperty['VALUE'];
		}

		if(is_array($value) && count($value) == 1)
			$value = implode("", $value);

		if ($bParam)
		{
			$result[$param] = array(
				"NAME" => $arProperties[$PROPERTY]['NAME'],
				"VALUES" => $value,
			);
		}
		else
		{
			$result[$param] = $value;
		}
	}

	return $result;
}