index.php 2.5 KB

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