$rsElements = CIBlockElement::GetPropertyValues($this->IBLOCK_ID, $arElementFilter, false, array('ID' => $this->arResult["PROPERTY_ID_LIST"])); while ($arElement = $rsElements->Fetch()) { $arElements[$arElement["IBLOCK_ELEMENT_ID"]] = $arElement; } } else { $rsElements = CIBlockElement::GetList(array('ID' => 'ASC'), $arElementFilter, false, false, array('ID', 'IBLOCK_ID')); while ($arElement = $rsElements->Fetch()) { $arElements[$arElement["ID"]] = array(); } } if (!empty($arElements) && $this->SKU_IBLOCK_ID && $arResult["SKU_PROPERTY_COUNT"] > 0) { $arSkuFilter = array("IBLOCK_ID" => $this->SKU_IBLOCK_ID, "ACTIVE_DATE" => "Y", "ACTIVE" => "Y", "CHECK_PERMISSIONS" => "Y", "=PROPERTY_" . $this->SKU_PROPERTY_ID => array_keys($arElements)); if ($this->arParams['HIDE_NOT_AVAILABLE'] == 'Y') { $arSkuFilter['CATALOG_AVAILABLE'] = 'Y'; } $rsElements = CIBlockElement::GetPropertyValues($this->SKU_IBLOCK_ID, $arSkuFilter, false, array('ID' => $this->arResult["SKU_PROPERTY_ID_LIST"])); while ($arSku = $rsElements->Fetch()) { foreach ($arResult["ITEMS"] as $PID => $arItem) { if (isset($arSku[$PID]) && $arSku[$this->SKU_PROPERTY_ID] > 0) { if (is_array($arSku[$PID])) { foreach ($arSku[$PID] as $value) { $arElements[$arSku[$this->SKU_PROPERTY_ID]][$PID][] = $value; } } else { $arElements[$arSku[$this->SKU_PROPERTY_ID]][$PID][] = $arSku[$PID]; } } } } } CTimeZone::Disable();
$arElements = array(); $rsElements = CIBlockElement::GetPropertyValues($this->IBLOCK_ID, $arElementFilter); while($arElement = $rsElements->Fetch()) $arElements[$arElement["IBLOCK_ELEMENT_ID"]] = $arElement; if (!empty($arElements) && $this->SKU_IBLOCK_ID && $this->SKU_PROPERTY_COUNT > 0) { $arSkuFilter = array( "IBLOCK_ID" => $this->SKU_IBLOCK_ID, "ACTIVE_DATE" => "Y", "ACTIVE" => "Y", "CHECK_PERMISSIONS" => "Y", "=PROPERTY_".$this->SKU_PROPERTY_ID => array_keys($arElements), ); $rsElements = CIBlockElement::GetPropertyValues($this->SKU_IBLOCK_ID, $arSkuFilter); while($arSku = $rsElements->Fetch()) { foreach($arResult["ITEMS"] as $PID => $arItem) { if (isset($arSku[$PID]) && $arSku[$this->SKU_PROPERTY_ID] > 0) $arElements[$arSku[$this->SKU_PROPERTY_ID]][$PID][] = $arSku[$PID]; } } } foreach($arElements as $arElement) { $propertyValues = $propertyEmptyValuesCombination; foreach($arResult["ITEMS"] as $PID => $arItem) {
public static function GetPropertyValuesArray(&$result, $iblockID, $filter, $propertyFilter = array()) { $iblockExtVersion = CIBlockElement::GetIBVersion($iblockID) == 2; $propertiesList = array(); $mapCodes = array(); $userTypesList = array(); $existList = array(); $selectListMultiply = array('SORT' => SORT_ASC, 'VALUE' => SORT_STRING); $selectAllMultiply = array('PROPERTY_VALUE_ID' => SORT_ASC); $propertyListFilter = array('IBLOCK_ID' => $iblockID); $propertyID = array(); if (isset($propertyFilter['ID'])) { $propertyID = is_array($propertyFilter['ID']) ? $propertyFilter['ID'] : array($propertyFilter['ID']); Collection::normalizeArrayValuesByInt($propertyID); } if (!empty($propertyID)) { $propertyListFilter['@ID'] = $propertyID; } elseif (isset($propertyFilter['CODE'])) { if (!is_array($propertyFilter['CODE'])) { $propertyFilter['CODE'] = array($propertyFilter['CODE']); } $propertyCodes = array(); if (!empty($propertyFilter['CODE'])) { foreach ($propertyFilter['CODE'] as &$code) { $code = (string) $code; if ($code !== '') { $propertyCodes[] = $code; } } unset($code); } if (!empty($propertyCodes)) { $propertyListFilter['@CODE'] = $propertyCodes; } unset($propertyCodes); } $propertyListFilter['=ACTIVE'] = isset($propertyFilter['ACTIVE']) && ($propertyFilter['ACTIVE'] == 'Y' || $propertyFilter['ACTIVE'] == 'N') ? $propertyFilter['ACTIVE'] : 'Y'; $propertyID = array(); $propertyIterator = PropertyTable::getList(array('select' => array('ID', 'IBLOCK_ID', 'NAME', 'ACTIVE', 'SORT', 'CODE', 'DEFAULT_VALUE', 'PROPERTY_TYPE', 'ROW_COUNT', 'COL_COUNT', 'LIST_TYPE', 'MULTIPLE', 'XML_ID', 'FILE_TYPE', 'MULTIPLE_CNT', 'LINK_IBLOCK_ID', 'WITH_DESCRIPTION', 'SEARCHABLE', 'FILTRABLE', 'IS_REQUIRED', 'VERSION', 'USER_TYPE', 'USER_TYPE_SETTINGS', 'HINT'), 'filter' => $propertyListFilter, 'order' => array('SORT' => 'ASC', 'ID' => 'ASC'))); while ($property = $propertyIterator->fetch()) { $propertyID[] = (int) $property['ID']; $property['CODE'] = trim((string) $property['CODE']); if ($property['CODE'] === '') { $property['CODE'] = $property['ID']; } $code = $property['CODE']; $property['~NAME'] = $property['NAME']; if (preg_match("/[;&<>\"]/", $property['NAME'])) { $property['NAME'] = htmlspecialcharsex($property['NAME']); } if ($property['USER_TYPE']) { $userType = CIBlockProperty::GetUserType($property['USER_TYPE']); if (isset($userType['ConvertFromDB'])) { $userTypesList[$property['ID']] = $userType; if (array_key_exists("DEFAULT_VALUE", $property)) { $value = array("VALUE" => $property["DEFAULT_VALUE"], "DESCRIPTION" => ""); $value = call_user_func_array($userType["ConvertFromDB"], array($property, $value)); $property["DEFAULT_VALUE"] = $value["VALUE"]; } } } if ($property['USER_TYPE_SETTINGS'] !== '' || $property['USER_TYPE_SETTINGS'] !== null) { $property['USER_TYPE_SETTINGS'] = unserialize($property['USER_TYPE_SETTINGS']); } $property['~DEFAULT_VALUE'] = $property['DEFAULT_VALUE']; if (is_array($property['DEFAULT_VALUE']) || preg_match("/[;&<>\"]/", $property['DEFAULT_VALUE'])) { $property['DEFAULT_VALUE'] = htmlspecialcharsex($property['DEFAULT_VALUE']); } if ($property['PROPERTY_TYPE'] == PropertyTable::TYPE_LIST) { $existList[] = $property['ID']; } $mapCodes[$property['ID']] = $code; $propertiesList[$code] = $property; } unset($property, $propertyIterator); if (empty($propertiesList)) { return; } if (!empty($existList)) { $enumList = array(); $enumIterator = PropertyEnumerationTable::getList(array('select' => array('ID', 'PROPERTY_ID', 'VALUE', 'SORT', 'XML_ID'), 'filter' => array('PROPERTY_ID' => $existList), 'order' => array('PROPERTY_ID' => 'ASC', 'SORT' => 'ASC', 'VALUE' => 'ASC'))); while ($enum = $enumIterator->fetch()) { if (!isset($enumList[$enum['PROPERTY_ID']])) { $enumList[$enum['PROPERTY_ID']] = array(); } $enumList[$enum['PROPERTY_ID']][$enum['ID']] = array('ID' => $enum['ID'], 'VALUE' => $enum['VALUE'], 'SORT' => $enum['SORT'], 'XML_ID' => $enum['XML_ID']); } unset($enum, $enumIterator); } $valuesRes = !empty($propertyID) ? CIBlockElement::GetPropertyValues($iblockID, $filter, true, array('ID' => $propertyID)) : CIBlockElement::GetPropertyValues($iblockID, $filter, true); while ($value = $valuesRes->Fetch()) { $elementID = $value['IBLOCK_ELEMENT_ID']; if (!isset($result[$elementID])) { continue; } $elementValues = array(); $existDescription = isset($value['DESCRIPTION']); foreach ($propertiesList as $code => $property) { $existElementDescription = isset($value['DESCRIPTION']) && array_key_exists($property['ID'], $value['DESCRIPTION']); $existElementPropertyID = isset($value['PROPERTY_VALUE_ID']) && array_key_exists($property['ID'], $value['PROPERTY_VALUE_ID']); $elementValues[$code] = $property; $elementValues[$code]['VALUE_ENUM'] = null; $elementValues[$code]['VALUE_XML_ID'] = null; $elementValues[$code]['VALUE_SORT'] = null; $elementValues[$code]['VALUE'] = null; if ('Y' === $property['MULTIPLE']) { $elementValues[$code]['PROPERTY_VALUE_ID'] = false; if (!isset($value[$property['ID']]) || empty($value[$property['ID']])) { $elementValues[$code]['DESCRIPTION'] = false; $elementValues[$code]['VALUE'] = false; $elementValues[$code]['~DESCRIPTION'] = false; $elementValues[$code]['~VALUE'] = false; if ('L' == $property['PROPERTY_TYPE']) { $elementValues[$code]['VALUE_ENUM_ID'] = false; $elementValues[$code]['VALUE_ENUM'] = false; $elementValues[$code]['VALUE_XML_ID'] = false; $elementValues[$code]['VALUE_SORT'] = false; } } else { if ($existElementPropertyID) { $elementValues[$code]['PROPERTY_VALUE_ID'] = $value['PROPERTY_VALUE_ID'][$property['ID']]; } if (isset($userTypesList[$property['ID']])) { foreach ($value[$property['ID']] as $valueKey => $oneValue) { $raw = call_user_func_array($userTypesList[$property['ID']]['ConvertFromDB'], array($property, array('VALUE' => $oneValue, 'DESCRIPTION' => $existElementDescription ? $value['DESCRIPTION'][$property['ID']][$valueKey] : ''))); $value[$property['ID']][$valueKey] = $raw['VALUE']; if (!$existDescription) { $value['DESCRIPTION'] = array(); $existDescription = true; } if (!$existElementDescription) { $value['DESCRIPTION'][$property['ID']] = array(); $existElementDescription = true; } $value['DESCRIPTION'][$property['ID']][$valueKey] = (string) $raw['DESCRIPTION']; } if (isset($oneValue)) { unset($oneValue); } } if ('L' == $property['PROPERTY_TYPE']) { if (empty($value[$property['ID']])) { $elementValues[$code]['VALUE_ENUM_ID'] = $value[$property['ID']]; $elementValues[$code]['DESCRIPTION'] = $existElementDescription ? $value['DESCRIPTION'][$property['ID']] : array(); } else { $selectedValues = array(); foreach ($value[$property['ID']] as $listKey => $listValue) { if (isset($enumList[$property['ID']][$listValue])) { $selectedValues[$listKey] = $enumList[$property['ID']][$listValue]; $selectedValues[$listKey]['DESCRIPTION'] = $existElementDescription && array_key_exists($listKey, $value['DESCRIPTION'][$property['ID']]) ? $value['DESCRIPTION'][$property['ID']][$listKey] : ''; $selectedValues[$listKey]['PROPERTY_VALUE_ID'] = $existElementPropertyID && array_key_exists($listKey, $value['PROPERTY_VALUE_ID'][$property['ID']]) ? $value['PROPERTY_VALUE_ID'][$property['ID']][$listKey] : ''; } } if (empty($selectedValues)) { $elementValues[$code]['VALUE_ENUM_ID'] = $value[$property['ID']]; $elementValues[$code]['DESCRIPTION'] = $existElementDescription ? $value['DESCRIPTION'][$property['ID']] : array(); } else { Collection::sortByColumn($selectedValues, $selectListMultiply); $elementValues[$code]['VALUE_ENUM_ID'] = array(); $elementValues[$code]['VALUE'] = array(); $elementValues[$code]['VALUE_ENUM'] = array(); $elementValues[$code]['VALUE_XML_ID'] = array(); $elementValues[$code]['DESCRIPTION'] = array(); $elementValues[$code]['PROPERTY_VALUE_ID'] = array(); foreach ($selectedValues as $listValue) { if (!isset($elementValues[$code]['VALUE_SORT'])) { $elementValues[$code]['VALUE_SORT'] = array($listValue['SORT']); } $elementValues[$code]['VALUE_ENUM_ID'][] = $listValue['ID']; $elementValues[$code]['VALUE'][] = $listValue['VALUE']; $elementValues[$code]['VALUE_ENUM'][] = $listValue['VALUE']; $elementValues[$code]['VALUE_XML_ID'][] = $listValue['XML_ID']; $elementValues[$code]['PROPERTY_VALUE_ID'][] = $listValue['PROPERTY_VALUE_ID']; $elementValues[$code]['DESCRIPTION'][] = $listValue['DESCRIPTION']; } unset($selectedValues); } } } else { if (empty($value[$property['ID']]) || !$existElementPropertyID || isset($userTypesList[$property['ID']])) { $elementValues[$code]['VALUE'] = $value[$property['ID']]; $elementValues[$code]['DESCRIPTION'] = $existElementDescription ? $value['DESCRIPTION'][$property['ID']] : array(); } else { $selectedValues = array(); foreach ($value['PROPERTY_VALUE_ID'][$property['ID']] as $propKey => $propValueID) { $selectedValues[$propKey] = array('PROPERTY_VALUE_ID' => $propValueID, 'VALUE' => $value[$property['ID']][$propKey]); if ($existElementDescription) { $selectedValues[$propKey]['DESCRIPTION'] = $value['DESCRIPTION'][$property['ID']][$propKey]; } } unset($propValueID, $propKey); Collection::sortByColumn($selectedValues, $selectAllMultiply); $elementValues[$code]['PROPERTY_VALUE_ID'] = array(); $elementValues[$code]['VALUE'] = array(); $elementValues[$code]['DESCRIPTION'] = array(); foreach ($selectedValues as &$propValue) { $elementValues[$code]['PROPERTY_VALUE_ID'][] = $propValue['PROPERTY_VALUE_ID']; $elementValues[$code]['VALUE'][] = $propValue['VALUE']; if ($existElementDescription) { $elementValues[$code]['DESCRIPTION'][] = $propValue['DESCRIPTION']; } } unset($propValue, $selectedValues); } } } $elementValues[$code]['~VALUE'] = $elementValues[$code]['VALUE']; if (is_array($elementValues[$code]['VALUE'])) { foreach ($elementValues[$code]['VALUE'] as &$oneValue) { $isArr = is_array($oneValue); if ($isArr || '' !== $oneValue && null !== $oneValue) { if ($isArr || preg_match("/[;&<>\"]/", $oneValue)) { $oneValue = htmlspecialcharsEx($oneValue); } } } if (isset($oneValue)) { unset($oneValue); } } else { if ('' !== $elementValues[$code]['VALUE'] && null !== $elementValues[$code]['VALUE']) { if (preg_match("/[;&<>\"]/", $elementValues[$code]['VALUE'])) { $elementValues[$code]['VALUE'] = htmlspecialcharsEx($elementValues[$code]['VALUE']); } } } $elementValues[$code]['~DESCRIPTION'] = $elementValues[$code]['DESCRIPTION']; if (is_array($elementValues[$code]['DESCRIPTION'])) { foreach ($elementValues[$code]['DESCRIPTION'] as &$oneDescr) { $isArr = is_array($oneDescr); if ($isArr || !$isArr && '' !== $oneDescr && null !== $oneDescr) { if ($isArr || preg_match("/[;&<>\"]/", $oneDescr)) { $oneDescr = htmlspecialcharsEx($oneDescr); } } } if (isset($oneDescr)) { unset($oneDescr); } } else { if ('' !== $elementValues[$code]['DESCRIPTION'] && null !== $elementValues[$code]['DESCRIPTION']) { if (preg_match("/[;&<>\"]/", $elementValues[$code]['DESCRIPTION'])) { $elementValues[$code]['DESCRIPTION'] = htmlspecialcharsEx($elementValues[$code]['DESCRIPTION']); } } } } else { $elementValues[$code]['VALUE_ENUM'] = $iblockExtVersion ? '' : null; $elementValues[$code]['PROPERTY_VALUE_ID'] = $iblockExtVersion ? $elementID . ':' . $property['ID'] : null; if (!isset($value[$property['ID']]) || false === $value[$property['ID']]) { $elementValues[$code]['DESCRIPTION'] = ''; $elementValues[$code]['VALUE'] = ''; $elementValues[$code]['~DESCRIPTION'] = ''; $elementValues[$code]['~VALUE'] = ''; if ('L' == $property['PROPERTY_TYPE']) { $elementValues[$code]['VALUE_ENUM_ID'] = null; } } else { if ($existElementPropertyID) { $elementValues[$code]['PROPERTY_VALUE_ID'] = $value['PROPERTY_VALUE_ID'][$property['ID']]; } if (isset($userTypesList[$property['ID']])) { $raw = call_user_func_array($userTypesList[$property['ID']]['ConvertFromDB'], array($property, array('VALUE' => $value[$property['ID']], 'DESCRIPTION' => $existElementDescription ? $value['DESCRIPTION'][$property['ID']] : ''))); $value[$property['ID']] = $raw['VALUE']; if (!$existDescription) { $value['DESCRIPTION'] = array(); $existDescription = true; } $value['DESCRIPTION'][$property['ID']] = (string) $raw['DESCRIPTION']; $existElementDescription = true; } if ('L' == $property['PROPERTY_TYPE']) { $elementValues[$code]['VALUE_ENUM_ID'] = $value[$property['ID']]; if (isset($enumList[$property['ID']][$value[$property['ID']]])) { $elementValues[$code]['VALUE'] = $enumList[$property['ID']][$value[$property['ID']]]['VALUE']; $elementValues[$code]['VALUE_ENUM'] = $elementValues[$code]['VALUE']; $elementValues[$code]['VALUE_XML_ID'] = $enumList[$property['ID']][$value[$property['ID']]]['XML_ID']; $elementValues[$code]['VALUE_SORT'] = $enumList[$property['ID']][$value[$property['ID']]]['SORT']; } $elementValues[$code]['DESCRIPTION'] = $existElementDescription ? $value['DESCRIPTION'][$property['ID']] : null; } else { $elementValues[$code]['VALUE'] = $value[$property['ID']]; $elementValues[$code]['DESCRIPTION'] = $existElementDescription ? $value['DESCRIPTION'][$property['ID']] : ''; } } $elementValues[$code]['~VALUE'] = $elementValues[$code]['VALUE']; $isArr = is_array($elementValues[$code]['VALUE']); if ($isArr || '' !== $elementValues[$code]['VALUE'] && null !== $elementValues[$code]['VALUE']) { if ($isArr || preg_match("/[;&<>\"]/", $elementValues[$code]['VALUE'])) { $elementValues[$code]['VALUE'] = htmlspecialcharsEx($elementValues[$code]['VALUE']); } } $elementValues[$code]['~DESCRIPTION'] = $elementValues[$code]['DESCRIPTION']; $isArr = is_array($elementValues[$code]['DESCRIPTION']); if ($isArr || '' !== $elementValues[$code]['DESCRIPTION'] && null !== $elementValues[$code]['DESCRIPTION']) { if ($isArr || preg_match("/[;&<>\"]/", $elementValues[$code]['DESCRIPTION'])) { $elementValues[$code]['DESCRIPTION'] = htmlspecialcharsEx($elementValues[$code]['DESCRIPTION']); } } } } if (isset($result[$elementID]['PROPERTIES'])) { $result[$elementID]['PROPERTIES'] = $elementValues; } else { $result[$elementID] = $elementValues; } unset($elementValues); } }
public static function GetPropertyValuesArray(&$result, $iblockID, $filter) { $iblockExtVersion = (CIBlockElement::GetIBVersion($iblockID) == 2); $propertiesList = array(); $mapCodes = array(); $userTypesList = array(); $existList = false; $selectListMultiply = array('SORT' => SORT_NUMERIC, 'VALUE' => SORT_STRING); $propertyRes = CIBlockProperty::GetList(array('SORT'=>'ASC','ID'=>'ASC'), array('IBLOCK_ID' => $iblockID, 'ACTIVE' => 'Y')); while ($property = $propertyRes->Fetch()) { $property['CODE'] = trim((string)$property['CODE']); if ('' === $property['CODE']) { $property['CODE'] = $property['ID']; } $code = $property['CODE']; $property['~NAME'] = $property['NAME']; if (preg_match("/[;&<>\"]/", $property['NAME'])) $property['NAME'] = htmlspecialcharsex($property['NAME']); $property['~DEFAULT_VALUE'] = $property['DEFAULT_VALUE']; if (is_array($property['DEFAULT_VALUE']) || preg_match("/[;&<>\"]/", $property['DEFAULT_VALUE'])) $property['DEFAULT_VALUE'] = htmlspecialcharsex($property['DEFAULT_VALUE']); if ('L' == $property['PROPERTY_TYPE']) { $existList = true; } if ('' != $property['USER_TYPE']) { $userType = CIBlockProperty::GetUserType($property['USER_TYPE']); if (isset($userType['ConvertFromDB'])) { $userTypesList[$property['ID']] = $userType; } } $mapCodes[$property['ID']] = $code; $propertiesList[$code] = $property; } if (empty($propertiesList)) { return; } if ($existList) { $enumList = array(); $enumRes = CIBlockPropertyEnum::GetList( array('PROPERTY_ID' => 'ASC', 'SORT' => 'ASC', 'VALUE' => 'ASC'), array('IBLOCK_ID' => $iblockID, 'PROPERTY_ACTIVE' => 'Y') ); while ($enum = $enumRes->Fetch()) { if (!isset($enumList[$enum['PROPERTY_ID']])) { $enumList[$enum['PROPERTY_ID']] = array(); } $enumList[$enum['PROPERTY_ID']][$enum['ID']] = array( 'ID' => $enum['ID'], 'VALUE' => $enum['VALUE'], 'SORT' => $enum['SORT'], 'XML_ID' => $enum['XML_ID'] ); } } $valuesRes = CIBlockElement::GetPropertyValues($iblockID, $filter, true); while ($value = $valuesRes->Fetch()) { $elementID = $value['IBLOCK_ELEMENT_ID']; if (!isset($result[$elementID])) { continue; } $elementValues = array(); $existDescription = isset($value['DESCRIPTION']); foreach ($propertiesList as $code => $property) { $existElementDescription = isset($value['DESCRIPTION']) && array_key_exists($property['ID'], $value['DESCRIPTION']); $existElementPropertyID = isset($value['PROPERTY_VALUE_ID']) && array_key_exists($property['ID'], $value['PROPERTY_VALUE_ID']); $elementValues[$code] = $property; $elementValues[$code]['VALUE_ENUM'] = null; $elementValues[$code]['VALUE_XML_ID'] = null; $elementValues[$code]['VALUE_SORT'] = null; $elementValues[$code]['VALUE'] = null; if ('Y' === $property['MULTIPLE']) { $elementValues[$code]['PROPERTY_VALUE_ID'] = false; if (!isset($value[$property['ID']]) || empty($value[$property['ID']])) { $elementValues[$code]['DESCRIPTION'] = false; $elementValues[$code]['VALUE'] = false; $elementValues[$code]['~DESCRIPTION'] = false; $elementValues[$code]['~VALUE'] = false; if ('L' == $property['PROPERTY_TYPE']) { $elementValues[$code]['VALUE_ENUM_ID'] = false; $elementValues[$code]['VALUE_ENUM'] = false; $elementValues[$code]['VALUE_XML_ID'] = false; $elementValues[$code]['VALUE_SORT'] = false; } } else { if ($existElementPropertyID) { $elementValues[$code]['PROPERTY_VALUE_ID'] = $value['PROPERTY_VALUE_ID'][$property['ID']]; } if (isset($userTypesList[$property['ID']])) { foreach ($value[$property['ID']] as $valueKey => $oneValue) { $raw = call_user_func_array( $userTypesList[$property['ID']]['ConvertFromDB'], array( $property, array( 'VALUE' => $oneValue, 'DESCRIPTION' => ($existElementDescription ? $value['DESCRIPTION'][$property['ID']][$valueKey] : ''), ) ) ); $value[$property['ID']][$valueKey] = $raw['VALUE']; if (!$existDescription) { $value['DESCRIPTION'] = array(); $existDescription = true; } if (!$existElementDescription) { $value['DESCRIPTION'][$property['ID']] = array(); $existElementDescription = true; } $value['DESCRIPTION'][$property['ID']][$valueKey] = (string)$raw['DESCRIPTION']; } if (isset($oneValue)) unset($oneValue); } if ('L' == $property['PROPERTY_TYPE']) { if (empty($value[$property['ID']])) { $elementValues[$code]['VALUE_ENUM_ID'] = $value[$property['ID']]; $elementValues[$code]['DESCRIPTION'] = ($existElementDescription ? $value['DESCRIPTION'][$property['ID']] : array()); } else { $selectedValues = array(); foreach ($value[$property['ID']] as $listKey => $listValue) { if (isset($enumList[$property['ID']][$listValue])) { $selectedValues[$listKey] = $enumList[$property['ID']][$listValue]; $selectedValues[$listKey]['DESCRIPTION'] = ( $existElementDescription && array_key_exists($listKey, $value['DESCRIPTION'][$property['ID']]) ? $value['DESCRIPTION'][$property['ID']][$listKey] : '' ); $selectedValues[$listKey]['PROPERTY_VALUE_ID'] = ( $existElementPropertyID && array_key_exists($listKey, $value['PROPERTY_VALUE_ID'][$property['ID']]) ? $value['PROPERTY_VALUE_ID'][$property['ID']][$listKey] : '' ); } } if (empty($selectedValues)) { $elementValues[$code]['VALUE_ENUM_ID'] = $value[$property['ID']]; $elementValues[$code]['DESCRIPTION'] = ($existElementDescription ? $value['DESCRIPTION'][$property['ID']] : array()); } else { \Freetrix\Main\Type\Collection::sortByColumn($selectedValues, $selectListMultiply); $elementValues[$code]['VALUE_ENUM_ID'] = array(); $elementValues[$code]['VALUE'] = array(); $elementValues[$code]['VALUE_ENUM'] = array(); $elementValues[$code]['VALUE_XML_ID'] = array(); $elementValues[$code]['DESCRIPTION'] = array(); $elementValues[$code]['PROPERTY_VALUE_ID'] = array(); foreach ($selectedValues as $listValue) { if (!isset($elementValues[$code]['VALUE_SORT'])) { $elementValues[$code]['VALUE_SORT'] = array($listValue['SORT']); } $elementValues[$code]['VALUE_ENUM_ID'][] = $listValue['ID']; $elementValues[$code]['VALUE'][] = $listValue['VALUE']; $elementValues[$code]['VALUE_ENUM'][] = $listValue['VALUE']; $elementValues[$code]['VALUE_XML_ID'][] = $listValue['XML_ID']; $elementValues[$code]['PROPERTY_VALUE_ID'][] = $listValue[PROPERTY_VALUE_ID]; $elementValues[$code]['DESCRIPTION'][] = $listValue['DESCRIPTION']; } unset($selectedValues); } } } else { $elementValues[$code]['VALUE'] = $value[$property['ID']]; $elementValues[$code]['DESCRIPTION'] = ($existElementDescription ? $value['DESCRIPTION'][$property['ID']] : array()); } } $elementValues[$code]['~VALUE'] = $elementValues[$code]['VALUE']; if (is_array($elementValues[$code]['VALUE'])) { foreach ($elementValues[$code]['VALUE'] as &$oneValue) { $isArr = is_array($oneValue); if ($isArr || ('' !== $oneValue && null !== $oneValue)) { if ($isArr || preg_match("/[;&<>\"]/", $oneValue)) { $oneValue = htmlspecialcharsEx($oneValue); } } } if (isset($oneValue)) unset($oneValue); } else { if ('' !== $elementValues[$code]['VALUE'] && null !== $elementValues[$code]['VALUE']) { if (preg_match("/[;&<>\"]/", $elementValues[$code]['VALUE'])) { $elementValues[$code]['VALUE'] = htmlspecialcharsEx($elementValues[$code]['VALUE']); } } } $elementValues[$code]['~DESCRIPTION'] = $elementValues[$code]['DESCRIPTION']; if (is_array($elementValues[$code]['DESCRIPTION'])) { foreach ($elementValues[$code]['DESCRIPTION'] as &$oneDescr) { $isArr = is_array($oneDescr); if ($isArr || (!$isArr && '' !== $oneDescr && null !== $oneDescr)) { if ($isArr || preg_match("/[;&<>\"]/", $oneDescr)) { $oneDescr = htmlspecialcharsEx($oneDescr); } } } if (isset($oneDescr)) unset($oneDescr); } else { if ('' !== $elementValues[$code]['DESCRIPTION'] && null !== $elementValues[$code]['DESCRIPTION']) { if (preg_match("/[;&<>\"]/", $elementValues[$code]['DESCRIPTION'])) { $elementValues[$code]['DESCRIPTION'] = htmlspecialcharsEx($elementValues[$code]['DESCRIPTION']); } } } } else { $elementValues[$code]['VALUE_ENUM'] = ($iblockExtVersion ? '' : null); $elementValues[$code]['PROPERTY_VALUE_ID'] = ($iblockExtVersion ? $elementID.':'.$property['ID'] : null); if (!isset($value[$property['ID']]) || false === $value[$property['ID']]) { $elementValues[$code]['DESCRIPTION'] = ''; $elementValues[$code]['VALUE'] = ''; $elementValues[$code]['~DESCRIPTION'] = ''; $elementValues[$code]['~VALUE'] = ''; if ('L' == $property['PROPERTY_TYPE']) { $elementValues[$code]['VALUE_ENUM_ID'] = null; } } else { if ($existElementPropertyID) { $elementValues[$code]['PROPERTY_VALUE_ID'] = $value['PROPERTY_VALUE_ID'][$property['ID']]; } if (isset($userTypesList[$property['ID']])) { $raw = call_user_func_array( $userTypesList[$property['ID']]['ConvertFromDB'], array( $property, array( 'VALUE' => $value[$property['ID']], 'DESCRIPTION' => ($existElementDescription ? $value['DESCRIPTION'][$property['ID']] : '') ) ) ); $value[$property['ID']] = $raw['VALUE']; if (!$existDescription) { $value['DESCRIPTION'] = array(); $existDescription = true; } $value['DESCRIPTION'][$property['ID']] = (string)$raw['DESCRIPTION']; $existElementDescription = true; } if ('L' == $property['PROPERTY_TYPE']) { $elementValues[$code]['VALUE_ENUM_ID'] = $value[$property['ID']]; if (isset($enumList[$property['ID']][$value[$property['ID']]])) { $elementValues[$code]['VALUE'] = $enumList[$property['ID']][$value[$property['ID']]]['VALUE']; $elementValues[$code]['VALUE_ENUM'] = $elementValues[$code]['VALUE']; $elementValues[$code]['VALUE_XML_ID'] = $enumList[$property['ID']][$value[$property['ID']]]['XML_ID']; $elementValues[$code]['VALUE_SORT'] = $enumList[$property['ID']][$value[$property['ID']]]['SORT']; } $elementValues[$code]['DESCRIPTION'] = ($existElementDescription ? $value['DESCRIPTION'][$property['ID']] : null); } else { $elementValues[$code]['VALUE'] = $value[$property['ID']]; $elementValues[$code]['DESCRIPTION'] = ($existElementDescription ? $value['DESCRIPTION'][$property['ID']] : ''); } } $elementValues[$code]['~VALUE'] = $elementValues[$code]['VALUE']; $isArr = is_array($elementValues[$code]['VALUE']); if ($isArr || ('' !== $elementValues[$code]['VALUE'] && null !== $elementValues[$code]['VALUE'])) { if ($isArr || preg_match("/[;&<>\"]/", $elementValues[$code]['VALUE'])) { $elementValues[$code]['VALUE'] = htmlspecialcharsEx($elementValues[$code]['VALUE']); } } $elementValues[$code]['~DESCRIPTION'] = $elementValues[$code]['DESCRIPTION']; $isArr = is_array($elementValues[$code]['DESCRIPTION']); if ($isArr || ('' !== $elementValues[$code]['DESCRIPTION'] && null !== $elementValues[$code]['DESCRIPTION'])) { if ($isArr || preg_match("/[;&<>\"]/", $elementValues[$code]['DESCRIPTION'])) $elementValues[$code]['DESCRIPTION'] = htmlspecialcharsEx($elementValues[$code]['DESCRIPTION']); } } } if (isset($result[$elementID]['PROPERTIES'])) { $result[$elementID]['PROPERTIES'] = $elementValues; } else { $result[$elementID] = $elementValues; } unset($elementValues); } }