/** * Render a FlashMessage across all TYPO3 version supported * @param FlashMessage $flashMessage * @return string HTML */ private function renderFlashMessage(FlashMessage $flashMessage) { // From TYPO3 8.0 and higher, we can use getMessageAsMarkup(), but everything older should use render() method if (is_callable([$flashMessage, 'getMessageAsMarkup'])) { return $flashMessage->getMessageAsMarkup(); } else { return $flashMessage->render(); } }
/** * @todo missing docblock */ function main() { $buffer = ''; $registry = GeneralUtility::makeInstance('KayStrobach\\Dyncss\\Configuration\\BeRegistry'); $handlers = $registry->getAllFileHandler(); if (count($handlers)) { foreach ($handlers as $extension => $class) { $parser = new $class(); $buffer .= '<tr><td>*.' . $extension . '</td><td>' . $class . '</td><td>' . $parser->getVersion() . '</td></tr>'; } $flashMessage = new FlashMessage('Congrats, you have ' . count($handlers) . ' handlers registered.', '', FlashMessage::OK); return $flashMessage->render() . '<table class="t3-table"><thead><tr><th>extension</th><th>class</th><th>version</th></tr></thead>' . $buffer . '</table>'; } else { $flashMessage = new FlashMessage('Please install one of the dyncss_* extensions', 'No handler registered! - No dynamic css is handled at all ;/', FlashMessage::ERROR); return $flashMessage->render(); } }
/** * 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); } }