aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/public.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_sharing/public.php')
-rw-r--r--apps/files_sharing/public.php90
1 files changed, 6 insertions, 84 deletions
diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php
index fe61dd4d5a0..ba2494a7b1a 100644
--- a/apps/files_sharing/public.php
+++ b/apps/files_sharing/public.php
@@ -11,31 +11,6 @@ if ($appConfig->getValue('core', 'shareapi_allow_links', 'yes') !== 'yes') {
exit();
}
-function fileCmp($a, $b) {
- if ($a['type'] == 'dir' and $b['type'] != 'dir') {
- return -1;
- } elseif ($a['type'] != 'dir' and $b['type'] == 'dir') {
- return 1;
- } else {
- return strnatcasecmp($a['name'], $b['name']);
- }
-}
-
-function determineIcon($file, $sharingRoot, $sharingToken) {
- // for folders we simply reuse the files logic
- if($file['type'] == 'dir') {
- return \OCA\Files\Helper::determineIcon($file);
- }
-
- $relativePath = substr($file['path'], 6);
- $relativePath = substr($relativePath, strlen($sharingRoot));
- if($file['isPreviewAvailable']) {
- return OCP\publicPreview_icon($relativePath, $sharingToken) . '&c=' . $file['etag'];
- }
- $icon = OCP\mimetype_icon($file['mimetype']);
- return substr($icon, 0, -3) . 'svg';
-}
-
if (isset($_GET['t'])) {
$token = $_GET['t'];
$linkItem = OCP\Share::getShareByToken($token, false);
@@ -153,13 +128,10 @@ if (isset($path)) {
$tmpl->assign('mimetype', \OC\Files\Filesystem::getMimeType($path));
$tmpl->assign('dirToken', $linkItem['token']);
$tmpl->assign('sharingToken', $token);
- $allowPublicUploadEnabled = (bool) ($linkItem['permissions'] & OCP\PERMISSION_CREATE);
- if ($appConfig->getValue('core', 'shareapi_allow_public_upload', 'yes') === 'no') {
- $allowPublicUploadEnabled = false;
- }
- if ($linkItem['item_type'] !== 'folder') {
- $allowPublicUploadEnabled = false;
- }
+ $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
+ $tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize));
+ $tmpl->assign('freeSpace', $freeSpace);
+ $tmpl->assign('uploadLimit', $uploadLimit); // PHP upload limit
$urlLinkIdentifiers= (isset($token)?'&t='.$token:'')
.(isset($_GET['dir'])?'&dir='.$_GET['dir']:'')
@@ -170,64 +142,18 @@ if (isset($path)) {
OCP\Util::addStyle('files', 'files');
OCP\Util::addStyle('files', 'upload');
+ OCP\Util::addScript('files', 'breadcrumb');
OCP\Util::addScript('files', 'files');
OCP\Util::addScript('files', 'filelist');
OCP\Util::addscript('files', 'keyboardshortcuts');
$files = array();
$rootLength = strlen($basePath) + 1;
- $totalSize = 0;
- foreach (\OC\Files\Filesystem::getDirectoryContent($path) as $i) {
- $totalSize += $i['size'];
- $i['date'] = OCP\Util::formatDate($i['mtime']);
- if ($i['type'] == 'file') {
- $fileinfo = pathinfo($i['name']);
- $i['basename'] = $fileinfo['filename'];
- if (!empty($fileinfo['extension'])) {
- $i['extension'] = '.' . $fileinfo['extension'];
- } else {
- $i['extension'] = '';
- }
- }
- $i['isPreviewAvailable'] = \OC::$server->getPreviewManager()->isMimeSupported($i['mimetype']);
- $i['directory'] = $getPath;
- $i['permissions'] = OCP\PERMISSION_READ;
- $i['icon'] = determineIcon($i, $basePath, $token);
- $files[] = $i;
- }
- usort($files, "fileCmp");
-
- // Make breadcrumb
- $breadcrumb = array();
- $pathtohere = '';
- foreach (explode('/', $getPath) as $i) {
- if ($i != '') {
- $pathtohere .= '/' . $i;
- $breadcrumb[] = array('dir' => $pathtohere, 'name' => $i);
- }
- }
- $list = new OCP\Template('files', 'part.list', '');
- $list->assign('files', $files);
- $list->assign('baseURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&path=');
- $list->assign('downloadURL',
- OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&download&path=');
- $list->assign('isPublic', true);
- $list->assign('sharingtoken', $token);
- $list->assign('sharingroot', $basePath);
- $breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', '');
- $breadcrumbNav->assign('breadcrumb', $breadcrumb);
- $breadcrumbNav->assign('rootBreadCrumb', $rootName);
- $breadcrumbNav->assign('baseURL', OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&path=');
$maxUploadFilesize=OCP\Util::maxUploadFilesize($path);
- $fileHeader = (!isset($files) or count($files) > 0);
- $emptyContent = ($allowPublicUploadEnabled and !$fileHeader);
$freeSpace=OCP\Util::freeSpace($path);
$uploadLimit=OCP\Util::uploadLimit();
$folder = new OCP\Template('files', 'index', '');
- $folder->assign('fileList', $list->fetchPage());
- $folder->assign('breadcrumb', $breadcrumbNav->fetchPage());
$folder->assign('dir', $getPath);
- $folder->assign('isCreatable', $allowPublicUploadEnabled);
$folder->assign('dirToken', $linkItem['token']);
$folder->assign('permissions', OCP\PERMISSION_READ);
$folder->assign('isPublic',true);
@@ -239,15 +165,11 @@ if (isset($path)) {
$folder->assign('uploadLimit', $uploadLimit); // PHP upload limit
$folder->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true)));
$folder->assign('usedSpacePercent', 0);
- $folder->assign('fileHeader', $fileHeader);
$folder->assign('disableSharing', true);
$folder->assign('trash', false);
- $folder->assign('emptyContent', $emptyContent);
- $folder->assign('ajaxLoad', false);
$tmpl->assign('folder', $folder->fetchPage());
$maxInputFileSize = OCP\Config::getSystemValue('maxZipInputSize', OCP\Util::computerFileSize('800 MB'));
- $allowZip = OCP\Config::getSystemValue('allowZipDownload', true)
- && ( $maxInputFileSize === 0 || $totalSize <= $maxInputFileSize);
+ $allowZip = OCP\Config::getSystemValue('allowZipDownload', true);
$tmpl->assign('allowZipDownload', intval($allowZip));
$tmpl->assign('downloadURL',
OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&download&path=' . urlencode($getPath));