if defined B_PROLOG_INCLUDED B_PROLOG_INCLUDED true die global USER if

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?
if(!defined("B_PROLOG_INCLUDED")||B_PROLOG_INCLUDED!==true)die();
global $USER;
if (isset($arParams["CARS_COUNT"]) && IntVal($arParams["CARS_COUNT"]) > 0) {
$arParams["CARS_COUNT"] = IntVal($arParams["CARS_COUNT"]);
} else {
$arParams["CARS_COUNT"] = 4;
}
if ($this->StartResultCache(3600)) {
$arResult["CARS"] = Array();
if(CModule::IncludeModule("iblock")) {
$arSelect = Array("ID", "NAME", "PREVIEW_PICTURE", "PROPERTY_DESCRIPTION", "DETAIL_PAGE_URL");
$arFilter = Array("IBLOCK_ID"=>IntVal($arParams["IBLOCK_ID"]), "ACTIVE"=>"Y");
$res = CIBlockElement::GetList(Array("SORT"=>"DESC"), $arFilter, false, Array("nTopCount"=>$arParams["CARS_COUNT"]), $arSelect);
while($ob = $res->GetNextElement()) {
$arFields = $ob->GetFields();
$arResult["CARS"][$arFields["ID"]]["NAME"] = $arFields["NAME"];
$arResult["CARS"][$arFields["ID"]]["IMG"] = CFile::GetFileArray($arFields["PREVIEW_PICTURE"]);
$arResult["CARS"][$arFields["ID"]]["DESCRIPTION"] = $arFields["PROPERTY_DESCRIPTION_VALUE"];
$arResult["CARS"][$arFields["ID"]]["DETAIL_PAGE_URL"] = $arFields["DETAIL_PAGE_URL"];
}
}
$this->IncludeComponentTemplate();
}
if ($USER->IsAdmin()) {
//echo "<pre>"; print_r($arResult); echo "</pre>";
}
?>