Skip to content
Snippets Groups Projects
Commit d5d7ee36 authored by Oliver Bartsch's avatar Oliver Bartsch
Browse files

[BUGFIX] Add missing file search to file link handler

The FileLinkHandler, used to select a file
in the link wizard does now also allow to
search for files, like it's also possible
in the FileBrowser already.

Resolves: #103241
Releases: main, 12.4
Change-Id: Icf3ded3d317e5fbdbd4bc17db0e5969f7b2a055f
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/83111


Tested-by: default avatarcore-ci <typo3@b13.com>
Tested-by: default avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: default avatarOliver Bartsch <bo@cedev.de>
parent bfd7cf90
Branches
Tags
No related merge requests found
......@@ -17,7 +17,9 @@ namespace TYPO3\CMS\Filelist\LinkHandler;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\View\FolderUtilityRenderer;
use TYPO3\CMS\Backend\View\RecordSearchBoxComponent;
use TYPO3\CMS\Core\Resource\ResourceInterface;
use TYPO3\CMS\Core\Resource\Search\FileSearchDemand;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Filelist\Matcher\Matcher;
......@@ -60,16 +62,6 @@ class FileLinkHandler extends AbstractResourceLinkHandler
{
$contentHtml = '';
if ($this->selectedFolder !== null) {
$markup = [];
// Create the filelist header bar
$markup[] = '<div class="row justify-content-between mb-2">';
$markup[] = ' <div class="col-auto"></div>';
$markup[] = ' <div class="col-auto">';
$markup[] = ' ' . $this->getViewModeButton($request);
$markup[] = ' </div>';
$markup[] = '</div>';
// Create the filelist
$this->filelist->start(
$this->selectedFolder,
......@@ -81,6 +73,9 @@ class FileLinkHandler extends AbstractResourceLinkHandler
$this->filelist->setResourceDisplayMatcher($this->resourceDisplayMatcher);
$this->filelist->setResourceSelectableMatcher($this->resourceSelectableMatcher);
$searchWord = trim((string)($request->getParsedBody()['searchTerm'] ?? $request->getQueryParams()['searchTerm'] ?? ''));
$searchDemand = $searchWord !== '' ? FileSearchDemand::createForSearchTerm($searchWord)->withFolder($this->selectedFolder)->withRecursive() : null;
$resource = $this->linkParts['url']['file'] ?? null;
if ($resource instanceof ResourceInterface) {
$resourceSelectedMatcher = GeneralUtility::makeInstance(Matcher::class);
......@@ -90,9 +85,27 @@ class FileLinkHandler extends AbstractResourceLinkHandler
$this->filelist->setResourceSelectedMatcher($resourceSelectedMatcher);
}
$markup[] = $this->filelist->render(null, $this->view);
$markup = [];
// Render the filelist search box
$markup[] = '<div class="mb-4">';
$markup[] = GeneralUtility::makeInstance(RecordSearchBoxComponent::class)
->setSearchWord($searchWord)
->render($request, $this->filelist->createModuleUri($this->getUrlParameters([])));
$markup[] = '</div>';
// Render the filelist header bar
$markup[] = '<div class="row justify-content-between mb-2">';
$markup[] = ' <div class="col-auto"></div>';
$markup[] = ' <div class="col-auto">';
$markup[] = ' ' . $this->getViewModeButton($request);
$markup[] = ' </div>';
$markup[] = '</div>';
// Render the filelist
$markup[] = $this->filelist->render($searchDemand, $this->view);
// Build the file upload and folder creation form
// Render the file upload and folder creation form
$folderUtilityRenderer = GeneralUtility::makeInstance(FolderUtilityRenderer::class, $this);
$markup[] = $folderUtilityRenderer->uploadForm($this->selectedFolder);
$markup[] = $folderUtilityRenderer->createFolder($this->selectedFolder);
......
......@@ -15,7 +15,7 @@
<f:section name="Content">
<f:if condition="{selectedFolder}">
<h4 class="text-truncate">
<h4 class="text-truncate mb-4">
<core:iconForResource resource="{selectedFolder}" />
{selectedFolder.storage.name}: {selectedFolder.identifier}
</h4>
......
......@@ -16,7 +16,7 @@
<f:section name="Content">
<f:if condition="{selectedFolder}">
<h4 class="text-truncate">
<h4 class="text-truncate mb-4">
<core:iconForResource resource="{selectedFolder}" />
<f:render section="LinkWrap" contentAs="linkText" arguments="{_all}">
{selectedFolder.storage.name}: {selectedFolder.identifier}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment