diff options
author | kondou <kondou@ts.unde.re> | 2013-09-05 16:54:12 +0200 |
---|---|---|
committer | kondou <kondou@ts.unde.re> | 2013-09-05 16:54:12 +0200 |
commit | 992b59f70bec5dcc6681db14c3a97036b4961403 (patch) | |
tree | f6b4acf1662e16a82419d2771415aacfd0808cdf /apps/files/ajax/rawlist.php | |
parent | 0527fb05ad4106db199bf3937b753563061c39bf (diff) | |
download | nextcloud-server-992b59f70bec5dcc6681db14c3a97036b4961403.tar.gz nextcloud-server-992b59f70bec5dcc6681db14c3a97036b4961403.zip |
Make it possible to pass rawlist.php an JSON array, to filter by more than one mimetype
Diffstat (limited to 'apps/files/ajax/rawlist.php')
-rw-r--r-- | apps/files/ajax/rawlist.php | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/apps/files/ajax/rawlist.php b/apps/files/ajax/rawlist.php index f568afad4da..37fd12f71d0 100644 --- a/apps/files/ajax/rawlist.php +++ b/apps/files/ajax/rawlist.php @@ -12,21 +12,33 @@ OCP\JSON::checkLoggedIn(); // Load the files $dir = isset( $_GET['dir'] ) ? $_GET['dir'] : ''; $mimetype = isset($_GET['mimetype']) ? $_GET['mimetype'] : ''; +$mimetypeList = isset($_GET['mimetype_list']) ? json_decode($_GET['mimetype_list'], true) : ''; // make filelist $files = array(); // If a type other than directory is requested first load them. -if($mimetype && strpos($mimetype, 'httpd/unix-directory') === false) { +if( ($mimetype || $mimetypeList) && strpos($mimetype, 'httpd/unix-directory') === false) { foreach( \OC\Files\Filesystem::getDirectoryContent( $dir, 'httpd/unix-directory' ) as $i ) { $i["date"] = OCP\Util::formatDate($i["mtime"] ); $i['mimetype_icon'] = $i['type'] == 'dir' ? \mimetype_icon('dir'): \mimetype_icon($i['mimetype']); $files[] = $i; } } -foreach( \OC\Files\Filesystem::getDirectoryContent( $dir, $mimetype ) as $i ) { - $i["date"] = OCP\Util::formatDate($i["mtime"] ); - $i['mimetype_icon'] = $i['type'] == 'dir' ? \mimetype_icon('dir'): \mimetype_icon($i['mimetype']); - $files[] = $i; + +if (is_array($mimetypeList)) { + foreach ($mimetypeList as $mimetype) { + foreach( \OC\Files\Filesystem::getDirectoryContent( $dir, $mimetype ) as $i ) { + $i["date"] = OCP\Util::formatDate($i["mtime"]); + $i['mimetype_icon'] = $i['type'] == 'dir' ? \mimetype_icon('dir'): \mimetype_icon($i['mimetype']); + $files[] = $i; + } + } +} else { + foreach( \OC\Files\Filesystem::getDirectoryContent( $dir, $mimetype ) as $i ) { + $i["date"] = OCP\Util::formatDate($i["mtime"] ); + $i['mimetype_icon'] = $i['type'] == 'dir' ? \mimetype_icon('dir'): \mimetype_icon($i['mimetype']); + $files[] = $i; + } } OCP\JSON::success(array('data' => $files)); |