]> source.dussan.org Git - nextcloud-server.git/commitdiff
Only use mimetype_list and clean up a bit
authorkondou <kondou@ts.unde.re>
Thu, 5 Sep 2013 16:40:55 +0000 (18:40 +0200)
committerkondou <kondou@ts.unde.re>
Thu, 5 Sep 2013 16:40:55 +0000 (18:40 +0200)
apps/files/ajax/rawlist.php
core/js/oc-dialogs.js

index 37fd12f71d0e093e63b04cf0762a2ad97b34e465..2fd6f67d308ca56be3405ee83b03d19460ce07e6 100644 (file)
@@ -11,22 +11,23 @@ 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) : '';
+$mimetypes = isset($_GET['mimetypes']) ? array_unique(json_decode($_GET['mimetypes'], true)) : '';
 
 // make filelist
 $files = array();
 // If a type other than directory is requested first load them.
-if( ($mimetype || $mimetypeList) && strpos($mimetype, 'httpd/unix-directory') === false) {
+if($mimetypes && !in_array('httpd/unix-directory', $mimetypes)) {
        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']);
+               $i['mimetype_icon'] = ($i['type'] == 'dir')
+                       ? \mimetype_icon('dir')
+                       : \mimetype_icon($i['mimetype']);
                $files[] = $i;
        }
 }
 
-if (is_array($mimetypeList)) {
-       foreach ($mimetypeList as $mimetype) {
+if (is_array($mimetypes) && count($mimetypes)) {
+       foreach ($mimetypes 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']);
@@ -34,11 +35,11 @@ if (is_array($mimetypeList)) {
                }
        }
 } else {
-       foreach( \OC\Files\Filesystem::getDirectoryContent( $dir, $mimetype ) as $i ) {
-               $i["date"] = OCP\Util::formatDate($i["mtime"] );
+       foreach( \OC\Files\Filesystem::getDirectoryContent( $dir ) 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));
+OC_JSON::success(array('data' => $files));
index f4c339702e1198040beff92920d934f7899fb210..ed4d7c678e1795060a57eedc43f42870a99ef850 100644 (file)
@@ -244,17 +244,19 @@ var OCdialogs = {
                return defer.promise();
        },
        _getFileList: function(dir, 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}
-                       );
+               if (typeof(mimeType) === "string") {
+                       var tmp = mimeType;
+                       mimeType = new Array();
+                       mimeType[0] = tmp;
                }
+
+               return $.getJSON(
+                       OC.filePath('files', 'ajax', 'rawlist.php'),
+                       {
+                               dir: dir,
+                               mimetypes: JSON.stringify(mimeType)
+                       }
+               );
        },
        _determineValue: function(element) {
                if ( $(element).attr('type') === 'checkbox' ) {