diff options
author | Andreas Gohr <andi@splitbrain.org> | 2010-02-28 12:32:01 +0100 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2010-02-28 12:32:01 +0100 |
commit | f71f4f5359fe234960829868bf22081bf1f2d947 (patch) | |
tree | 28637c8a8bf82d1ecd4754fc286e0d58c9f911e0 | |
parent | bd0293e7406f93a8897c471193b69413b78b6236 (diff) | |
download | rpg-f71f4f5359fe234960829868bf22081bf1f2d947.tar.gz rpg-f71f4f5359fe234960829868bf22081bf1f2d947.tar.bz2 |
added dokuwiki.search XMLRPC call FS#1882
-rw-r--r-- | lib/exe/xmlrpc.php | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index d3913482f..a29a40612 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -7,7 +7,7 @@ if(isset($HTTP_RAW_POST_DATA)) $HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA); /** * Increased whenever the API is changed */ -define('DOKU_XMLRPC_API_VERSION',2); +define('DOKU_XMLRPC_API_VERSION',3); require_once(DOKU_INC.'inc/init.php'); require_once(DOKU_INC.'inc/common.php'); @@ -119,6 +119,13 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { ); $this->addCallback( + 'dokuwiki.search', + 'this:search', + array('struct','string'), + 'Perform a fulltext search and return a list of matching pages' + ); + + $this->addCallback( 'dokuwiki.getTime', 'time', array('int'), @@ -385,6 +392,41 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { } /** + * List all pages in the given namespace (and below) + */ + function search($query){ + require_once(DOKU_INC.'inc/fulltext.php'); + + $regex = ''; + $data = ft_pageSearch($query,$regex); + $pages = array(); + + // prepare additional data + $idx = 0; + foreach($data as $id => $score){ + $file = wikiFN($id); + + if($idx < FT_SNIPPET_NUMBER){ + $snippet = ft_snippet($id,$regex); + $idx++; + }else{ + $snippet = ''; + } + + $pages[] = array( + 'id' => $id, + 'score' => $score, + 'rev' => filemtime($file), + 'mtime' => filemtime($file), + 'size' => filesize($file), + 'snippet' => $snippet, + ); + } + return $data; + } + + + /** * List all media files. * * Available options are 'recursive' for also including the subnamespaces |