diff options
author | Jörn Friedrich Dreyer <jfd@butonic.de> | 2013-09-17 19:10:46 +0200 |
---|---|---|
committer | Jörn Friedrich Dreyer <jfd@butonic.de> | 2013-09-17 19:10:46 +0200 |
commit | b59ce403d8ea80ba7aac5683f667853218757502 (patch) | |
tree | 2e657117cc3e9fd7a8dfe032945cb1e9a63edc46 /apps/files/ajax | |
parent | 2c9b3d32efa466b655a7f24c5022a42045ef482f (diff) | |
parent | 9d18e16c77e8c2690dd23dd19ca1f8e1968161c8 (diff) | |
download | nextcloud-server-b59ce403d8ea80ba7aac5683f667853218757502.tar.gz nextcloud-server-b59ce403d8ea80ba7aac5683f667853218757502.zip |
Merge branch 'master' into fix_3728_with_file_exists_dialog
Conflicts:
apps/files/css/files.css
apps/files/js/file-upload.js
apps/files/js/filelist.js
apps/files/js/files.js
apps/files_sharing/js/public.js
core/js/jquery.ocdialog.js
core/js/oc-dialogs.js
Diffstat (limited to 'apps/files/ajax')
-rw-r--r-- | apps/files/ajax/list.php | 43 | ||||
-rw-r--r-- | apps/files/ajax/rawlist.php | 54 |
2 files changed, 66 insertions, 31 deletions
diff --git a/apps/files/ajax/list.php b/apps/files/ajax/list.php index c50e96b2429..f1b713b5534 100644 --- a/apps/files/ajax/list.php +++ b/apps/files/ajax/list.php @@ -10,35 +10,38 @@ OCP\JSON::checkLoggedIn(); // Load the files $dir = isset( $_GET['dir'] ) ? $_GET['dir'] : ''; + +if (!\OC\Files\Filesystem::is_dir($dir . '/')) { + header("HTTP/1.0 404 Not Found"); + exit(); +} + $doBreadcrumb = isset($_GET['breadcrumb']); $data = array(); +$baseUrl = OCP\Util::linkTo('files', 'index.php') . '?dir='; + +$permissions = \OCA\files\lib\Helper::getDirPermissions($dir); // Make breadcrumb if($doBreadcrumb) { - $breadcrumb = array(); - $pathtohere = "/"; - foreach( explode( "/", $dir ) as $i ) { - if( $i != "" ) { - $pathtohere .= "$i/"; - $breadcrumb[] = array( "dir" => $pathtohere, "name" => $i ); - } - } - - $breadcrumbNav = new OCP\Template( "files", "part.breadcrumb", "" ); - $breadcrumbNav->assign( "breadcrumb", $breadcrumb, false ); + $breadcrumb = \OCA\files\lib\Helper::makeBreadcrumb($dir); + + $breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', ''); + $breadcrumbNav->assign('breadcrumb', $breadcrumb, false); + $breadcrumbNav->assign('baseURL', $baseUrl); $data['breadcrumb'] = $breadcrumbNav->fetchPage(); } // make filelist -$files = array(); -foreach( \OC\Files\Filesystem::getDirectoryContent( $dir ) as $i ) { - $i["date"] = OCP\Util::formatDate($i["mtime"] ); - $files[] = $i; -} - -$list = new OCP\Template( "files", "part.list", "" ); -$list->assign( "files", $files, false ); -$data = array('files' => $list->fetchPage()); +$files = \OCA\files\lib\Helper::getFiles($dir); + +$list = new OCP\Template("files", "part.list", ""); +$list->assign('files', $files, false); +$list->assign('baseURL', $baseUrl, false); +$list->assign('downloadURL', OCP\Util::linkToRoute('download', array('file' => '/'))); +$list->assign('isPublic', false); +$data['files'] = $list->fetchPage(); +$data['permissions'] = $permissions; OCP\JSON::success(array('data' => $data)); diff --git a/apps/files/ajax/rawlist.php b/apps/files/ajax/rawlist.php index f568afad4da..9ccd4cc299a 100644 --- a/apps/files/ajax/rawlist.php +++ b/apps/files/ajax/rawlist.php @@ -11,22 +11,54 @@ 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['directory'] = $dir; + $file['isPreviewAvailable'] = \OCP\Preview::isMimeSupported($file['mimetype']); + $file["date"] = OCP\Util::formatDate($file["mtime"]); + $file['mimetype_icon'] = \OCA\files\lib\Helper::determineIcon($file); + $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['directory'] = $dir; + $file['isPreviewAvailable'] = \OCP\Preview::isMimeSupported($file['mimetype']); + $file["date"] = OCP\Util::formatDate($file["mtime"]); + $file['mimetype_icon'] = \OCA\files\lib\Helper::determineIcon($file); + $files[] = $file; + } + } +} else { + foreach( \OC\Files\Filesystem::getDirectoryContent( $dir ) as $file ) { + $file['directory'] = $dir; + $file['isPreviewAvailable'] = \OCP\Preview::isMimeSupported($file['mimetype']); + $file["date"] = OCP\Util::formatDate($file["mtime"]); + $file['mimetype_icon'] = \OCA\files\lib\Helper::determineIcon($file); + $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)); |