Первый бит, 2 задание

 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
34
35
36
37
38
39
$obCache = new CPHPCache;
$life_time = 86400;
$cache_id = date("dmY") . "cities";
// если кеш есть и он ещё не истек то
if ($obCache->InitCache($life_time, $cache_id, "/" . SITE_ID . "/custom/")) {
$vars = $obCache->GetVars();
$arResult["ITEMS"] = $vars["ITEMS"];
} else {
CModule::IncludeModule("iblock");
$ib_cities = 12;
$ib_courses = 13;
$ib_schedule = 14;
$arSelect = Array("NAME");
$arFilter = array(
"IBLOCK_ID" => $ib_courses,
"ID" => CIBlockElement::SubQuery("PROPERTY_COURSE_ID", Array(
"IBLOCK_ID" => $ib_schedule,
"ACTIVE" => "Y",
">=DATE_ACTIVE_FROM" => array(false, ConvertTimeStamp(false, "FULL")),
)),
"PROPERTY_CITY.NAME" => "Торжок"
);
$res = CIBlockElement::GetList(Array(), $arFilter, false, false, $arSelect);
while ($fields = $res->GetNext()) {
$arResult["ITEMS"][] = $fields;
}
}
if ($obCache->StartDataCache()):
$obCache->EndDataCache(
array(
"ITEMS" => $arResult["ITEMS"],
)
);
endif;