function _querypath_examples_show_multiplerss in QueryPath 6
Same name and namespace in other branches
- 7.3 querypath_examples.module \_querypath_examples_show_multiplerss()
- 7.2 querypath_examples.module \_querypath_examples_show_multiplerss()
1 call to _querypath_examples_show_multiplerss()
- querypath_examples_show_multiplerss in ./
querypath_examples.module - Display the titles of each item in the RSS feed.
File
- ./
querypath_examples.module, line 529 - The main file for querypath_examples.
Code
function _querypath_examples_show_multiplerss($urls, $limit) {
$feeds = array();
$tot = 1;
foreach ($urls as $u) {
$url = url($u, array(
'absolute' => TRUE,
));
foreach (qp($url, 'item') as $item) {
$title = $item
->find('title')
->text();
$link = $item
->parent()
->children('link')
->text();
$desc = $item
->parent()
->children('description')
->text();
$pubdate = strtotime($item
->parent()
->children('pubDate')
->text());
if (!$pubdate) {
$pubdate = strtotime($item
->parent()
->children('lastBuildDate')
->text());
}
$feeds[$pubdate] = array(
'url' => $u,
'title' => $title,
'link' => $link,
'desc' => $desc,
);
if ($tot == $limit) {
break;
}
$tot++;
}
$tot = 1;
}
krsort($feeds);
$c = count($feeds);
for ($i = $c; $i > $c - $limit - 1; $i--) {
array_pop($feeds);
}
return $feeds;
}