]> source.dussan.org Git - nextcloud-server.git/commitdiff
Make it possible to pass rawlist.php an JSON array, to filter by more than one mimetype
authorkondou <kondou@ts.unde.re>
Thu, 5 Sep 2013 14:54:12 +0000 (16:54 +0200)
committerkondou <kondou@ts.unde.re>
Thu, 5 Sep 2013 14:54:12 +0000 (16:54 +0200)
apps/files/ajax/rawlist.php
core/js/oc-dialogs.js

index f568afad4da44f87f4d74cd301cee93202c8aa9b..37fd12f71d0e093e63b04cf0762a2ad97b34e465 100644 (file)
@@ -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));
index f184a1022bcf870132d793d94f21077169766bb4..f4c339702e1198040beff92920d934f7899fb210 100644 (file)
@@ -244,10 +244,17 @@ var OCdialogs = {
                return defer.promise();
        },
        _getFileList: function(dir, mimeType) {
-               return $.getJSON(
-                       OC.filePath('files', 'ajax', 'rawlist.php'),
-                       {dir: dir, mimetype: mimeType}
-               );
+               if (typeof(mimeType) === "object") {
+                       return $.getJSON(
+                               OC.filePath('files', 'ajax', 'rawlist.php'),
+                               {dir: dir, "mimetype_list": JSON.stringify(mimeType)}
+                       );
+               } else {
+                       return $.getJSON(
+                               OC.filePath('files', 'ajax', 'rawlist.php'),
+                               {dir: dir, mimetype: mimeType}
+                       );
+               }
        },
        _determineValue: function(element) {
                if ( $(element).attr('type') === 'checkbox' ) {