From 3275953aed09bc2b5f49805637a2679f1d7d6bab Mon Sep 17 00:00:00 2001 From: Gina Haeussge Date: Sat, 23 Aug 2008 16:07:55 +0200 Subject: XMLRPC: Added options for recursion and filtering in listAttachments darcs-hash:20080823140755-2b4f5-f7d4ce991c38cc6a42e0013e738e291a3d134a43.gz --- lib/exe/xmlrpc.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'lib/exe') 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 */ - 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']; -- cgit v1.2.3