diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-04-14 00:39:12 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-04-14 00:39:12 +0200 |
commit | ffa115b51725c4774b49c2419f88cb91d726386b (patch) | |
tree | 22d35c12ad982b7688a87befd70274121d4db428 /apps | |
parent | e36c0a0c12ca92ec6e23617a93ff57296b3ea223 (diff) | |
parent | 59efcb63a334b70b3f392a4eea18c67e79ac4a21 (diff) | |
download | nextcloud-server-ffa115b51725c4774b49c2419f88cb91d726386b.tar.gz nextcloud-server-ffa115b51725c4774b49c2419f88cb91d726386b.zip |
Merge pull request #15566 from owncloud/fix-filepicker
fix filepicker
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files/ajax/list.php | 26 | ||||
-rw-r--r-- | apps/files/lib/helper.php | 5 |
2 files changed, 27 insertions, 4 deletions
diff --git a/apps/files/ajax/list.php b/apps/files/ajax/list.php index 8daea6ca3fe..19129e9de11 100644 --- a/apps/files/ajax/list.php +++ b/apps/files/ajax/list.php @@ -45,10 +45,32 @@ try { $sortAttribute = isset($_GET['sort']) ? (string)$_GET['sort'] : 'name'; $sortDirection = isset($_GET['sortdirection']) ? ($_GET['sortdirection'] === 'desc') : false; + $mimetypeFilters = isset($_GET['mimetypes']) ? json_decode($_GET['mimetypes']) : ''; - // make filelist + $files = []; + // Clean up duplicates from array + if (is_array($mimetypeFilters) && count($mimetypeFilters)) { + $mimetypeFilters = array_unique($mimetypeFilters); + + if (!in_array('httpd/unix-directory', $mimetypeFilters)) { + // append folder filter to be able to browse folders + $mimetypeFilters[] = 'httpd/unix-directory'; + } + + // create filelist with mimetype filter - as getFiles only supports on + // mimetype filter at once we will filter this folder for each + // mimetypeFilter + foreach ($mimetypeFilters as $mimetypeFilter) { + $files = array_merge($files, \OCA\Files\Helper::getFiles($dir, $sortAttribute, $sortDirection, $mimetypeFilter)); + } + + // sort the files accordingly + $files = \OCA\Files\Helper::sortFiles($files, $sortAttribute, $sortDirection); + } else { + // create file list without mimetype filter + $files = \OCA\Files\Helper::getFiles($dir, $sortAttribute, $sortDirection); + } - $files = \OCA\Files\Helper::getFiles($dir, $sortAttribute, $sortDirection); $files = \OCA\Files\Helper::populateTags($files); $data['directory'] = $dir; $data['files'] = \OCA\Files\Helper::formatFileInfos($files); diff --git a/apps/files/lib/helper.php b/apps/files/lib/helper.php index cc1b2d3cfbe..e966e60d00a 100644 --- a/apps/files/lib/helper.php +++ b/apps/files/lib/helper.php @@ -196,10 +196,11 @@ class Helper { * @param string $dir path to the directory * @param string $sortAttribute attribute to sort on * @param bool $sortDescending true for descending sort, false otherwise + * @param string $mimetypeFilter limit returned content to this mimetype or mimepart * @return \OCP\Files\FileInfo[] files */ - public static function getFiles($dir, $sortAttribute = 'name', $sortDescending = false) { - $content = \OC\Files\Filesystem::getDirectoryContent($dir); + public static function getFiles($dir, $sortAttribute = 'name', $sortDescending = false, $mimetypeFilter = '') { + $content = \OC\Files\Filesystem::getDirectoryContent($dir, $mimetypeFilter); return self::sortFiles($content, $sortAttribute, $sortDescending); } |