aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/lib/Controller/ViewController.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/lib/Controller/ViewController.php')
-rw-r--r--apps/files/lib/Controller/ViewController.php22
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));