Skip to content
Snippets Groups Projects
Commit 6a91d990 authored by Guido Schmechel's avatar Guido Schmechel Committed by Susanne Moog
Browse files

[FEATURE] Add options and clipboard to filelist search

Use the already existing functions for listOptions and
clipboard and integrate them into the filelist search view.

Resolves: #79310
Releases: master
Change-Id: I2d89d2cac8763e3ff1e135608d434b81264c3589
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/56502


Tested-by: default avatarDaniel Goerz <daniel.goerz@posteo.de>
Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: default avatarSusanne Moog <look@susi.dev>
Reviewed-by: default avatarDaniel Goerz <daniel.goerz@posteo.de>
Reviewed-by: default avatarSusanne Moog <look@susi.dev>
parent 2b23357d
Branches
Tags
No related merge requests found
.. include:: ../../Includes.txt
==============================================================
Feature: #79310 - Add options and clipboard to filelist search
==============================================================
See :issue:`79310`
Description
===========
The filelist backend module now shows the clipboard and the display options
checkboxes on search results.
Impact
======
Files and folders can now be put on the clipboard when using the search result
view of the filelist backend module.
.. index:: Backend, ext:filelist
<?php <?php
namespace TYPO3\CMS\Filelist\Controller; namespace TYPO3\CMS\Filelist\Controller;
/* /*
...@@ -337,6 +338,7 @@ class FileListController extends ActionController implements LoggerAwareInterfac ...@@ -337,6 +338,7 @@ class FileListController extends ActionController implements LoggerAwareInterfac
// There there was access to this file path, continue, make the list // There there was access to this file path, continue, make the list
if ($this->folderObject) { if ($this->folderObject) {
$this->initClipboard();
$userTsConfig = $this->getBackendUser()->getTSConfig(); $userTsConfig = $this->getBackendUser()->getTSConfig();
$this->filelist = GeneralUtility::makeInstance(FileList::class); $this->filelist = GeneralUtility::makeInstance(FileList::class);
$this->filelist->thumbs = $GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'] && $this->MOD_SETTINGS['displayThumbs']; $this->filelist->thumbs = $GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'] && $this->MOD_SETTINGS['displayThumbs'];
...@@ -354,6 +356,7 @@ class FileListController extends ActionController implements LoggerAwareInterfac ...@@ -354,6 +356,7 @@ class FileListController extends ActionController implements LoggerAwareInterfac
$this->filelist->clipObj->cleanCurrent(); $this->filelist->clipObj->cleanCurrent();
// Saves // Saves
$this->filelist->clipObj->endClipboard(); $this->filelist->clipObj->endClipboard();
// If the "cmd" was to delete files from the list (clipboard thing), do that: // If the "cmd" was to delete files from the list (clipboard thing), do that:
if ($this->cmd === 'delete') { if ($this->cmd === 'delete') {
$items = $this->filelist->clipObj->cleanUpCBC(GeneralUtility::_POST('CBC'), '_FILE', 1); $items = $this->filelist->clipObj->cleanUpCBC(GeneralUtility::_POST('CBC'), '_FILE', 1);
...@@ -393,11 +396,7 @@ class FileListController extends ActionController implements LoggerAwareInterfac ...@@ -393,11 +396,7 @@ class FileListController extends ActionController implements LoggerAwareInterfac
} }
// Set top JavaScript: // Set top JavaScript:
$this->view->getModuleTemplate()->addJavaScriptCode( $this->addJumpToUrl();
'FileListIndex',
'if (top.fsMod) top.fsMod.recentIds["file"] = "' . rawurlencode($this->id) . '";
'
);
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/ClipboardComponent'); $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/ClipboardComponent');
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Filelist/FileDelete'); $pageRenderer->loadRequireJsModule('TYPO3/CMS/Filelist/FileDelete');
$pageRenderer->addInlineLanguageLabelFile('EXT:backend/Resources/Private/Language/locallang_alt_doc.xlf', 'buttons'); $pageRenderer->addInlineLanguageLabelFile('EXT:backend/Resources/Private/Language/locallang_alt_doc.xlf', 'buttons');
...@@ -469,6 +468,7 @@ class FileListController extends ActionController implements LoggerAwareInterfac ...@@ -469,6 +468,7 @@ class FileListController extends ActionController implements LoggerAwareInterfac
$this->view->assign('fileDenyPattern', $GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern']); $this->view->assign('fileDenyPattern', $GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern']);
$this->view->assign('maxFileSize', GeneralUtility::getMaxUploadFileSize() * 1024); $this->view->assign('maxFileSize', GeneralUtility::getMaxUploadFileSize() * 1024);
$this->view->assign('defaultAction', $this->getDefaultAction()); $this->view->assign('defaultAction', $this->getDefaultAction());
$this->buildListOptionCheckboxes();
} else { } else {
$this->forward('missingFolder'); $this->forward('missingFolder');
} }
...@@ -551,9 +551,14 @@ class FileListController extends ActionController implements LoggerAwareInterfac ...@@ -551,9 +551,14 @@ class FileListController extends ActionController implements LoggerAwareInterfac
$this->view->assign('settings', [ $this->view->assign('settings', [
'jsConfirmationDelete' => $this->getBackendUser()->jsConfirmation(JsConfirmation::DELETE) 'jsConfirmationDelete' => $this->getBackendUser()->jsConfirmation(JsConfirmation::DELETE)
]); ]);
$this->view->assign('moduleSettings', $this->MOD_SETTINGS);
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Filelist/FileDelete'); $pageRenderer->loadRequireJsModule('TYPO3/CMS/Filelist/FileDelete');
$pageRenderer->addInlineLanguageLabelFile('EXT:backend/Resources/Private/Language/locallang_alt_doc.xlf', 'buttons'); $pageRenderer->addInlineLanguageLabelFile('EXT:backend/Resources/Private/Language/locallang_alt_doc.xlf', 'buttons');
$this->initClipboard();
$this->buildListOptionCheckboxes($searchWord);
$this->addJumpToUrl();
} }
/** /**
...@@ -746,4 +751,101 @@ class FileListController extends ActionController implements LoggerAwareInterfac ...@@ -746,4 +751,101 @@ class FileListController extends ActionController implements LoggerAwareInterfac
{ {
return $GLOBALS['BE_USER']; return $GLOBALS['BE_USER'];
} }
/**
* build option checkboxes for filelist
*/
protected function buildListOptionCheckboxes(string $searchWord = ''): void
{
$backendUser = $this->getBackendUser();
$userTsConfig = $backendUser->getTSConfig();
$addParams = '';
if ($searchWord) {
$addParams = '&tx_filelist_file_filelistlist%5Baction%5D=search';
$addParams .= '&tx_filelist_file_filelistlist%5Bcontroller%5D=FileList';
$addParams .= '&tx_filelist_file_filelistlist%5BsearchWord%5D=' . htmlspecialchars($searchWord);
}
$this->view->assign('checkboxes', [
'bigControlPanel' => [
'enabled' => $userTsConfig['options.']['file_list.']['enableDisplayBigControlPanel'] === 'selectable',
'label' => htmlspecialchars($this->getLanguageService()->getLL('bigControlPanel')),
'html' => BackendUtility::getFuncCheck(
$this->id,
'SET[bigControlPanel]',
$this->MOD_SETTINGS['bigControlPanel'] ?? '',
'',
$addParams,
'id="bigControlPanel"'
),
],
'displayThumbs' => [
'enabled' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'] && $userTsConfig['options.']['file_list.']['enableDisplayThumbnails'] === 'selectable',
'label' => htmlspecialchars($this->getLanguageService()->getLL('displayThumbs')),
'html' => BackendUtility::getFuncCheck(
$this->id,
'SET[displayThumbs]',
$this->MOD_SETTINGS['displayThumbs'] ?? '',
'',
$addParams,
'id="checkDisplayThumbs"'
),
],
'enableClipBoard' => [
'enabled' => $userTsConfig['options.']['file_list.']['enableClipBoard'] === 'selectable',
'label' => htmlspecialchars($this->getLanguageService()->getLL('clipBoard')),
'html' => BackendUtility::getFuncCheck(
$this->id,
'SET[clipBoard]',
$this->MOD_SETTINGS['clipBoard'] ?? '',
'',
$addParams,
'id="checkClipBoard"'
),
]
]);
}
/**
* init and assign clipboard to view
*/
protected function initClipboard(): void
{
// Create fileListing object
$this->filelist = GeneralUtility::makeInstance(FileList::class, $this);
$this->filelist->thumbs = $GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'] && $this->MOD_SETTINGS['displayThumbs'];
// Create clipboard object and initialize that
$this->filelist->clipObj = GeneralUtility::makeInstance(Clipboard::class);
$this->filelist->clipObj->fileMode = true;
$this->filelist->clipObj->initializeClipboard();
$CB = GeneralUtility::_GET('CB');
if ($this->cmd === 'setCB') {
$CB['el'] = $this->filelist->clipObj->cleanUpCBC(array_merge(
GeneralUtility::_POST('CBH'),
(array)GeneralUtility::_POST('CBC')
), '_FILE');
}
if (!$this->MOD_SETTINGS['clipBoard']) {
$CB['setP'] = 'normal';
}
$this->filelist->clipObj->setCmd($CB);
$this->filelist->clipObj->cleanCurrent();
// Saves
$this->filelist->clipObj->endClipboard();
$this->view->assign('showClipBoard', (bool)$this->MOD_SETTINGS['clipBoard']);
$this->view->assign('clipBoardHtml', $this->filelist->clipObj->printClipboard());
}
/**
* add javascript jumpToUrl function
*/
protected function addJumpToUrl(): void
{
$this->view->getModuleTemplate()->addJavaScriptCode(
'FileListIndex',
'if (top.fsMod) top.fsMod.recentIds["file"] = "' . rawurlencode($this->id) . '";
'
);
}
} }
<f:if condition="{showClipBoard}">
{clipBoardHtml -> f:format.raw()}
<f:be.buttons.csh table="xMOD_csh_corebe" field="filelist_clipboard" wrap="<span class='btn btn-sm btn-default'>|</span>" />
</f:if>
<!--
Listing options for extended view, clipboard and thumbnails
-->
<div class="typo3-listOptions">
<f:if condition="{checkboxes.bigControlPanel.enabled}">
<div class="checkbox">
<label for="bigControlPanel">
{checkboxes.bigControlPanel.html -> f:format.raw()}
{checkboxes.bigControlPanel.label}
</label>
</div>
</f:if>
<f:if condition="{checkboxes.displayThumbs.enabled}">
<div class="checkbox">
<label for="checkDisplayThumbs">
{checkboxes.displayThumbs.html -> f:format.raw()}
{checkboxes.displayThumbs.label}
</label>
</div>
</f:if>
<f:if condition="{checkboxes.enableClipBoard.enabled}">
<div class="checkbox">
<label for="checkClipBoard">
{checkboxes.enableClipBoard.html -> f:format.raw()}
{checkboxes.enableClipBoard.label}
</label>
</div>
</f:if>
</div>
...@@ -14,40 +14,7 @@ ...@@ -14,40 +14,7 @@
</f:form> </f:form>
<f:if condition="{listHtml}"> <f:if condition="{listHtml}">
<!-- <f:render partial="ListOptions" arguments="{checkboxes:checkboxes}" />
Listing options for extended view, clipboard and thumbnails <f:render partial="ClipBoard" arguments="{showClipBoard:showClipBoard,clipBoardHtml:clipBoardHtml}" />
-->
<div class="typo3-listOptions">
<f:if condition="{checkboxes.bigControlPanel.enabled}">
<div class="checkbox">
<label for="bigControlPanel">
{checkboxes.bigControlPanel.html -> f:format.raw()}
{checkboxes.bigControlPanel.label}
</label>
</div>
</f:if>
<f:if condition="{checkboxes.displayThumbs.enabled}">
<div class="checkbox">
<label for="checkDisplayThumbs">
{checkboxes.displayThumbs.html -> f:format.raw()}
{checkboxes.displayThumbs.label}
</label>
</div>
</f:if>
<f:if condition="{checkboxes.enableClipBoard.enabled}">
<div class="checkbox">
<label for="checkClipBoard">
{checkboxes.enableClipBoard.html -> f:format.raw()}
{checkboxes.enableClipBoard.label}
</label>
</div>
</f:if>
</div>
<f:if condition="{showClipBoard}">
{clipBoardHtml -> f:format.raw()}
<f:be.buttons.csh table="xMOD_csh_corebe" field="filelist_clipboard" wrap="<span class='btn btn-sm btn-default'>|</span>" />
</f:if>
</f:if> </f:if>
</f:section> </f:section>
...@@ -221,5 +221,8 @@ ...@@ -221,5 +221,8 @@
</table> </table>
</div> </div>
</f:if> </f:if>
<f:render partial="ListOptions" arguments="{checkboxes:checkboxes}" />
<f:render partial="ClipBoard" arguments="{showClipBoard:showClipBoard,clipBoardHtml:clipBoardHtml}" />
</f:section> </f:section>
</html> </html>
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