From 7305616844af0c5f916578da1a6588f72cba745f Mon Sep 17 00:00:00 2001 From: Michael Klier <chi@chimeric.de> Date: Wed, 5 Mar 2008 20:55:32 +0100 Subject: [PATCH] XMLRPC: new function pageVersions() This function can be used to retrieve a list of revisions for a given wiki page. darcs-hash:20080305195532-23886-dee2ffff8dcdc21532fb62674edce8a74d6c5525.gz --- lib/exe/xmlrpc.php | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index 64c85be05..3fe432157 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -93,6 +93,12 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { array('struct','string','int'), 'Returns a struct with infos about the page.' ); + $this->addCallback( + 'wiki.getPageVersions', + 'this:pageVersions', + array('struct','string','int'), + 'Returns the available revisions of the page.' + ); $this->addCallback( 'wiki.putPage', 'this:putPage', @@ -345,6 +351,57 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { return new IXR_Error(30, 'There are no changes in the specified timeframe'); } + /** + * Returns a list of available revisions of a given wiki page + * + * @author Michael Klier <chi@chimeric.de> + */ + function pageVersions($id, $first) { + global $conf; + + $versions = array(); + + if(empty($id)) + return new IXR_Error(1, 'Empty page ID'); + + require_once(DOKU_INC.'inc/changelog.php'); + + $revisions = getRevisions($id, $first, $conf['recent']+1); + + if(count($revisions)==0 && $first!=0) { + $first=0; + $revisions = getRevisions($id, $first, $conf['recent']+1); + } + + $hasNext = false; + if (count($revisions)>$conf['recent']) { + $hasNext = true; + array_pop($revisions); // remove extra log entry + } + + if(!empty($revisions)) { + foreach($revisions as $rev) { + $file = wikiFN($id,$rev); + $time = @filemtime($file); + if($time){ + $info = getRevisionInfo($id, $time, 1024); + if(!empty($info)) { + $data['user'] = $info['user']; + $data['ip'] = $info['ip']; + $data['type'] = $info['type']; + $data['sum'] = $info['sum']; + $data['modified'] = new IXR_Date($info['date']); + $data['version'] = $info['date']; + array_push($versions, $data); + } + } + } + return $versions; + } else { + return array(); + } + } + /** * The version of Wiki RPC API supported */ -- GitLab