Skip to content

Commit

Permalink
[BUGFIX] Keep last opened folder in file link handler
Browse files Browse the repository at this point in the history
This change uses the existing session information
(moduleData[browse_links.php][expandFolder]) to read
and write the last opened folder not just for the File
Browser (as currently used) but also the file link handler.

Resolves: #73195
Releases: master
Change-Id: I7957325599407333486898d5538247d452c7af18
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/70959
Tested-by: core-ci <typo3@b13.com>
Tested-by: Oliver Bartsch <bo@cedev.de>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Susanne Moog <look@susi.dev>
Reviewed-by: Rick Septer <rick.septer@maxserv.com>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
  • Loading branch information
bmack authored and georgringer committed Sep 13, 2021
1 parent bb682be commit 1072c56
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions typo3/sysext/recordlist/Classes/LinkHandler/FileLinkHandler.php
Expand Up @@ -105,13 +105,19 @@ public function render(ServerRequestInterface $request)
$this->view->assign('treeActions', ($this->mode === 'folder') ? ['link'] : []);

$this->expandFolder = $request->getQueryParams()['expandFolder'] ?? null;
if (!empty($this->linkParts) && !isset($this->expandFolder)) {
$fileOrFolder = $this->linkParts['url'][$this->mode];
if ($fileOrFolder instanceof File) {
$fileOrFolder = $fileOrFolder->getParentFolder();
}
if ($fileOrFolder instanceof Folder) {
$this->expandFolder = $fileOrFolder->getCombinedIdentifier();
if (!isset($this->expandFolder)) {
if (!empty($this->linkParts)) {
$fileOrFolder = $this->linkParts['url'][$this->mode];
if ($fileOrFolder instanceof File) {
$fileOrFolder = $fileOrFolder->getParentFolder();
}
if ($fileOrFolder instanceof Folder) {
$this->expandFolder = $fileOrFolder->getCombinedIdentifier();
}
} else {
// Look up in the user's session which folder was opened the last time
$moduleSessionData = $this->getBackendUser()->getModuleData('browse_links.php', 'ses');
$this->expandFolder = $moduleSessionData['expandFolder'] ?? null;
}
}

Expand All @@ -120,6 +126,14 @@ public function render(ServerRequestInterface $request)

// Build the file upload and folder creation form
if ($selectedFolder) {

// If a folder is found, store it in the session to continue where the editor left off the last time
if ($selectedFolder->checkActionPermission('read')) {
$moduleSessionData = $this->getBackendUser()->getModuleData('browse_links.php', 'ses') ?: [];
$moduleSessionData['expandFolder'] = $selectedFolder->getCombinedIdentifier();
$this->getBackendUser()->pushModuleData('browse_links.php', $moduleSessionData);
}

$folderUtilityRenderer = GeneralUtility::makeInstance(FolderUtilityRenderer::class, $this);
$uploadForm = $this->mode === 'file' ? $folderUtilityRenderer->uploadForm($selectedFolder, []) : '';
$createFolder = $folderUtilityRenderer->createFolder($selectedFolder);
Expand Down

0 comments on commit 1072c56

Please sign in to comment.