/** * Render the output of an RSS feed * * @param string $url URL of the feed * @param array $params Finetuning of the output */ function rss($url, $params) { global $lang; require_once DOKU_INC . 'inc/FeedParser.php'; $feed = new FeedParser(); $feed->feed_url($url); //disable warning while fetching $elvl = null; if (!defined('DOKU_E_LEVEL')) { $elvl = error_reporting(E_ERROR); } $rc = $feed->init(); if (!defined('DOKU_E_LEVEL')) { error_reporting($elvl); } //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->listu_open(); if ($rc) { for ($x = $start; $x != $end; $x += $mod) { $item = $feed->get_item($x); $this->listitem_open(0); $this->listcontent_open(); $this->externallink($item->get_permalink(), $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->cdata(' ' . $lang['by'] . ' ' . $name); } } } if ($params['date']) { $this->cdata(' (' . $item->get_date($this->config->getParam('dformat')) . ')'); } if ($params['details']) { $this->cdata(strip_tags($item->get_description())); } $this->listcontent_close(); $this->listitem_close(); } } else { $this->listitem_open(0); $this->listcontent_open(); $this->emphasis_open(); $this->cdata($lang['rssfailed']); $this->emphasis_close(); $this->externallink($url); $this->listcontent_close(); $this->listitem_close(); } $this->listu_close(); }
/** * 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->feed_url($url); //disable warning while fetching if (!defined('DOKU_E_LEVEL')) { $elvl = error_reporting(E_ERROR); } $rc = $feed->init(); if (!defined('DOKU_E_LEVEL')) { error_reporting($elvl); } //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">'; $this->listu_open(); if ($rc) { for ($x = $start; $x != $end; $x += $mod) { $item = $feed->get_item($x); //$this->doc .= '<li><div class="li">'; $this->listitem_open(1); $this->externallink($item->get_permalink(), $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->cdata(' ' . $lang['by'] . ' ' . $name); } //$this->doc .= ' '.$lang['by'].' '.$name; } } if ($params['date']) { $this->cdata(' (' . $item->get_date($conf['dformat']) . ')'); //$this->doc .= ' ('.$item->get_date($conf['dformat']).')'; } if ($params['details']) { //$this->doc .= '<div class="detail">'; if ($htmlok) { $this->cdata($item->get_description()); } else { $this->cdata(strip_tags($item->get_description())); } //$this->doc .= '</div>'; } //$this->doc .= '</div></li>'; $this->listitem_close(); } } else { //$this->doc .= '<li><div class="li">'; $this->listitem_open(1); $this->emphasis_open(); //$this->doc .= '<em>'.$lang['rssfailed'].'</em>'; $this->cdata($lang['rssfailed']); $this->emphasis_close(); $this->externallink($url); // if($conf['allowdebug']){ // $this->doc .= '<!--'.hsc($feed->error).'-->'; // } // $this->doc .= '</div></li>'; $this->listitem_close(); } // $this->doc .= '</ul>'; $this->listu_close(); }