index.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. // Check if we are a user
  3. OCP\User::checkLoggedIn();
  4. OCP\App::setActiveNavigationEntry('files_index');
  5. OCP\Util::addScript('files_trashbin', 'disableDefaultActions');
  6. OCP\Util::addScript('files', 'fileactions');
  7. $tmpl = new OCP\Template('files_trashbin', 'index', 'user');
  8. OCP\Util::addStyle('files', 'files');
  9. OCP\Util::addScript('files', 'filelist');
  10. // filelist overrides
  11. OCP\Util::addScript('files_trashbin', 'filelist');
  12. OCP\Util::addscript('files', 'files');
  13. OCP\Util::addScript('files_trashbin', 'trash');
  14. $dir = isset($_GET['dir']) ? stripslashes($_GET['dir']) : '';
  15. $isIE8 = false;
  16. preg_match('/MSIE (.*?);/', $_SERVER['HTTP_USER_AGENT'], $matches);
  17. if (count($matches) > 0 && $matches[1] <= 8){
  18. $isIE8 = true;
  19. }
  20. // if IE8 and "?dir=path" was specified, reformat the URL to use a hash like "#?dir=path"
  21. if ($isIE8 && isset($_GET['dir'])){
  22. if ($dir === ''){
  23. $dir = '/';
  24. }
  25. header('Location: ' . OCP\Util::linkTo('files_trashbin', 'index.php') . '#?dir=' . \OCP\Util::encodePath($dir));
  26. exit();
  27. }
  28. $ajaxLoad = false;
  29. if (!$isIE8){
  30. $files = \OCA\Files_Trashbin\Helper::getTrashFiles($dir);
  31. }
  32. else{
  33. $files = array();
  34. $ajaxLoad = true;
  35. }
  36. // Redirect if directory does not exist
  37. if ($files === null){
  38. header('Location: ' . OCP\Util::linkTo('files_trashbin', 'index.php'));
  39. exit();
  40. }
  41. $dirlisting = false;
  42. if ($dir && $dir !== '/') {
  43. $dirlisting = true;
  44. }
  45. $breadcrumb = \OCA\Files_Trashbin\Helper::makeBreadcrumb($dir);
  46. $breadcrumbNav = new OCP\Template('files_trashbin', 'part.breadcrumb', '');
  47. $breadcrumbNav->assign('breadcrumb', $breadcrumb);
  48. $breadcrumbNav->assign('baseURL', OCP\Util::linkTo('files_trashbin', 'index.php') . '?dir=');
  49. $breadcrumbNav->assign('home', OCP\Util::linkTo('files', 'index.php'));
  50. $list = new OCP\Template('files_trashbin', 'part.list', '');
  51. $list->assign('files', $files);
  52. $encodedDir = \OCP\Util::encodePath($dir);
  53. $list->assign('baseURL', OCP\Util::linkTo('files_trashbin', 'index.php'). '?dir='.$encodedDir);
  54. $list->assign('downloadURL', OCP\Util::linkTo('files_trashbin', 'download.php') . '?file='.$encodedDir);
  55. $list->assign('dirlisting', $dirlisting);
  56. $list->assign('disableDownloadActions', true);
  57. $tmpl->assign('dirlisting', $dirlisting);
  58. $tmpl->assign('breadcrumb', $breadcrumbNav->fetchPage());
  59. $tmpl->assign('fileList', $list->fetchPage());
  60. $tmpl->assign('files', $files);
  61. $tmpl->assign('dir', $dir);
  62. $tmpl->assign('disableSharing', true);
  63. $tmpl->assign('ajaxLoad', true);
  64. $tmpl->printPage();