‪TYPO3CMS  10.4
FileListController.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
18 use Psr\Log\LoggerAwareInterface;
19 use Psr\Log\LoggerAwareTrait;
49 
54 class ‪FileListController extends ‪ActionController implements LoggerAwareInterface
55 {
56  use LoggerAwareTrait;
57 
58  public const ‪UPLOAD_ACTION_REPLACE = 'replace';
59  public const ‪UPLOAD_ACTION_RENAME = 'rename';
60  public const ‪UPLOAD_ACTION_SKIP = 'cancel';
61 
65  protected ‪$MOD_MENU = [];
66 
70  protected ‪$MOD_SETTINGS = [];
71 
77  protected ‪$id;
78 
82  protected ‪$folderObject;
83 
87  protected ‪$errorMessage;
88 
94  protected ‪$pointer;
95 
101  protected ‪$imagemode;
102 
106  protected ‪$cmd;
107 
114  protected ‪$overwriteExistingFiles;
115 
121  protected ‪$filelist;
122 
128  protected ‪$moduleName = 'file_list';
129 
133  protected ‪$fileRepository;
134 
138  protected ‪$view;
139 
145  protected ‪$defaultViewObjectName = BackendTemplateView::class;
146 
151  {
152  $this->fileRepository = ‪$fileRepository;
153  }
154 
161  public function ‪initializeObject()
162  {
163  $this->‪getLanguageService()->‪includeLLFile('EXT:filelist/Resources/Private/Language/locallang_mod_file_list.xlf');
164  $this->‪getLanguageService()->‪includeLLFile('EXT:core/Resources/Private/Language/locallang_misc.xlf');
165 
166  // Setting GPvars:
167  $this->id = ($combinedIdentifier = GeneralUtility::_GP('id'));
168  $this->pointer = GeneralUtility::_GP('pointer');
169  $this->imagemode = GeneralUtility::_GP('imagemode');
170  $this->cmd = GeneralUtility::_GP('cmd');
171  $this->overwriteExistingFiles = ‪DuplicationBehavior::cast(GeneralUtility::_GP('overwriteExistingFiles'));
172 
173  try {
174  if ($combinedIdentifier) {
176  $resourceFactory = GeneralUtility::makeInstance(ResourceFactory::class);
177  $storage = $resourceFactory->getStorageObjectFromCombinedIdentifier($combinedIdentifier);
178  $identifier = substr($combinedIdentifier, strpos($combinedIdentifier, ':') + 1);
179  if (!$storage->hasFolder($identifier)) {
180  $identifier = $storage->getFolderIdentifierFromFileIdentifier($identifier);
181  }
182 
183  $this->folderObject = $resourceFactory->getFolderObjectFromCombinedIdentifier($storage->getUid() . ':' . $identifier);
184  // Disallow access to fallback storage 0
185  if ($storage->getUid() === 0) {
187  'You are not allowed to access files outside your storages',
188  1434539815
189  );
190  }
191  // Disallow the rendering of the processing folder (e.g. could be called manually)
192  if ($this->folderObject && $storage->isProcessingFolder($this->folderObject)) {
193  $this->folderObject = $storage->getRootLevelFolder();
194  }
195  } else {
196  // Take the first object of the first storage
197  $fileStorages = $this->‪getBackendUser()->‪getFileStorages();
198  $fileStorage = reset($fileStorages);
199  if ($fileStorage) {
200  $this->folderObject = $fileStorage->getRootLevelFolder();
201  } else {
202  throw new \RuntimeException('Could not find any folder to be displayed.', 1349276894);
203  }
204  }
205 
206  if ($this->folderObject && !$this->folderObject->getStorage()->isWithinFileMountBoundaries($this->folderObject)) {
207  throw new \RuntimeException('Folder not accessible.', 1430409089);
208  }
209  } catch (InsufficientFolderAccessPermissionsException $permissionException) {
210  $this->folderObject = null;
211  $this->errorMessage = GeneralUtility::makeInstance(
212  FlashMessage::class,
213  sprintf(
214  $this->‪getLanguageService()->getLL('missingFolderPermissionsMessage'),
215  $this->id
216  ),
217  $this->‪getLanguageService()->getLL('missingFolderPermissionsTitle'),
219  );
220  } catch (Exception $fileException) {
221  // Set folder object to null and throw a message later on
222  $this->folderObject = null;
223  // Take the first object of the first storage
224  $fileStorages = $this->‪getBackendUser()->‪getFileStorages();
225  $fileStorage = reset($fileStorages);
226  if ($fileStorage instanceof ResourceStorage) {
227  $this->folderObject = $fileStorage->getRootLevelFolder();
228  if (!$fileStorage->isWithinFileMountBoundaries($this->folderObject)) {
229  $this->folderObject = null;
230  }
231  }
232  $this->errorMessage = GeneralUtility::makeInstance(
233  FlashMessage::class,
234  sprintf(
235  $this->‪getLanguageService()->getLL('folderNotFoundMessage'),
236  $this->id
237  ),
238  $this->‪getLanguageService()->getLL('folderNotFoundTitle'),
240  );
241  } catch (\RuntimeException $e) {
242  $this->folderObject = null;
243  $this->errorMessage = GeneralUtility::makeInstance(
244  FlashMessage::class,
245  $e->getMessage() . ' (' . $e->getCode() . ')',
246  $this->getLanguageService()->getLL('folderNotFoundTitle'),
248  );
249  }
250 
251  if ($this->folderObject && !$this->folderObject->getStorage()->checkFolderActionPermission(
252  'read',
253  $this->folderObject
254  )
255  ) {
256  $this->folderObject = null;
257  }
258 
259  // Configure the "menu" - which is used internally to save the values of sorting, displayThumbs etc.
260  $this->‪menuConfig();
261  }
262 
266  protected function ‪menuConfig()
267  {
268  // MENU-ITEMS:
269  // If array, then it's a selector box menu
270  // If empty string it's just a variable, that will be saved.
271  // Values NOT in this array will not be saved in the settings-array for the module.
272  $this->MOD_MENU = [
273  'sort' => '',
274  'reverse' => '',
275  'displayThumbs' => '',
276  'clipBoard' => '',
277  'bigControlPanel' => ''
278  ];
279  // CLEANSE SETTINGS
280  $this->MOD_SETTINGS = ‪BackendUtility::getModuleData(
281  $this->MOD_MENU,
282  GeneralUtility::_GP('SET'),
283  $this->moduleName
284  );
285  }
286 
292  protected function ‪initializeView(‪ViewInterface ‪$view)
293  {
295  parent::initializeView(‪$view);
296  $pageRenderer = $this->view->getModuleTemplate()->getPageRenderer();
297  $pageRenderer->loadRequireJsModule('TYPO3/CMS/Filelist/FileListLocalisation');
298  $pageRenderer->loadRequireJsModule('TYPO3/CMS/Filelist/FileList');
299  $pageRenderer->loadRequireJsModule('TYPO3/CMS/Filelist/FileSearch');
300  $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/ContextMenu');
302  if ($this->folderObject instanceof ‪Folder) {
304  'currentFolderHash',
305  'folder' . GeneralUtility::md5int($this->folderObject->getCombinedIdentifier())
306  );
307  }
308  ‪$view->‪assign('currentIdentifier', $this->id);
309  }
310 
311  protected function ‪initializeIndexAction()
312  {
313  // Apply predefined values for hidden checkboxes
314  // Set predefined value for DisplayBigControlPanel:
315  $backendUser = $this->‪getBackendUser();
316  $userTsConfig = $backendUser->getTSConfig();
317  if (($userTsConfig['options.']['file_list.']['enableDisplayBigControlPanel'] ?? '') === 'activated') {
318  $this->MOD_SETTINGS['bigControlPanel'] = true;
319  } elseif (($userTsConfig['options.']['file_list.']['enableDisplayBigControlPanel'] ?? '') === 'deactivated') {
320  $this->MOD_SETTINGS['bigControlPanel'] = false;
321  }
322  // Set predefined value for DisplayThumbnails:
323  if (($userTsConfig['options.']['file_list.']['enableDisplayThumbnails'] ?? '') === 'activated') {
324  $this->MOD_SETTINGS['displayThumbs'] = true;
325  } elseif (($userTsConfig['options.']['file_list.']['enableDisplayThumbnails'] ?? '') === 'deactivated') {
326  $this->MOD_SETTINGS['displayThumbs'] = false;
327  }
328  // Set predefined value for Clipboard:
329  if (($userTsConfig['options.']['file_list.']['enableClipBoard'] ?? '') === 'activated') {
330  $this->MOD_SETTINGS['clipBoard'] = true;
331  } elseif (($userTsConfig['options.']['file_list.']['enableClipBoard'] ?? '') === 'deactivated') {
332  $this->MOD_SETTINGS['clipBoard'] = false;
333  }
334  // If user never opened the list module, set the value for displayThumbs
335  if (!isset($this->MOD_SETTINGS['displayThumbs'])) {
336  $this->MOD_SETTINGS['displayThumbs'] = $backendUser->uc['thumbnailsByDefault'];
337  }
338  if (!isset($this->MOD_SETTINGS['sort'])) {
339  // Set default sorting
340  $this->MOD_SETTINGS['sort'] = 'file';
341  $this->MOD_SETTINGS['reverse'] = 0;
342  }
343  }
344 
345  protected function ‪indexAction()
346  {
347  $pageRenderer = $this->view->getModuleTemplate()->getPageRenderer();
348  $pageRenderer->setTitle($this->‪getLanguageService()->getLL('files'));
349 
350  // There there was access to this file path, continue, make the list
351  if ($this->folderObject) {
352  $this->‪initClipboard();
353  $userTsConfig = $this->‪getBackendUser()->‪getTSConfig();
354  $this->filelist = GeneralUtility::makeInstance(FileList::class);
355  $this->filelist->thumbs = ‪$GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'] && $this->MOD_SETTINGS['displayThumbs'];
356  $CB = GeneralUtility::_GET('CB');
357  if ($this->cmd === 'setCB') {
358  $CB['el'] = $this->filelist->clipObj->cleanUpCBC(array_merge(
359  GeneralUtility::_POST('CBH'),
360  (array)GeneralUtility::_POST('CBC')
361  ), '_FILE');
362  }
363  if (!$this->MOD_SETTINGS['clipBoard']) {
364  $CB['setP'] = 'normal';
365  }
366  $this->filelist->clipObj->setCmd($CB);
367  $this->filelist->clipObj->cleanCurrent();
368  // Saves
369  $this->filelist->clipObj->endClipboard();
370 
371  // If the "cmd" was to delete files from the list (clipboard thing), do that:
372  if ($this->cmd === 'delete') {
373  $items = $this->filelist->clipObj->cleanUpCBC(GeneralUtility::_POST('CBC'), '_FILE', 1);
374  if (!empty($items)) {
375  // Make command array:
376  $FILE = [];
377  foreach ($items as $clipboardIdentifier => $combinedIdentifier) {
378  $FILE['delete'][] = ['data' => $combinedIdentifier];
379  $this->filelist->clipObj->removeElement($clipboardIdentifier);
380  }
381  // Init file processing object for deleting and pass the cmd array.
383  $fileProcessor = GeneralUtility::makeInstance(ExtendedFileUtility::class);
384  $fileProcessor->setActionPermissions();
385  $fileProcessor->setExistingFilesConflictMode($this->overwriteExistingFiles);
386  $fileProcessor->start($FILE);
387  $fileProcessor->processData();
388  // Clean & Save clipboard state
389  $this->filelist->clipObj->cleanCurrent();
390  $this->filelist->clipObj->endClipboard();
391  }
392  }
393  // Start up filelisting object, include settings.
394  $this->filelist->start(
395  $this->folderObject,
396  ‪MathUtility::forceIntegerInRange($this->pointer, 0, 100000),
397  $this->MOD_SETTINGS['sort'],
398  (bool)$this->MOD_SETTINGS['reverse'],
399  (bool)$this->MOD_SETTINGS['clipBoard'],
400  (bool)$this->MOD_SETTINGS['bigControlPanel']
401  );
402  // Generate the list, if accessible
403  if ($this->folderObject->getStorage()->isBrowsable()) {
404  $this->view->assign('listHtml', $this->filelist->getTable());
405  } else {
406  $this->‪addFlashMessage(
407  $this->‪getLanguageService()->getLL('storageNotBrowsableMessage'),
408  $this->‪getLanguageService()->getLL('storageNotBrowsableTitle'),
410  );
411  }
412 
413  $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/ClipboardComponent');
414  $pageRenderer->loadRequireJsModule('TYPO3/CMS/Filelist/FileDelete');
415  $pageRenderer->addInlineLanguageLabelFile('EXT:backend/Resources/Private/Language/locallang_alt_doc.xlf', 'buttons');
416 
417  // Include DragUploader only if we have write access
418  if ($this->folderObject->getStorage()->checkUserActionPermission('add', 'File')
419  && $this->folderObject->checkActionPermission('write')
420  ) {
421  $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/DragUploader');
422  $pageRenderer->addInlineLanguageLabelFile('EXT:core/Resources/Private/Language/locallang_core.xlf', 'file_upload');
423  $pageRenderer->addInlineLanguageLabelArray([
424  'permissions.read' => $this->‪getLanguageService()->getLL('read'),
425  'permissions.write' => $this->‪getLanguageService()->getLL('write'),
426  ]);
427  }
428 
429  // Setting up the buttons
430  $this->‪registerButtons();
431 
432  $pageRecord = [
433  '_additional_info' => $this->filelist->getFolderInfo(),
434  'combined_identifier' => $this->folderObject->getCombinedIdentifier(),
435  ];
436  $this->view->getModuleTemplate()->getDocHeaderComponent()->setMetaInformation($pageRecord);
437 
438  $this->view->assign('headline', $this->‪getModuleHeadline());
439 
440  $this->view->assign('checkboxes', [
441  'bigControlPanel' => [
442  'enabled' => ($userTsConfig['options.']['file_list.']['enableDisplayBigControlPanel'] ?? '') === 'selectable',
443  'label' => htmlspecialchars($this->‪getLanguageService()->getLL('bigControlPanel')),
445  $this->id,
446  'SET[bigControlPanel]',
447  $this->MOD_SETTINGS['bigControlPanel'] ?? '',
448  '',
449  '',
450  'id="bigControlPanel"'
451  ),
452  ],
453  'displayThumbs' => [
454  'enabled' => ‪$GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'] && ($userTsConfig['options.']['file_list.']['enableDisplayThumbnails'] ?? '') === 'selectable',
455  'label' => htmlspecialchars($this->‪getLanguageService()->getLL('displayThumbs')),
457  $this->id,
458  'SET[displayThumbs]',
459  $this->MOD_SETTINGS['displayThumbs'] ?? '',
460  '',
461  '',
462  'id="checkDisplayThumbs"'
463  ),
464  ],
465  'enableClipBoard' => [
466  'enabled' => ($userTsConfig['options.']['file_list.']['enableClipBoard'] ?? '') === 'selectable',
467  'label' => htmlspecialchars($this->‪getLanguageService()->getLL('clipBoard')),
469  $this->id,
470  'SET[clipBoard]',
471  $this->MOD_SETTINGS['clipBoard'] ?? '',
472  '',
473  '',
474  'id="checkClipBoard"'
475  ),
476  ]
477  ]);
478  $this->view->assign('showClipBoard', (bool)$this->MOD_SETTINGS['clipBoard']);
479  $this->view->assign('clipBoardHtml', $this->filelist->clipObj->printClipboard());
480  $this->view->assign('folderIdentifier', $this->folderObject->getCombinedIdentifier());
481  $this->view->assign('fileDenyPattern', ‪$GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern']);
482  $this->view->assign('maxFileSize', GeneralUtility::getMaxUploadFileSize() * 1024);
483  $this->view->assign('defaultAction', $this->‪getDefaultAction());
485  } else {
486  $this->‪forward('missingFolder');
487  }
488  }
489 
490  protected function ‪getDefaultAction(): string
491  {
492  $defaultAction = $this->‪getBackendUser()->‪getTSConfig()
493  ['options.']['file_list.']['uploader.']['defaultAction'] ?? '';
494 
495  if ($defaultAction === '') {
496  $defaultAction = ‪self::UPLOAD_ACTION_SKIP;
497  }
498  if (!in_array($defaultAction, [
499  self::UPLOAD_ACTION_REPLACE,
500  self::UPLOAD_ACTION_RENAME,
501  self::UPLOAD_ACTION_SKIP
502  ], true)) {
503  $this->logger->warning(sprintf(
504  'TSConfig: options.file_list.uploader.defaultAction contains an invalid value ("%s"), fallback to default value: "%s"',
505  $defaultAction,
506  self::UPLOAD_ACTION_SKIP
507  ));
508  $defaultAction = ‪self::UPLOAD_ACTION_SKIP;
509  }
510  return $defaultAction;
511  }
512 
513  protected function ‪missingFolderAction()
514  {
515  if ($this->errorMessage) {
516  $this->errorMessage->setSeverity(‪FlashMessage::ERROR);
517  $this->controllerContext->getFlashMessageQueue('core.template.flashMessages')->addMessage($this->errorMessage);
518  }
519  }
520 
526  protected function ‪searchAction($searchWord = '')
527  {
528  if (empty($searchWord)) {
529  $this->‪forward('index');
530  }
531  $searchDemand = ‪FileSearchDemand::createForSearchTerm($searchWord)->withRecursive();
532  $files = $this->folderObject->searchFiles($searchDemand);
533 
534  $fileFacades = [];
535  if (count($files) === 0) {
536  $this->controllerContext->getFlashMessageQueue('core.template.flashMessages')->addMessage(
537  new FlashMessage(
538  ‪LocalizationUtility::translate('flashmessage.no_results', 'filelist') ?? '',
539  '',
541  )
542  );
543  } else {
544  foreach ($files as $file) {
545  $fileFacades[] = new FileFacade($file);
546  }
547  }
548 
549  ‪$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
550 
551  $thumbnailConfiguration = GeneralUtility::makeInstance(ThumbnailConfiguration::class);
552  $this->view->assign('thumbnail', [
553  'width' => $thumbnailConfiguration->getWidth(),
554  'height' => $thumbnailConfiguration->getHeight(),
555  ]);
556 
557  $this->view->assign('searchWord', $searchWord);
558  $this->view->assign('files', $fileFacades);
559  $this->view->assign('deleteUrl', (string)‪$uriBuilder->buildUriFromRoute('tce_file'));
560  $this->view->assign('settings', [
561  'jsConfirmationDelete' => $this->‪getBackendUser()->jsConfirmation(‪JsConfirmation::DELETE)
562  ]);
563  $this->view->assign('moduleSettings', $this->MOD_SETTINGS);
564 
565  $pageRenderer = $this->view->getModuleTemplate()->getPageRenderer();
566  $pageRenderer->loadRequireJsModule('TYPO3/CMS/Filelist/FileDelete');
567  $pageRenderer->addInlineLanguageLabelFile('EXT:backend/Resources/Private/Language/locallang_alt_doc.xlf', 'buttons');
568 
569  $this->‪initClipboard();
570  $this->‪buildListOptionCheckboxes($searchWord);
571  }
572 
579  protected function ‪getModuleHeadline()
580  {
581  $name = $this->folderObject->getName();
582  if ($name === '') {
583  // Show storage name on storage root
584  if ($this->folderObject->getIdentifier() === '/') {
585  $name = $this->folderObject->getStorage()->getName();
586  }
587  } else {
589  [$name => $this->folderObject]
590  ));
591  }
592  return $name;
593  }
594 
600  protected function ‪registerDocHeaderButtons()
601  {
603  $buttonBar = $this->view->getModuleTemplate()->getDocHeaderComponent()->getButtonBar();
604 
605  // CSH
606  $cshButton = $buttonBar->makeHelpButton()
607  ->setModuleName('xMOD_csh_corebe')
608  ->setFieldName('filelist_module');
609  $buttonBar->addButton($cshButton);
610  }
611 
615  protected function ‪registerButtons()
616  {
618  $buttonBar = $this->view->getModuleTemplate()->getDocHeaderComponent()->getButtonBar();
619 
621  $iconFactory = $this->view->getModuleTemplate()->getIconFactory();
622 
623  $resourceFactory = GeneralUtility::makeInstance(ResourceFactory::class);
624 
625  $lang = $this->‪getLanguageService();
626 
627  ‪$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
628 
629  // Refresh page
630  $refreshLink = GeneralUtility::linkThisScript(
631  [
632  'target' => rawurlencode($this->folderObject->getCombinedIdentifier()),
633  'imagemode' => $this->filelist->thumbs
634  ]
635  );
636  $refreshButton = $buttonBar->makeLinkButton()
637  ->setHref($refreshLink)
638  ->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.reload'))
639  ->setIcon($iconFactory->getIcon('actions-refresh', ‪Icon::SIZE_SMALL));
640  $buttonBar->addButton($refreshButton, ‪ButtonBar::BUTTON_POSITION_RIGHT);
641 
642  // Level up
643  try {
644  $currentStorage = $this->folderObject->getStorage();
645  $parentFolder = $this->folderObject->getParentFolder();
646  if ($parentFolder->getIdentifier() !== $this->folderObject->getIdentifier()
647  && $currentStorage->isWithinFileMountBoundaries($parentFolder)
648  ) {
649  $levelUpButton = $buttonBar->makeLinkButton()
650  ->setDataAttributes([
651  'tree-update-request' => htmlspecialchars('folder' . GeneralUtility::md5int($parentFolder->getCombinedIdentifier())),
652  ])
653  ->setHref((string)‪$uriBuilder->buildUriFromRoute('file_FilelistList', ['id' => $parentFolder->getCombinedIdentifier()]))
654  ->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.upOneLevel'))
655  ->setIcon($iconFactory->getIcon('actions-view-go-up', ‪Icon::SIZE_SMALL));
656  $buttonBar->addButton($levelUpButton, ‪ButtonBar::BUTTON_POSITION_LEFT, 1);
657  }
658  } catch (\Exception $e) {
659  }
660 
661  // Shortcut
662  if ($this->‪getBackendUser()->mayMakeShortcut()) {
663  $shortCutButton = $buttonBar->makeShortcutButton()->setModuleName('file_FilelistList');
664  $buttonBar->addButton($shortCutButton, ‪ButtonBar::BUTTON_POSITION_RIGHT);
665  }
666 
667  // Upload button (only if upload to this directory is allowed)
668  if ($this->folderObject && $this->folderObject->getStorage()->checkUserActionPermission(
669  'add',
670  'File'
671  ) && $this->folderObject->checkActionPermission('write')
672  ) {
673  $uploadButton = $buttonBar->makeLinkButton()
674  ->setHref((string)‪$uriBuilder->buildUriFromRoute(
675  'file_upload',
676  [
677  'target' => $this->folderObject->getCombinedIdentifier(),
678  'returnUrl' => $this->filelist->listURL(),
679  ]
680  ))
681  ->setClasses('t3js-drag-uploader-trigger')
682  ->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.upload'))
683  ->setIcon($iconFactory->getIcon('actions-edit-upload', ‪Icon::SIZE_SMALL));
684  $buttonBar->addButton($uploadButton, ‪ButtonBar::BUTTON_POSITION_LEFT, 1);
685  }
686 
687  // New folder button
688  if ($this->folderObject && $this->folderObject->checkActionPermission('write')
689  && ($this->folderObject->getStorage()->checkUserActionPermission(
690  'add',
691  'File'
692  ) || $this->folderObject->checkActionPermission('add'))
693  ) {
694  $newButton = $buttonBar->makeLinkButton()
695  ->setHref((string)‪$uriBuilder->buildUriFromRoute(
696  'file_newfolder',
697  [
698  'target' => $this->folderObject->getCombinedIdentifier(),
699  'returnUrl' => $this->filelist->listURL(),
700  ]
701  ))
702  ->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.new'))
703  ->setIcon($iconFactory->getIcon('actions-add', ‪Icon::SIZE_SMALL));
704  $buttonBar->addButton($newButton, ‪ButtonBar::BUTTON_POSITION_LEFT, 1);
705  }
706 
707  // Add paste button if clipboard is initialized
708  if ($this->filelist->clipObj instanceof Clipboard && $this->folderObject->checkActionPermission('write')) {
709  $elFromTable = $this->filelist->clipObj->elFromTable('_FILE');
710  if (!empty($elFromTable)) {
711  $addPasteButton = true;
712  $elToConfirm = [];
713  foreach ($elFromTable as $key => $element) {
714  $clipBoardElement = $resourceFactory->retrieveFileOrFolderObject($element);
715  if ($clipBoardElement instanceof Folder && $clipBoardElement->getStorage()->isWithinFolder(
716  $clipBoardElement,
717  $this->folderObject
718  )
719  ) {
720  $addPasteButton = false;
721  }
722  $elToConfirm[$key] = $clipBoardElement->getName();
723  }
724  if ($addPasteButton) {
725  $confirmText = $this->filelist->clipObj
726  ->confirmMsgText('_FILE', $this->folderObject->getReadablePath(), 'into', $elToConfirm);
727  $pasteButton = $buttonBar->makeLinkButton()
728  ->setHref($this->filelist->clipObj
729  ->pasteUrl('_FILE', $this->folderObject->getCombinedIdentifier()))
730  ->setClasses('t3js-modal-trigger')
731  ->setDataAttributes([
732  'severity' => 'warning',
733  'content' => $confirmText,
734  'title' => $lang->getLL('clip_paste')
735  ])
736  ->setTitle($lang->getLL('clip_paste'))
737  ->setIcon($iconFactory->getIcon('actions-document-paste-into', ‪Icon::SIZE_SMALL));
738  $buttonBar->addButton($pasteButton, ‪ButtonBar::BUTTON_POSITION_LEFT, 2);
739  }
740  }
741  }
742  }
743 
749  protected function ‪getLanguageService(): LanguageService
750  {
751  return ‪$GLOBALS['LANG'];
752  }
753 
759  protected function ‪getBackendUser(): ‪BackendUserAuthentication
760  {
761  return ‪$GLOBALS['BE_USER'];
762  }
763 
767  protected function ‪buildListOptionCheckboxes(string $searchWord = ''): void
768  {
769  $backendUser = $this->‪getBackendUser();
770  $userTsConfig = $backendUser->getTSConfig();
771 
772  $addParams = '';
773  if ($searchWord) {
774  $addParams = '&tx_filelist_file_filelistlist%5Baction%5D=search';
775  $addParams .= '&tx_filelist_file_filelistlist%5Bcontroller%5D=FileList';
776  $addParams .= '&tx_filelist_file_filelistlist%5BsearchWord%5D=' . htmlspecialchars($searchWord);
777  }
778  $this->view->assign('checkboxes', [
779  'bigControlPanel' => [
780  'enabled' => $userTsConfig['options.']['file_list.']['enableDisplayBigControlPanel'] === 'selectable',
781  'label' => htmlspecialchars($this->‪getLanguageService()->getLL('bigControlPanel')),
783  $this->id,
784  'SET[bigControlPanel]',
785  $this->MOD_SETTINGS['bigControlPanel'] ?? '',
786  '',
787  $addParams,
788  'id="bigControlPanel"'
789  ),
790  ],
791  'displayThumbs' => [
792  'enabled' => ‪$GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'] && $userTsConfig['options.']['file_list.']['enableDisplayThumbnails'] === 'selectable',
793  'label' => htmlspecialchars($this->‪getLanguageService()->getLL('displayThumbs')),
795  $this->id,
796  'SET[displayThumbs]',
797  $this->MOD_SETTINGS['displayThumbs'] ?? '',
798  '',
799  $addParams,
800  'id="checkDisplayThumbs"'
801  ),
802  ],
803  'enableClipBoard' => [
804  'enabled' => $userTsConfig['options.']['file_list.']['enableClipBoard'] === 'selectable',
805  'label' => htmlspecialchars($this->‪getLanguageService()->getLL('clipBoard')),
807  $this->id,
808  'SET[clipBoard]',
809  $this->MOD_SETTINGS['clipBoard'] ?? '',
810  '',
811  $addParams,
812  'id="checkClipBoard"'
813  ),
814  ]
815  ]);
816  }
817 
821  protected function ‪initClipboard(): void
822  {
823  // Create fileListing object
824  $this->filelist = GeneralUtility::makeInstance(FileList::class, $this);
825  $this->filelist->thumbs = ‪$GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'] && $this->MOD_SETTINGS['displayThumbs'];
826  // Create clipboard object and initialize that
827  $this->filelist->clipObj = GeneralUtility::makeInstance(Clipboard::class);
828  $this->filelist->clipObj->fileMode = true;
829  $this->filelist->clipObj->initializeClipboard();
830  $CB = GeneralUtility::_GET('CB');
831  if ($this->cmd === 'setCB') {
832  $CB['el'] = $this->filelist->clipObj->cleanUpCBC(array_merge(
833  GeneralUtility::_POST('CBH'),
834  (array)GeneralUtility::_POST('CBC')
835  ), '_FILE');
836  }
837  if (!$this->MOD_SETTINGS['clipBoard']) {
838  $CB['setP'] = 'normal';
839  }
840  $this->filelist->clipObj->setCmd($CB);
841  $this->filelist->clipObj->cleanCurrent();
842  // Saves
843  $this->filelist->clipObj->endClipboard();
844 
845  $this->view->assign('showClipBoard', (bool)$this->MOD_SETTINGS['clipBoard']);
846  $this->view->assign('clipBoardHtml', $this->filelist->clipObj->printClipboard());
847  }
848 }
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication\evaluateUserSpecificFileFilterSettings
‪evaluateUserSpecificFileFilterSettings()
Definition: BackendUserAuthentication.php:1798
‪TYPO3\CMS\Core\Imaging\Icon\SIZE_SMALL
‪const SIZE_SMALL
Definition: Icon.php:30
‪TYPO3\CMS\Filelist\Configuration\ThumbnailConfiguration
Definition: ThumbnailConfiguration.php:27
‪TYPO3\CMS\Filelist\Controller\FileListController\getDefaultAction
‪getDefaultAction()
Definition: FileListController.php:476
‪TYPO3\CMS\Extbase\Mvc\Controller\ActionController\forward
‪forward($actionName, $controllerName=null, $extensionName=null, array $arguments=null)
Definition: ActionController.php:815
‪TYPO3\CMS\Filelist\Controller\FileListController\$imagemode
‪string $imagemode
Definition: FileListController.php:94
‪TYPO3\CMS\Filelist\Controller\FileListController\UPLOAD_ACTION_SKIP
‪const UPLOAD_ACTION_SKIP
Definition: FileListController.php:60
‪TYPO3\CMS\Core\Localization\LanguageService\includeLLFile
‪array includeLLFile($fileRef, $setGlobal=null, $mergeLocalOntoDefault=null)
Definition: LanguageService.php:297
‪TYPO3\CMS\Backend\Template\Components\ButtonBar\BUTTON_POSITION_LEFT
‪const BUTTON_POSITION_LEFT
Definition: ButtonBar.php:36
‪TYPO3\CMS\Backend\Template\Components\ButtonBar
Definition: ButtonBar.php:32
‪TYPO3\CMS\Core\Resource\DuplicationBehavior
Definition: DuplicationBehavior.php:24
‪TYPO3\CMS\Filelist\Controller\FileListController\initializeObject
‪initializeObject()
Definition: FileListController.php:147
‪TYPO3\CMS\Extbase\Utility\LocalizationUtility
Definition: LocalizationUtility.php:33
‪TYPO3\CMS\Core\Resource\Exception\InsufficientFolderAccessPermissionsException
Definition: InsufficientFolderAccessPermissionsException.php:24
‪TYPO3\CMS\Backend\Clipboard\Clipboard
Definition: Clipboard.php:43
‪TYPO3\CMS\Core\Imaging\Icon
Definition: Icon.php:26
‪TYPO3\CMS\Filelist\Controller\FileListController\$overwriteExistingFiles
‪TYPO3 CMS Core Resource DuplicationBehavior $overwriteExistingFiles
Definition: FileListController.php:105
‪TYPO3\CMS\Filelist\Controller\FileListController\searchAction
‪searchAction($searchWord='')
Definition: FileListController.php:512
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication\getTSConfig
‪array getTSConfig()
Definition: BackendUserAuthentication.php:1217
‪TYPO3\CMS\Filelist\Controller\FileListController\$filelist
‪FileList $filelist
Definition: FileListController.php:111
‪TYPO3\CMS\Core\Utility\MathUtility\forceIntegerInRange
‪static int forceIntegerInRange($theInt, $min, $max=2000000000, $defaultValue=0)
Definition: MathUtility.php:32
‪TYPO3\CMS\Filelist\Controller\FileListController\initializeView
‪initializeView(ViewInterface $view)
Definition: FileListController.php:278
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:33
‪TYPO3\CMS\Extbase\Mvc\Controller\ActionController\addFlashMessage
‪addFlashMessage($messageBody, $messageTitle='', $severity=AbstractMessage::OK, $storeInSession=true)
Definition: ActionController.php:747
‪TYPO3\CMS\Core\Resource\Utility\ListUtility
Definition: ListUtility.php:25
‪TYPO3\CMS\Filelist\Controller\FileListController\menuConfig
‪menuConfig()
Definition: FileListController.php:252
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication\getFileStorages
‪TYPO3 CMS Core Resource ResourceStorage[] getFileStorages()
Definition: BackendUserAuthentication.php:1784
‪TYPO3\CMS\Filelist\FileFacade
Definition: FileFacade.php:38
‪TYPO3\CMS\Core\Type\Bitmask\JsConfirmation\DELETE
‪const DELETE
Definition: JsConfirmation.php:39
‪TYPO3\CMS\Filelist\Controller\FileListController\buildListOptionCheckboxes
‪buildListOptionCheckboxes(string $searchWord='')
Definition: FileListController.php:753
‪TYPO3\CMS\Core\Resource\Folder\getStorage
‪ResourceStorage getStorage()
Definition: Folder.php:149
‪TYPO3\CMS\Core\Type\Enumeration\cast
‪static static cast($value)
Definition: Enumeration.php:186
‪TYPO3\CMS\Core\Utility\File\ExtendedFileUtility
Definition: ExtendedFileUtility.php:70
‪TYPO3\CMS\Backend\View\BackendTemplateView\assign
‪TYPO3 CMS Fluid View AbstractTemplateView assign($key, $value)
Definition: BackendTemplateView.php:94
‪TYPO3\CMS\Filelist\Controller\FileListController\registerButtons
‪registerButtons()
Definition: FileListController.php:601
‪TYPO3\CMS\Filelist\Controller\FileListController\getLanguageService
‪LanguageService getLanguageService()
Definition: FileListController.php:735
‪TYPO3\CMS\Filelist\Controller\FileListController\injectFileRepository
‪injectFileRepository(FileRepository $fileRepository)
Definition: FileListController.php:136
‪TYPO3\CMS\Filelist\Controller
‪TYPO3\CMS\Filelist\FileList
Definition: FileList.php:47
‪TYPO3\CMS\Core\Resource\FileRepository
Definition: FileRepository.php:33
‪TYPO3\CMS\Filelist\Controller\FileListController\UPLOAD_ACTION_RENAME
‪const UPLOAD_ACTION_RENAME
Definition: FileListController.php:59
‪TYPO3\CMS\Filelist\Controller\FileListController
Definition: FileListController.php:55
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand
Definition: FileSearchDemand.php:26
‪TYPO3\CMS\Filelist\Controller\FileListController\$view
‪BackendTemplateView $view
Definition: FileListController.php:125
‪TYPO3\CMS\Backend\Routing\UriBuilder
Definition: UriBuilder.php:38
‪TYPO3\CMS\Extbase\Mvc\Controller\ActionController\$uriBuilder
‪TYPO3 CMS Extbase Mvc Web Routing UriBuilder $uriBuilder
Definition: ActionController.php:127
‪TYPO3\CMS\Core\Resource\Folder
Definition: Folder.php:37
‪TYPO3\CMS\Core\Resource\ResourceFactory
Definition: ResourceFactory.php:41
‪TYPO3\CMS\Core\Resource\ResourceStorage\isWithinFolder
‪bool isWithinFolder(Folder $folder, ResourceInterface $resource)
Definition: ResourceStorage.php:2596
‪TYPO3\CMS\Backend\Utility\BackendUtility\getModuleData
‪static array getModuleData( $MOD_MENU, $CHANGED_SETTINGS, $modName, $type='', $dontValidateList='', $setDefaultList='')
Definition: BackendUtility.php:2893
‪TYPO3\CMS\Backend\Utility\BackendUtility\getFuncCheck
‪static string getFuncCheck( $mainParams, $elementName, $currentValue, $script='', $addParams='', $tagParams='')
Definition: BackendUtility.php:2709
‪TYPO3\CMS\Filelist\Controller\FileListController\$fileRepository
‪TYPO3 CMS Core Resource FileRepository $fileRepository
Definition: FileListController.php:121
‪TYPO3\CMS\Extbase\Utility\LocalizationUtility\translate
‪static string null translate(string $key, ?string $extensionName=null, array $arguments=null, string $languageKey=null, array $alternativeLanguageKeys=null)
Definition: LocalizationUtility.php:67
‪TYPO3\CMS\Filelist\Controller\FileListController\indexAction
‪indexAction()
Definition: FileListController.php:331
‪TYPO3\CMS\Filelist\Controller\FileListController\missingFolderAction
‪missingFolderAction()
Definition: FileListController.php:499
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Filelist\Controller\FileListController\$moduleName
‪string $moduleName
Definition: FileListController.php:117
‪TYPO3\CMS\Filelist\Controller\FileListController\UPLOAD_ACTION_REPLACE
‪const UPLOAD_ACTION_REPLACE
Definition: FileListController.php:58
‪TYPO3\CMS\Extbase\Mvc\View\ViewInterface
Definition: ViewInterface.php:24
‪TYPO3\CMS\Filelist\Controller\FileListController\initializeIndexAction
‪initializeIndexAction()
Definition: FileListController.php:297
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:75
‪TYPO3\CMS\Filelist\Controller\FileListController\$MOD_SETTINGS
‪array $MOD_SETTINGS
Definition: FileListController.php:68
‪TYPO3\CMS\Filelist\Controller\FileListController\initClipboard
‪initClipboard()
Definition: FileListController.php:807
‪TYPO3\CMS\Filelist\Controller\FileListController\$id
‪string $id
Definition: FileListController.php:74
‪TYPO3\CMS\Filelist\Controller\FileListController\getBackendUser
‪BackendUserAuthentication getBackendUser()
Definition: FileListController.php:745
‪TYPO3\CMS\Core\Resource\Exception
Definition: Exception.php:22
‪TYPO3\CMS\Backend\View\BackendTemplateView
Definition: BackendTemplateView.php:28
‪TYPO3\CMS\Core\Messaging\AbstractMessage\INFO
‪const INFO
Definition: AbstractMessage.php:28
‪TYPO3\CMS\Core\Resource\ResourceStorage
Definition: ResourceStorage.php:122
‪TYPO3\CMS\Core\Messaging\FlashMessage
Definition: FlashMessage.php:24
‪TYPO3\CMS\Filelist\Controller\FileListController\getModuleHeadline
‪string getModuleHeadline()
Definition: FileListController.php:565
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Filelist\Controller\FileListController\$pointer
‪int $pointer
Definition: FileListController.php:88
‪TYPO3\CMS\Extbase\Mvc\Controller\ActionController
Definition: ActionController.php:55
‪TYPO3\CMS\Core\Utility\MathUtility
Definition: MathUtility.php:22
‪TYPO3\CMS\Core\Messaging\AbstractMessage\NOTICE
‪const NOTICE
Definition: AbstractMessage.php:27
‪TYPO3\CMS\Filelist\Controller\FileListController\$MOD_MENU
‪array $MOD_MENU
Definition: FileListController.php:64
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:42
‪TYPO3\CMS\Filelist\Controller\FileListController\$cmd
‪string $cmd
Definition: FileListController.php:98
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\Resource\Search\FileSearchDemand\createForSearchTerm
‪static createForSearchTerm(string $searchTerm)
Definition: FileSearchDemand.php:70
‪TYPO3\CMS\Filelist\Controller\FileListController\$errorMessage
‪FlashMessage $errorMessage
Definition: FileListController.php:82
‪TYPO3\CMS\Backend\Template\Components\ButtonBar\BUTTON_POSITION_RIGHT
‪const BUTTON_POSITION_RIGHT
Definition: ButtonBar.php:41
‪TYPO3\CMS\Core\Resource\Utility\ListUtility\resolveSpecialFolderNames
‪static array resolveSpecialFolderNames(array $folders)
Definition: ListUtility.php:32
‪TYPO3\CMS\Core\Type\Bitmask\JsConfirmation
Definition: JsConfirmation.php:25
‪TYPO3\CMS\Core\Resource\Exception
Definition: AbstractFileOperationException.php:16
‪TYPO3\CMS\Core\Messaging\AbstractMessage\ERROR
‪const ERROR
Definition: AbstractMessage.php:31
‪TYPO3\CMS\Filelist\Controller\FileListController\$defaultViewObjectName
‪string $defaultViewObjectName
Definition: FileListController.php:131
‪TYPO3\CMS\Filelist\Controller\FileListController\registerDocHeaderButtons
‪registerDocHeaderButtons()
Definition: FileListController.php:586
‪TYPO3\CMS\Filelist\Controller\FileListController\$folderObject
‪Folder $folderObject
Definition: FileListController.php:78