diff options
author | Gina Haeussge <osd@foosel.net> | 2008-08-23 16:07:55 +0200 |
---|---|---|
committer | Gina Haeussge <osd@foosel.net> | 2008-08-23 16:07:55 +0200 |
commit | 3275953aed09bc2b5f49805637a2679f1d7d6bab (patch) | |
tree | b09d0d5026fc528a308509dbcf21bf59aec32834 | |
parent | 5672e868b61109a6a4376636618f3c48c37751fa (diff) | |
download | rpg-3275953aed09bc2b5f49805637a2679f1d7d6bab.tar.gz rpg-3275953aed09bc2b5f49805637a2679f1d7d6bab.tar.bz2 |
XMLRPC: Added options for recursion and filtering in listAttachments
darcs-hash:20080823140755-2b4f5-f7d4ce991c38cc6a42e0013e738e291a3d134a43.gz
-rw-r--r-- | lib/exe/xmlrpc.php | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index 0f364ab6f..4dd27186f 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -225,26 +225,39 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { /** * List all media files. + * + * Available options are 'recursive' for also including the subnamespaces + * in the listing, and 'pattern' for filtering the returned files against + * a regular expression matching their name. + * + * @author Gina Haeussge <osd@foosel.net> */ - function listAttachments($ns) { + function listAttachments($ns, $options = array()) { global $conf; global $lang; $ns = cleanID($ns); + if (!is_array($options)) + $options = array(); + + if (!isset($options['recursive'])) $options['recursive'] = false; + 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('recursive' => true), $dir); - + search($data, $conf['mediadir'], 'search_media', array('recursive' => $options['recursive']), $dir); + if(!count($data)) { return array(); } $files = array(); foreach($data as $item) { + if (isset($options['pattern']) && !@preg_match($options['pattern'], $item['id'])) + continue; $file = array(); $file['id'] = $item['id']; $file['size'] = $item['size']; |