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