2 namespace TYPO3\CMS\Filelist\Controller
;
5 * This file is part of the TYPO3 CMS project.
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
14 * The TYPO3 project - inspiring people to share!
17 use TYPO3\CMS\Backend\Clipboard\Clipboard
;
18 use TYPO3\CMS\Backend\Template\Components\ButtonBar
;
19 use TYPO3\CMS\Backend\Template\DocumentTemplate
;
20 use TYPO3\CMS\Backend\Utility\BackendUtility
;
21 use TYPO3\CMS\Backend\View\BackendTemplateView
;
22 use TYPO3\CMS\Core\Imaging\Icon
;
23 use TYPO3\CMS\Core\Imaging\IconFactory
;
24 use TYPO3\CMS\Core\Messaging\FlashMessage
;
25 use TYPO3\CMS\Core\Resource\DuplicationBehavior
;
26 use TYPO3\CMS\Core\Resource\Exception
;
27 use TYPO3\CMS\Core\Resource\Folder
;
28 use TYPO3\CMS\Core\Resource\ResourceFactory
;
29 use TYPO3\CMS\Core\Resource\Utility\ListUtility
;
30 use TYPO3\CMS\Core\Type\Bitmask\JsConfirmation
;
31 use TYPO3\CMS\Core\Utility\File\ExtendedFileUtility
;
32 use TYPO3\CMS\Core\Utility\GeneralUtility
;
33 use TYPO3\CMS\Core\Utility\MathUtility
;
34 use TYPO3\CMS\Extbase\Mvc\Controller\ActionController
;
35 use TYPO3\CMS\Extbase\Mvc\View\ViewInterface
;
36 use TYPO3\CMS\Extbase\Utility\LocalizationUtility
;
37 use TYPO3\CMS\Filelist\Configuration\ThumbnailConfiguration
;
38 use TYPO3\CMS\Filelist\FileList
;
41 * Script Class for creating the list of files in the File > Filelist module
43 class FileListController
extends ActionController
48 public $MOD_MENU = [];
53 public $MOD_SETTINGS = [];
56 * Document template object
58 * @var DocumentTemplate
63 * "id" -> the path to list.
72 protected $folderObject;
77 protected $errorMessage;
105 * Defines behaviour when uploading files with names that already exist; possible values are
106 * the values of the \TYPO3\CMS\Core\Resource\DuplicationBehavior enumeration
108 * @var \TYPO3\CMS\Core\Resource\DuplicationBehavior
110 protected $overwriteExistingFiles;
113 * The filelist object
120 * The name of the module
124 protected $moduleName = 'file_list';
127 * @var \TYPO3\CMS\Core\Resource\FileRepository
129 protected $fileRepository;
132 * @var BackendTemplateView
137 * BackendTemplateView Container
139 * @var BackendTemplateView
141 protected $defaultViewObjectName = BackendTemplateView
::class;
144 * @param \TYPO3\CMS\Core\Resource\FileRepository $fileRepository
146 public function injectFileRepository(\TYPO3\CMS\Core\Resource\FileRepository
$fileRepository)
148 $this->fileRepository
= $fileRepository;
152 * Initialize variables, file object
153 * Incoming GET vars include id, pointer, table, imagemode
155 * @throws \RuntimeException
156 * @throws Exception\InsufficientFolderAccessPermissionsException
158 public function initializeObject()
160 $this->doc
= GeneralUtility
::makeInstance(DocumentTemplate
::class);
161 $this->getLanguageService()->includeLLFile('EXT:filelist/Resources/Private/Language/locallang_mod_file_list.xlf');
162 $this->getLanguageService()->includeLLFile('EXT:core/Resources/Private/Language/locallang_misc.xlf');
165 $this->id
= ($combinedIdentifier = GeneralUtility
::_GP('id'));
166 $this->pointer
= GeneralUtility
::_GP('pointer');
167 $this->table
= GeneralUtility
::_GP('table');
168 $this->imagemode
= GeneralUtility
::_GP('imagemode');
169 $this->cmd
= GeneralUtility
::_GP('cmd');
170 $this->overwriteExistingFiles
= DuplicationBehavior
::cast(GeneralUtility
::_GP('overwriteExistingFiles'));
173 if ($combinedIdentifier) {
174 /** @var ResourceFactory $resourceFactory */
175 $resourceFactory = GeneralUtility
::makeInstance(ResourceFactory
::class);
176 $storage = $resourceFactory->getStorageObjectFromCombinedIdentifier($combinedIdentifier);
177 $identifier = substr($combinedIdentifier, strpos($combinedIdentifier, ':') +
1);
178 if (!$storage->hasFolder($identifier)) {
179 $identifier = $storage->getFolderIdentifierFromFileIdentifier($identifier);
182 $this->folderObject
= $resourceFactory->getFolderObjectFromCombinedIdentifier($storage->getUid() . ':' . $identifier);
183 // Disallow access to fallback storage 0
184 if ($storage->getUid() === 0) {
185 throw new Exception\
InsufficientFolderAccessPermissionsException(
186 'You are not allowed to access files outside your storages',
190 // Disallow the rendering of the processing folder (e.g. could be called manually)
191 if ($this->folderObject
&& $storage->isProcessingFolder($this->folderObject
)) {
192 $this->folderObject
= $storage->getRootLevelFolder();
195 // Take the first object of the first storage
196 $fileStorages = $this->getBackendUser()->getFileStorages();
197 $fileStorage = reset($fileStorages);
199 $this->folderObject
= $fileStorage->getRootLevelFolder();
201 throw new \
RuntimeException('Could not find any folder to be displayed.', 1349276894);
205 if ($this->folderObject
&& !$this->folderObject
->getStorage()->isWithinFileMountBoundaries($this->folderObject
)) {
206 throw new \
RuntimeException('Folder not accessible.', 1430409089);
208 } catch (Exception\InsufficientFolderAccessPermissionsException
$permissionException) {
209 $this->folderObject
= null
;
210 $this->errorMessage
= GeneralUtility
::makeInstance(
213 $this->getLanguageService()->getLL('missingFolderPermissionsMessage'),
216 $this->getLanguageService()->getLL('missingFolderPermissionsTitle'),
219 } catch (Exception
$fileException) {
220 // Set folder object to null and throw a message later on
221 $this->folderObject
= null
;
222 // Take the first object of the first storage
223 $fileStorages = $this->getBackendUser()->getFileStorages();
224 $fileStorage = reset($fileStorages);
225 if ($fileStorage instanceof \TYPO3\CMS\Core\Resource\ResourceStorage
) {
226 $this->folderObject
= $fileStorage->getRootLevelFolder();
227 if (!$fileStorage->isWithinFileMountBoundaries($this->folderObject
)) {
228 $this->folderObject
= null
;
231 $this->errorMessage
= GeneralUtility
::makeInstance(
234 $this->getLanguageService()->getLL('folderNotFoundMessage'),
237 $this->getLanguageService()->getLL('folderNotFoundTitle'),
240 } catch (\RuntimeException
$e) {
241 $this->folderObject
= null
;
242 $this->errorMessage
= GeneralUtility
::makeInstance(
244 $e->getMessage() . ' (' . $e->getCode() . ')',
245 $this->getLanguageService()->getLL('folderNotFoundTitle'),
250 if ($this->folderObject
&& !$this->folderObject
->getStorage()->checkFolderActionPermission(
255 $this->folderObject
= null
;
258 // Configure the "menu" - which is used internally to save the values of sorting, displayThumbs etc.
263 * Setting the menu/session variables
265 public function menuConfig()
268 // If array, then it's a selector box menu
269 // If empty string it's just a variable, that will be saved.
270 // Values NOT in this array will not be saved in the settings-array for the module.
274 'displayThumbs' => '',
276 'bigControlPanel' => ''
279 $this->MOD_SETTINGS
= BackendUtility
::getModuleData(
281 GeneralUtility
::_GP('SET'),
287 * Initialize the view
289 * @param ViewInterface $view The view
291 public function initializeView(ViewInterface
$view)
293 /** @var BackendTemplateView $view */
294 parent
::initializeView($view);
295 $pageRenderer = $this->view
->getModuleTemplate()->getPageRenderer();
296 $pageRenderer->loadRequireJsModule('TYPO3/CMS/Filelist/FileListLocalisation');
297 $pageRenderer->loadRequireJsModule('TYPO3/CMS/Filelist/FileSearch');
298 $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/ContextMenu');
299 $this->registerDocHeaderButtons();
304 public function initializeIndexAction()
306 // Apply predefined values for hidden checkboxes
307 // Set predefined value for DisplayBigControlPanel:
308 $backendUser = $this->getBackendUser();
309 $userTsConfig = $backendUser->getTSConfig();
310 if (($userTsConfig['options.']['file_list.']['enableDisplayBigControlPanel'] ??
'') === 'activated') {
311 $this->MOD_SETTINGS
['bigControlPanel'] = true
;
312 } elseif (($userTsConfig['options.']['file_list.']['enableDisplayBigControlPanel'] ??
'') === 'deactivated') {
313 $this->MOD_SETTINGS
['bigControlPanel'] = false
;
315 // Set predefined value for DisplayThumbnails:
316 if (($userTsConfig['options.']['file_list.']['enableDisplayThumbnails'] ??
'') === 'activated') {
317 $this->MOD_SETTINGS
['displayThumbs'] = true
;
318 } elseif (($userTsConfig['options.']['file_list.']['enableDisplayThumbnails'] ??
'') === 'deactivated') {
319 $this->MOD_SETTINGS
['displayThumbs'] = false
;
321 // Set predefined value for Clipboard:
322 if (($userTsConfig['options.']['file_list.']['enableClipBoard'] ??
'') === 'activated') {
323 $this->MOD_SETTINGS
['clipBoard'] = true
;
324 } elseif (($userTsConfig['options.']['file_list.']['enableClipBoard'] ??
'') === 'deactivated') {
325 $this->MOD_SETTINGS
['clipBoard'] = false
;
327 // If user never opened the list module, set the value for displayThumbs
328 if (!isset($this->MOD_SETTINGS
['displayThumbs'])) {
329 $this->MOD_SETTINGS
['displayThumbs'] = $backendUser->uc
['thumbnailsByDefault'];
331 if (!isset($this->MOD_SETTINGS
['sort'])) {
332 // Set default sorting
333 $this->MOD_SETTINGS
['sort'] = 'file';
334 $this->MOD_SETTINGS
['reverse'] = 0;
340 public function indexAction()
342 $pageRenderer = $this->view
->getModuleTemplate()->getPageRenderer();
343 $pageRenderer->setTitle($this->getLanguageService()->getLL('files'));
345 // There there was access to this file path, continue, make the list
346 if ($this->folderObject
) {
347 $userTsConfig = $this->getBackendUser()->getTSConfig();
348 // Create fileListing object
349 $this->filelist
= GeneralUtility
::makeInstance(FileList
::class, $this);
350 $this->filelist
->thumbs
= $GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'] && $this->MOD_SETTINGS
['displayThumbs'];
351 // Create clipboard object and initialize that
352 $this->filelist
->clipObj
= GeneralUtility
::makeInstance(Clipboard
::class);
353 $this->filelist
->clipObj
->fileMode
= true
;
354 $this->filelist
->clipObj
->initializeClipboard();
355 $CB = GeneralUtility
::_GET('CB');
356 if ($this->cmd
=== 'setCB') {
357 $CB['el'] = $this->filelist
->clipObj
->cleanUpCBC(array_merge(
358 GeneralUtility
::_POST('CBH'),
359 (array)GeneralUtility
::_POST('CBC')
362 if (!$this->MOD_SETTINGS
['clipBoard']) {
363 $CB['setP'] = 'normal';
365 $this->filelist
->clipObj
->setCmd($CB);
366 $this->filelist
->clipObj
->cleanCurrent();
368 $this->filelist
->clipObj
->endClipboard();
369 // If the "cmd" was to delete files from the list (clipboard thing), do that:
370 if ($this->cmd
=== 'delete') {
371 $items = $this->filelist
->clipObj
->cleanUpCBC(GeneralUtility
::_POST('CBC'), '_FILE', 1);
372 if (!empty($items)) {
373 // Make command array:
375 foreach ($items as $v) {
376 $FILE['delete'][] = ['data' => $v];
378 // Init file processing object for deleting and pass the cmd array.
379 /** @var ExtendedFileUtility $fileProcessor */
380 $fileProcessor = GeneralUtility
::makeInstance(ExtendedFileUtility
::class);
381 $fileProcessor->setActionPermissions();
382 $fileProcessor->setExistingFilesConflictMode($this->overwriteExistingFiles
);
383 $fileProcessor->start($FILE);
384 $fileProcessor->processData();
387 // Start up filelisting object, include settings.
388 $this->pointer
= MathUtility
::forceIntegerInRange($this->pointer
, 0, 100000);
389 $this->filelist
->start(
392 $this->MOD_SETTINGS
['sort'],
393 $this->MOD_SETTINGS
['reverse'],
394 $this->MOD_SETTINGS
['clipBoard'],
395 $this->MOD_SETTINGS
['bigControlPanel']
398 $this->filelist
->generateList();
399 // Set top JavaScript:
400 $this->view
->getModuleTemplate()->addJavaScriptCode(
402 'if (top.fsMod) top.fsMod.recentIds["file"] = "' . rawurlencode($this->id
) . '";' . $this->filelist
->CBfunctions() . '
403 function jumpToUrl(URL) {
404 window.location.href = URL;
409 $pageRenderer->loadRequireJsModule('TYPO3/CMS/Filelist/FileDelete');
410 $pageRenderer->addInlineLanguageLabelFile('EXT:backend/Resources/Private/Language/locallang_alt_doc.xlf', 'buttons');
412 // Include DragUploader only if we have write access
413 if ($this->folderObject
->getStorage()->checkUserActionPermission('add', 'File')
414 && $this->folderObject
->checkActionPermission('write')
416 $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/DragUploader');
417 $pageRenderer->addInlineLanguageLabelFile('EXT:core/Resources/Private/Language/locallang_core.xlf', 'file_upload');
418 $pageRenderer->addInlineLanguageLabelArray([
419 'permissions.read' => $this->getLanguageService()->getLL('read'),
420 'permissions.write' => $this->getLanguageService()->getLL('write'),
424 // Setting up the buttons
425 $this->registerButtons();
428 '_additional_info' => $this->filelist
->getFolderInfo(),
429 'combined_identifier' => $this->folderObject
->getCombinedIdentifier(),
431 $this->view
->getModuleTemplate()->getDocHeaderComponent()->setMetaInformation($pageRecord);
433 $this->view
->assign('headline', $this->getModuleHeadline());
434 $this->view
->assign('listHtml', $this->filelist
->HTMLcode
);
436 $this->view
->assign('checkboxes', [
437 'bigControlPanel' => [
438 'enabled' => ($userTsConfig['options.']['file_list.']['enableDisplayBigControlPanel'] ??
'') === 'selectable',
439 'label' => htmlspecialchars($this->getLanguageService()->getLL('bigControlPanel')),
440 'html' => BackendUtility
::getFuncCheck(
442 'SET[bigControlPanel]',
443 $this->MOD_SETTINGS
['bigControlPanel'] ??
'',
446 'id="bigControlPanel"'
450 'enabled' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'] && ($userTsConfig['options.']['file_list.']['enableDisplayThumbnails'] ??
'') === 'selectable',
451 'label' => htmlspecialchars($this->getLanguageService()->getLL('displayThumbs')),
452 'html' => BackendUtility
::getFuncCheck(
454 'SET[displayThumbs]',
455 $this->MOD_SETTINGS
['displayThumbs'] ??
'',
458 'id="checkDisplayThumbs"'
461 'enableClipBoard' => [
462 'enabled' => ($userTsConfig['options.']['file_list.']['enableClipBoard'] ??
'') === 'selectable',
463 'label' => htmlspecialchars($this->getLanguageService()->getLL('clipBoard')),
464 'html' => BackendUtility
::getFuncCheck(
467 $this->MOD_SETTINGS
['clipBoard'] ??
'',
470 'id="checkClipBoard"'
474 $this->view
->assign('showClipBoard', (bool
)$this->MOD_SETTINGS
['clipBoard']);
475 $this->view
->assign('clipBoardHtml', $this->filelist
->clipObj
->printClipboard());
476 $this->view
->assign('folderIdentifier', $this->folderObject
->getCombinedIdentifier());
477 $this->view
->assign('fileDenyPattern', $GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern']);
478 $this->view
->assign('maxFileSize', GeneralUtility
::getMaxUploadFileSize() * 1024);
480 $this->forward('missingFolder');
486 public function missingFolderAction()
488 if ($this->errorMessage
) {
489 $this->errorMessage
->setSeverity(FlashMessage
::ERROR
);
490 $this->controllerContext
->getFlashMessageQueue('core.template.flashMessages')->addMessage($this->errorMessage
);
495 * Search for files by name and pass them with a facade to fluid
497 * @param string $searchWord
499 public function searchAction($searchWord = '')
501 if (empty($searchWord)) {
502 $this->forward('index');
506 $files = $this->fileRepository
->searchByName($this->folderObject
, $searchWord);
509 $this->controllerContext
->getFlashMessageQueue('core.template.flashMessages')->addMessage(
511 LocalizationUtility
::translate('flashmessage.no_results', 'filelist'),
517 foreach ($files as $file) {
518 $fileFacades[] = new \TYPO3\CMS\Filelist\
FileFacade($file);
522 /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
523 $uriBuilder = GeneralUtility
::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder
::class);
525 $pageRenderer = $this->view
->getModuleTemplate()->getPageRenderer();
526 $pageRenderer->addInlineSetting('ShowItem', 'moduleUrl', (string)$uriBuilder->buildUriFromRoute('show_item'));
527 $pageRenderer->loadRequireJsModule('TYPO3/CMS/Filelist/FileList');
529 $thumbnailConfiguration = GeneralUtility
::makeInstance(ThumbnailConfiguration
::class);
530 $this->view
->assign('thumbnail', [
531 'width' => $thumbnailConfiguration->getWidth(),
532 'height' => $thumbnailConfiguration->getHeight(),
535 $this->view
->assign('searchWord', $searchWord);
536 $this->view
->assign('files', $fileFacades);
537 $this->view
->assign('deleteUrl', (string)$uriBuilder->buildUriFromRoute('tce_file'));
538 $this->view
->assign('settings', [
539 'jsConfirmationDelete' => $this->getBackendUser()->jsConfirmation(JsConfirmation
::DELETE
)
542 $pageRenderer->loadRequireJsModule('TYPO3/CMS/Filelist/FileDelete');
543 $pageRenderer->addInlineLanguageLabelFile('EXT:backend/Resources/Private/Language/locallang_alt_doc.xlf', 'buttons');
547 * Get main headline based on active folder or storage for backend module
548 * Folder names are resolved to their special names like done in the tree view.
552 protected function getModuleHeadline()
554 $name = $this->folderObject
->getName();
556 // Show storage name on storage root
557 if ($this->folderObject
->getIdentifier() === '/') {
558 $name = $this->folderObject
->getStorage()->getName();
561 $name = key(ListUtility
::resolveSpecialFolderNames(
562 [$name => $this->folderObject
]
569 * Registers the Icons into the docheader
571 * @throws \InvalidArgumentException
573 protected function registerDocHeaderButtons()
575 /** @var ButtonBar $buttonBar */
576 $buttonBar = $this->view
->getModuleTemplate()->getDocHeaderComponent()->getButtonBar();
579 $cshButton = $buttonBar->makeHelpButton()
580 ->setModuleName('xMOD_csh_corebe')
581 ->setFieldName('filelist_module');
582 $buttonBar->addButton($cshButton);
586 * Create the panel of buttons for submitting the form or otherwise perform operations.
588 * @return array All available buttons as an assoc. array
590 protected function registerButtons()
592 /** @var ButtonBar $buttonBar */
593 $buttonBar = $this->view
->getModuleTemplate()->getDocHeaderComponent()->getButtonBar();
595 /** @var IconFactory $iconFactory */
596 $iconFactory = $this->view
->getModuleTemplate()->getIconFactory();
598 /** @var ResourceFactory $resourceFactory */
599 $resourceFactory = GeneralUtility
::makeInstance(ResourceFactory
::class);
601 $lang = $this->getLanguageService();
603 /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
604 $uriBuilder = GeneralUtility
::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder
::class);
607 $refreshLink = GeneralUtility
::linkThisScript(
609 'target' => rawurlencode($this->folderObject
->getCombinedIdentifier()),
610 'imagemode' => $this->filelist
->thumbs
613 $refreshButton = $buttonBar->makeLinkButton()
614 ->setHref($refreshLink)
615 ->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.reload'))
616 ->setIcon($iconFactory->getIcon('actions-refresh', Icon
::SIZE_SMALL
));
617 $buttonBar->addButton($refreshButton, ButtonBar
::BUTTON_POSITION_RIGHT
);
621 $currentStorage = $this->folderObject
->getStorage();
622 $parentFolder = $this->folderObject
->getParentFolder();
623 if ($parentFolder->getIdentifier() !== $this->folderObject
->getIdentifier()
624 && $currentStorage->isWithinFileMountBoundaries($parentFolder)
626 $levelUpClick = 'top.document.getElementsByName("nav_frame")[0].contentWindow.Tree.highlightActiveItem("file","folder'
627 . GeneralUtility
::md5int($parentFolder->getCombinedIdentifier()) . '_"+top.fsMod.currentBank)';
628 $levelUpButton = $buttonBar->makeLinkButton()
629 ->setHref((string)$uriBuilder->buildUriFromRoute('file_FilelistList', ['id' => $parentFolder->getCombinedIdentifier()]))
630 ->setOnClick($levelUpClick)
631 ->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.upOneLevel'))
632 ->setIcon($iconFactory->getIcon('actions-view-go-up', Icon
::SIZE_SMALL
));
633 $buttonBar->addButton($levelUpButton, ButtonBar
::BUTTON_POSITION_LEFT
, 1);
635 } catch (\Exception
$e) {
639 if ($this->getBackendUser()->mayMakeShortcut()) {
640 $shortCutButton = $buttonBar->makeShortcutButton()->setModuleName('file_FilelistList');
641 $buttonBar->addButton($shortCutButton, ButtonBar
::BUTTON_POSITION_RIGHT
);
644 // Upload button (only if upload to this directory is allowed)
645 if ($this->folderObject
&& $this->folderObject
->getStorage()->checkUserActionPermission(
648 ) && $this->folderObject
->checkActionPermission('write')
650 $uploadButton = $buttonBar->makeLinkButton()
651 ->setHref((string)$uriBuilder->buildUriFromRoute(
654 'target' => $this->folderObject
->getCombinedIdentifier(),
655 'returnUrl' => $this->filelist
->listURL(),
658 ->setClasses('t3js-drag-uploader-trigger')
659 ->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.upload'))
660 ->setIcon($iconFactory->getIcon('actions-edit-upload', Icon
::SIZE_SMALL
));
661 $buttonBar->addButton($uploadButton, ButtonBar
::BUTTON_POSITION_LEFT
, 1);
665 if ($this->folderObject
&& $this->folderObject
->checkActionPermission('write')
666 && ($this->folderObject
->getStorage()->checkUserActionPermission(
669 ) ||
$this->folderObject
->checkActionPermission('add'))
671 $newButton = $buttonBar->makeLinkButton()
672 ->setHref((string)$uriBuilder->buildUriFromRoute(
675 'target' => $this->folderObject
->getCombinedIdentifier(),
676 'returnUrl' => $this->filelist
->listURL(),
679 ->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.new'))
680 ->setIcon($iconFactory->getIcon('actions-add', Icon
::SIZE_SMALL
));
681 $buttonBar->addButton($newButton, ButtonBar
::BUTTON_POSITION_LEFT
, 1);
684 // Add paste button if clipboard is initialized
685 if ($this->filelist
->clipObj
instanceof Clipboard
&& $this->folderObject
->checkActionPermission('write')) {
686 $elFromTable = $this->filelist
->clipObj
->elFromTable('_FILE');
687 if (!empty($elFromTable)) {
688 $addPasteButton = true
;
690 foreach ($elFromTable as $key => $element) {
691 $clipBoardElement = $resourceFactory->retrieveFileOrFolderObject($element);
692 if ($clipBoardElement instanceof Folder
&& $clipBoardElement->getStorage()->isWithinFolder(
697 $addPasteButton = false
;
699 $elToConfirm[$key] = $clipBoardElement->getName();
701 if ($addPasteButton) {
702 $confirmText = $this->filelist
->clipObj
703 ->confirmMsgText('_FILE', $this->folderObject
->getReadablePath(), 'into', $elToConfirm);
704 $pasteButton = $buttonBar->makeLinkButton()
705 ->setHref($this->filelist
->clipObj
706 ->pasteUrl('_FILE', $this->folderObject
->getCombinedIdentifier()))
707 ->setClasses('t3js-modal-trigger')
708 ->setDataAttributes([
709 'severity' => 'warning',
710 'content' => $confirmText,
711 'title' => $lang->getLL('clip_paste')
713 ->setTitle($lang->getLL('clip_paste'))
714 ->setIcon($iconFactory->getIcon('actions-document-paste-into', Icon
::SIZE_SMALL
));
715 $buttonBar->addButton($pasteButton, ButtonBar
::BUTTON_POSITION_LEFT
, 2);
722 * Returns an instance of LanguageService
724 * @return \TYPO3\CMS\Core\Localization\LanguageService
726 protected function getLanguageService()
728 return $GLOBALS['LANG'];
732 * Returns the current BE user.
734 * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
736 protected function getBackendUser()
738 return $GLOBALS['BE_USER'];