diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2013-09-16 10:40:06 +0200 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2013-09-16 10:40:06 +0200 |
commit | 534d93d2d3d549039db2661cdc4b9e939a0abe0d (patch) | |
tree | 7868026ba14b6558c8e50b601a9a5fa85fdc585b /apps/files/index.php | |
parent | f8563ec5831713b341db1b2cd480328912818607 (diff) | |
parent | 46f59b165e5bd1908509e8a62b67bf983cfd6224 (diff) | |
download | nextcloud-server-534d93d2d3d549039db2661cdc4b9e939a0abe0d.tar.gz nextcloud-server-534d93d2d3d549039db2661cdc4b9e939a0abe0d.zip |
Merge branch 'master' into sharing_mail_notification_master
Conflicts:
apps/files/index.php
Diffstat (limited to 'apps/files/index.php')
-rw-r--r-- | apps/files/index.php | 78 |
1 files changed, 30 insertions, 48 deletions
diff --git a/apps/files/index.php b/apps/files/index.php index 28ec1681fc6..d9377550eb2 100644 --- a/apps/files/index.php +++ b/apps/files/index.php @@ -41,79 +41,58 @@ if (!\OC\Files\Filesystem::is_dir($dir . '/')) { 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']); +$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', 'index.php') . '#?dir=' . \OCP\Util::encodePath($dir)); + exit(); } +$ajaxLoad = false; $files = array(); $user = OC_User::getUser(); if (\OC\Files\Cache\Upgrade::needUpgrade($user)) { //dont load anything if we need to upgrade the cache - $content = array(); $needUpgrade = true; $freeSpace = 0; } else { - $content = \OC\Files\Filesystem::getDirectoryContent($dir); + if ($isIE8){ + // after the redirect above, the URL will have a format + // like "files#?dir=path" which means that no path was given + // (dir is not set). In that specific case, we don't return any + // files because the client will take care of switching the dir + // to the one from the hash, then ajax-load the initial file list + $files = array(); + $ajaxLoad = true; + } + else{ + $files = \OCA\files\lib\Helper::getFiles($dir); + } $freeSpace = \OC\Files\Filesystem::free_space($dir); $needUpgrade = false; } -foreach ($content as $i) { - $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['directory'] = $dir; - $i['isPreviewAvailable'] = \OCP\Preview::isMimeSupported($i['mimetype']); - $files[] = $i; -} - -usort($files, "fileCmp"); // Make breadcrumb -$breadcrumb = array(); -$pathtohere = ''; -foreach (explode('/', $dir) as $i) { - if ($i != '') { - $pathtohere .= '/' . $i; - $breadcrumb[] = array('dir' => $pathtohere, 'name' => $i); - } -} +$breadcrumb = \OCA\files\lib\Helper::makeBreadcrumb($dir); // make breadcrumb und filelist markup $list = new OCP\Template('files', 'part.list', ''); $list->assign('files', $files); $list->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir='); $list->assign('downloadURL', OCP\Util::linkToRoute('download', array('file' => '/'))); -$list->assign('disableSharing', false); $list->assign('isPublic', false); $breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', ''); $breadcrumbNav->assign('breadcrumb', $breadcrumb); $breadcrumbNav->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir='); -$permissions = OCP\PERMISSION_READ; -if (\OC\Files\Filesystem::isCreatable($dir . '/')) { - $permissions |= OCP\PERMISSION_CREATE; -} -if (\OC\Files\Filesystem::isUpdatable($dir . '/')) { - $permissions |= OCP\PERMISSION_UPDATE; -} -if (\OC\Files\Filesystem::isDeletable($dir . '/')) { - $permissions |= OCP\PERMISSION_DELETE; -} -if (\OC\Files\Filesystem::isSharable($dir . '/')) { - $permissions |= OCP\PERMISSION_SHARE; -} +$permissions = \OCA\files\lib\Helper::getDirPermissions($dir); if ($needUpgrade) { OCP\Util::addscript('files', 'upgrade'); @@ -154,5 +133,8 @@ if ($needUpgrade) { $tmpl->assign('publicUploadEnabled', $publicUploadEnabled); $tmpl->assign("encryptedFiles", \OCP\Util::encryptedFiles()); $tmpl->assign("mailNotificationEnabled", \OC_Appconfig::getValue('core', 'shareapi_allow_mail_notification', 'yes')); + $tmpl->assign('disableSharing', false); + $tmpl->assign('ajaxLoad', $ajaxLoad); + $tmpl->printPage(); } |