[TASK] Fluidification of RenameFileController 25/50725/2
authorMichael Oehlhof <typo3@oehlhof.de>
Mon, 21 Nov 2016 16:04:46 +0000 (17:04 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Thu, 1 Dec 2016 10:22:05 +0000 (11:22 +0100)
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>
typo3/sysext/backend/Classes/Controller/File/RenameFileController.php
typo3/sysext/backend/Resources/Private/Templates/File/RenameFile.html [new file with mode: 0644]

index d28b2f7..105fa3f 100644 (file)
@@ -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 (file)
index 0000000..e6a1441
--- /dev/null
@@ -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