<?
if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true) die();
/** @var CBitrixComponent $this */
/** @var array $arParams */
/** @var array $arResult */
/** @var string $componentPath */
/** @var string $componentName */
/** @var string $componentTemplate */
/** @global CDatabase $DB */
/** @global CUser $USER */
/** @global CMain $APPLICATION */

use Bitrix\Main\Context,
	Bitrix\Main\Type\DateTime,
	Bitrix\Main\Loader,
	Bitrix\Iblock;

//if($this->StartResultCache(60*60*24, md5(var_export($_POST, true))))
//{
	if(CModule::IncludeModule('iblock'))
	{
		$arResult = [
			'CITIES' => []
		];

		$cities_res = CIBlockElement::GetList([ "NAME" => "ASC" ], [ "ACTIVE" => "Y", "IBLOCK_ID" => IBLOCK_ID_CITIES ], false, []);
		while ($cities_ob_element = $cities_res->GetNextElement())
		{
			$cities_ar_res = $cities_ob_element->GetFields();
			$cities_ar_res['PROPERTIES'] = $cities_ob_element->GetProperties();

			if(isset($cities_ar_res['PREVIEW_PICTURE']))
			{
				$cities_ar_res['PREVIEW_PICTURE'] = CFile::GetPath($cities_ar_res['PREVIEW_PICTURE']);
			}

			$arResult['CITIES'][] = $cities_ar_res;
		}

		$this->IncludeComponentTemplate();
	}
//}