Michael Klier wrote: > Hi everyone, > > attached is a patch that adds support for the listLinks() method > (suggested in the Wiki RPC Interface 2 specs) to DokuWikis xmlrpc > interface (and another one which fixes a little typo). UPDATE: In this patch the listLinks() function didn't check the ACLs! Attached is an updated version of the patch, patched against latest darcs revision. Regards, Chi -- Michael Klier mail: chi@xxxxxxxxxxx www: http://www.chimeric.de icq: 206179334 jabber: chi@xxxxxxxxxxxxxxxxxx key: http://downloads.chimeric.de/chi.asc key-id: 0x8308F551
New patches: [added XMLRPC linkList() Michael Klier <chi@xxxxxxxxxxx>**20071109112720] { hunk ./lib/exe/xmlrpc.php 95 - hunk ./lib/exe/xmlrpc.php 101 + $this->addCallback( + 'wiki.listLinks', + 'this:listLinks', + array('struct','string'), + 'Lists all links contained in a wiki page' + ); hunk ./lib/exe/xmlrpc.php 110 - 'wiki.listLinks' hunk ./lib/exe/xmlrpc.php 147 - function listBacklinks($id){ + function listBackLinks($id){ hunk ./lib/exe/xmlrpc.php 179 - - function putPage($put_id, $put_text, $put_summary='', $put_minor=0, $put_rev = '', $put_pre = '', $put_suf = '') { - + function putPage($put_id, $put_text, $put_summary='', $put_minor=0, $put_rev='', $put_pre='', $put_suf='') { hunk ./lib/exe/xmlrpc.php 185 - - if (checklock($put_id) !== false) { - + if (checklock($put_id) !== false) hunk ./lib/exe/xmlrpc.php 188 - } - hunk ./lib/exe/xmlrpc.php 189 - if(checkwordblock()) + if(checkwordblock()) hunk ./lib/exe/xmlrpc.php 192 - // lock the page - hunk ./lib/exe/xmlrpc.php 194 - // save it - - saveWikiText($put_id,con($put_pre,$put_text,$put_suf,1),$put_summary,$put_minor); //use pretty mode for con - - // unlock it + saveWikiText($put_id,con($put_pre,$put_text,$put_suf,1),$put_summary,$put_minor); hunk ./lib/exe/xmlrpc.php 199 + } + + /** + * Lists all links contained in a wiki page + */ + function listLinks($id) { + if(auth_quickaclcheck($id) < AUTH_READ){ + return new IXR_Error(1, 'You are not allowed to read this page'); + } + $links = array(); + + // resolve page instructions + $ins = p_cached_instructions(wikiFN(cleanID($id))); + + // instantiate new Renderer - needed for interwiki links + include(DOKU_INC.'inc/parser/xhtml.php'); + $Renderer = new Doku_Renderer_xhtml(); + $Renderer->interwiki = getInterwiki(); + + // parse parse instructions + foreach($ins as $in) { + $link = array(); + switch($in[0]) { + case 'internallink': + $link['type'] = 'local'; + $link['page'] = $in[1][0]; + $link['href'] = wl($in[1][0]); + array_push($links,$link); + break; + case 'externallink': + $link['type'] = 'extern'; + $link['page'] = $in[1][0]; + $link['href'] = $in[1][0]; + array_push($links,$link); + break; + case 'interwikilink': + $url = $Renderer->_resolveInterWiki($in[1][2],$in[1][3]); + $link['type'] = 'extern'; + $link['page'] = $url; + $link['href'] = $url; + array_push($links,$link); + break; + } + } hunk ./lib/exe/xmlrpc.php 244 + return $links; } Context: [fix problems if $USERINFO['grps'] is not set Andreas Gohr <andi@xxxxxxxxxxxxxx>**20071102181850] [russian language update Andreas Gohr <andi@xxxxxxxxxxxxxx>**20071102181710] [utf8_trim bugfix Andreas Gohr <andi@xxxxxxxxxxxxxx>**20071102181430 Fixes the utf8_trim() function when a charlist is given ] [TAG develsnap 2007-11-01 Andreas Gohr <andi@xxxxxxxxxxxxxx>**20071101000001] Patch bundle hash: 994c39d5c6cf08496941e178d5f0583a12bca9a4