list.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. $doBreadcrumb = isset( $_GET['breadcrumb'] ) ? true : false;
  9. $data = array();
  10. // Make breadcrumb
  11. if($doBreadcrumb) {
  12. $breadcrumb = \OCA\Files_Trashbin\Helper::makeBreadcrumb($dir);
  13. $breadcrumbNav = new OCP\Template('files_trashbin', 'part.breadcrumb', '');
  14. $breadcrumbNav->assign('breadcrumb', $breadcrumb, false);
  15. $breadcrumbNav->assign('baseURL', OCP\Util::linkTo('files_trashbin', 'index.php') . '?dir=');
  16. $breadcrumbNav->assign('home', OCP\Util::linkTo('files', 'index.php'));
  17. $data['breadcrumb'] = $breadcrumbNav->fetchPage();
  18. }
  19. // make filelist
  20. $files = \OCA\Files_Trashbin\Helper::getTrashFiles($dir);
  21. if ($files === null){
  22. header("HTTP/1.0 404 Not Found");
  23. exit();
  24. }
  25. $dirlisting = false;
  26. if ($dir && $dir !== '/') {
  27. $dirlisting = true;
  28. }
  29. $encodedDir = \OCP\Util::encodePath($dir);
  30. $list = new OCP\Template('files_trashbin', 'part.list', '');
  31. $list->assign('files', $files, false);
  32. $list->assign('baseURL', OCP\Util::linkTo('files_trashbin', 'index.php'). '?dir='.$encodedDir);
  33. $list->assign('downloadURL', OCP\Util::linkToRoute('download', array('file' => '/')));
  34. $list->assign('dirlisting', $dirlisting);
  35. $list->assign('disableDownloadActions', true);
  36. $data['files'] = $list->fetchPage();
  37. OCP\JSON::success(array('data' => $data));