/** * Renders an RSS feed * * @author Andreas Gohr <*****@*****.**> */ function rss($url, $params) { global $lang; global $conf; require_once DOKU_INC . 'inc/FeedParser.php'; $feed = new FeedParser(); $feed->set_feed_url($url); //disable warning while fetching if (!defined('DOKU_E_LEVEL')) { $elvl = error_reporting(E_ERROR); } $rc = $feed->init(); if (isset($elvl)) { error_reporting($elvl); } if ($params['nosort']) { $feed->enable_order_by_date(false); } //decide on start and end if ($params['reverse']) { $mod = -1; $start = $feed->get_item_quantity() - 1; $end = $start - $params['max']; $end = $end < -1 ? -1 : $end; } else { $mod = 1; $start = 0; $end = $feed->get_item_quantity(); $end = $end > $params['max'] ? $params['max'] : $end; } $this->doc .= '<ul class="rss">'; if ($rc) { for ($x = $start; $x != $end; $x += $mod) { $item = $feed->get_item($x); $this->doc .= '<li><div class="li">'; // support feeds without links $lnkurl = $item->get_permalink(); if ($lnkurl) { // title is escaped by SimplePie, we unescape here because it // is escaped again in externallink() FS#1705 $this->externallink($item->get_permalink(), html_entity_decode($item->get_title(), ENT_QUOTES, 'UTF-8')); } else { $this->doc .= ' ' . $item->get_title(); } if ($params['author']) { $author = $item->get_author(0); if ($author) { $name = $author->get_name(); if (!$name) { $name = $author->get_email(); } if ($name) { $this->doc .= ' ' . $lang['by'] . ' ' . $name; } } } if ($params['date']) { $this->doc .= ' (' . $item->get_local_date($conf['dformat']) . ')'; } if ($params['details']) { $this->doc .= '<div class="detail">'; if ($conf['htmlok']) { $this->doc .= $item->get_description(); } else { $this->doc .= strip_tags($item->get_description()); } $this->doc .= '</div>'; } $this->doc .= '</div></li>'; } } else { $this->doc .= '<li><div class="li">'; $this->doc .= '<em>' . $lang['rssfailed'] . '</em>'; $this->externallink($url); if ($conf['allowdebug']) { $this->doc .= '<!--' . hsc($feed->error) . '-->'; } $this->doc .= '</div></li>'; } $this->doc .= '</ul>'; }