84 $this->pageRenderer->loadRequireJsModule(
'TYPO3/CMS/Recordlist/BrowseFiles');
85 $this->fileRepository = GeneralUtility::makeInstance(FileRepository::class);
89 $this->thumbnailConfiguration[
'width'] = (int)$thumbnailConfig[
'width'];
92 $this->thumbnailConfiguration[
'height'] = (int)$thumbnailConfig[
'height'];
101 parent::initVariables();
102 $this->expandFolder = GeneralUtility::_GP(
'expandFolder');
103 $this->searchWord = (string)GeneralUtility::_GP(
'searchWord');
114 if ($this->expandFolder !==
null) {
118 $this->expandFolder = $data[
'expandFolder'];
121 return [$data, $store];
133 $allowedFileExtensions = GeneralUtility::trimExplode(
',', explode(
'|', $this->bparams)[3],
true);
134 if (!empty($allowedFileExtensions) && $allowedFileExtensions[0] !==
'sys_file' && $allowedFileExtensions[0] !==
'*') {
136 $filterObject = GeneralUtility::makeInstance(FileExtensionFilter::class);
137 $filterObject->setAllowedFileExtensions($allowedFileExtensions);
139 $storages = $backendUser->getFileStorages();
141 foreach ($storages as $storage) {
142 $storage->addFileAndFolderNameFilter([$filterObject,
'filterFileList']);
145 if ($this->expandFolder) {
146 $fileOrFolderObject =
null;
152 }
catch (Exception $accessException) {
154 }
catch (\InvalidArgumentException $driverMissingExecption) {
158 if ($fileOrFolderObject instanceof Folder) {
160 $this->selectedFolder = $fileOrFolderObject;
161 } elseif ($fileOrFolderObject instanceof FileInterface) {
167 if (!$this->selectedFolder) {
169 [, $pid, $table,, $field] = explode(
'-', explode(
'|', $this->bparams)[4]);
170 $this->selectedFolder = $backendUser->getDefaultUploadFolder($pid, $table, $field);
171 }
catch (\Exception $e) {
178 if ($this->selectedFolder) {
179 $folderUtilityRenderer = GeneralUtility::makeInstance(FolderUtilityRenderer::class, $this);
180 $uploadForm = $folderUtilityRenderer->uploadForm($this->selectedFolder, $allowedFileExtensions);
181 $createFolder = $folderUtilityRenderer->createFolder($this->selectedFolder);
185 $noThumbs = $backendUser->getTSConfig()[
'options.'][
'noThumbsInEB'] ??
false;
189 $_MOD_MENU = [
'displayThumbs' =>
''];
190 $_MCONF[
'name'] =
'file_list';
193 $displayThumbs = $_MOD_SETTINGS[
'displayThumbs'] ??
false;
194 $noThumbs = $noThumbs ?: !$displayThumbs;
197 $folderTree = GeneralUtility::makeInstance(ElementBrowserFolderTreeView::class);
198 $folderTree->setLinkParameterProvider($this);
199 $tree = $folderTree->getBrowsableTree();
200 if ($this->selectedFolder) {
208 $content = $this->doc->startPage(htmlspecialchars($this->
getLanguageService()->getLL(
'fileSelector')));
212 $markup[] =
'<!-- Wrapper table for folder tree / filelist: -->';
213 $markup[] =
'<div class="element-browser">';
214 $markup[] =
' <div class="element-browser-panel element-browser-main">';
215 $markup[] =
' <div class="element-browser-main-sidebar">';
216 $markup[] =
' <div class="element-browser-body">';
217 $markup[] =
' ' . $tree;
218 $markup[] =
' </div>';
219 $markup[] =
' </div>';
220 $markup[] =
' <div class="element-browser-main-content">';
221 $markup[] =
' <div class="element-browser-body">';
222 $markup[] =
' ' . $this->doc->getFlashMessages();
223 $markup[] =
' ' . $files;
224 $markup[] =
' ' . $uploadForm;
225 $markup[] =
' ' . $createFolder;
226 $markup[] =
' </div>';
227 $markup[] =
' </div>';
228 $markup[] =
' </div>';
229 $markup[] =
'</div>';
230 $content .= implode(
'', $markup);
233 $content .= $this->doc->endPage();
234 return $this->doc->insertStylesAndJS($content);
245 public function renderFilesInFolder(Folder $folder, array $extensionList = [], $noThumbs =
false)
247 if (!$folder->checkActionPermission(
'read')) {
253 if ($this->searchWord !==
'') {
255 $files = $folder->searchFiles($searchDemand);
257 $extensionList = !empty($extensionList) && $extensionList[0] ===
'*' ? [] : $extensionList;
260 $filesCount = count($files);
265 $folderIcon = $this->iconFactory->getIconForResource($folder,
Icon::SIZE_SMALL);
269 <th class="col-title nowrap">' . $folderIcon .
' ' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($folder->getStorage()->getName() .
':' . $folder->getReadablePath(), $titleLen)) .
'</th>
270 <th class="col-control nowrap"></th>
271 <th class="col-clipboard nowrap">
272 <a href="#" class="btn btn-default" id="t3js-importSelection" title="' . htmlspecialchars($lang->getLL(
'importSelection')) .
'">' . $this->iconFactory->getIcon(
'actions-document-import-t3d',
Icon::SIZE_SMALL) .
'</a>
273 <a href="#" class="btn btn-default" id="t3js-toggleSelection" title="' . htmlspecialchars($lang->getLL(
'toggleSelection')) .
'">' . $this->iconFactory->getIcon(
'actions-document-select',
Icon::SIZE_SMALL) .
'</a>
275 <th class="nowrap"> </th>
278 if ($filesCount === 0) {
281 <td colspan="4">No files found.</td>
285 foreach ($files as $fileObject) {
286 $fileExtension = $fileObject->getExtension();
289 if (!$noThumbs && GeneralUtility::inList(strtolower(
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'imagefile_ext'] .
',' .
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'mediafile_ext']), strtolower($fileExtension))) {
290 $processedFile = $fileObject->process(
292 $this->thumbnailConfiguration
294 $imageUrl = $processedFile->getPublicUrl(
true);
296 $fileObject->getProperty(
'width'),
297 $fileObject->getProperty(
'height')
299 $pDim = $imgInfo[0] .
'x' . $imgInfo[1] .
' pixels';
300 $clickIcon =
'<img src="' . $imageUrl .
'"'
301 .
' width="' . $processedFile->getProperty(
'width') .
'"'
302 .
' height="' . $processedFile->getProperty(
'height') .
'"'
303 .
' hspace="5" vspace="5" border="1" />';
309 $size =
' (' . GeneralUtility::formatSize($fileObject->getSize(), $this->getLanguageService()->sL(
'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:byteSizeUnits')) . ($pDim ?
', ' . $pDim :
'') .
')';
310 $icon =
'<span title="id=' . htmlspecialchars($fileObject->getUid()) .
'">' . $this->iconFactory->getIconForResource($fileObject,
Icon::SIZE_SMALL) .
'</span>';
312 $filesIndex = count($this->elements);
313 $this->elements[
'file_' . $filesIndex] = [
315 'table' =>
'sys_file',
316 'uid' => $fileObject->getUid(),
317 'fileName' => $fileObject->getName(),
318 'filePath' => $fileObject->getUid(),
319 'fileExt' => $fileExtension,
323 $ATag =
'<a href="#" class="btn btn-default" title="' . htmlspecialchars($fileObject->getName()) .
'" data-file-index="' . htmlspecialchars($filesIndex) .
'" data-close="0">';
324 $ATag .=
'<span title="' . htmlspecialchars($lang->getLL(
'addToList')) .
'">' . $this->iconFactory->getIcon(
'actions-add',
Icon::SIZE_SMALL)->render() .
'</span>';
325 $ATag_alt =
'<a href="#" title="' . htmlspecialchars($fileObject->getName()) . $size .
'" data-file-index="' . htmlspecialchars($filesIndex) .
'" data-close="1">';
327 $bulkCheckBox =
'<label class="btn btn-default btn-checkbox"><input type="checkbox" class="typo3-bulk-item" name="file_' . $filesIndex .
'" value="0" /><span class="t3-icon fa"></span></label>';
335 $uriBuilder = GeneralUtility::makeInstance(\
TYPO3\CMS\Backend\Routing\UriBuilder::class);
337 $Ahref = (string)$uriBuilder->buildUriFromRoute(
'show_item', [
340 'uid' => $fileObject->getCombinedIdentifier(),
341 'returnUrl' => GeneralUtility::getIndpEnv(
'REQUEST_URI')
345 $filenameAndIcon = $ATag_alt . $icon . htmlspecialchars(GeneralUtility::fixed_lgd_cs($fileObject->getName(), $titleLen)) . $ATag_e;
348 <tr class="file_list_normal">
349 <td class="col-title nowrap">' . $filenameAndIcon .
' </td>
350 <td class="col-control">
351 <div class="btn-group">' . $ATag . $ATag_e .
'
352 <a href="' . htmlspecialchars($Ahref) .
'" class="btn btn-default" title="' . htmlspecialchars($lang->getLL(
'info')) .
'">' . $this->iconFactory->getIcon(
'actions-document-info',
Icon::SIZE_SMALL) .
'</a>
354 <td class="col-clipboard" valign="top">' . $bulkCheckBox .
'</td>
355 <td class="nowrap"> ' . $pDim .
'</td>
360 <td class="filelistThumbnail" colspan="4">' . $ATag_alt . $clickIcon . $ATag_e .
'</td>
366 $markup[] =
'<h3>' . htmlspecialchars($lang->getLL(
'files')) .
' ' . $filesCount .
':</h3>';
367 $markup[] = GeneralUtility::makeInstance(FolderUtilityRenderer::class, $this)->getFileSearchField($this->searchWord);
368 $markup[] =
'<div id="filelist">';
370 $markup[] =
' <!-- Filelisting -->';
371 $markup[] =
' <div class="table-fit">';
372 $markup[] =
' <table class="table table-striped table-hover" id="typo3-filelist">';
373 $markup[] =
' ' . implode(
'', $lines);
374 $markup[] =
' </table>';
375 $markup[] =
' </div>';
376 $markup[] =
' </div>';
377 $content = implode(
'', $markup);
391 if (!empty($extensionList)) {
393 $filter = GeneralUtility::makeInstance(FileExtensionFilter::class);
394 $filter->setAllowedFileExtensions($extensionList);
395 $folder->setFileAndFolderNameFilters([[$filter,
'filterFileList']]);
397 return $folder->getFiles();
417 if (!$noThumbsInEB && $this->selectedFolder) {
419 $_MOD_MENU = [
'displayThumbs' =>
''];
420 $_MCONF[
'name'] =
'file_list';
423 $thumbNailCheck =
'<div class="checkbox" style="padding:5px 0 15px 0"><label for="checkDisplayThumbs">'
426 'SET[displayThumbs]',
427 $_MOD_SETTINGS[
'displayThumbs'],
430 'id="checkDisplayThumbs"'
432 . htmlspecialchars($lang->sL(
'LLL:EXT:filelist/Resources/Private/Language/locallang_mod_file_list.xlf:displayThumbs')) .
'</label></div>';
433 $out .= $thumbNailCheck;
435 $out .=
'<div style="padding-top: 15px;"></div>';
460 'data-mode' =>
'file',
461 'data-elements' => json_encode($this->elements)