aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/ajax/list.php
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2013-08-17 13:07:18 +0200
committerVincent Petry <pvince81@owncloud.com>2013-09-13 19:59:14 +0200
commit1304b511e9533dee4cf1125e625568c8a74719a1 (patch)
tree2430ff5abeeb0f378547e49cb4b311b41c035421 /apps/files/ajax/list.php
parentc149b57d3b4020c65d33966d5dc8395b8b821fc9 (diff)
downloadnextcloud-server-1304b511e9533dee4cf1125e625568c8a74719a1.tar.gz
nextcloud-server-1304b511e9533dee4cf1125e625568c8a74719a1.zip
Ajax calls for "files" and "files_trashbin" apps
Frontend: - The files app list now uses ajax calls to refresh the list. - Added support the browser back button (history API). - Added mask + spinner while loading file list Backend: - Added utility function in core JS for parsing query strings. - Moved file list + breadcrumb template data code to helper functions - Fixed some file paths in trashbin app to be similar to the files app
Diffstat (limited to 'apps/files/ajax/list.php')
-rw-r--r--apps/files/ajax/list.php38
1 files changed, 18 insertions, 20 deletions
diff --git a/apps/files/ajax/list.php b/apps/files/ajax/list.php
index 14ed43cbb3a..035ffc0e393 100644
--- a/apps/files/ajax/list.php
+++ b/apps/files/ajax/list.php
@@ -10,36 +10,34 @@ 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=';
// 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"] );
- $i['icon'] = \OCA\files\lib\Helper::determineIcon($i);
- $files[] = $i;
-}
+$files = \OCA\files\lib\Helper::getFiles($dir);
-$list = new OCP\Template( "files", "part.list", "" );
-$list->assign( "files", $files, false );
-$data = array('files' => $list->fetchPage());
+$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' => '/')));
+$data['files'] = $list->fetchPage();
OCP\JSON::success(array('data' => $data));