summaryrefslogtreecommitdiff
path: root/inc/parser
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2006-04-14 13:00:47 +0200
committerAndreas Gohr <andi@splitbrain.org>2006-04-14 13:00:47 +0200
commit3db95bec49bcc5481c2b68517d7db3c0c40a1cc6 (patch)
treeb59ac9e4e929fb47544dff7f338835ed3d59b53e /inc/parser
parentc6480b76a58fe21a89e7ee0c41626742aa5342ea (diff)
downloadrpg-3db95bec49bcc5481c2b68517d7db3c0c40a1cc6.tar.gz
rpg-3db95bec49bcc5481c2b68517d7db3c0c40a1cc6.tar.bz2
feed aggregation revamped
Feeds are now parsed with SimplePie. The feed syntax was enhanced darcs-hash:20060414110047-7ad00-6dd4b96845baab8683a2f837d6ad6fcb2fd53131.gz
Diffstat (limited to 'inc/parser')
-rw-r--r--inc/parser/handler.php17
-rw-r--r--inc/parser/xhtml.php61
2 files changed, 62 insertions, 16 deletions
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 <andi@splitbrain.org>
*/
- 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 .= '<ul class="rss">';
- if($rss){
- foreach ($rss->items as $item ) {
- $this->doc .= '<li>';
- $this->externallink($item['link'],$item['title']);
- $this->doc .= '</li>';
+ if($rc){
+ for ($x = $start; $x != $end; $x += $mod) {
+ $this->doc .= '<li><div class="li">';
+ $this->externallink($feed->get_item_permalink($x),
+ $feed->get_item_title($x));
+ if($params['author']){
+ $this->doc .= ' '.$lang['by'].' '.$feed->get_item_author($x);
+ }
+ if($params['date']){
+ $this->doc .= ' ('.$feed->get_item_date($x,$conf['dformat']).')';
+ }
+ if($params['date']){
+ $this->doc .= '<div class="detail">';
+ if($htmlok){
+ $this->doc .= $feed->get_item_description($x);
+ }else{
+ $this->doc .= strip_tags($feed->get_item_description($x));
+ }
+ $this->doc .= '</div>';
+ }
+
+ $this->doc .= '</div></li>';
}
}else{
- $this->doc .= '<li>';
+ $this->doc .= '<li><div class="li">';
$this->doc .= '<em>'.$lang['rssfailed'].'</em>';
$this->externallink($url);
- $this->doc .= '</li>';
+ $this->doc .= '</div></li>';
}
$this->doc .= '</ul>';
}
@@ -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 :