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