$arVideos = array();
if ($info['http_code'] == 200) {
$xml = simplexml_load_string($data);
foreach ($xml->entry as $entry) {
$arVideo = array();
$id = explode(':',$entry->id);
$arVideo['code'] = $id[2];
$arVideo['title'] = (string)$entry->title;
$arVideo['uri'] = (string)$entry->link->attributes()->href;
$arVideo['published'] = (string)$entry->published;
$media = $entry->children('media', true);
$arVideo['thumbnail'] = (string)$media->group->thumbnail->attributes()->url;
$arVideo['views'] = (integer)$media->group->community->statistics->attributes()->views;
$date = new DateTime($arVideo['published']);
$arVideo['timestamp'] = $date->getTimestamp();
$arVideos[] = $arVideo;
}
}
[
"QUERY" => Поисковй запрос,
"SITE_ID" => Id сайта,
"PARAMS" => [SECTION_ID => id раздела]
];
/**
* @param $category
* @return array
*/
public function getCategoryParams($category) {
if ($category == 'news') {
return [
'MODULE_ID' => 'iblock',
'PARAM2' => IB_NEWS_EVENTS,
"PARAMS" => ['type' => NEWS_TYPE_NEWS],
];
} elseif ($category == 'events') {
return [
'MODULE_ID' => 'iblock',
'PARAM2' => IB_NEWS_EVENTS,
"PARAMS" => ['type' => NEWS_TYPE_EVENTS],
];
} elseif ($category == 'catalog') {
return [
'MODULE_ID' => 'iblock',
'PARAM2' => IB_CATALOG,
];
} elseif ($category == 'site') {
return [
'MODULE_ID' => 'main'
];
}
return [];
}
/**
* @param $query
* @param bool $category
* @return int
*/
public function count($query, $category = false) {
$bxSearch = new CSearch();
$params = [
"QUERY" => $query,
"SITE_ID" => LANG,
];
if ($category !== false) {
$params = array_merge($params, $this->getCategoryParams($category));
}
$bxSearch->Search($params, [], [
'STEMMING' => false
]);
$bxSearch->NavStart();
return $bxSearch->NavRecordCount;
}
public static function beforeIndexHandler($arFields) {
if ($arFields["MODULE_ID"] == "iblock" && $arFields["PARAM2"] == IB_NEWS_EVENTS && substr($arFields["ITEM_ID"], 0, 1) != "S") {
$self = new static();
$element = $self->getElement($arFields["ITEM_ID"]);
$arFields["PARAMS"]["type"] = $element->PROPERTY_TYPE_ENUM_ID;
}
return $arFields;
}