/** * Main function, creating the listing * * @return void */ public function main() { // Initialize the template object $this->doc = GeneralUtility::makeInstance(DocumentTemplate::class); $this->doc->backPath = $GLOBALS['BACK_PATH']; $this->doc->setModuleTemplate('EXT:filelist/Resources/Private/Templates/file_list.html'); /** @var $pageRenderer \TYPO3\CMS\Core\Page\PageRenderer */ $pageRenderer = $this->doc->getPageRenderer(); $pageRenderer->loadJQuery(); $pageRenderer->loadRequireJsModule('TYPO3/CMS/Filelist/FileListLocalisation'); // There there was access to this file path, continue, make the list if ($this->folderObject) { // Create filelisting object $this->filelist = GeneralUtility::makeInstance(FileList::class); $this->filelist->backPath = $GLOBALS['BACK_PATH']; // Apply predefined values for hidden checkboxes // Set predefined value for DisplayBigControlPanel: $backendUser = $this->getBackendUser(); if ($backendUser->getTSConfigVal('options.file_list.enableDisplayBigControlPanel') === 'activated') { $this->MOD_SETTINGS['bigControlPanel'] = TRUE; } elseif ($backendUser->getTSConfigVal('options.file_list.enableDisplayBigControlPanel') === 'deactivated') { $this->MOD_SETTINGS['bigControlPanel'] = FALSE; } // Set predefined value for DisplayThumbnails: if ($backendUser->getTSConfigVal('options.file_list.enableDisplayThumbnails') === 'activated') { $this->MOD_SETTINGS['displayThumbs'] = TRUE; } elseif ($backendUser->getTSConfigVal('options.file_list.enableDisplayThumbnails') === 'deactivated') { $this->MOD_SETTINGS['displayThumbs'] = FALSE; } // Set predefined value for Clipboard: if ($backendUser->getTSConfigVal('options.file_list.enableClipBoard') === 'activated') { $this->MOD_SETTINGS['clipBoard'] = TRUE; } elseif ($backendUser->getTSConfigVal('options.file_list.enableClipBoard') === 'deactivated') { $this->MOD_SETTINGS['clipBoard'] = FALSE; } // If user never opened the list module, set the value for displayThumbs if (!isset($this->MOD_SETTINGS['displayThumbs'])) { $this->MOD_SETTINGS['displayThumbs'] = $backendUser->uc['thumbnailsByDefault']; } $this->filelist->thumbs = $this->MOD_SETTINGS['displayThumbs']; // Create clipboard object and initialize that $this->filelist->clipObj = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Clipboard\Clipboard::class); $this->filelist->clipObj->fileMode = 1; $this->filelist->clipObj->initializeClipboard(); $CB = GeneralUtility::_GET('CB'); if ($this->cmd == 'setCB') { $CB['el'] = $this->filelist->clipObj->cleanUpCBC(array_merge(GeneralUtility::_POST('CBH'), (array) GeneralUtility::_POST('CBC')), '_FILE'); } if (!$this->MOD_SETTINGS['clipBoard']) { $CB['setP'] = 'normal'; } $this->filelist->clipObj->setCmd($CB); $this->filelist->clipObj->cleanCurrent(); // Saves $this->filelist->clipObj->endClipboard(); // If the "cmd" was to delete files from the list (clipboard thing), do that: if ($this->cmd == 'delete') { $items = $this->filelist->clipObj->cleanUpCBC(GeneralUtility::_POST('CBC'), '_FILE', 1); if (!empty($items)) { // Make command array: $FILE = array(); foreach ($items as $v) { $FILE['delete'][] = array('data' => $v); } // Init file processing object for deleting and pass the cmd array. $fileProcessor = GeneralUtility::makeInstance(ExtendedFileUtility::class); $fileProcessor->init(array(), $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']); $fileProcessor->setActionPermissions(); $fileProcessor->dontCheckForUnique = $this->overwriteExistingFiles ? 1 : 0; $fileProcessor->start($FILE); $fileProcessor->processData(); $fileProcessor->pushErrorMessagesToFlashMessageQueue(); } } if (!isset($this->MOD_SETTINGS['sort'])) { // Set default sorting $this->MOD_SETTINGS['sort'] = 'file'; $this->MOD_SETTINGS['reverse'] = 0; } // Start up filelisting object, include settings. $this->pointer = MathUtility::forceIntegerInRange($this->pointer, 0, 100000); $this->filelist->start($this->folderObject, $this->pointer, $this->MOD_SETTINGS['sort'], $this->MOD_SETTINGS['reverse'], $this->MOD_SETTINGS['clipBoard'], $this->MOD_SETTINGS['bigControlPanel']); // Generate the list $this->filelist->generateList(); // Set top JavaScript: $this->doc->JScode = $this->doc->wrapScriptTags('if (top.fsMod) top.fsMod.recentIds["file"] = "' . rawurlencode($this->id) . '";' . $this->filelist->CBfunctions()); // This will return content necessary for the context sensitive clickmenus to work: bodytag events, JavaScript functions and DIV-layers. $this->doc->getContextMenuCode(); // Setting up the buttons and markers for docheader list($buttons, $otherMarkers) = $this->filelist->getButtonsAndOtherMarkers($this->folderObject); // add the folder info to the marker array $otherMarkers['FOLDER_INFO'] = $this->filelist->getFolderInfo(); $docHeaderButtons = array_merge($this->getButtons(), $buttons); // Include DragUploader only if we have write access if ($this->folderObject->getStorage()->checkUserActionPermission('add', 'File') && $this->folderObject->checkActionPermission('write')) { $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/DragUploader'); $pageRenderer->addInlineLanguagelabelFile(ExtensionManagementUtility::extPath('lang') . 'locallang_core.xlf', 'file_upload'); } // Build the <body> for the module $moduleHeadline = $this->getModuleHeadline(); // Create output $pageContent = $moduleHeadline !== '' ? '<h1>' . $moduleHeadline . '</h1>' : ''; $pageContent .= '<form action="' . htmlspecialchars($this->filelist->listURL()) . '" method="post" name="dblistForm">'; $pageContent .= $this->filelist->HTMLcode; $pageContent .= '<input type="hidden" name="cmd" /></form>'; // Making listing options: if ($this->filelist->HTMLcode) { $pageContent .= ' <!-- Listing options for extended view, clipboard and thumbnails --> <div id="typo3-listOptions"> '; // Add "display bigControlPanel" checkbox: if ($backendUser->getTSConfigVal('options.file_list.enableDisplayBigControlPanel') === 'selectable') { $pageContent .= '<div class="checkbox">' . '<label for="bigControlPanel">' . BackendUtility::getFuncCheck($this->id, 'SET[bigControlPanel]', $this->MOD_SETTINGS['bigControlPanel'], '', '', 'id="bigControlPanel"') . $this->getLanguageService()->getLL('bigControlPanel', TRUE) . '</label>' . '</div>'; } // Add "display thumbnails" checkbox: if ($backendUser->getTSConfigVal('options.file_list.enableDisplayThumbnails') === 'selectable') { $pageContent .= '<div class="checkbox">' . '<label for="checkDisplayThumbs">' . BackendUtility::getFuncCheck($this->id, 'SET[displayThumbs]', $this->MOD_SETTINGS['displayThumbs'], '', '', 'id="checkDisplayThumbs"') . $this->getLanguageService()->getLL('displayThumbs', TRUE) . '</label>' . '</div>'; } // Add "clipboard" checkbox: if ($backendUser->getTSConfigVal('options.file_list.enableClipBoard') === 'selectable') { $pageContent .= '<div class="checkbox">' . '<label for="checkClipBoard">' . BackendUtility::getFuncCheck($this->id, 'SET[clipBoard]', $this->MOD_SETTINGS['clipBoard'], '', '', 'id="checkClipBoard"') . $this->getLanguageService()->getLL('clipBoard', TRUE) . '</label>' . '</div>'; } $pageContent .= ' </div> '; // Set clipboard: if ($this->MOD_SETTINGS['clipBoard']) { $pageContent .= $this->filelist->clipObj->printClipboard(); $pageContent .= BackendUtility::cshItem('xMOD_csh_corebe', 'filelist_clipboard'); } } $markerArray = array('CSH' => $docHeaderButtons['csh'], 'FUNC_MENU' => BackendUtility::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']), 'CONTENT' => ($this->errorMessage ? $this->errorMessage->render() : '') . $pageContent, 'FOLDER_IDENTIFIER' => $this->folderObject->getCombinedIdentifier(), 'FILEDENYPATERN' => $GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern'], 'MAXFILESIZE' => GeneralUtility::getMaxUploadFileSize() * 1024); $this->content = $this->doc->moduleBody(array(), $docHeaderButtons, array_merge($markerArray, $otherMarkers)); // Renders the module page $this->content = $this->doc->render($this->getLanguageService()->getLL('files'), $this->content); } else { $content = ''; if ($this->errorMessage) { $this->errorMessage->setSeverity(FlashMessage::ERROR); $content = $this->doc->moduleBody(array(), array_merge(array('REFRESH' => '', 'PASTE' => '', 'LEVEL_UP' => ''), $this->getButtons()), array('CSH' => '', 'TITLE' => '', 'FOLDER_INFO' => '', 'PAGE_ICON' => '', 'FUNC_MENU' => '', 'CONTENT' => $this->errorMessage->render())); } // Create output - no access (no warning though) $this->content = $this->doc->render($this->getLanguageService()->getLL('files'), $content); } }
/** * @return void */ public function indexAction() { $pageRenderer = $this->view->getModuleTemplate()->getPageRenderer(); $pageRenderer->setTitle($this->getLanguageService()->getLL('files')); // There there was access to this file path, continue, make the list if ($this->folderObject) { // Create fileListing object $this->filelist = GeneralUtility::makeInstance(FileList::class, $this); $this->filelist->thumbs = $GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'] && $this->MOD_SETTINGS['displayThumbs']; // Create clipboard object and initialize that $this->filelist->clipObj = GeneralUtility::makeInstance(Clipboard::class); $this->filelist->clipObj->fileMode = 1; $this->filelist->clipObj->initializeClipboard(); $CB = GeneralUtility::_GET('CB'); if ($this->cmd == 'setCB') { $CB['el'] = $this->filelist->clipObj->cleanUpCBC(array_merge(GeneralUtility::_POST('CBH'), (array) GeneralUtility::_POST('CBC')), '_FILE'); } if (!$this->MOD_SETTINGS['clipBoard']) { $CB['setP'] = 'normal'; } $this->filelist->clipObj->setCmd($CB); $this->filelist->clipObj->cleanCurrent(); // Saves $this->filelist->clipObj->endClipboard(); // If the "cmd" was to delete files from the list (clipboard thing), do that: if ($this->cmd == 'delete') { $items = $this->filelist->clipObj->cleanUpCBC(GeneralUtility::_POST('CBC'), '_FILE', 1); if (!empty($items)) { // Make command array: $FILE = []; foreach ($items as $v) { $FILE['delete'][] = ['data' => $v]; } // Init file processing object for deleting and pass the cmd array. /** @var ExtendedFileUtility $fileProcessor */ $fileProcessor = GeneralUtility::makeInstance(ExtendedFileUtility::class); $fileProcessor->setActionPermissions(); $fileProcessor->setExistingFilesConflictMode($this->overwriteExistingFiles); $fileProcessor->start($FILE); $fileProcessor->processData(); } } // Start up filelisting object, include settings. $this->pointer = MathUtility::forceIntegerInRange($this->pointer, 0, 100000); $this->filelist->start($this->folderObject, $this->pointer, $this->MOD_SETTINGS['sort'], $this->MOD_SETTINGS['reverse'], $this->MOD_SETTINGS['clipBoard'], $this->MOD_SETTINGS['bigControlPanel']); // Generate the list $this->filelist->generateList(); // Set top JavaScript: $this->view->getModuleTemplate()->addJavaScriptCode('FileListIndex', 'if (top.fsMod) top.fsMod.recentIds["file"] = "' . rawurlencode($this->id) . '";' . $this->filelist->CBfunctions() . ' function jumpToUrl(URL) { window.location.href = URL; return false; } '); $pageRenderer->loadRequireJsModule('TYPO3/CMS/Filelist/FileDelete'); $pageRenderer->addInlineLanguageLabelFile('EXT:lang/Resources/Private/Language/locallang_alt_doc.xlf', 'buttons'); // Include DragUploader only if we have write access if ($this->folderObject->getStorage()->checkUserActionPermission('add', 'File') && $this->folderObject->checkActionPermission('write')) { $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/DragUploader'); $pageRenderer->addInlineLanguageLabelFile('EXT:lang/Resources/Private/Language/locallang_core.xlf', 'file_upload'); $pageRenderer->addInlineLanguageLabelArray(['permissions.read' => $this->getLanguageService()->getLL('read'), 'permissions.write' => $this->getLanguageService()->getLL('write')]); } // Setting up the buttons $this->registerButtons(); $pageRecord = ['_additional_info' => $this->filelist->getFolderInfo(), 'combined_identifier' => $this->folderObject->getCombinedIdentifier()]; $this->view->getModuleTemplate()->getDocHeaderComponent()->setMetaInformation($pageRecord); $this->view->assign('headline', $this->getModuleHeadline()); $this->view->assign('listHtml', $this->filelist->HTMLcode); $this->view->assign('checkboxes', ['bigControlPanel' => ['enabled' => $this->getBackendUser()->getTSConfigVal('options.file_list.enableDisplayBigControlPanel') === 'selectable', 'label' => htmlspecialchars($this->getLanguageService()->getLL('bigControlPanel')), 'html' => BackendUtility::getFuncCheck($this->id, 'SET[bigControlPanel]', $this->MOD_SETTINGS['bigControlPanel'], '', '', 'id="bigControlPanel"')], 'displayThumbs' => ['enabled' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'] && $this->getBackendUser()->getTSConfigVal('options.file_list.enableDisplayThumbnails') === 'selectable', 'label' => htmlspecialchars($this->getLanguageService()->getLL('displayThumbs')), 'html' => BackendUtility::getFuncCheck($this->id, 'SET[displayThumbs]', $this->MOD_SETTINGS['displayThumbs'], '', '', 'id="checkDisplayThumbs"')], 'enableClipBoard' => ['enabled' => $this->getBackendUser()->getTSConfigVal('options.file_list.enableClipBoard') === 'selectable', 'label' => htmlspecialchars($this->getLanguageService()->getLL('clipBoard')), 'html' => BackendUtility::getFuncCheck($this->id, 'SET[clipBoard]', $this->MOD_SETTINGS['clipBoard'], '', '', 'id="checkClipBoard"')]]); $this->view->assign('showClipBoard', (bool) $this->MOD_SETTINGS['clipBoard']); $this->view->assign('clipBoardHtml', $this->filelist->clipObj->printClipboard()); $this->view->assign('folderIdentifier', $this->folderObject->getCombinedIdentifier()); $this->view->assign('fileDenyPattern', $GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern']); $this->view->assign('maxFileSize', GeneralUtility::getMaxUploadFileSize() * 1024); } else { $this->forward('missingFolder'); } }
/** * @return void */ public function indexAction() { // There there was access to this file path, continue, make the list if ($this->folderObject) { $requireJsModules = ['TYPO3/CMS/Filelist/FileListLocalisation', 'TYPO3/CMS/Filelist/FileSearch']; $addJsInlineLabels = []; // Create filelisting object $this->filelist = GeneralUtility::makeInstance(FileList::class, $this); $this->filelist->thumbs = $this->MOD_SETTINGS['displayThumbs']; // Create clipboard object and initialize that $this->filelist->clipObj = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Clipboard\Clipboard::class); $this->filelist->clipObj->fileMode = 1; $this->filelist->clipObj->initializeClipboard(); $CB = GeneralUtility::_GET('CB'); if ($this->cmd == 'setCB') { $CB['el'] = $this->filelist->clipObj->cleanUpCBC(array_merge(GeneralUtility::_POST('CBH'), (array) GeneralUtility::_POST('CBC')), '_FILE'); } if (!$this->MOD_SETTINGS['clipBoard']) { $CB['setP'] = 'normal'; } $this->filelist->clipObj->setCmd($CB); $this->filelist->clipObj->cleanCurrent(); // Saves $this->filelist->clipObj->endClipboard(); // If the "cmd" was to delete files from the list (clipboard thing), do that: if ($this->cmd == 'delete') { $items = $this->filelist->clipObj->cleanUpCBC(GeneralUtility::_POST('CBC'), '_FILE', 1); if (!empty($items)) { // Make command array: $FILE = array(); foreach ($items as $v) { $FILE['delete'][] = array('data' => $v); } // Init file processing object for deleting and pass the cmd array. /** @var ExtendedFileUtility $fileProcessor */ $fileProcessor = GeneralUtility::makeInstance(ExtendedFileUtility::class); $fileProcessor->init(array(), $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']); $fileProcessor->setActionPermissions(); $fileProcessor->setExistingFilesConflictMode($this->overwriteExistingFiles); $fileProcessor->start($FILE); $fileProcessor->processData(); $fileProcessor->pushErrorMessagesToFlashMessageQueue(); } } // Start up filelisting object, include settings. $this->pointer = MathUtility::forceIntegerInRange($this->pointer, 0, 100000); $this->filelist->start($this->folderObject, $this->pointer, $this->MOD_SETTINGS['sort'], $this->MOD_SETTINGS['reverse'], $this->MOD_SETTINGS['clipBoard'], $this->MOD_SETTINGS['bigControlPanel']); // Generate the list $this->filelist->generateList(); // Set top JavaScript: $addJsInline = 'if (top.fsMod) top.fsMod.recentIds["file"] = "' . rawurlencode($this->id) . '";' . $this->filelist->CBfunctions(); // Setting up the buttons and markers for docheader list($buttons, $otherMarkers) = $this->filelist->getButtonsAndOtherMarkers($this->folderObject); // add the folder info to the marker array $otherMarkers['FOLDER_INFO'] = $this->filelist->getFolderInfo(); $docHeaderButtons = array_merge($this->getButtons(), $buttons); // Include DragUploader only if we have write access if ($this->folderObject->getStorage()->checkUserActionPermission('add', 'File') && $this->folderObject->checkActionPermission('write')) { $requireJsModules[] = 'TYPO3/CMS/Backend/DragUploader'; $addJsInlineLabelFiles[] = ['file' => ExtensionManagementUtility::extPath('lang') . 'locallang_core.xlf', 'prefix' => 'file_upload']; } $this->view->assign('otherMarkers', $otherMarkers); $this->view->assign('docHeaderButtons', $docHeaderButtons); $this->view->assign('pageTitle', $this->getLanguageService()->getLL('files')); $this->view->assign('requireJsModules', $requireJsModules); $this->view->assign('addJsInlineLabelFiles', $addJsInlineLabelFiles); $this->view->assign('addJsInline', $addJsInline); $this->view->assign('headline', $this->getModuleHeadline()); $this->view->assign('listHtml', $this->filelist->HTMLcode); $this->view->assign('checkboxes', ['bigControlPanel' => ['enabled' => $this->getBackendUser()->getTSConfigVal('options.file_list.enableDisplayBigControlPanel') === 'selectable', 'label' => $this->getLanguageService()->getLL('bigControlPanel', true), 'html' => BackendUtility::getFuncCheck($this->id, 'SET[bigControlPanel]', $this->MOD_SETTINGS['bigControlPanel'], '', '', 'id="bigControlPanel"')], 'displayThumbs' => ['enabled' => $this->getBackendUser()->getTSConfigVal('options.file_list.enableDisplayThumbnails') === 'selectable', 'label' => $this->getLanguageService()->getLL('displayThumbs', true), 'html' => BackendUtility::getFuncCheck($this->id, 'SET[displayThumbs]', $this->MOD_SETTINGS['displayThumbs'], '', '', 'id="checkDisplayThumbs"')], 'enableClipBoard' => ['enabled' => $this->getBackendUser()->getTSConfigVal('options.file_list.enableClipBoard') === 'selectable', 'label' => $this->getLanguageService()->getLL('clipBoard', true), 'html' => BackendUtility::getFuncCheck($this->id, 'SET[clipBoard]', $this->MOD_SETTINGS['clipBoard'], '', '', 'id="checkClipBoard"')]]); $this->view->assign('showClipBoard', (bool) $this->MOD_SETTINGS['clipBoard']); $this->view->assign('clipBoardHtml', $this->filelist->clipObj->printClipboard()); $this->view->assign('folderIdentifier', $this->folderObject->getCombinedIdentifier()); $this->view->assign('fileDenyPattern', $GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern']); $this->view->assign('maxFileSize', GeneralUtility::getMaxUploadFileSize() * 1024); } else { $this->forward('missingFolder'); } }