summaryrefslogtreecommitdiff
path: root/feed.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2007-07-18 09:10:53 +0200
committerAndreas Gohr <andi@splitbrain.org>2007-07-18 09:10:53 +0200
commit4bb1b5aebf56b2cf69230d1e557674419bc06eaa (patch)
tree52a9a5a658e05d9eb2ba30c3a2aeb37697340c04 /feed.php
parent2f1faf4976459076277ef549b2b235cab2593095 (diff)
downloadrpg-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
Diffstat (limited to 'feed.php')
-rw-r--r--feed.php25
1 files changed, 23 insertions, 2 deletions
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 <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 :
?>