From 3db95bec49bcc5481c2b68517d7db3c0c40a1cc6 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 14 Apr 2006 13:00:47 +0200 Subject: feed aggregation revamped Feeds are now parsed with SimplePie. The feed syntax was enhanced darcs-hash:20060414110047-7ad00-6dd4b96845baab8683a2f837d6ad6fcb2fd53131.gz --- inc/parser/handler.php | 17 +++++++++++++- inc/parser/xhtml.php | 61 +++++++++++++++++++++++++++++++++++++------------- 2 files changed, 62 insertions(+), 16 deletions(-) (limited to 'inc/parser') diff --git a/inc/parser/handler.php b/inc/parser/handler.php index 9cc53c42f..7a8fc9bc2 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -456,7 +456,22 @@ class Doku_Handler { function rss($match, $state, $pos) { $link = preg_replace(array('/^\{\{rss>/','/\}\}$/'),'',$match); - $this->_addCall('rss',array($link),$pos); + + // get params + list($link,$params) = explode(' ',$link,2); + + $p = array(); + if(preg_match('/\b(\d+)\b/',$params,$match)){ + $p['max'] = $match[1]; + }else{ + $p['max'] = 8; + } + $p['reverse'] = (preg_match('/rev/',$params)); + $p['author'] = (preg_match('/\b(by|author)/',$params)); + $p['date'] = (preg_match('/\b(date)/',$params)); + $p['details'] = (preg_match('/\b(desc|detail)/',$params)); + + $this->_addCall('rss',array($link,$p),$pos); return TRUE; } diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index b3b341f9b..682551169 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -780,34 +780,65 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } /** - * Renders an RSS feed using Magpie + * Renders an RSS feed * * @author Andreas Gohr */ - function rss ($url){ + function rss ($url,$params){ global $lang; - define('MAGPIE_CACHE_ON', false); //we do our own caching - define('MAGPIE_DIR', DOKU_INC.'inc/magpie/'); - define('MAGPIE_OUTPUT_ENCODING','UTF-8'); //return all feeds as UTF-8 - require_once(MAGPIE_DIR.'/rss_fetch.inc'); + global $conf; + + require_once(DOKU_INC.'inc/FeedParser.php'); + $feed = new FeedParser(); + $feed->feed_url($url); //disable warning while fetching $elvl = error_reporting(E_ERROR); - $rss = fetch_rss($url); + $rc = $feed->init(); 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 < 0) ? 0 : $end; + }else{ + $mod = 1; + $start = 0; + $end = $feed->get_item_quantity(); + $end = ($end > $params['max']) ? $params['max'] : $end;; + } + $this->doc .= ''; } @@ -1067,4 +1098,4 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } } -//Setup VIM: ex: et ts=4 enc=utf-8 : \ No newline at end of file +//Setup VIM: ex: et ts=4 enc=utf-8 : -- cgit v1.2.3