aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files/ajax/rawlist.php56
-rw-r--r--core/js/oc-dialogs.js9
2 files changed, 53 insertions, 12 deletions
diff --git a/apps/files/ajax/rawlist.php b/apps/files/ajax/rawlist.php
index f568afad4da..e9ae1f5305f 100644
--- a/apps/files/ajax/rawlist.php
+++ b/apps/files/ajax/rawlist.php
@@ -11,22 +11,56 @@ OCP\JSON::checkLoggedIn();
// Load the files
$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : '';
-$mimetype = isset($_GET['mimetype']) ? $_GET['mimetype'] : '';
+$mimetypes = isset($_GET['mimetypes']) ? json_decode($_GET['mimetypes'], true) : '';
+
+// Clean up duplicates from array and deal with non-array requests
+if (is_array($mimetypes)) {
+ $mimetypes = array_unique($mimetypes);
+} elseif (is_null($mimetypes)) {
+ $mimetypes = array($_GET['mimetypes']);
+}
// make filelist
$files = array();
// If a type other than directory is requested first load them.
-if($mimetype && 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;
+if($mimetypes && !in_array('httpd/unix-directory', $mimetypes)) {
+ foreach( \OC\Files\Filesystem::getDirectoryContent( $dir, 'httpd/unix-directory' ) as $file ) {
+ $file["date"] = OCP\Util::formatDate($file["mtime"]);
+ $file['mimetype_icon'] = \mimetype_icon('dir');
+ $files[] = $file;
}
}
-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($mimetypes) && count($mimetypes)) {
+ foreach ($mimetypes as $mimetype) {
+ foreach( \OC\Files\Filesystem::getDirectoryContent( $dir, $mimetype ) as $file ) {
+ $file["date"] = OCP\Util::formatDate($file["mtime"]);
+ if ($file['type'] === "dir") {
+ $file['mimetype_icon'] = \mimetype_icon('dir');
+ } else {
+ $file['mimetype_icon'] = \mimetype_icon($file['mimetype']);
+ }
+ $files[] = $file;
+ }
+ }
+} else {
+ foreach( \OC\Files\Filesystem::getDirectoryContent( $dir ) as $file ) {
+ $file["date"] = OCP\Util::formatDate($file["mtime"]);
+ if ($file['type'] === "dir") {
+ $file['mimetype_icon'] = \mimetype_icon('dir');
+ } else {
+ $file['mimetype_icon'] = \mimetype_icon($file['mimetype']);
+ }
+ $files[] = $file;
+ }
}
-OCP\JSON::success(array('data' => $files));
+// Sort by name
+usort($files, function ($a, $b) {
+ if ($a['name'] === $b['name']) {
+ return 0;
+ }
+ return ($a['name'] < $b['name']) ? -1 : 1;
+});
+
+OC_JSON::success(array('data' => $files));
diff --git a/core/js/oc-dialogs.js b/core/js/oc-dialogs.js
index f184a1022bc..61b58d00fa6 100644
--- a/core/js/oc-dialogs.js
+++ b/core/js/oc-dialogs.js
@@ -244,9 +244,16 @@ var OCdialogs = {
return defer.promise();
},
_getFileList: function(dir, mimeType) {
+ if (typeof(mimeType) === "string") {
+ mimeType = [mimeType];
+ }
+
return $.getJSON(
OC.filePath('files', 'ajax', 'rawlist.php'),
- {dir: dir, mimetype: mimeType}
+ {
+ dir: dir,
+ mimetypes: JSON.stringify(mimeType)
+ }
);
},
_determineValue: function(element) {