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