list.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. // only need filesystem apps
  3. $RUNTIME_APPTYPES=array('filesystem');
  4. // Init owncloud
  5. OCP\JSON::checkLoggedIn();
  6. // Load the files
  7. $dir = isset( $_GET['dir'] ) ? $_GET['dir'] : '';
  8. if (!\OC\Files\Filesystem::is_dir($dir . '/')) {
  9. header("HTTP/1.0 404 Not Found");
  10. exit();
  11. }
  12. $doBreadcrumb = isset($_GET['breadcrumb']);
  13. $data = array();
  14. $baseUrl = OCP\Util::linkTo('files', 'index.php') . '?dir=';
  15. $permissions = \OCA\Files\Helper::getDirPermissions($dir);
  16. // Make breadcrumb
  17. if($doBreadcrumb) {
  18. $breadcrumb = \OCA\Files\Helper::makeBreadcrumb($dir);
  19. $breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', '');
  20. $breadcrumbNav->assign('breadcrumb', $breadcrumb, false);
  21. $breadcrumbNav->assign('baseURL', $baseUrl);
  22. $data['breadcrumb'] = $breadcrumbNav->fetchPage();
  23. }
  24. // make filelist
  25. $files = \OCA\Files\Helper::getFiles($dir);
  26. $list = new OCP\Template("files", "part.list", "");
  27. $list->assign('files', $files, false);
  28. $list->assign('baseURL', $baseUrl, false);
  29. $list->assign('downloadURL', OCP\Util::linkToRoute('download', array('file' => '/')));
  30. $list->assign('isPublic', false);
  31. $data['files'] = $list->fetchPage();
  32. $data['permissions'] = $permissions;
  33. OCP\JSON::success(array('data' => $data));