diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/CachedIBlock.php b/CachedIBlock.php new file mode 100644 index 0000000..1827387 --- /dev/null +++ b/CachedIBlock.php @@ -0,0 +1,48 @@ +lifetime = $livetime; + $this->id = $id; + } + +// $query аналогичен запросу \Bitrix\Iblock\ElementTable::getList +// array( +// 'order' => array('SORT' => 'ASC'), // сортировка +// 'select' => array('ID', 'NAME', 'IBLOCK_ID', 'SORT', 'TAGS'), // выбираемые поля, без свойств. Свойства можно получать на старом ядре \CIBlockElement::getProperty +// 'filter' => array('IBLOCK_ID' => 4), // фильтр только по полям элемента, свойства (PROPERTY) использовать нельзя +// 'group' => array('TAGS'), // группировка по полю, order должен быть пустой +// 'limit' => 1000, // целое число, ограничение выбираемого кол-ва +// 'offset' => 0, // целое число, указывающее номер первого столбца в результате +// 'count_total' => 1 // дает возможность получить кол-во элементов через метод getCount() +// ) +// ) + + public function getList($query) { + $cache = Cache::createInstance(); + if ($cache->initCache($this->lifetime, $this->id, $initdir, $basedir)) { + $arResult = $cache->getVars(); + } elseif ($cache->startDataCache()) { + $arResult = array(); + if ($dbItems = ElementTable::getList($query)) { + $arResult = $dbItems->fetchAll(); + } else { + $cache->abortDataCache(); + } + $cache->endDataCache($arResult); + } + return $arResult; + } + +} \ No newline at end of file diff --git a/FETCH_HEAD b/FETCH_HEAD new file mode 100644 index 0000000..e69de29 diff --git a/getLastNews.php b/getLastNews.php new file mode 100644 index 0000000..b1b01cd --- /dev/null +++ b/getLastNews.php @@ -0,0 +1,13 @@ +channel->item[$i]; + echo PHP_EOL.$item->title . PHP_EOL.$item->link . PHP_EOL.trim($item->description) . PHP_EOL; + $i++; + endwhile; + echo PHP_EOL; + +} else { echo "Parse error" . PHP_EOL; } \ No newline at end of file