summaryrefslogtreecommitdiff
path: root/lib/exe
diff options
context:
space:
mode:
authorMichael Klier <chi@chimeric.de>2008-07-13 18:52:10 +0200
committerMichael Klier <chi@chimeric.de>2008-07-13 18:52:10 +0200
commit26bec61e9e45fa53d4c3ac5426eae19943c8aea6 (patch)
tree5ab8a9d7d6aa27b46615b443024e00a671bf27a1 /lib/exe
parente62b9ea586eb7763bfb64c8c4dc440a2819e1aa9 (diff)
downloadrpg-26bec61e9e45fa53d4c3ac5426eae19943c8aea6.tar.gz
rpg-26bec61e9e45fa53d4c3ac5426eae19943c8aea6.tar.bz2
XML-RPC: added getAttachments()
darcs-hash:20080713165210-23886-d28593ac62f3471a4dc4a5410263edb0e48986bc.gz
Diffstat (limited to 'lib/exe')
-rw-r--r--lib/exe/xmlrpc.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php
index cd25a3d33..b752183c6 100644
--- a/lib/exe/xmlrpc.php
+++ b/lib/exe/xmlrpc.php
@@ -76,6 +76,12 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer {
'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',
array('struct','string'),
@@ -162,6 +168,44 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer {
}
/**
+ * 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
*/
function listBackLinks($id){