diff options
author | Andreas Gohr <andi@splitbrain.org> | 2007-07-18 09:10:53 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2007-07-18 09:10:53 +0200 |
commit | 4bb1b5aebf56b2cf69230d1e557674419bc06eaa (patch) | |
tree | 52a9a5a658e05d9eb2ba30c3a2aeb37697340c04 | |
parent | 2f1faf4976459076277ef549b2b235cab2593095 (diff) | |
download | rpg-4bb1b5aebf56b2cf69230d1e557674419bc06eaa.tar.gz rpg-4bb1b5aebf56b2cf69230d1e557674419bc06eaa.tar.bz2 |
RSS feeds for search results
Lets you subscribe to the result of a full text search
darcs-hash:20070718071053-7ad00-131c87d5a51ec0d600358590539193ab59b3dbe6.gz
-rw-r--r-- | feed.php | 25 | ||||
-rw-r--r-- | inc/template.php | 6 |
2 files changed, 29 insertions, 2 deletions
@@ -59,6 +59,8 @@ if($opt['feed_mode'] == 'list'){ rssListNamespace($rss,$opt); + }elseif($opt['feed_mode'] == 'search'){ + rssSearch($rss,$opt); }else{ rssRecentChanges($rss,$opt); } @@ -88,6 +90,7 @@ function rss_parseOptions(){ $opt['namespace'] = $_REQUEST['ns']; $opt['link_to'] = $_REQUEST['linkto']; $opt['item_content'] = $_REQUEST['content']; + $opt['search_query'] = $_REQUEST['q']; if(!$opt['feed_type']) $opt['feed_type'] = $conf['rss_type']; if(!$opt['item_content']) $opt['item_content'] = $conf['rss_content']; @@ -132,6 +135,11 @@ function rss_buildItems(&$rss,&$data,$opt){ global $lang; foreach($data as $ditem){ + if(!is_array($ditem)){ + // not an array? then only a list of IDs was given + $ditem = array( 'id' => $ditem ); + } + $item = new FeedItem(); $id = $ditem['id']; $meta = p_get_metadata($id); @@ -256,7 +264,7 @@ function rss_buildItems(&$rss,&$data,$opt){ /** - * Add recent changed pages to a feed object + * Add recent changed pages to the feed object * * @author Andreas Gohr <andi@splitbrain.org> */ @@ -273,7 +281,7 @@ function rssRecentChanges(&$rss,$opt){ } /** - * Add all pages of a namespace to a feedobject + * Add all pages of a namespace to the feed object * * @author Andreas Gohr <andi@splitbrain.org> */ @@ -291,7 +299,20 @@ function rssListNamespace(&$rss,$opt){ rss_buildItems($rss,$data,$opt); } +/** + * Add the result of a full text search to the feed object + * + * @author Andreas Gohr <andi@splitbrain.org> + */ +function rssSearch(&$rss,$opt){ + if(!$opt['search_query']) return; + require_once(DOKU_INC.'inc/fulltext.php'); + $data = array(); + $data = ft_pageSearch($opt['search_query'],$poswords); + $data = array_keys($data); + rss_buildItems($rss,$data,$opt); +} //Setup VIM: ex: et ts=4 enc=utf-8 : ?> diff --git a/inc/template.php b/inc/template.php index c941a64f4..c105ee258 100644 --- a/inc/template.php +++ b/inc/template.php @@ -181,6 +181,7 @@ function tpl_metaheaders($alt=true){ global $REV; global $INFO; global $ACT; + global $QUERY; global $lang; global $conf; $it=2; @@ -203,6 +204,11 @@ function tpl_metaheaders($alt=true){ $head['link'][] = array( 'rel'=>'alternate', 'type'=>'application/rss+xml', 'title'=>'Current Namespace', 'href'=>DOKU_BASE.'feed.php?mode=list&ns='.$INFO['namespace']); + if($ACT == 'search'){ + $head['link'][] = array( 'rel'=>'alternate', 'type'=>'application/rss+xml', + 'title'=>'Search Result', + 'href'=>DOKU_BASE.'feed.php?mode=search&q='.$QUERY); + } if(actionOK('export_xhtml')){ $head['link'][] = array( 'rel'=>'alternate', 'type'=>'text/html', 'title'=>'Plain HTML', |