From 1eca31f3a069e9c13d0fb99515e78d0e56b2f262 Mon Sep 17 00:00:00 2001 From: Michael Oehlhof <typo3@oehlhof.de> Date: Mon, 21 Nov 2016 14:10:06 +0100 Subject: [PATCH] [!!!][TASK] Fluidification of EditFileController Resolves: #78759 Releases: master Change-Id: I2ba72aeda6d56610cc4977f222abe26d124b7f15 Reviewed-on: https://review.typo3.org/50722 Reviewed-by: Gleb Levitin <gleb.levitin@dkd.de> Tested-by: Gleb Levitin <gleb.levitin@dkd.de> Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Jan Helke <typo3@helke.de> Tested-by: Jan Helke <typo3@helke.de> Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de> --- .../Controller/File/EditFileController.php | 44 +++++++++---------- .../Private/Templates/File/EditFile.html | 14 ++++++ ...759-FluidificationOfEditFileController.rst | 32 ++++++++++++++ 3 files changed, 67 insertions(+), 23 deletions(-) create mode 100644 typo3/sysext/backend/Resources/Private/Templates/File/EditFile.html create mode 100644 typo3/sysext/core/Documentation/Changelog/master/Breaking-78759-FluidificationOfEditFileController.rst diff --git a/typo3/sysext/backend/Classes/Controller/File/EditFileController.php b/typo3/sysext/backend/Classes/Controller/File/EditFileController.php index 6f91a53e14ad..7f854e3e277b 100644 --- a/typo3/sysext/backend/Classes/Controller/File/EditFileController.php +++ b/typo3/sysext/backend/Classes/Controller/File/EditFileController.php @@ -24,6 +24,7 @@ use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException; use TYPO3\CMS\Core\Resource\ResourceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Fluid\View\StandaloneView; /** * Script Class for rendering the file editing screen @@ -144,7 +145,7 @@ class EditFileController extends AbstractModule public function main() { $this->getButtons(); - // Hook before compiling the output + // Hook: before compiling the output if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['preOutputProcessingHook'])) { $preOutputProcessingHook = &$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['preOutputProcessingHook']; if (is_array($preOutputProcessingHook)) { @@ -158,12 +159,10 @@ class EditFileController extends AbstractModule } } - $pageContent = '<form action="' . htmlspecialchars(BackendUtility::getModuleUrl('tce_file')) . '" method="post" id="EditFileController" name="editform">'; - $pageContent .= '<h1>' - . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:file_edit.php.pagetitle') - . ' ' . htmlspecialchars($this->fileObject->getName()) . '</h1>'; + $assigns = []; + $assigns['moduleUrlTceFile'] = BackendUtility::getModuleUrl('tce_file'); + $assigns['fileName'] = $this->fileObject->getName(); - $code = ''; $extList = $GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext']; try { if (!$extList || !GeneralUtility::inList($extList, $this->fileObject->getExtension())) { @@ -178,24 +177,24 @@ class EditFileController extends AbstractModule 'target' => $this->origTarget, 'returnUrl' => $this->returnUrl ]); - $code .= ' - <div id="c-edit"> - <textarea rows="30" name="file[editfile][0][data]" wrap="off" class="form-control text-monospace t3js-enable-tab">' . htmlspecialchars($fileContent) . '</textarea> - <input type="hidden" name="file[editfile][0][target]" value="' . $this->fileObject->getUid() . '" /> - <input type="hidden" name="redirect" value="' . htmlspecialchars($hValue) . '" /> - </div> - <br />'; + $assigns['uid'] = $this->fileObject->getUid(); + $assigns['fileContent'] = $fileContent; + $assigns['hValue'] = $hValue; } catch (\Exception $e) { - $code .= sprintf( - $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:file_edit.php.coundNot'), - $extList - ); + $assigns['extList'] = $extList; } - // Ending of section and outputting editing form: - $pageContent .= $code; - - // Hook after compiling the output + // Rendering of the output via fluid + $view = GeneralUtility::makeInstance(StandaloneView::class); + $view->setTemplateRootPaths([GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Private/Templates')]); + $view->setPartialRootPaths([GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Private/Partials')]); + $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName( + 'EXT:backend/Resources/Private/Templates/File/EditFile.html' + )); + $view->assignMultiple($assigns); + $pageContent = $view->render(); + + // Hook: after compiling the output if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['postOutputProcessingHook'])) { $postOutputProcessingHook = &$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['postOutputProcessingHook']; if (is_array($postOutputProcessingHook)) { @@ -208,9 +207,8 @@ class EditFileController extends AbstractModule } } } - $pageContent .= '</form>'; - $this->content = $pageContent; + $this->content .= $pageContent; $this->moduleTemplate->setContent($this->content); } diff --git a/typo3/sysext/backend/Resources/Private/Templates/File/EditFile.html b/typo3/sysext/backend/Resources/Private/Templates/File/EditFile.html new file mode 100644 index 000000000000..f505c4340756 --- /dev/null +++ b/typo3/sysext/backend/Resources/Private/Templates/File/EditFile.html @@ -0,0 +1,14 @@ +<form action="{moduleUrlTceFile}" method="post" id="EditFileController" name="editform"> + <h1><f:translate key="LLL:EXT:lang/locallang_core.xlf:file_edit.php.pagetitle" /> {fileName}</h1> + <div id="c-edit"> + <textarea rows="30" name="file[editfile][0][data]" wrap="off" class="form-control text-monospace t3js-enable-tab">{fileContent}</textarea> + <input type="hidden" name="file[editfile][0][target]" value="{uid}" /> + <input type="hidden" name="redirect" value="{hValue}" /> + </div> + <br /> + <f:if condition="{extList}"> + <f:format.raw> + <f:translate key="LLL:EXT:lang/locallang_core.xlf:file_edit.php.coundNot" arguments="{0: extList}" /> + </f:format.raw> + </f:if> +</form> diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-78759-FluidificationOfEditFileController.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-78759-FluidificationOfEditFileController.rst new file mode 100644 index 000000000000..e7f886f8ed42 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Breaking-78759-FluidificationOfEditFileController.rst @@ -0,0 +1,32 @@ +.. include:: ../../Includes.txt + +======================================================= +Breaking: #78759 - Fluidification of EditFileController +======================================================= + +See :issue:`78759` + +Description +=========== + +While moving all HTML from PHP code to an own Fluid template the HTML data given to the hook after compiling the output is different now. + + +Impact +====== + +The HTML data given to the hook after compiling the output now contains the closing form tag (</form>). + + +Affected Installations +====================== + +All installations that append text to the HTML code in the hook after compiling the output. + + +Migration +========= + +The hook code has to be changed to insert additional code before the closing form tag. + +.. index:: Backend, Fluid \ No newline at end of file -- GitLab