nextcloud/apps/files_trashbin/index.php

82 lines
2.4 KiB
PHP
Raw Normal View History

2013-01-18 16:11:29 +04:00
<?php
2013-02-22 20:21:57 +04:00
// Check if we are a user
2013-01-18 16:11:29 +04:00
OCP\User::checkLoggedIn();
OCP\App::setActiveNavigationEntry('files_index');
2013-01-18 16:11:29 +04:00
OCP\Util::addScript('files_trashbin', 'trash');
2013-01-23 14:30:42 +04:00
OCP\Util::addScript('files_trashbin', 'disableDefaultActions');
2013-01-18 16:11:29 +04:00
OCP\Util::addScript('files', 'fileactions');
$tmpl = new OCP\Template('files_trashbin', 'index', 'user');
OCP\Util::addStyle('files', 'files');
OCP\Util::addScript('files', 'filelist');
// filelist overrides
OCP\Util::addScript('files_trashbin', 'filelist');
OCP\Util::addscript('files', 'files');
2013-01-18 16:11:29 +04:00
2013-01-21 16:07:43 +04:00
$dir = isset($_GET['dir']) ? stripslashes($_GET['dir']) : '';
$isIE8 = false;
preg_match('/MSIE (.*?);/', $_SERVER['HTTP_USER_AGENT'], $matches);
if (count($matches) > 0 && $matches[1] <= 8){
$isIE8 = true;
}
// if IE8 and "?dir=path" was specified, reformat the URL to use a hash like "#?dir=path"
if ($isIE8 && isset($_GET['dir'])){
if ($dir === ''){
$dir = '/';
}
header('Location: ' . OCP\Util::linkTo('files_trashbin', 'index.php') . '#?dir=' . \OCP\Util::encodePath($dir));
exit();
}
$ajaxLoad = false;
if (!$isIE8){
$files = \OCA\files_trashbin\lib\Helper::getTrashFiles($dir);
}
else{
$files = array();
$ajaxLoad = true;
}
2013-01-18 16:11:29 +04:00
// Redirect if directory does not exist
if ($files === null){
header('Location: ' . OCP\Util::linkTo('files_trashbin', 'index.php'));
exit();
2013-01-18 16:11:29 +04:00
}
$dirlisting = false;
if ($dir && $dir !== '/') {
$dirlisting = true;
}
$breadcrumb = \OCA\files_trashbin\lib\Helper::makeBreadcrumb($dir);
2013-01-21 16:07:43 +04:00
$breadcrumbNav = new OCP\Template('files_trashbin', 'part.breadcrumb', '');
2013-02-28 00:46:37 +04:00
$breadcrumbNav->assign('breadcrumb', $breadcrumb);
$breadcrumbNav->assign('baseURL', OCP\Util::linkTo('files_trashbin', 'index.php') . '?dir=');
2013-03-07 16:51:18 +04:00
$breadcrumbNav->assign('home', OCP\Util::linkTo('files', 'index.php'));
2013-01-18 16:11:29 +04:00
$list = new OCP\Template('files_trashbin', 'part.list', '');
2013-02-28 00:46:37 +04:00
$list->assign('files', $files);
2013-07-04 20:41:42 +04:00
$encodedDir = \OCP\Util::encodePath($dir);
$list->assign('baseURL', OCP\Util::linkTo('files_trashbin', 'index.php'). '?dir='.$encodedDir);
$list->assign('downloadURL', OCP\Util::linkTo('files_trashbin', 'download.php') . '?file='.$encodedDir);
2013-03-07 17:54:59 +04:00
$list->assign('dirlisting', $dirlisting);
2013-01-18 16:11:29 +04:00
$list->assign('disableDownloadActions', true);
2013-07-04 20:41:42 +04:00
$tmpl->assign('dirlisting', $dirlisting);
2013-02-28 00:46:37 +04:00
$tmpl->assign('breadcrumb', $breadcrumbNav->fetchPage());
$tmpl->assign('fileList', $list->fetchPage());
$tmpl->assign('files', $files);
$tmpl->assign('dir', $dir);
$tmpl->assign('disableSharing', true);
$tmpl->assign('ajaxLoad', true);
2013-01-18 16:11:29 +04:00
$tmpl->printPage();