diff options
author | Daniel Rudolf <github.com@daniel-rudolf.de> | 2021-08-04 18:52:55 +0200 |
---|---|---|
committer | Daniel Rudolf <github.com@daniel-rudolf.de> | 2021-08-04 18:52:55 +0200 |
commit | aa455e71d95c877b0dc758bc5c873d9278e6e112 (patch) | |
tree | 6f1135402c356f68cd940e0b2ca5efd1f8d91a67 /apps/files/lib/Controller/ViewController.php | |
parent | b768cade2b2c6664851de6462a17ef3531305971 (diff) | |
parent | 2a632195365be77889428e85801a00c74ab6a836 (diff) | |
download | nextcloud-server-aa455e71d95c877b0dc758bc5c873d9278e6e112.tar.gz nextcloud-server-aa455e71d95c877b0dc758bc5c873d9278e6e112.zip |
Merge branch 'master' into enhancement/noid/IURLGenerator-linkToDefaultPageUrl
Diffstat (limited to 'apps/files/lib/Controller/ViewController.php')
-rw-r--r-- | apps/files/lib/Controller/ViewController.php | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index 80e3b06616c..64ebbea0cfb 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -165,7 +165,7 @@ class ViewController extends Controller { public function showFile(string $fileid = null): Response { // This is the entry point from the `/f/{fileid}` URL which is hardcoded in the server. try { - return $this->redirectToFile($fileid); + return $this->redirectToFile($fileid, true); } catch (NotFoundException $e) { return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', ['fileNotFound' => true])); } @@ -179,7 +179,7 @@ class ViewController extends Controller { * @param string $view * @param string $fileid * @param bool $fileNotFound - * @param string $openfile + * @param string $openfile - the openfile URL parameter if it was present in the initial request * @return TemplateResponse|RedirectResponse * @throws NotFoundException */ @@ -221,17 +221,17 @@ class ViewController extends Controller { $navBarPositionPosition = 6; $currentCount = 0; - foreach ($favElements['folders'] as $dir) { - $link = $this->urlGenerator->linkToRoute('files.view.index', ['dir' => $dir, 'view' => 'files']); + foreach ($favElements['folders'] as $favElement) { + $link = $this->urlGenerator->linkToRoute('files.view.index', ['dir' => $favElement, 'view' => 'files']); $sortingValue = ++$currentCount; $element = [ - 'id' => str_replace('/', '-', $dir), + 'id' => str_replace('/', '-', $favElement), 'view' => 'files', 'href' => $link, - 'dir' => $dir, + 'dir' => $favElement, 'order' => $navBarPositionPosition, 'folderPosition' => $sortingValue, - 'name' => basename($dir), + 'name' => basename($favElement), 'icon' => 'files', 'quickaccesselement' => 'true' ]; @@ -391,10 +391,11 @@ class ViewController extends Controller { * Redirects to the file list and highlight the given file id * * @param string $fileId file id to show + * @param bool $setOpenfile - whether or not to set the openfile URL parameter * @return RedirectResponse redirect response or not found response * @throws \OCP\Files\NotFoundException */ - private function redirectToFile($fileId) { + private function redirectToFile($fileId, bool $setOpenfile = false) { $uid = $this->userSession->getUser()->getUID(); $baseFolder = $this->rootFolder->getUserFolder($uid); $files = $baseFolder->getById($fileId); @@ -416,6 +417,11 @@ class ViewController extends Controller { $params['dir'] = $baseFolder->getRelativePath($file->getParent()->getPath()); // and scroll to the entry $params['scrollto'] = $file->getName(); + + if ($setOpenfile) { + // forward the openfile URL parameter. + $params['openfile'] = $fileId; + } } return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', $params)); |