From 4bb1b5aebf56b2cf69230d1e557674419bc06eaa Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 18 Jul 2007 09:10:53 +0200 Subject: RSS feeds for search results Lets you subscribe to the result of a full text search darcs-hash:20070718071053-7ad00-131c87d5a51ec0d600358590539193ab59b3dbe6.gz --- feed.php | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'feed.php') diff --git a/feed.php b/feed.php index db10cc3e6..ce8b26e28 100644 --- a/feed.php +++ b/feed.php @@ -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 */ @@ -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 */ @@ -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 + */ +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 : ?> -- cgit v1.2.3