From 797c0d11858d591047f014cb179cd254faaac238 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 25 Nov 2006 00:27:44 +0100 Subject: experimental XMLRPC support This adds experimental XMLRPC support to DokuWiki. A subset of the Wiki XMLRPC API v2 [1] is implemented. You need to remove the die() call in lib/exe/xmlrpc.php to use it. [1] http://www.jspwiki.org/wiki/WikiRPCInterface2 darcs-hash:20061124232744-7ad00-fdaccc68787c3b0349b155a94a1a56003560c5d8.gz --- lib/exe/xmlrpc.php | 176 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 176 insertions(+) create mode 100644 lib/exe/xmlrpc.php (limited to 'lib') diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php new file mode 100644 index 000000000..46db3cb30 --- /dev/null +++ b/lib/exe/xmlrpc.php @@ -0,0 +1,176 @@ +IXR_IntrospectionServer(); + + /* DokuWiki's own methods */ + $this->addCallback( + 'dokuwiki.getVersion', + 'getVersion', + array('string'), + 'Returns the running DokuWiki version' + ); + + /* Wiki API v2 http://www.jspwiki.org/wiki/WikiRPCInterface2 */ + $this->addCallback( + 'wiki.getRPCVersionSupported', + 'this:wiki_RPCVersion', + array('int'), + 'Returns 2 with the supported RPC API version' + ); + $this->addCallback( + 'wiki.getPage', + 'this:rawPage', + array('string','string'), + 'Get the raw Wiki text of page, latest version.' + ); + $this->addCallback( + 'wiki.getPageVersion', + 'this:rawPage', + array('string','string','int'), + 'Get the raw Wiki text of page.' + ); + $this->addCallback( + 'wiki.getPageHTML', + 'this:htmlPage', + array('string','string'), + 'Return page in rendered HTML, latest version.' + ); + $this->addCallback( + 'wiki.getPageHTMLVersion', + 'this:htmlPage', + array('string','string','int'), + 'Return page in rendered HTML.' + ); + $this->addCallback( + 'wiki.getAllPages', + 'this:listPages', + array('struct'), + 'Returns a list of all pages. The result is an array of utf8 pagenames.' + ); + $this->addCallback( + 'wiki.getBackLinks', + 'this:listBackLinks', + array('struct','string'), + 'Returns the pages that link to this page.' + ); + $this->addCallback( + 'wiki.getPageInfo', + 'this:pageInfo', + array('struct','string'), + 'Returns a struct with infos about the page.' + ); + $this->addCallback( + 'wiki.getPageInfoVersion', + 'this:pageInfo', + array('struct','string','int'), + 'Returns a struct with infos about the page.' + ); +/* + FIXME: missing, yet + 'wiki.getRecentChanges' + 'wiki.listLinks' + 'wiki.putPage' +*/ + + $this->serve(); + } + + /** + * Return a raw wiki page + */ + function rawPage($id,$rev=''){ + if(auth_quickaclcheck($id) < AUTH_READ){ + return new IXR_Error(1, 'You are not allowed to read this page'); + } + return rawWiki($id,$rev); + } + + /** + * Return a wiki page rendered to html + */ + function htmlPage($id,$rev=''){ + if(auth_quickaclcheck($id) < AUTH_READ){ + return new IXR_Error(1, 'You are not allowed to read this page'); + } + return p_wiki_xhtml($id,$rev,false); + } + + /** + * List all pages - we use the indexer list here + */ + function listPages(){ + require_once(DOKU_INC.'inc/fulltext.php'); + return ft_pageLookup(''); + } + + + /** + * Return a list of backlinks + */ + function listBacklinks($id){ + require_once(DOKU_INC.'inc/fulltext.php'); + return ft_backlinks($id); + } + + /** + * return some basic data about a page + */ + function pageInfo($id,$rev=''){ + if(auth_quickaclcheck($id) < AUTH_READ){ + return new IXR_Error(1, 'You are not allowed to read this page'); + } + $file = wikiFN($id,$rev); + $time = @filemtime($file); + if(!$time){ + return new IXR_Error(10, 'The requested page does not exist'); + } + + $info = getRevisionInfo($id, $time, 1024); + + $data = array( + 'name' => $id, + 'lastModified' => new IXR_Date($time), + 'author' => (($info['user']) ? $info['user'] : $info['ip']), + 'version' => $time + ); + return $data; + } + + /** + * The version of Wiki RPC API supported + */ + function wiki_RPCVersion(){ + return 2; + } + +} + +$server = new dokuwiki_xmlrpc_server(); + -- cgit v1.2.3