[!!!][TASK] Deprecate IconUtility
[Packages/TYPO3.CMS.git] / typo3 / sysext / filelist / Classes / FileList.php
1 <?php
2 namespace TYPO3\CMS\Filelist;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
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.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Backend\Clipboard\Clipboard;
18 use TYPO3\CMS\Backend\Configuration\TranslationConfigurationProvider;
19 use TYPO3\CMS\Backend\RecordList\AbstractRecordList;
20 use TYPO3\CMS\Backend\Utility\BackendUtility;
21 use TYPO3\CMS\Core\Database\DatabaseConnection;
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\File;
26 use TYPO3\CMS\Core\Resource\Folder;
27 use TYPO3\CMS\Core\Resource\InaccessibleFolder;
28 use TYPO3\CMS\Core\Resource\ProcessedFile;
29 use TYPO3\CMS\Core\Resource\ResourceFactory;
30 use TYPO3\CMS\Core\Resource\Utility\ListUtility;
31 use TYPO3\CMS\Core\Type\Bitmask\JsConfirmation;
32 use TYPO3\CMS\Core\Utility\GeneralUtility;
33 use TYPO3\CMS\Core\Resource\FolderInterface;
34 use TYPO3\CMS\Filelist\Controller\FileListController;
35
36 /**
37 * Class for rendering of File>Filelist
38 */
39 class FileList extends AbstractRecordList {
40
41 /**
42 * Default Max items shown
43 *
44 * @var int
45 */
46 public $iLimit = 40;
47
48 /**
49 * Thumbnails on records containing files (pictures)
50 *
51 * @var bool
52 */
53 public $thumbs = FALSE;
54
55 /**
56 * Space icon used for alignment when no button is available
57 *
58 * @var string
59 */
60 public $spaceIcon;
61
62 /**
63 * Max length of strings
64 *
65 * @var int
66 */
67 public $fixedL = 30;
68
69 /**
70 * If TRUE click menus are generated on files and folders
71 *
72 * @var bool
73 */
74 public $clickMenus = 1;
75
76 /**
77 * The field to sort by
78 *
79 * @var string
80 */
81 public $sort = '';
82
83 /**
84 * Reverse sorting flag
85 *
86 * @var bool
87 */
88 public $sortRev = 1;
89
90 /**
91 * @var int
92 */
93 public $firstElementNumber = 0;
94
95 /**
96 * @var bool
97 */
98 public $clipBoard = 0;
99
100 /**
101 * @var bool
102 */
103 public $bigControlPanel = 0;
104
105 /**
106 * @var string
107 */
108 public $JScode = '';
109
110 /**
111 * @var string
112 */
113 public $HTMLcode = '';
114
115 /**
116 * @var int
117 */
118 public $totalbytes = 0;
119
120 /**
121 * @var array
122 */
123 public $dirs = array();
124
125 /**
126 * @var array
127 */
128 public $files = array();
129
130 /**
131 * @var string
132 */
133 public $path = '';
134
135 /**
136 * @var Folder
137 */
138 protected $folderObject;
139
140 /**
141 * Counting the elements no matter what
142 *
143 * @var int
144 */
145 public $eCounter = 0;
146
147 /**
148 * @var string
149 */
150 public $totalItems = '';
151
152 /**
153 * @var array
154 */
155 public $CBnames = array();
156
157 /**
158 * @var Clipboard $clipObj
159 */
160 public $clipObj;
161
162 /**
163 * @var ResourceFactory
164 */
165 protected $resourceFactory;
166
167 /**
168 * @param ResourceFactory $resourceFactory
169 */
170 public function injectResourceFactory(ResourceFactory $resourceFactory) {
171 $this->resourceFactory = $resourceFactory;
172 }
173
174 /**
175 * @var IconFactory
176 */
177 protected $iconFactory;
178
179 /**
180 * @var FileListController
181 */
182 protected $fileListController;
183
184 /**
185 * Construct
186 */
187 public function __construct(FileListController $fileListController) {
188 $this->fileListController = $fileListController;
189 $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
190 }
191
192 /**
193 * Initialization of class
194 *
195 * @param Folder $folderObject The folder to work on
196 * @param int $pointer Pointer
197 * @param bool $sort Sorting column
198 * @param bool $sortRev Sorting direction
199 * @param bool $clipBoard
200 * @param bool $bigControlPanel Show clipboard flag
201 * @return void
202 */
203 public function start(Folder $folderObject, $pointer, $sort, $sortRev, $clipBoard = FALSE, $bigControlPanel = FALSE) {
204 $this->folderObject = $folderObject;
205 $this->counter = 0;
206 $this->totalbytes = 0;
207 $this->JScode = '';
208 $this->HTMLcode = '';
209 $this->path = $folderObject->getReadablePath();
210 $this->sort = $sort;
211 $this->sortRev = $sortRev;
212 $this->firstElementNumber = $pointer;
213 $this->clipBoard = $clipBoard;
214 $this->bigControlPanel = $bigControlPanel;
215 // Setting the maximum length of the filenames to the user's settings or minimum 30 (= $this->fixedL)
216 $this->fixedL = max($this->fixedL, $this->getBackendUser()->uc['titleLen']);
217 $this->getLanguageService()->includeLLFile('EXT:lang/locallang_common.xlf');
218 $this->resourceFactory = ResourceFactory::getInstance();
219 }
220
221 /**
222 * Reading files and directories, counting elements and generating the list in ->HTMLcode
223 *
224 * @return void
225 */
226 public function generateList() {
227 $this->HTMLcode .= $this->getTable('fileext,tstamp,size,rw,_REF_');
228 }
229
230 /**
231 * Return the buttons used by the filelist to include in the top header
232 *
233 * @param Folder $folderObject
234 * @return array
235 */
236 public function getButtonsAndOtherMarkers(Folder $folderObject) {
237 $otherMarkers = array(
238 'PAGE_ICON' => '',
239 'TITLE' => ''
240 );
241 $buttons = array(
242 'level_up' => $this->getLinkToParentFolder($folderObject),
243 'refresh' => '',
244 'title' => '',
245 'page_icon' => '',
246 'PASTE' => ''
247 );
248 // Makes the code for the folder icon in the top
249 if ($folderObject) {
250 $title = $folderObject->getReadablePath();
251 // Start compiling the HTML
252 // If this is some subFolder under the mount root....
253 if ($folderObject->getStorage()->isWithinFileMountBoundaries($folderObject)) {
254 // The icon with link
255 $otherMarkers['PAGE_ICON'] = '<span title="' . htmlspecialchars($title) . '">' . $this->iconFactory->getIconForResource($folderObject, Icon::SIZE_SMALL) . '</span>';
256 } else {
257 // This is the root folder
258 $otherMarkers['PAGE_ICON'] = '<span title="' . htmlspecialchars($title) . '">' . $this->iconFactory->getIconForResource($folderObject, Icon::SIZE_SMALL, NULL, array('mount-root' => TRUE)) . '</span>';
259 }
260 $otherMarkers['TITLE'] .= htmlspecialchars(GeneralUtility::fixed_lgd_cs($title, -($this->fixedL + 20)));
261
262 if ($this->clickMenus) {
263 $otherMarkers['PAGE_ICON'] = $this->fileListController->doc->wrapClickMenuOnIcon($otherMarkers['PAGE_ICON'], $folderObject->getCombinedIdentifier());
264 }
265 // Add paste button if clipboard is initialized
266 if ($this->clipObj instanceof Clipboard && $folderObject->checkActionPermission('write')) {
267 $elFromTable = $this->clipObj->elFromTable('_FILE');
268 if (!empty($elFromTable)) {
269 $addPasteButton = TRUE;
270 $elToConfirm = array();
271 foreach ($elFromTable as $key => $element) {
272 $clipBoardElement = $this->resourceFactory->retrieveFileOrFolderObject($element);
273 if ($clipBoardElement instanceof Folder && $clipBoardElement->getStorage()->isWithinFolder($clipBoardElement, $folderObject)) {
274 $addPasteButton = FALSE;
275 }
276 $elToConfirm[$key] = $clipBoardElement->getName();
277 }
278 if ($addPasteButton) {
279 $buttons['PASTE'] = '<a href="' . htmlspecialchars($this->clipObj->pasteUrl('_FILE', $folderObject->getCombinedIdentifier())) . '" onclick="return ' . htmlspecialchars($this->clipObj->confirmMsg('_FILE', $this->path, 'into', $elToConfirm)) . '" title="' . $this->getLanguageService()->getLL('clip_paste', TRUE) . '">' . $this->iconFactory->getIcon('actions-document-paste-after', Icon::SIZE_SMALL) . '</a>';
280 }
281 }
282 }
283
284 }
285 $buttons['refresh'] = '<a href="' . htmlspecialchars($this->listURL()) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.reload', TRUE) . '">' . $this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL) . '</a>';
286 return array($buttons, $otherMarkers);
287 }
288
289 /**
290 * Wrapping input string in a link with clipboard command.
291 *
292 * @param string $string String to be linked - must be htmlspecialchar'ed / prepared before.
293 * @param string $table table - NOT USED
294 * @param string $cmd "cmd" value
295 * @param string $warning Warning for JS confirm message
296 * @return string Linked string
297 */
298 public function linkClipboardHeaderIcon($string, $table, $cmd, $warning = '') {
299 $onClickEvent = 'document.dblistForm.cmd.value=\'' . $cmd . '\';document.dblistForm.submit();';
300 if ($warning) {
301 $onClickEvent = 'if (confirm(' . GeneralUtility::quoteJSvalue($warning) . ')){' . $onClickEvent . '}';
302 }
303 return '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($onClickEvent) . 'return false;">' . $string . '</a>';
304 }
305
306 /**
307 * Returns a table with directories and files listed.
308 *
309 * @param array $rowlist Array of files from path
310 * @return string HTML-table
311 */
312 public function getTable($rowlist) {
313 // prepare space icon
314 $this->spaceIcon = '<span class="btn btn-default disabled">' . $this->iconFactory->getIcon('empty-empty', Icon::SIZE_SMALL) . '</span>';
315
316 // @todo use folder methods directly when they support filters
317 $storage = $this->folderObject->getStorage();
318 $storage->resetFileAndFolderNameFiltersToDefault();
319
320 // Only render the contents of a browsable storage
321 if ($this->folderObject->getStorage()->isBrowsable()) {
322 try {
323 $foldersCount = $storage->countFoldersInFolder($this->folderObject);
324 $filesCount = $storage->countFilesInFolder($this->folderObject);
325 } catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientFolderAccessPermissionsException $e) {
326 $foldersCount = 0;
327 $filesCount = 0;
328 }
329
330 if ($foldersCount <= $this->firstElementNumber) {
331 $foldersFrom = FALSE;
332 $foldersNum = FALSE;
333 } else {
334 $foldersFrom = $this->firstElementNumber;
335 if ($this->firstElementNumber + $this->iLimit > $foldersCount) {
336 $foldersNum = $foldersCount - $this->firstElementNumber;
337 } else {
338 $foldersNum = $this->iLimit;
339 }
340 }
341 if ($foldersCount >= $this->firstElementNumber + $this->iLimit) {
342 $filesFrom = FALSE;
343 $filesNum = FALSE;
344 } else {
345 if ($this->firstElementNumber <= $foldersCount) {
346 $filesFrom = 0;
347 $filesNum = $this->iLimit - $foldersNum;
348 } else {
349 $filesFrom = $this->firstElementNumber - $foldersCount;
350 if ($filesFrom + $this->iLimit > $filesCount) {
351 $filesNum = $filesCount - $filesFrom;
352 } else {
353 $filesNum = $this->iLimit;
354 }
355 }
356 }
357 $folders = $storage->getFoldersInFolder($this->folderObject, $foldersFrom, $foldersNum, TRUE, FALSE, trim($this->sort), (bool)$this->sortRev);
358 $files = $this->folderObject->getFiles($filesFrom, $filesNum, Folder::FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS, FALSE, trim($this->sort), (bool)$this->sortRev);
359 $this->totalItems = $foldersCount + $filesCount;
360 // Adds the code of files/dirs
361 $out = '';
362 $titleCol = 'file';
363 // Cleaning rowlist for duplicates and place the $titleCol as the first column always!
364 $rowlist = '_LOCALIZATION_,' . $rowlist;
365 $rowlist = GeneralUtility::rmFromList($titleCol, $rowlist);
366 $rowlist = GeneralUtility::uniqueList($rowlist);
367 $rowlist = $rowlist ? $titleCol . ',' . $rowlist : $titleCol;
368 if ($this->clipBoard) {
369 $rowlist = str_replace('_LOCALIZATION_,', '_LOCALIZATION_,_CLIPBOARD_,', $rowlist);
370 $this->addElement_tdCssClass['_CLIPBOARD_'] = 'col-clipboard';
371 }
372 if ($this->bigControlPanel) {
373 $rowlist = str_replace('_LOCALIZATION_,', '_LOCALIZATION_,_CONTROL_,', $rowlist);
374 $this->addElement_tdCssClass['_CONTROL_'] = 'col-control';
375 }
376 $this->fieldArray = explode(',', $rowlist);
377
378 // Add classes to table cells
379 $this->addElement_tdCssClass[$titleCol] = 'col-title';
380 $this->addElement_tdCssClass['_LOCALIZATION_'] = 'col-localizationa';
381
382 $folders = ListUtility::resolveSpecialFolderNames($folders);
383
384 $iOut = '';
385 // Directories are added
386 $this->eCounter = $this->firstElementNumber;
387 list($flag, $code) = $this->fwd_rwd_nav();
388 $iOut .= $code;
389
390 $iOut .= $this->formatDirList($folders);
391 // Files are added
392 $iOut .= $this->formatFileList($files);
393
394 $this->eCounter = $this->firstElementNumber + $this->iLimit <= $this->totalItems
395 ? $this->firstElementNumber + $this->iLimit
396 : $this->totalItems;
397 list($flag, $code) = $this->fwd_rwd_nav();
398 $iOut .= $code;
399
400 // Header line is drawn
401 $theData = array();
402 foreach ($this->fieldArray as $v) {
403 if ($v == '_CLIPBOARD_' && $this->clipBoard) {
404 $cells = array();
405 $table = '_FILE';
406 $elFromTable = $this->clipObj->elFromTable($table);
407 if (!empty($elFromTable) && $this->folderObject->checkActionPermission('write')) {
408 $addPasteButton = TRUE;
409 $elToConfirm = array();
410 foreach ($elFromTable as $key => $element) {
411 $clipBoardElement = $this->resourceFactory->retrieveFileOrFolderObject($element);
412 if ($clipBoardElement instanceof Folder && $clipBoardElement->getStorage()->isWithinFolder($clipBoardElement, $this->folderObject)) {
413 $addPasteButton = FALSE;
414 }
415 $elToConfirm[$key] = $clipBoardElement->getName();
416 }
417 if ($addPasteButton) {
418 $cells[] = '<a class="btn btn-default" href="' . htmlspecialchars($this->clipObj->pasteUrl('_FILE', $this->folderObject->getCombinedIdentifier())) . '" onclick="return ' . htmlspecialchars($this->clipObj->confirmMsg('_FILE', $this->path, 'into', $elToConfirm)) . '" title="' . $this->getLanguageService()->getLL('clip_paste', 1) . '">' . $this->iconFactory->getIcon('actions-document-paste-after', Icon::SIZE_SMALL) . '</a>';
419 }
420 }
421 if ($this->clipObj->current !== 'normal' && $iOut) {
422 $cells[] = $this->linkClipboardHeaderIcon('<span title="' . $this->getLanguageService()->getLL('clip_selectMarked', TRUE) . '">' . $this->iconFactory->getIcon('actions-edit-copy', Icon::SIZE_SMALL) . '</span>', $table, 'setCB');
423 $cells[] = $this->linkClipboardHeaderIcon('<span title="' . $this->getLanguageService()->getLL('clip_deleteMarked', TRUE) . '">' . $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL), $table, 'delete', $this->getLanguageService()->getLL('clip_deleteMarkedWarning'));
424 $onClick = 'checkOffCB(\'' . implode(',', $this->CBnames) . '\', this); return false;';
425 $cells[] = '<a class="btn btn-default" rel="" href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . $this->getLanguageService()->getLL('clip_markRecords', TRUE) . '">' . $this->iconFactory->getIcon('actions-document-select', Icon::SIZE_SMALL) . '</a>';
426 }
427 $theData[$v] = implode('', $cells);
428 } else {
429 // Normal row:
430 $theT = $this->linkWrapSort($this->getLanguageService()->getLL('c_' . $v, TRUE), $this->folderObject->getCombinedIdentifier(), $v);
431 $theData[$v] = $theT;
432 }
433 }
434
435 $out .= '<thead>' . $this->addelement(1, '', $theData, '', '', '', 'th') . '</thead>';
436 $out .= '<tbody>' . $iOut . '</tbody>';
437 // half line is drawn
438 // finish
439 $out = '
440 <!--
441 Filelist table:
442 -->
443 <div class="table-fit">
444 <table class="table table-striped table-hover" id="typo3-filelist">
445 ' . $out . '
446 </table>
447 </div>';
448
449 } else {
450 /** @var $flashMessage FlashMessage */
451 $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $this->getLanguageService()->getLL('storageNotBrowsableMessage'), $this->getLanguageService()->getLL('storageNotBrowsableTitle'), FlashMessage::INFO);
452 $out = $flashMessage->render();
453 }
454 return $out;
455 }
456
457 /**
458 * If there is a parent folder and user has access to it, return an icon
459 * which is linked to the filelist of the parent folder.
460 *
461 * @param Folder $currentFolder
462 * @return string
463 */
464 protected function getLinkToParentFolder(Folder $currentFolder) {
465 $levelUp = '';
466 try {
467 $currentStorage = $currentFolder->getStorage();
468 $parentFolder = $currentFolder->getParentFolder();
469 if ($parentFolder->getIdentifier() !== $currentFolder->getIdentifier() && $currentStorage->isWithinFileMountBoundaries($parentFolder)) {
470 $levelUp = $this->linkWrapDir(
471 '<span title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.php:labels.upOneLevel', TRUE) . '">'
472 . $this->iconFactory->getIcon('actions-view-go-up', Icon::SIZE_SMALL)
473 . '</span>',
474 $parentFolder
475 );
476 }
477 } catch (\Exception $e) {}
478 return $levelUp;
479 }
480
481 /**
482 * Gets the number of files and total size of a folder
483 *
484 * @return string
485 */
486 public function getFolderInfo() {
487 if ($this->counter == 1) {
488 $fileLabel = $this->getLanguageService()->getLL('file', TRUE);
489 } else {
490 $fileLabel = $this->getLanguageService()->getLL('files', TRUE);
491 }
492 return $this->counter . ' ' . $fileLabel . ', ' . GeneralUtility::formatSize($this->totalbytes, $this->getLanguageService()->getLL('byteSizeUnits', TRUE));
493 }
494
495 /**
496 * This returns tablerows for the directories in the array $items['sorting'].
497 *
498 * @param Folder[] $folders Folders of \TYPO3\CMS\Core\Resource\Folder
499 * @return string HTML table rows.
500 */
501 public function formatDirList(array $folders) {
502 $out = '';
503 foreach ($folders as $folderName => $folderObject) {
504 $role = $folderObject->getRole();
505 if ($role === FolderInterface::ROLE_PROCESSING) {
506 // don't show processing-folder
507 continue;
508 }
509 if ($role !== FolderInterface::ROLE_DEFAULT) {
510 $displayName = '<strong>' . htmlspecialchars($folderName) . '</strong>';
511 } else {
512 $displayName = htmlspecialchars($folderName);
513 }
514
515 $isLocked = $folderObject instanceof InaccessibleFolder;
516 $isWritable = $folderObject->checkActionPermission('write');
517
518 // Initialization
519 $this->counter++;
520
521 // The icon with link
522 $theIcon = '<span title="' . htmlspecialchars($folderName) . '">' . $this->iconFactory->getIconForResource($folderObject, Icon::SIZE_SMALL) . '</span>';
523 if (!$isLocked && $this->clickMenus) {
524 $theIcon = $this->fileListController->doc->wrapClickMenuOnIcon($theIcon, $folderObject->getCombinedIdentifier());
525 }
526
527 // Preparing and getting the data-array
528 $theData = array();
529 if ($isLocked) {
530 foreach ($this->fieldArray as $field) {
531 $theData[$field] = '';
532 }
533 $theData['file'] = $displayName;
534 } else {
535 foreach ($this->fieldArray as $field) {
536 switch ($field) {
537 case 'size':
538 try {
539 $numFiles = $folderObject->getFileCount();
540 } catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientFolderAccessPermissionsException $e) {
541 $numFiles = 0;
542 }
543 $theData[$field] = $numFiles . ' ' . $this->getLanguageService()->getLL(($numFiles === 1 ? 'file' : 'files'), TRUE);
544 break;
545 case 'rw':
546 $theData[$field] = '<strong class="text-danger">' . $this->getLanguageService()->getLL('read', TRUE) . '</strong>' . (!$isWritable ? '' : '<strong class="text-danger">' . $this->getLanguageService()->getLL('write', TRUE) . '</strong>');
547 break;
548 case 'fileext':
549 $theData[$field] = $this->getLanguageService()->getLL('folder', TRUE);
550 break;
551 case 'tstamp':
552 // @todo: FAL: how to get the mtime info -- $theData[$field] = \TYPO3\CMS\Backend\Utility\BackendUtility::date($theFile['tstamp']);
553 $theData[$field] = '-';
554 break;
555 case 'file':
556 $theData[$field] = $this->linkWrapDir($displayName, $folderObject);
557 break;
558 case '_CONTROL_':
559 $theData[$field] = $this->makeEdit($folderObject);
560 break;
561 case '_CLIPBOARD_':
562 $theData[$field] = $this->makeClip($folderObject);
563 break;
564 case '_REF_':
565 $theData[$field] = $this->makeRef($folderObject);
566 break;
567 default:
568 $theData[$field] = GeneralUtility::fixed_lgd_cs($theData[$field], $this->fixedL);
569 }
570 }
571 }
572 $out .= $this->addelement(1, $theIcon, $theData);
573 }
574 return $out;
575 }
576
577 /**
578 * Wraps the directory-titles
579 *
580 * @param string $title String to be wrapped in links
581 * @param Folder $folderObject Folder to work on
582 * @return string HTML
583 */
584 public function linkWrapDir($title, Folder $folderObject) {
585 $href = BackendUtility::getModuleUrl('file_FilelistList', ['id' => $folderObject->getCombinedIdentifier()]);
586 $onclick = ' onclick="' . htmlspecialchars(('top.document.getElementsByName("navigation")[0].contentWindow.Tree.highlightActiveItem("file","folder' . GeneralUtility::md5int($folderObject->getCombinedIdentifier()) . '_"+top.fsMod.currentBank)')) . '"';
587 // Sometimes $code contains plain HTML tags. In such a case the string should not be modified!
588 if ((string)$title === strip_tags($title)) {
589 return '<a href="' . htmlspecialchars($href) . '"' . $onclick . ' title="' . htmlspecialchars($title) . '">' . GeneralUtility::fixed_lgd_cs($title, $this->fixedL) . '</a>';
590 } else {
591 return '<a href="' . htmlspecialchars($href) . '"' . $onclick . '>' . $title . '</a>';
592 }
593 }
594
595 /**
596 * Wraps filenames in links which opens the metadata editor.
597 *
598 * @param string $code String to be wrapped in links
599 * @param File $fileObject File to be linked
600 * @return string HTML
601 */
602 public function linkWrapFile($code, File $fileObject) {
603 try {
604 if ($fileObject instanceof File && $fileObject->isIndexed() && $fileObject->checkActionPermission('write') && $this->getBackendUser()->check('tables_modify', 'sys_file_metadata')) {
605 $metaData = $fileObject->_getMetaData();
606 $urlParameters = [
607 'edit' => [
608 'sys_file_metadata' => [
609 $metaData['uid'] => 'edit'
610 ]
611 ],
612 'returnUrl' => $this->listURL()
613 ];
614 $url = BackendUtility::getModuleUrl('record_edit', $urlParameters);
615 $title = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.editMetadata'));
616 $code = '<a href="' . htmlspecialchars($url) . '" title="' . $title . '">' . GeneralUtility::fixed_lgd_cs($code, $this->fixedL) . '</a>';
617 }
618 } catch (\Exception $e) {
619 // intentional fall-through
620 }
621 return $code;
622 }
623
624 /**
625 * Returns list URL; This is the URL of the current script with id and imagemode parameters, that's all.
626 * The URL however is not relative, otherwise GeneralUtility::sanitizeLocalUrl() would say that
627 * the URL would be invalid
628 *
629 * @return string URL
630 */
631 public function listURL($altId = '') {
632 return GeneralUtility::linkThisScript(array(
633 'target' => rawurlencode($this->folderObject->getCombinedIdentifier()),
634 'imagemode' => $this->thumbs
635 ));
636 }
637
638 /**
639 * This returns tablerows for the files in the array $items['sorting'].
640 *
641 * @param File[] $files File items
642 * @return string HTML table rows.
643 */
644 public function formatFileList(array $files) {
645 $out = '';
646 // first two keys are "0" (default) and "-1" (multiple), after that comes the "other languages"
647 $allSystemLanguages = GeneralUtility::makeInstance(TranslationConfigurationProvider::class)->getSystemLanguages();
648 $systemLanguages = array_filter($allSystemLanguages, function($languageRecord) {
649 if ($languageRecord['uid'] === -1 || $languageRecord['uid'] === 0 || !$this->getBackendUser()->checkLanguageAccess($languageRecord['uid'])) {
650 return FALSE;
651 } else {
652 return TRUE;
653 }
654 });
655
656 foreach ($files as $fileObject) {
657 // Initialization
658 $this->counter++;
659 $this->totalbytes += $fileObject->getSize();
660 $ext = $fileObject->getExtension();
661 $fileName = trim($fileObject->getName());
662 // The icon with link
663 $theIcon = '<span title="' . htmlspecialchars($fileName . ' [' . (int)$fileObject->getUid() . ']') . '">'
664 . $this->iconFactory->getIconForResource($fileObject, Icon::SIZE_SMALL) . '</span>';
665 if ($this->clickMenus) {
666 $theIcon = $this->fileListController->doc->wrapClickMenuOnIcon($theIcon, $fileObject->getCombinedIdentifier());
667 }
668 // Preparing and getting the data-array
669 $theData = array();
670 foreach ($this->fieldArray as $field) {
671 switch ($field) {
672 case 'size':
673 $theData[$field] = GeneralUtility::formatSize($fileObject->getSize(), $this->getLanguageService()->getLL('byteSizeUnits', TRUE));
674 break;
675 case 'rw':
676 $theData[$field] = '' . (!$fileObject->checkActionPermission('read') ? ' ' : '<strong class="text-danger">' . $this->getLanguageService()->getLL('read', TRUE) . '</strong>') . (!$fileObject->checkActionPermission('write') ? '' : '<strong class="text-danger">' . $this->getLanguageService()->getLL('write', TRUE) . '</strong>');
677 break;
678 case 'fileext':
679 $theData[$field] = strtoupper($ext);
680 break;
681 case 'tstamp':
682 $theData[$field] = BackendUtility::date($fileObject->getModificationTime());
683 break;
684 case '_CONTROL_':
685 $theData[$field] = $this->makeEdit($fileObject);
686 break;
687 case '_CLIPBOARD_':
688 $theData[$field] = $this->makeClip($fileObject);
689 break;
690 case '_LOCALIZATION_':
691 if (!empty($systemLanguages) && $fileObject->isIndexed() && $fileObject->checkActionPermission('write') && $this->getBackendUser()->check('tables_modify', 'sys_file_metadata')) {
692 $metaDataRecord = $fileObject->_getMetaData();
693 $translations = $this->getTranslationsForMetaData($metaDataRecord);
694 $languageCode = '';
695
696 foreach ($systemLanguages as $language) {
697 $languageId = $language['uid'];
698 $flagIcon = $language['flagIcon'];
699 if (array_key_exists($languageId, $translations)) {
700 $title = htmlspecialchars(sprintf($GLOBALS['LANG']->getLL('editMetadataForLanguage'), $language['title']));
701 // @todo the overlay for the flag needs to be added ($flagIcon . '-overlay')
702 $urlParameters = [
703 'edit' => [
704 'sys_file_metadata' => [
705 $translations[$languageId]['uid'] => 'edit'
706 ]
707 ],
708 'returnUrl' => $this->listURL()
709 ];
710 $flagButtonIcon = $this->iconFactory->getIcon($flagIcon, Icon::SIZE_SMALL, 'overlay-edit');
711 $data = array(
712 'sys_file_metadata' => array($translations[$languageId]['uid'] => 'edit')
713 );
714 $url = BackendUtility::getModuleUrl('record_edit', $urlParameters);
715 $languageCode .= '<a href="' . htmlspecialchars($url)
716 . '" class="btn btn-default" title="' . $title . '">'
717 . $flagButtonIcon . '</a>';
718 } else {
719 $parameters = [
720 'justLocalized' => 'sys_file_metadata:' . $metaDataRecord['uid'] . ':' . $languageId,
721 'returnUrl' => $this->listURL()
722 ];
723 $returnUrl = BackendUtility::getModuleUrl('record_edit', $parameters);
724 $href = $this->fileListController->doc->issueCommand(
725 '&cmd[sys_file_metadata][' . $metaDataRecord['uid'] . '][localize]=' . $languageId,
726 $returnUrl
727 );
728 $flagButtonIcon = '<span title="' . htmlspecialchars(sprintf($GLOBALS['LANG']->getLL('createMetadataForLanguage'), $language['title'])) . '">' . $this->iconFactory->getIcon($flagIcon, Icon::SIZE_SMALL, 'overlay-new') . '</span>';
729 $languageCode .= '<a href="' . htmlspecialchars($href) . '" class="btn btn-default">' . $flagButtonIcon . '</a> ';
730 }
731 }
732
733 // Hide flag button bar when not translated yet
734 $theData[$field] = ' <div class="localisationData btn-group" data-fileid="' . $fileObject->getUid() . '"' .
735 (empty($translations) ? ' style="display: none;"' : '') . '>' . $languageCode . '</div>';
736 $theData[$field] .= '<a class="btn btn-default filelist-translationToggler" data-fileid="' . $fileObject->getUid() . '">' .
737 '<span title="' . $GLOBALS['LANG']->getLL('translateMetadata', TRUE) . '">'
738 . $this->iconFactory->getIcon('mimetypes-x-content-page-language-overlay', Icon::SIZE_SMALL) . '</span>'
739 . '</a>';
740 }
741 break;
742 case '_REF_':
743 $theData[$field] = $this->makeRef($fileObject);
744 break;
745 case 'file':
746 // Edit metadata of file
747 $theData[$field] = $this->linkWrapFile(htmlspecialchars($fileName), $fileObject);
748
749 if ($fileObject->isMissing()) {
750 $flashMessage = \TYPO3\CMS\Core\Resource\Utility\BackendUtility::getFlashMessageForMissingFile($fileObject);
751 $theData[$field] .= $flashMessage->render();
752 // Thumbnails?
753 } elseif ($this->thumbs && ($this->isImage($ext) || $this->isMediaFile($ext))) {
754 $processedFile = $fileObject->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, array());
755 if ($processedFile) {
756 $thumbUrl = $processedFile->getPublicUrl(TRUE);
757 $theData[$field] .= '<br /><img src="' . $thumbUrl . '" ' .
758 'width="' . $processedFile->getProperty('width') . '" ' .
759 'height="' . $processedFile->getProperty('height') . '" ' .
760 'title="' . htmlspecialchars($fileName) . '" alt="" />';
761 }
762 }
763 break;
764 default:
765 $theData[$field] = '';
766 if ($fileObject->hasProperty($field)) {
767 $theData[$field] = htmlspecialchars(GeneralUtility::fixed_lgd_cs($fileObject->getProperty($field), $this->fixedL));
768 }
769 }
770 }
771 $out .= $this->addelement(1, $theIcon, $theData);
772 }
773 return $out;
774 }
775
776 /**
777 * Fetch the translations for a sys_file_metadata record
778 *
779 * @param $metaDataRecord
780 * @return array keys are the sys_language uids, values are the $rows
781 */
782 protected function getTranslationsForMetaData($metaDataRecord) {
783 $where = $GLOBALS['TCA']['sys_file_metadata']['ctrl']['transOrigPointerField'] . '=' . (int)$metaDataRecord['uid'] .
784 ' AND ' . $GLOBALS['TCA']['sys_file_metadata']['ctrl']['languageField'] . '>0';
785 $translationRecords = $this->getDatabaseConnection()->exec_SELECTgetRows('*', 'sys_file_metadata', $where);
786 $translations = array();
787 foreach ($translationRecords as $record) {
788 $translations[$record[$GLOBALS['TCA']['sys_file_metadata']['ctrl']['languageField']]] = $record;
789 }
790 return $translations;
791 }
792
793 /**
794 * Returns TRUE if $ext is an image-extension according to $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
795 *
796 * @param string $ext File extension
797 * @return bool
798 */
799 public function isImage($ext) {
800 return GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], strtolower($ext));
801 }
802
803 /**
804 * Returns TRUE if $ext is an media-extension according to $GLOBALS['TYPO3_CONF_VARS']['SYS']['mediafile_ext']
805 *
806 * @param string $ext File extension
807 * @return bool
808 */
809 public function isMediaFile($ext) {
810 return GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['SYS']['mediafile_ext'], strtolower($ext));
811 }
812
813 /**
814 * Wraps the directory-titles ($code) in a link to filelist/Modules/Filelist/index.php (id=$path) and sorting commands...
815 *
816 * @param string $code String to be wrapped
817 * @param string $folderIdentifier ID (path)
818 * @param string $col Sorting column
819 * @return string HTML
820 */
821 public function linkWrapSort($code, $folderIdentifier, $col) {
822 $params = ['id' => $folderIdentifier, 'SET' => [ 'sort' => $col ]];
823
824 if ($this->sort === $col) {
825 // Check reverse sorting
826 $params['SET']['reverse'] = ($this->sortRev ? '0' : '1');
827 $sortArrow = $this->iconFactory->getIcon('status-status-sorting-light-' . ($this->sortRev ? 'desc' : 'asc'), Icon::SIZE_SMALL);
828 } else {
829 $params['SET']['reverse'] = 0;
830 $sortArrow = '';
831 }
832 $href = BackendUtility::getModuleUrl('file_FilelistList', $params);
833 return '<a href="' . htmlspecialchars($href) . '">' . $code . ' ' . $sortArrow . '</a>';
834 }
835
836 /**
837 * Creates the clipboard control pad
838 *
839 * @param File|Folder $fileOrFolderObject Array with information about the file/directory for which to make the clipboard panel for the listing.
840 * @return string HTML-table
841 */
842 public function makeClip($fileOrFolderObject) {
843 if (!$fileOrFolderObject->checkActionPermission('read')) {
844 return '';
845 }
846 $cells = array();
847 $fullIdentifier = $fileOrFolderObject->getCombinedIdentifier();
848 $fullName = $fileOrFolderObject->getName();
849 $md5 = GeneralUtility::shortmd5($fullIdentifier);
850 // For normal clipboard, add copy/cut buttons:
851 if ($this->clipObj->current === 'normal') {
852 $isSel = $this->clipObj->isSelected('_FILE', $md5);
853 $copyTitle = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.copy', TRUE);
854 $cutTitle = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.cut', TRUE);
855 $copyIcon = $this->iconFactory->getIcon('actions-edit-copy', Icon::SIZE_SMALL);
856 $cutIcon = $this->iconFactory->getIcon('actions-edit-cut', Icon::SIZE_SMALL);
857
858 if ($isSel === 'copy') {
859 $copyIcon = $this->iconFactory->getIcon('actions-edit-copy-release', Icon::SIZE_SMALL);
860 } elseif ($isSel === 'cut') {
861 $cutIcon = $this->iconFactory->getIcon('actions-edit-cut-release', Icon::SIZE_SMALL);
862 }
863
864 $cells[] = '<a class="btn btn-default"" href="' . htmlspecialchars($this->clipObj->selUrlFile($fullIdentifier, 1, ($isSel === 'copy'))) . '" title="' . $copyTitle . '">' . $copyIcon . '</a>';
865 // we can only cut if file can be moved
866 if ($fileOrFolderObject->checkActionPermission('move')) {
867 $cells[] = '<a class="btn btn-default" href="' . htmlspecialchars($this->clipObj->selUrlFile($fullIdentifier, 0, ($isSel === 'cut'))) . '" title="' . $cutTitle . '">' . $cutIcon . '</a>';
868 } else {
869 $cells[] = $this->spaceIcon;
870 }
871 } else {
872 // For numeric pads, add select checkboxes:
873 $n = '_FILE|' . $md5;
874 $this->CBnames[] = $n;
875 $checked = $this->clipObj->isSelected('_FILE', $md5) ? ' checked="checked"' : '';
876 $cells[] = '<label class="btn btn-default btn-checkbox"><input type="hidden" name="CBH[' . $n . ']" value="0" /><input type="checkbox" name="CBC[' . $n . ']" value="' . htmlspecialchars($fullIdentifier) . '" ' . $checked . ' /><span class="t3-icon fa"></span></label>';
877 }
878 // Display PASTE button, if directory:
879 $elFromTable = $this->clipObj->elFromTable('_FILE');
880 if ($fileOrFolderObject instanceof Folder && !empty($elFromTable) && $fileOrFolderObject->checkActionPermission('write')) {
881 $addPasteButton = TRUE;
882 $elToConfirm = array();
883 foreach ($elFromTable as $key => $element) {
884 $clipBoardElement = $this->resourceFactory->retrieveFileOrFolderObject($element);
885 if ($clipBoardElement instanceof Folder && $clipBoardElement->getStorage()->isWithinFolder($clipBoardElement, $fileOrFolderObject)) {
886 $addPasteButton = FALSE;
887 }
888 $elToConfirm[$key] = $clipBoardElement->getName();
889 }
890 if ($addPasteButton) {
891 $cells[] = '<a class="btn btn-default" href="' . htmlspecialchars($this->clipObj->pasteUrl('_FILE', $fullIdentifier)) . '" onclick="return ' . htmlspecialchars($this->clipObj->confirmMsg('_FILE', $fullName, 'into', $elToConfirm)) . '" title="' . $this->getLanguageService()->getLL('clip_pasteInto', TRUE) . '">' . $this->iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL) . '</a>';
892 }
893 }
894 // Compile items into a DIV-element:
895 return ' <div class="btn-group" role="group">' . implode('', $cells) . '</div>';
896 }
897
898 /**
899 * Creates the edit control section
900 *
901 * @param File|Folder $fileOrFolderObject Array with information about the file/directory for which to make the edit control section for the listing.
902 * @return string HTML-table
903 */
904 public function makeEdit($fileOrFolderObject) {
905 $cells = array();
906 $fullIdentifier = $fileOrFolderObject->getCombinedIdentifier();
907
908 // Edit file content (if editable)
909 if ($fileOrFolderObject instanceof File && $fileOrFolderObject->checkActionPermission('write') && GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'], $fileOrFolderObject->getExtension())) {
910 $url = BackendUtility::getModuleUrl('file_edit', array('target' => $fullIdentifier));
911 $editOnClick = 'top.content.list_frame.location.href=' . GeneralUtility::quoteJSvalue($url) . '+\'&returnUrl=\'+top.rawurlencode(top.content.list_frame.document.location.pathname+top.content.list_frame.document.location.search);return false;';
912 $cells['edit'] = '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($editOnClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.editcontent') . '">'
913 . $this->iconFactory->getIcon('actions-page-open', Icon::SIZE_SMALL)
914 . '</a>';
915 } else {
916 $cells['edit'] = $this->spaceIcon;
917 }
918 if ($fileOrFolderObject instanceof File) {
919 $fileUrl = $fileOrFolderObject->getPublicUrl(TRUE);
920 if ($fileUrl) {
921 $aOnClick = 'return top.openUrlInWindow(' . GeneralUtility::quoteJSvalue($fileUrl) . ', \'WebFile\');';
922 $cells['view'] = '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($aOnClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.view') . '">' . $this->iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL) . '</a>';
923 } else {
924 $cells['view'] = $this->spaceIcon;
925 }
926 } else {
927 $cells['view'] = $this->spaceIcon;
928 }
929
930 // replace file
931 if ($fileOrFolderObject instanceof File && $fileOrFolderObject->checkActionPermission('replace')) {
932 $url = BackendUtility::getModuleUrl('file_replace', array('target' => $fullIdentifier, 'uid' => $fileOrFolderObject->getUid()));
933 $replaceOnClick = 'top.content.list_frame.location.href = ' . GeneralUtility::quoteJSvalue($url) . '+\'&returnUrl=\'+top.rawurlencode(top.content.list_frame.document.location.pathname+top.content.list_frame.document.location.search);return false;';
934 $cells['replace'] = '<a href="#" class="btn btn-default" onclick="' . $replaceOnClick . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:cm.replace') . '">' . $this->iconFactory->getIcon('actions-edit-replace', Icon::SIZE_SMALL) . '</a>';
935 }
936
937 // rename the file
938 if ($fileOrFolderObject->checkActionPermission('rename')) {
939 $url = BackendUtility::getModuleUrl('file_rename', array('target' => $fullIdentifier));
940 $renameOnClick = 'top.content.list_frame.location.href = ' . GeneralUtility::quoteJSvalue($url) . '+\'&returnUrl=\'+top.rawurlencode(top.content.list_frame.document.location.pathname+top.content.list_frame.document.location.search);return false;';
941 $cells['rename'] = '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($renameOnClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.rename') . '">' . $this->iconFactory->getIcon('actions-edit-rename', Icon::SIZE_SMALL) . '</a>';
942 } else {
943 $cells['rename'] = $this->spaceIcon;
944 }
945 if ($fileOrFolderObject->checkActionPermission('read')) {
946 $infoOnClick = '';
947 if ($fileOrFolderObject instanceof Folder) {
948 $infoOnClick = 'top.launchView( \'_FOLDER\', ' . GeneralUtility::quoteJSvalue($fullIdentifier) . ');return false;';
949 } elseif ($fileOrFolderObject instanceof File) {
950 $infoOnClick = 'top.launchView( \'_FILE\', ' . GeneralUtility::quoteJSvalue($fullIdentifier) . ');return false;';
951 }
952 $cells['info'] = '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($infoOnClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.info') . '">' . $this->iconFactory->getIcon('actions-document-info', Icon::SIZE_SMALL)->render() . '</a>';
953 } else {
954 $cells['info'] = $this->spaceIcon;
955 }
956
957 // delete the file
958 if ($fileOrFolderObject->checkActionPermission('delete')) {
959 $identifier = $fileOrFolderObject->getIdentifier();
960 if ($fileOrFolderObject instanceof Folder) {
961 $referenceCountText = BackendUtility::referenceCount('_FILE', $identifier, ' (There are %s reference(s) to this folder!)');
962 } else {
963 $referenceCountText = BackendUtility::referenceCount('sys_file', $fileOrFolderObject->getUid(), ' (There are %s reference(s) to this file!)');
964 }
965
966 if ($this->getBackendUser()->jsConfirmation(JsConfirmation::DELETE)) {
967 $confirmationCheck = 'confirm(' . GeneralUtility::quoteJSvalue(sprintf($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:mess.delete'), $fileOrFolderObject->getName()) . $referenceCountText) . ')';
968 } else {
969 $confirmationCheck = '1 == 1';
970 }
971
972 $removeOnClick = 'if (' . $confirmationCheck . ') { top.content.list_frame.location.href=' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('tce_file') .'&file[delete][0][data]=' . rawurlencode($fileOrFolderObject->getCombinedIdentifier()) . '&vC=' . $this->getBackendUser()->veriCode() . '&redirect=') . '+top.rawurlencode(top.content.list_frame.document.location.pathname+top.content.list_frame.document.location.search);};';
973
974 $cells['delete'] = '<a href="#" class="btn btn-default" onclick="' . htmlspecialchars($removeOnClick) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.delete') . '">' . $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL) . '</a>';
975 } else {
976 $cells['delete'] = $this->spaceIcon;
977 }
978
979 // Hook for manipulating edit icons.
980 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['fileList']['editIconsHook'])) {
981 $cells['__fileOrFolderObject'] = $fileOrFolderObject;
982 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['fileList']['editIconsHook'] as $classData) {
983 $hookObject = GeneralUtility::getUserObj($classData);
984 if (!$hookObject instanceof FileListEditIconHookInterface) {
985 throw new \UnexpectedValueException(
986 '$hookObject must implement interface \\TYPO3\\CMS\\Filelist\\FileListEditIconHookInterface',
987 1235225797
988 );
989 }
990 $hookObject->manipulateEditIcons($cells, $this);
991 }
992 unset($cells['__fileOrFolderObject']);
993 }
994 // Compile items into a DIV-element:
995 return '<div class="btn-group">' . implode('', $cells) . '</div>';
996 }
997
998 /**
999 * Make reference count
1000 *
1001 * @param File|Folder $fileOrFolderObject Array with information about the file/directory for which to make the clipboard panel for the listing.
1002 * @return string HTML
1003 */
1004 public function makeRef($fileOrFolderObject) {
1005 if ($fileOrFolderObject instanceof FolderInterface) {
1006 return '-';
1007 }
1008 // Look up the file in the sys_refindex.
1009 // Exclude sys_file_metadata records as these are no use references
1010 $databaseConnection = $this->getDatabaseConnection();
1011 $table = 'sys_refindex';
1012 $referenceCount = $databaseConnection->exec_SELECTcountRows(
1013 '*',
1014 $table,
1015 'ref_table=' . $databaseConnection->fullQuoteStr('sys_file', $table)
1016 . ' AND ref_uid=' . (int)$fileOrFolderObject->getUid()
1017 . ' AND deleted=0'
1018 . ' AND tablename != ' . $databaseConnection->fullQuoteStr('sys_file_metadata', $table)
1019 );
1020 return $this->generateReferenceToolTip($referenceCount, '\'_FILE\', ' . GeneralUtility::quoteJSvalue($fileOrFolderObject->getCombinedIdentifier()));
1021 }
1022
1023 /**
1024 * Returns the database connection
1025 *
1026 * @return DatabaseConnection
1027 */
1028 protected function getDatabaseConnection() {
1029 return $GLOBALS['TYPO3_DB'];
1030 }
1031
1032 /**
1033 * Returns an instance of LanguageService
1034 *
1035 * @return \TYPO3\CMS\Lang\LanguageService
1036 */
1037 protected function getLanguageService() {
1038 return $GLOBALS['LANG'];
1039 }
1040
1041 /**
1042 * Returns the current BE user.
1043 *
1044 * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
1045 */
1046 protected function getBackendUser() {
1047 return $GLOBALS['BE_USER'];
1048 }
1049
1050 }