From 3fdbeb369cf633cc3f443f62a87e465327926ed7 Mon Sep 17 00:00:00 2001 From: Michael Oehlhof <typo3@oehlhof.de> Date: Mon, 21 Nov 2016 17:04:46 +0100 Subject: [PATCH] [TASK] Fluidification of RenameFileController Resolves: #78762 Releases: master Change-Id: Ib9306710f92b8ce3cfb49ac23f4d847598a19f98 Reviewed-on: https://review.typo3.org/50725 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Joerg Boesche <typo3@joergboesche.de> Reviewed-by: Markus Sommer <markussom@posteo.de> Reviewed-by: Jan Helke <typo3@helke.de> Tested-by: Jan Helke <typo3@helke.de> Reviewed-by: Gianluigi Martino <gmartino27@gmail.com> Tested-by: Gianluigi Martino <gmartino27@gmail.com> Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de> --- .../Controller/File/RenameFileController.php | 41 +++++++------------ .../Private/Templates/File/RenameFile.html | 14 +++++++ 2 files changed, 29 insertions(+), 26 deletions(-) create mode 100644 typo3/sysext/backend/Resources/Private/Templates/File/RenameFile.html diff --git a/typo3/sysext/backend/Classes/Controller/File/RenameFileController.php b/typo3/sysext/backend/Classes/Controller/File/RenameFileController.php index d28b2f7550f3..105fa3f44eff 100644 --- a/typo3/sysext/backend/Classes/Controller/File/RenameFileController.php +++ b/typo3/sysext/backend/Classes/Controller/File/RenameFileController.php @@ -20,6 +20,7 @@ use TYPO3\CMS\Backend\Module\AbstractModule; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Fluid\View\StandaloneView; /** * Script Class for the rename-file form. @@ -138,27 +139,11 @@ class RenameFileController extends AbstractModule } else { $fileIdentifier = $this->fileOrFolderObject->getUid(); } - $pageContent = '<form action="' . htmlspecialchars(BackendUtility::getModuleUrl('tce_file')) . '" method="post" name="editform" role="form">'; - // Making the formfields for renaming: - $pageContent .= ' - - <div class="form-group"> - <input class="form-control" type="text" name="file[rename][0][target]" value="' . htmlspecialchars($this->fileOrFolderObject->getName()) . '" ' . $this->getDocumentTemplate()->formWidth(40) . ' /> - <input type="hidden" name="file[rename][0][data]" value="' . htmlspecialchars($fileIdentifier) . '" /> - </div> - '; - // Making submit button: - $pageContent .= ' - <div class="form-group"> - <input class="btn btn-primary" type="submit" value="' . - htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:file_rename.php.submit')) . '" /> - <input class="btn btn-danger" type="submit" value="' . - htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.cancel')) . - '" onclick="backToList(); return false;" /> - <input type="hidden" name="redirect" value="' . htmlspecialchars($this->returnUrl) . '" /> - </div> - '; - $pageContent .= '</form>'; + $assigns = []; + $assigns['moduleUrlTceFile'] = BackendUtility::getModuleUrl('tce_file'); + $assigns['fileName'] = $this->fileOrFolderObject->getName(); + $assigns['fileIdentifier'] = $fileIdentifier; + $assigns['returnUrl'] = $this->returnUrl; // Create buttons $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar(); @@ -178,11 +163,15 @@ class RenameFileController extends AbstractModule $buttonBar->addButton($backButton); } - // set header - $this->content = '<h1>' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:file_rename.php.pagetitle') . '</h1>'; - - // add section - $this->content .= '<div>' . $pageContent . '</div>'; + // 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/RenameFile.html' + )); + $view->assignMultiple($assigns); + $this->content = $view->render(); $this->moduleTemplate->setContent($this->content); } diff --git a/typo3/sysext/backend/Resources/Private/Templates/File/RenameFile.html b/typo3/sysext/backend/Resources/Private/Templates/File/RenameFile.html new file mode 100644 index 000000000000..e6a1441f8f18 --- /dev/null +++ b/typo3/sysext/backend/Resources/Private/Templates/File/RenameFile.html @@ -0,0 +1,14 @@ +<h1><f:translate key="LLL:EXT:lang/locallang_core.xlf:file_rename.php.pagetitle" /></h1> +<div> + <form action="{moduleUrlTceFile}" method="post" name="editform" role="form"> + <div class="form-group"> + <input class="form-control" type="text" name="file[rename][0][target]" value="{fileName}" style="width:384px;" /> + <input type="hidden" name="file[rename][0][data]" value="{fileIdentifier}" /> + </div> + <div class="form-group"> + <input class="btn btn-primary" type="submit" value="{f:translate(key: 'LLL:EXT:lang/locallang_core.xlf:file_rename.php.submit')}" /> + <input class="btn btn-danger" type="submit" value="{f:translate(key: 'LLL:EXT:lang/locallang_core.xlf:labels.cancel')}" onclick="backToList(); return false;" /> + <input type="hidden" name="redirect" value="{returnUrl}" /> + </div> + </form> +</div> \ No newline at end of file -- GitLab