Blame view

sources/apps/files/ajax/list.php 1.25 KB
03e52840d   Kload   Init
1
2
3
4
5
6
7
8
9
10
11
12
  <?php
  
  // only need filesystem apps
  $RUNTIME_APPTYPES=array('filesystem');
  
  // Init owncloud
  
  
  OCP\JSON::checkLoggedIn();
  
  // Load the files
  $dir = isset( $_GET['dir'] ) ? $_GET['dir'] : '';
31b7f2792   Kload   Upgrade to ownclo...
13
14
15
16
17
18
19
  $dir = \OC\Files\Filesystem::normalizePath($dir);
  if (!\OC\Files\Filesystem::is_dir($dir . '/')) {
  	header("HTTP/1.0 404 Not Found");
  	exit();
  }
  
  $doBreadcrumb = isset($_GET['breadcrumb']);
03e52840d   Kload   Init
20
  $data = array();
31b7f2792   Kload   Upgrade to ownclo...
21
22
23
  $baseUrl = OCP\Util::linkTo('files', 'index.php') . '?dir=';
  
  $permissions = \OCA\Files\Helper::getDirPermissions($dir);
03e52840d   Kload   Init
24
25
26
  
  // Make breadcrumb
  if($doBreadcrumb) {
31b7f2792   Kload   Upgrade to ownclo...
27
28
29
30
31
  	$breadcrumb = \OCA\Files\Helper::makeBreadcrumb($dir);
  
  	$breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', '');
  	$breadcrumbNav->assign('breadcrumb', $breadcrumb, false);
  	$breadcrumbNav->assign('baseURL', $baseUrl);
03e52840d   Kload   Init
32
33
34
35
36
  
  	$data['breadcrumb'] = $breadcrumbNav->fetchPage();
  }
  
  // make filelist
31b7f2792   Kload   Upgrade to ownclo...
37
38
39
40
41
42
43
44
45
  $files = \OCA\Files\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;
03e52840d   Kload   Init
46
47
  
  OCP\JSON::success(array('data' => $data));