Skip to content
Snippets Groups Projects
Commit 26bec61e authored by Michael Klier's avatar Michael Klier
Browse files

XML-RPC: added getAttachments()

darcs-hash:20080713165210-23886-d28593ac62f3471a4dc4a5410263edb0e48986bc.gz
parent e62b9ea5
No related branches found
No related tags found
No related merge requests found
......@@ -75,6 +75,12 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer {
array('struct'),
'Returns a list of all pages. The result is an array of utf8 pagenames.'
);
$this->addCallback(
'wiki.getAttachments',
'this:listAttachments',
array('struct'),
'Returns a list of all media files.'
);
$this->addCallback(
'wiki.getBackLinks',
'this:listBackLinks',
......@@ -161,6 +167,44 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer {
return ft_pageLookup('');
}
/**
* List all media files.
*/
function listAttachments($ns) {
global $conf;
global $lang;
$ns = cleanID($ns);
if(auth_quickaclcheck($ns.':*') >= AUTH_READ) {
$dir = utf8_encodeFN(str_replace(':', '/', $ns));
$data = array();
require_once(DOKU_INC.'inc/search.php');
search($data, $conf['mediadir'], 'search_media', array(), $dir);
if(!count($data)) {
return array();
}
$files = array();
foreach($data as $item) {
$file = array();
$file['id'] = $item['id'];
$file['size'] = $item['size'];
$file['mtime'] = $item['mtime'];
$file['isimg'] = $item['isimg'];
$file['writable'] = $item['writeable'];
array_push($files, $file);
}
return $files;
} else {
return new IXR_Error(1, 'You are not allowed to list media files.');
}
}
/**
* Return a list of backlinks
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment