Example #1
0
	protected static function AppyUserSettings($suffix)
	{
		$arAuthServices = self::$arAuthServices;

		//user settings: sorting, active
		$arServices = unserialize(COption::GetOptionString("socialservices", "auth_services".$suffix, ""));
		if(is_array($arServices))
		{
			$i = 0;
			foreach($arServices as $serv=>$active)
			{
				if(isset($arAuthServices[$serv]))
				{
					$arAuthServices[$serv]["__sort"] = $i++;
					$arAuthServices[$serv]["__active"] = ($active == "Y");
				}
			}
			\Freetrix\Main\Type\Collection::sortByColumn($arAuthServices, "__sort");
		}
		return $arAuthServices;
	}
Example #2
0
	if (is_array($browserTitle))
		$APPLICATION->SetPageProperty("title", implode(" ", $browserTitle), $arTitleOptions);
	elseif ($browserTitle != "")
		$APPLICATION->SetPageProperty("title", $browserTitle, $arTitleOptions);

	$metaKeywords = \Freetrix\Main\Type\Collection::firstNotEmpty(
		$arResult["PROPERTIES"], array($arParams["META_KEYWORDS"], "VALUE")
		,$arResult["IPROPERTY_VALUES"], "SECTION_META_KEYWORDS"
	);
	if (is_array($metaKeywords))
		$APPLICATION->SetPageProperty("keywords", implode(" ", $metaKeywords), $arTitleOptions);
	elseif ($metaKeywords != "")
		$APPLICATION->SetPageProperty("keywords", $metaKeywords, $arTitleOptions);

	$metaDescription = \Freetrix\Main\Type\Collection::firstNotEmpty(
		$arResult["PROPERTIES"], array($arParams["META_DESCRIPTION"], "VALUE")
		,$arResult["IPROPERTY_VALUES"], "SECTION_META_DESCRIPTION"
	);
	if (is_array($metaDescription))
		$APPLICATION->SetPageProperty("description", implode(" ", $metaDescription), $arTitleOptions);
	elseif ($metaDescription != "")
		$APPLICATION->SetPageProperty("description", $metaDescription, $arTitleOptions);

	if($arParams["ADD_SECTIONS_CHAIN"])
	{
		foreach($arResult["PATH"] as $arPath)
		{
			$APPLICATION->AddChainItem($arPath["NAME"], $arPath["~SECTION_PAGE_URL"]);
		}
	}
}
Example #3
0
	public static function GetArray($IBLOCK_ID, $SECTION_ID = 0, $bNewSection = false)
	{
		global $DB;
		$IBLOCK_ID = intval($IBLOCK_ID);
		$SECTION_ID = intval($SECTION_ID);
		$result = array();
		if ($SECTION_ID > 0)
		{
			$rs = $DB->Query($s = "
				SELECT
					B.SECTION_PROPERTY,
					BP.ID PROPERTY_ID,
					BSP.SECTION_ID LINK_ID,
					BSP.SMART_FILTER,
					BP.SORT,
					BS.LEFT_MARGIN,
					BS.NAME LINK_TITLE
				FROM
					b_iblock B
					INNER JOIN b_iblock_property BP ON BP.IBLOCK_ID = B.ID
					INNER JOIN b_iblock_section M ON M.ID = ".$SECTION_ID."
					INNER JOIN b_iblock_section BS ON BS.IBLOCK_ID = M.IBLOCK_ID
						AND M.LEFT_MARGIN >= BS.LEFT_MARGIN
						AND M.RIGHT_MARGIN <= BS.RIGHT_MARGIN
					INNER JOIN b_iblock_section_property BSP ON BSP.IBLOCK_ID = BS.IBLOCK_ID AND BSP.SECTION_ID = BS.ID AND BSP.PROPERTY_ID = BP.ID
				WHERE
					B.ID = ".$IBLOCK_ID."
				ORDER BY
					BP.SORT ASC, BP.ID ASC, BS.LEFT_MARGIN DESC
			");
			while ($ar = $rs->Fetch())
			{
				$result[$ar["PROPERTY_ID"]] = array(
					"PROPERTY_ID" => $ar["PROPERTY_ID"],
					"SMART_FILTER" => $ar["SMART_FILTER"],
					"INHERITED" => $SECTION_ID == $ar["LINK_ID"] ? "N" : "Y",
					"INHERITED_FROM" => $ar["LINK_ID"],
					"SORT" => $ar["SORT"],
					"LEFT_MARGIN" => $ar["LEFT_MARGIN"],
					"LINK_TITLE" => $ar["LINK_TITLE"],
				);
			}
		}
		if ($SECTION_ID >= 0)
		{
			$rs = $DB->Query("
				SELECT
					B.SECTION_PROPERTY,
					BP.ID PROPERTY_ID,
					BSP.SECTION_ID LINK_ID,
					BSP.SMART_FILTER,
					BP.SORT,
					0 LEFT_MARGIN,
					B.NAME LINK_TITLE
				FROM
					b_iblock B
					INNER JOIN b_iblock_property BP ON BP.IBLOCK_ID = B.ID
					LEFT JOIN b_iblock_section_property BSP ON BSP.SECTION_ID = 0 AND BSP.PROPERTY_ID = BP.ID
				WHERE
					B.ID = ".$IBLOCK_ID."
				ORDER BY
					BP.SORT ASC, BP.ID ASC
			");
			while ($ar = $rs->Fetch())
			{
				if ($ar["SECTION_PROPERTY"] === "Y")
				{
					if (strlen($ar["LINK_ID"]))
						$result[$ar["PROPERTY_ID"]] = array(
							"PROPERTY_ID" => $ar["PROPERTY_ID"],
							"SMART_FILTER" => $ar["SMART_FILTER"],
							"INHERITED" => $SECTION_ID == 0 && !$bNewSection? "N" : "Y",
							"INHERITED_FROM" => 0,
							"SORT" => $ar["SORT"],
							"LEFT_MARGIN" => $ar["LEFT_MARGIN"],
							"LINK_TITLE" => $ar["LINK_TITLE"],
						);
				}
				else
				{
					$result[$ar["PROPERTY_ID"]] = array(
						"PROPERTY_ID" => $ar["PROPERTY_ID"],
						"SMART_FILTER" => "N",
						"INHERITED" => $SECTION_ID == 0 && !$bNewSection? "N" : "Y",
						"INHERITED_FROM" => 0,
						"SORT" => $ar["SORT"],
						"LEFT_MARGIN" => $ar["LEFT_MARGIN"],
						"LINK_TITLE" => $ar["LINK_TITLE"],
					);
				}
			}
			if (!empty($result))
				\Freetrix\Main\Type\Collection::sortByColumn($result, array("SORT" => SORT_ASC, "PROPERTY_ID" => SORT_ASC), '', null, true);
		}
		return $result;
	}
Example #4
0
	array(
		"id"=>"HINT",
		"content"=>GetMessage("IBP_ADM_HINT"),
	),
);

$arPropType = array(
	"S" => GetMessage("IBLOCK_PROP_S"),
	"N" => GetMessage("IBLOCK_PROP_N"),
	"L" => GetMessage("IBLOCK_PROP_L"),
	"F" => GetMessage("IBLOCK_PROP_F"),
	"G" => GetMessage("IBLOCK_PROP_G"),
	"E" => GetMessage("IBLOCK_PROP_E"),
);
$arUserTypeList = CIBlockProperty::GetUserType();
\Freetrix\Main\Type\Collection::sortByColumn($arUserTypeList, array('DESCRIPTION' => SORT_STRING));
foreach($arUserTypeList as $arUserType)
	$arPropType[$arUserType["PROPERTY_TYPE"].":".$arUserType["USER_TYPE"]] = $arUserType["DESCRIPTION"];

$lAdmin->AddHeaders($arHeader);

$rsIBlockProps = CIBlockProperty::GetList($arOrder, $arFilter);
$rsIBlockProps = new CAdminResult($rsIBlockProps, $sTableID);
$rsIBlockProps->NavStart();

$lAdmin->NavText($rsIBlockProps->GetNavPrint(GetMessage("IBP_ADM_PAGER")));

while($dbrs = $rsIBlockProps->NavNext(true, "f_"))
{
	if($dbrs["USER_TYPE"])
		$dbrs["PROPERTY_TYPE"] .= ":".$dbrs["USER_TYPE"];
Example #5
0
/**
 * Sorting array by column.
 * You can use short mode: Collection::sortByColumn($arr, 'value'); This is equal Collection::sortByColumn($arr, array('value' => SORT_ASC))
 *
 * More example:
 * Collection::sortByColumn($arr, array('value' => array(SORT_NUMERIC, SORT_ASC), 'attr' => SORT_DESC), array('attr' => 'strlen'), 'www');
 *
 * @param array        $array
 * @param string|array $columns
 * @param string|array $callbacks
 * @param bool         $preserveKeys If false numeric keys will be re-indexed. If true - preserve.
 * @param null         $defaultValueIfNotSetValue If value not set - use $defaultValueIfNotSetValue (any cols)
 */
function sortByColumn(array &$array, $columns, $callbacks = '', $defaultValueIfNotSetValue = null, $preserveKeys = false)
{
	\Freetrix\Main\Type\Collection::sortByColumn($array, $columns, $callbacks, $defaultValueIfNotSetValue, $preserveKeys);
}
Example #6
0
 function GetList($arOrder = array(), $arFilter = array(), $arSelect = false)
 {
     /** @global CMain $APPLICATION */
     global $APPLICATION;
     if (isset($arFilter["ID"]) && !is_array($arFilter["ID"])) {
         $arFilter["ID"] = array($arFilter["ID"]);
     }
     $folders = array("/local/templates", FX_PERSONAL_ROOT . "/templates");
     $arRes = array();
     foreach ($folders as $folder) {
         $path = $_SERVER["DOCUMENT_ROOT"] . $folder;
         if (is_dir($path)) {
             $handle = opendir($path);
             if ($handle) {
                 while (($file = readdir($handle)) !== false) {
                     if ($file == "." || $file == ".." || !is_dir($path . "/" . $file)) {
                         continue;
                     }
                     if ($file == ".default") {
                         continue;
                     }
                     if (isset($arRes[$file])) {
                         continue;
                     }
                     if (isset($arFilter["ID"]) && !in_array($file, $arFilter["ID"])) {
                         continue;
                     }
                     $arTemplate = array("DESCRIPTION" => "");
                     if (file_exists($fname = $path . "/" . $file . "/lang/" . LANGUAGE_ID . "/description.php")) {
                         __IncludeLang($fname, false, true);
                     } elseif (file_exists($fname = $path . "/" . $file . "/lang/" . LangSubst(LANGUAGE_ID) . "/description.php")) {
                         __IncludeLang($fname, false, true);
                     }
                     if (file_exists($fname = $path . "/" . $file . "/description.php")) {
                         include $fname;
                     }
                     $arTemplate["ID"] = $file;
                     $arTemplate["PATH"] = $folder . "/" . $file;
                     if (!isset($arTemplate["NAME"])) {
                         $arTemplate["NAME"] = $file;
                     }
                     if ($arSelect === false || in_array("SCREENSHOT", $arSelect)) {
                         if (file_exists($path . "/" . $file . "/lang/" . LANGUAGE_ID . "/screen.gif")) {
                             $arTemplate["SCREENSHOT"] = $folder . "/" . $file . "/lang/" . LANGUAGE_ID . "/screen.gif";
                         } elseif (file_exists($path . "/" . $file . "/screen.gif")) {
                             $arTemplate["SCREENSHOT"] = $folder . "/" . $file . "/screen.gif";
                         } else {
                             $arTemplate["SCREENSHOT"] = false;
                         }
                         if (file_exists($path . "/" . $file . "/lang/" . LANGUAGE_ID . "/preview.gif")) {
                             $arTemplate["PREVIEW"] = $folder . "/" . $file . "/lang/" . LANGUAGE_ID . "/preview.gif";
                         } elseif (file_exists($path . "/" . $file . "/preview.gif")) {
                             $arTemplate["PREVIEW"] = $folder . "/" . $file . "/preview.gif";
                         } else {
                             $arTemplate["PREVIEW"] = false;
                         }
                     }
                     if ($arSelect === false || in_array("CONTENT", $arSelect)) {
                         $arTemplate["CONTENT"] = $APPLICATION->GetFileContent($path . "/" . $file . "/header.php") . "#WORK_AREA#" . $APPLICATION->GetFileContent($path . "/" . $file . "/footer.php");
                     }
                     if ($arSelect === false || in_array("STYLES", $arSelect)) {
                         if (file_exists($path . "/" . $file . "/styles.css")) {
                             $arTemplate["STYLES"] = $APPLICATION->GetFileContent($path . "/" . $file . "/styles.css");
                             $arTemplate["STYLES_TITLE"] = CSiteTemplate::__GetByStylesTitle($path . "/" . $file . "/.styles.php");
                         }
                         if (file_exists($path . "/" . $file . "/template_styles.css")) {
                             $arTemplate["TEMPLATE_STYLES"] = $APPLICATION->GetFileContent($path . "/" . $file . "/template_styles.css");
                         }
                     }
                     $arRes[$file] = $arTemplate;
                 }
                 closedir($handle);
             }
         }
     }
     if (is_array($arOrder)) {
         $columns = array();
         static $fields = array("ID" => 1, "NAME" => 1, "DESCRIPTION" => 1, "SORT" => 1);
         foreach ($arOrder as $key => $val) {
             $key = strtoupper($key);
             if (isset($fields[$key])) {
                 $columns[$key] = strtoupper($val) == "DESC" ? SORT_DESC : SORT_ASC;
             }
         }
         if (!empty($columns)) {
             \Freetrix\Main\Type\Collection::sortByColumn($arRes, $columns);
         }
     }
     $db_res = new CDBResult();
     $db_res->InitFromArray($arRes);
     return $db_res;
 }
Example #7
0
function __AddPropCellType($intOFPropID,$strPrefix,$arPropInfo)
{
	static $arUserTypeList = null;
	if (null === $arUserTypeList)
	{
		$arUserTypeList = CIBlockProperty::GetUserType();
		\Freetrix\Main\Type\Collection::sortByColumn($arUserTypeList, array('DESCRIPTION' => SORT_STRING));
	}
	$boolUserPropExist = !empty($arUserTypeList);
	ob_start();
	?><select name="<?echo $strPrefix.$intOFPropID?>_PROPERTY_TYPE" id="<?echo $strPrefix.$intOFPropID?>_PROPERTY_TYPE" style="width:150px"><?
	if ($boolUserPropExist)
	{
		?><optgroup label="<? echo GetMessage('IB_E_PROP_BASE_TYPE_GROUP'); ?>"><?
	}
	?>
	<option value="S" <?if($arPropInfo['PROPERTY_TYPE']=="S" && !$arPropInfo['USER_TYPE'])echo " selected"?>><?echo GetMessage("IB_E_PROP_TYPE_S")?></option>
	<option value="N" <?if($arPropInfo['PROPERTY_TYPE']=="N" && !$arPropInfo['USER_TYPE'])echo " selected"?>><?echo GetMessage("IB_E_PROP_TYPE_N")?></option>
	<option value="L" <?if($arPropInfo['PROPERTY_TYPE']=="L" && !$arPropInfo['USER_TYPE'])echo " selected"?>><?echo GetMessage("IB_E_PROP_TYPE_L")?></option>
	<option value="F" <?if($arPropInfo['PROPERTY_TYPE']=="F" && !$arPropInfo['USER_TYPE'])echo " selected"?>><?echo GetMessage("IB_E_PROP_TYPE_F")?></option>
	<option value="G" <?if($arPropInfo['PROPERTY_TYPE']=="G" && !$arPropInfo['USER_TYPE'])echo " selected"?>><?echo GetMessage("IB_E_PROP_TYPE_G")?></option>
	<option value="E" <?if($arPropInfo['PROPERTY_TYPE']=="E" && !$arPropInfo['USER_TYPE'])echo " selected"?>><?echo GetMessage("IB_E_PROP_TYPE_E")?></option>
	<?
	if ($boolUserPropExist)
	{
		?></optgroup><optgroup label="<? echo GetMessage('IB_E_PROP_USER_TYPE_GROUP'); ?>"><?
	}
	foreach($arUserTypeList as $ar)
	{
		?><option value="<?php 
echo htmlspecialcharsbx($ar["PROPERTY_TYPE"] . ":" . $ar["USER_TYPE"]);
?>
" <?if($arPropInfo['PROPERTY_TYPE']==$ar["PROPERTY_TYPE"] && $arPropInfo['USER_TYPE']==$ar["USER_TYPE"])echo " selected"?>><?php 
echo htmlspecialcharsbx($ar["DESCRIPTION"]);
?>
</option>
		<?
	}
	if ($boolUserPropExist)
	{
		?></optgroup><?
	}
	?>
	</select><?
	$strResult = ob_get_contents();
	ob_end_clean();
	return $strResult;
}
Example #8
0
					$arResult['OFFERS'][$keyOffer]['TREE'] = array();
				$arResult['OFFERS'][$keyOffer]['TREE']['PROP_'.$arSKUPropList[$strOneCode]['ID']] = $arMatrix[$keyOffer][$strOneCode]['VALUE'];
				$arResult['OFFERS'][$keyOffer]['SKU_SORT_'.$strOneCode] = $arMatrix[$keyOffer][$strOneCode]['SORT'];
				$arUsedFields[$strOneCode] = true;
				$arSortFields['SKU_SORT_'.$strOneCode] = SORT_NUMERIC;
			}
			else
			{
				unset($arMatrix[$keyOffer][$strOneCode]);
			}
		}
	}
	$arResult['OFFERS_PROP'] = $arUsedFields;
	$arResult['OFFERS_PROP_CODES'] = (!empty($arUsedFields) ? base64_encode(serialize(array_keys($arUsedFields))) : '');

	\Freetrix\Main\Type\Collection::sortByColumn($arResult['OFFERS'], $arSortFields);

	if (!empty($arIDS) && CBXFeatures::IsFeatureEnabled('CatCompleteSet'))
	{
		$rsSets = CCatalogProductSet::getList(
			array(),
			array(
				'@OWNER_ID' => $arIDS,
				'=SET_ID' => 0,
				'=TYPE' => CCatalogProductSet::TYPE_GROUP
			),
			false,
			false,
			array('ID', 'OWNER_ID')
		);
		while ($arSet = $rsSets->Fetch())
Example #9
0
	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);
		}
	}