[TASK] Refactoring of backend login screen 43/38043/11
authorFrank Nägler <typo3@naegler.net>
Mon, 23 Mar 2015 15:06:41 +0000 (16:06 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Sun, 29 Mar 2015 12:29:40 +0000 (14:29 +0200)
Refactoring of LoginController and introducing a complete new
login screen.

Resolves: #65939
Releases: master
Change-Id: I89d98754377b6529828dcbf2a56051a8052ccda2
Reviewed-on: http://review.typo3.org/38043
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/backend/Classes/Controller/LoginController.php
typo3/sysext/backend/Resources/Private/Templates/Login.html [new file with mode: 0644]
typo3/sysext/backend/Resources/Private/Templates/login.html [deleted file]
typo3/sysext/core/Documentation/Changelog/master/Breaking-65939-BackendLoginRefactoring.rst [new file with mode: 0644]

index a26b0f0..9ad60e5 100644 (file)
@@ -16,10 +16,14 @@ namespace TYPO3\CMS\Backend\Controller;
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Utility\IconUtility;
-use TYPO3\CMS\Core\Html\HtmlParser;
+use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
+use TYPO3\CMS\Core\Database\DatabaseConnection;
+use TYPO3\CMS\Core\FormProtection\FormProtectionFactory;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\HttpUtility;
+use TYPO3\CMS\Fluid\View\StandaloneView;
+use TYPO3\CMS\Lang\LanguageService;
 
 /**
  * Script Class for rendering the login form
@@ -27,9 +31,6 @@ use TYPO3\CMS\Core\Utility\HttpUtility;
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  */
 class LoginController {
-
-       const SIGNAL_RenderLoginForm = 'renderLoginForm';
-
        /**
         * The URL to redirect to after login.
         *
@@ -140,11 +141,6 @@ class LoginController {
        public $loginSecurityLevel = 'superchallenged';
 
        /**
-        * @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher
-        */
-       protected $signalSlotDispatcher;
-
-       /**
         * Constructor
         */
        public function __construct() {
@@ -178,18 +174,17 @@ class LoginController {
                        $this->loginSecurityLevel = $GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel'];
                }
                // Try to get the preferred browser language
-               $preferredBrowserLanguage = $GLOBALS['LANG']->csConvObj->getPreferredClientLanguage(GeneralUtility::getIndpEnv('HTTP_ACCEPT_LANGUAGE'));
+               $preferredBrowserLanguage = $this->getLanguageService()->csConvObj->getPreferredClientLanguage(GeneralUtility::getIndpEnv('HTTP_ACCEPT_LANGUAGE'));
                // If we found a $preferredBrowserLanguage and it is not the default language and no be_user is logged in
-               // initialize $GLOBALS['LANG'] again with $preferredBrowserLanguage
-               if ($preferredBrowserLanguage !== 'default' && empty($GLOBALS['BE_USER']->user['uid'])) {
-                       $GLOBALS['LANG']->init($preferredBrowserLanguage);
+               // initialize $this->getLanguageService() again with $preferredBrowserLanguage
+               if ($preferredBrowserLanguage !== 'default' && empty($this->getBackendUserAuthentication()->user['uid'])) {
+                       $this->getLanguageService()->init($preferredBrowserLanguage);
                }
-               $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_login.xlf');
                // Setting the redirect URL to "backend.php" if no alternative input is given
                $this->redirectToURL = $this->redirect_url ?: 'backend.php';
                // Do a logout if the command is set
-               if ($this->L == 'OUT' && is_object($GLOBALS['BE_USER'])) {
-                       $GLOBALS['BE_USER']->logoff();
+               if ($this->L == 'OUT' && is_object($this->getBackendUserAuthentication())) {
+                       $this->getBackendUserAuthentication()->logoff();
                        HttpUtility::redirect($this->redirect_url);
                }
        }
@@ -201,9 +196,10 @@ class LoginController {
         */
        public function main() {
                // Initialize template object:
-               $GLOBALS['TBE_TEMPLATE']->moduleTemplate = $GLOBALS['TBE_TEMPLATE']->getHtmlTemplate('EXT:backend/Resources/Private/Templates/login.html');
+               $view = $this->getFluidTemplateObject('EXT:backend/Resources/Private/Templates/Login.html');
+
                /** @var $pageRenderer \TYPO3\CMS\Core\Page\PageRenderer */
-               $pageRenderer = $GLOBALS['TBE_TEMPLATE']->getPageRenderer();
+               $pageRenderer = $this->getDocumentTemplate()->getPageRenderer();
                $pageRenderer->loadJquery();
 
                // support placeholders for IE9 and lower
@@ -216,9 +212,9 @@ class LoginController {
                if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/index.php']['loginScriptHook'])) {
                        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/index.php']['loginScriptHook'] as $function) {
                                $params = array();
-                               $JSCode = GeneralUtility::callUserFunction($function, $params, $this);
-                               if ($JSCode) {
-                                       $GLOBALS['TBE_TEMPLATE']->JScode .= $JSCode;
+                               $javaScriptCode = GeneralUtility::callUserFunction($function, $params, $this);
+                               if ($javaScriptCode) {
+                                       $this->getDocumentTemplate()->JScode .= $javaScriptCode;
                                        break;
                                }
                        }
@@ -227,25 +223,48 @@ class LoginController {
                // Checking, if we should make a redirect.
                // Might set JavaScript in the header to close window.
                $this->checkRedirect();
-               // Initialize interface selectors:
-               $this->makeInterfaceSelectorBox();
-               // Creating form based on whether there is a login or not:
-               if (empty($GLOBALS['BE_USER']->user['uid'])) {
-                       $GLOBALS['TBE_TEMPLATE']->form = $this->startForm();
-                       $loginForm = $this->makeLoginForm();
+
+               if ($GLOBALS['TBE_STYLES']['logo_login']) {
+                       $logo = '<img src="' . htmlspecialchars(($GLOBALS['BACK_PATH'] . $GLOBALS['TBE_STYLES']['logo_login'])) . '" alt="" class="t3-login-logo" />';
                } else {
-                       $GLOBALS['TBE_TEMPLATE']->form = '
-                               <form action="index.php" method="post" name="loginform">
-                               <input type="hidden" name="login_status" value="logout" />
-                               ';
-                       $loginForm = $this->makeLogoutForm();
+                       $logo = '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/typo3-transparent@2x.png', 'width="140" height="39"') . ' alt="" class="t3-login-logo t3-default-logo" />';
                }
 
+               $formType = empty($this->getBackendUserAuthentication()->user['uid']) ? 'loginForm' : 'logoutForm';
+               $loginNewsTitle = $GLOBALS['TYPO3_CONF_VARS']['BE']['loginNewsTitle']
+                       ? $GLOBALS['TYPO3_CONF_VARS']['BE']['loginNewsTitle']
+                       : $this->getLanguageService()->getLL('newsheadline');
+
+               // Start form
+               $view->assignMultiple(array(
+                       'formTag' => $this->startForm(),
+                       'labelPrefixPath' => 'LLL:EXT:lang/locallang_login.xlf:',
+                       'backendUser' => $this->getBackendUserAuthentication()->user,
+                       'hasLoginError' => $this->isLoginInProgress(),
+                       'presetUsername' => $this->u,
+                       'presetPassword' => $this->p,
+                       'presetOpenId' => $this->openIdUrl,
+                       'formType' => $formType,
+                       'logo' => $logo,
+                       'isOpenIdLoaded' => ExtensionManagementUtility::isLoaded('openid'),
+                       'copyright' => BackendUtility::TYPO3_copyRightNotice($GLOBALS['TYPO3_CONF_VARS']['SYS']['loginCopyrightShowVersion']),
+                       'loginNewsTitle' => $loginNewsTitle,
+                       'loginNewsItems' => $this->getSystemNews()
+               ));
+
+               // Initialize interface selectors:
+               $this->makeInterfaceSelectorBox();
+               $view->assignMultiple(array(
+                       'interfaceSelector' => $this->interfaceSelector,
+                       'interfaceSelectorJump' => $this->interfaceSelector_jump
+               ));
+
                // Starting page:
-               $this->content .= $GLOBALS['TBE_TEMPLATE']->startPage('TYPO3 CMS Login: ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'], FALSE);
-               // Add login form:
-               $this->content .= $this->wrapLoginForm($loginForm);
-               $this->content .= $GLOBALS['TBE_TEMPLATE']->endPage();
+               $this->content .= $this->getDocumentTemplate()->startPage('TYPO3 CMS Login: ' .
+                       $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'], FALSE);
+               // Add Content:
+               $this->content .= $view->render();
+               $this->content .= $this->getDocumentTemplate()->endPage();
        }
 
        /**
@@ -263,151 +282,49 @@ class LoginController {
         *
         ******************************/
        /**
-        * Creates the login form
-        * This is drawn when NO login exists.
-        *
-        * @return string HTML output
-        */
-       public function makeLoginForm() {
-               $content = HtmlParser::getSubpart($GLOBALS['TBE_TEMPLATE']->moduleTemplate, '###LOGIN_FORM###');
-               $markers = array(
-                       'VALUE_USERNAME' => htmlspecialchars($this->u),
-                       'VALUE_PASSWORD' => htmlspecialchars($this->p),
-                       'VALUE_OPENID_URL' => htmlspecialchars($this->openIdUrl),
-                       'VALUE_SUBMIT' => $GLOBALS['LANG']->getLL('labels.submitLogin', TRUE)
-               );
-               // Show an error message if the login command was successful already, otherwise remove the subpart
-               if (!$this->isLoginInProgress()) {
-                       $content = HtmlParser::substituteSubpart($content, '###LOGIN_ERROR###', '');
-               } else {
-                       $markers['ERROR_MESSAGE'] = $GLOBALS['LANG']->getLL('error.login', TRUE);
-                       $markers['ERROR_LOGIN_TITLE'] = $GLOBALS['LANG']->getLL('error.login.title', TRUE);
-                       $markers['ERROR_LOGIN_DESCRIPTION'] = $GLOBALS['LANG']->getLL('error.login.description', TRUE);
-               }
-               // Remove the interface selector markers if it's not available
-               if (!($this->interfaceSelector && !$this->loginRefresh)) {
-                       $content = HtmlParser::substituteSubpart($content, '###INTERFACE_SELECTOR###', '');
-               } else {
-                       $markers['LABEL_INTERFACE'] = $GLOBALS['LANG']->getLL('labels.interface', TRUE);
-                       $markers['VALUE_INTERFACE'] = $this->interfaceSelector;
-               }
-               return HtmlParser::substituteMarkerArray($content, $markers, '###|###');
-       }
-
-       /**
-        * Creates the logout form
-        * This is drawn if a user login already exists.
-        *
-        * @return string HTML output
-        */
-       public function makeLogoutForm() {
-               $content = HtmlParser::getSubpart($GLOBALS['TBE_TEMPLATE']->moduleTemplate, '###LOGOUT_FORM###');
-               $markers = array(
-                       'LABEL_USERNAME' => $GLOBALS['LANG']->getLL('labels.username', TRUE),
-                       'VALUE_USERNAME' => htmlspecialchars($GLOBALS['BE_USER']->user['username']),
-                       'VALUE_SUBMIT' => $GLOBALS['LANG']->getLL('labels.submitLogout', TRUE)
-               );
-               // Remove the interface selector markers if it's not available
-               if (!$this->interfaceSelector_jump) {
-                       $content = HtmlParser::substituteSubpart($content, '###INTERFACE_SELECTOR###', '');
-               } else {
-                       $markers['LABEL_INTERFACE'] = $GLOBALS['LANG']->getLL('labels.interface', TRUE);
-                       $markers['VALUE_INTERFACE'] = $this->interfaceSelector_jump;
-               }
-               return HtmlParser::substituteMarkerArray($content, $markers, '###|###');
-       }
-
-       /**
-        * Wrapping the login form table in another set of tables etc:
-        *
-        * @param string $content HTML content for the login form
-        * @return string The HTML for the page.
-        */
-       public function wrapLoginForm($content) {
-               $mainContent = HtmlParser::getSubpart($GLOBALS['TBE_TEMPLATE']->moduleTemplate, '###PAGE###');
-
-               if ($GLOBALS['TBE_STYLES']['logo_login']) {
-                       $logo = '<img src="' . htmlspecialchars(($GLOBALS['BACK_PATH'] . $GLOBALS['TBE_STYLES']['logo_login'])) . '" alt="" class="t3-login-logo" />';
-               } else {
-                       $logo = '<img' . IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/typo3-transparent@2x.png', 'width="140" height="39"') . ' alt="" class="t3-login-logo t3-default-logo" />';
-               }
-
-               $additionalCssClasses = array();
-               if ($this->isLoginInProgress()) {
-                       $additionalCssClasses[] = 'error';
-               }
-               if ($this->loginRefresh) {
-                       $additionalCssClasses[] = 'refresh';
-               }
-               $markers = array(
-                       'LOGO' => $logo,
-                       'LOGINBOX_IMAGE' => '',
-                       'FORM' => $content,
-                       'NEWS' => $this->makeLoginNews(),
-                       'COPYRIGHT' => BackendUtility::TYPO3_copyRightNotice($GLOBALS['TYPO3_CONF_VARS']['SYS']['loginCopyrightShowVersion']),
-                       'CSS_CLASSES' => !empty($additionalCssClasses) ? 'class="' . implode(' ', $additionalCssClasses) . '"' : '',
-                       'CSS_OPENIDCLASS' => 't3-login-openid-' . (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('openid') ? 'enabled' : 'disabled'),
-                       // The labels will be replaced later on, thus the other parts above
-                       // can use these markers as well and it will be replaced
-                       'HEADLINE' => $GLOBALS['LANG']->getLL('headline', TRUE),
-                       'INFO_ABOUT' => $GLOBALS['LANG']->getLL('info.about', TRUE),
-                       'INFO_RELOAD' => $GLOBALS['LANG']->getLL('info.reset', TRUE),
-                       'INFO' => $GLOBALS['LANG']->getLL('info.cookies_and_js', TRUE),
-                       'ERROR_JAVASCRIPT' => $GLOBALS['LANG']->getLL('error.javascript', TRUE),
-                       'ERROR_COOKIES' => $GLOBALS['LANG']->getLL('error.cookies', TRUE),
-                       'ERROR_COOKIES_IGNORE' => $GLOBALS['LANG']->getLL('error.cookies_ignore', TRUE),
-                       'ERROR_CAPSLOCK' => $GLOBALS['LANG']->getLL('error.capslock', TRUE),
-                       'ERROR_FURTHERHELP' => $GLOBALS['LANG']->getLL('error.furtherInformation', TRUE),
-                       'LABEL_DONATELINK' => $GLOBALS['LANG']->getLL('labels.donate', TRUE),
-                       'LABEL_USERNAME' => $GLOBALS['LANG']->getLL('labels.username', TRUE),
-                       'LABEL_OPENID' => $GLOBALS['LANG']->getLL('labels.openId', TRUE),
-                       'LABEL_PASSWORD' => $GLOBALS['LANG']->getLL('labels.password', TRUE),
-                       'LABEL_WHATISOPENID' => $GLOBALS['LANG']->getLL('labels.whatIsOpenId', TRUE),
-                       'LABEL_SWITCHOPENID' => $GLOBALS['LANG']->getLL('labels.switchToOpenId', TRUE),
-                       'LABEL_SWITCHDEFAULT' => $GLOBALS['LANG']->getLL('labels.switchToDefault', TRUE),
-                       'CLEAR' => $GLOBALS['LANG']->getLL('clear', TRUE),
-                       'LOGIN_PROCESS' => $GLOBALS['LANG']->getLL('login_process', TRUE),
-                       'SITELINK' => '<a href="/">###SITENAME###</a>',
-                       // Global variables will now be replaced (at last)
-                       'SITENAME' => htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'])
-               );
-               $markers = $this->emitRenderLoginFormSignal($markers);
-               $mainContent = HtmlParser::substituteMarkerArray($mainContent, $markers, '###|###');
-
-               // OPENID_LOADED
-               if (!ExtensionManagementUtility::isLoaded('openid')) {
-                       $mainContent = HtmlParser::substituteSubpart($mainContent, 'OPENID_LOADED', '');
-               }
-               return $mainContent;
-       }
-
-       /**
         * Checking, if we should perform some sort of redirection OR closing of windows.
         *
         * @return void
         */
        public function checkRedirect() {
-               // Do redirect:
-               // If a user is logged in AND a) if either the login is just done (isLoginInProgress) or b) a loginRefresh is done or c) the interface-selector is NOT enabled (If it is on the other hand, it should not just load an interface, because people has to choose then...)
-               if (!empty($GLOBALS['BE_USER']->user['uid']) && ($this->isLoginInProgress() || $this->loginRefresh || !$this->interfaceSelector)) {
-                       // If no cookie has been set previously we tell people that this is a problem. This assumes that a cookie-setting script (like this one) has been hit at least once prior to this instance.
-                       if (!$_COOKIE[\TYPO3\CMS\Core\Authentication\BackendUserAuthentication::getCookieName()]) {
+               /*
+                * Do redirect:
+                *
+                * If a user is logged in AND
+                *   a) if either the login is just done (isLoginInProgress) or
+                *   b) a loginRefresh is done or c) the interface-selector is NOT enabled
+                *      (If it is on the other hand, it should not just load an interface,
+                *      because people has to choose then...)
+                */
+               if (!empty($this->getBackendUserAuthentication()->user['uid'])
+                       && ($this->isLoginInProgress() || $this->loginRefresh || !$this->interfaceSelector)) {
+                       /*
+                        * If no cookie has been set previously we tell people that this is a problem.
+                        * This assumes that a cookie-setting script (like this one) has been hit at
+                        * least once prior to this instance.
+                        */
+                       if (!$_COOKIE[BackendUserAuthentication::getCookieName()]) {
                                if ($this->commandLI == 'setCookie') {
-                                       // we tried it a second time but still no cookie
-                                       // 26/4 2005: This does not work anymore, because the saving of challenge values in $_SESSION means the system will act as if the password was wrong.
-                                       throw new \RuntimeException('Login-error: Yeah, that\'s a classic. No cookies, no TYPO3.<br /><br />Please accept cookies from TYPO3 - otherwise you\'ll not be able to use the system.', 1294586846);
+                                       /*
+                                        * we tried it a second time but still no cookie
+                                        * 26/4 2005: This does not work anymore, because the saving of challenge values
+                                        * in $_SESSION means the system will act as if the password was wrong.
+                                        */
+                                       throw new \RuntimeException('Login-error: Yeah, that\'s a classic. No cookies, no TYPO3.<br /><br />' .
+                                               'Please accept cookies from TYPO3 - otherwise you\'ll not be able to use the system.', 1294586846);
                                } else {
                                        // try it once again - that might be needed for auto login
                                        $this->redirectToURL = 'index.php?commandLI=setCookie';
                                }
                        }
-                       if ($redirectToURL = (string)$GLOBALS['BE_USER']->getTSConfigVal('auth.BE.redirectToURL')) {
-                               $this->redirectToURL = $redirectToURL;
+                       $redirectToUrl = (string)$this->getBackendUserAuthentication()->getTSConfigVal('auth.BE.redirectToURL');
+                       if (!empty($redirectToUrl)) {
+                               $this->redirectToURL = $redirectToUrl;
                                $this->GPinterface = '';
                        }
                        // store interface
-                       $GLOBALS['BE_USER']->uc['interfaceSetup'] = $this->GPinterface;
-                       $GLOBALS['BE_USER']->writeUC();
+                       $this->getBackendUserAuthentication()->uc['interfaceSetup'] = $this->GPinterface;
+                       $this->getBackendUserAuthentication()->writeUC();
                        // Based on specific setting of interface we set the redirect script:
                        switch ($this->GPinterface) {
                                case 'backend':
@@ -418,7 +335,7 @@ class LoginController {
                                        break;
                        }
                        /** @var $formProtection \TYPO3\CMS\Core\FormProtection\BackendFormProtection */
-                       $formProtection = \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get();
+                       $formProtection = FormProtectionFactory::get();
                        // If there is a redirect URL AND if loginRefresh is not set...
                        if (!$this->loginRefresh) {
                                $formProtection->storeSessionTokenInRegistry();
@@ -426,14 +343,14 @@ class LoginController {
                        } else {
                                $formProtection->setSessionTokenFromRegistry();
                                $formProtection->persistSessionToken();
-                               $GLOBALS['TBE_TEMPLATE']->JScode .= $GLOBALS['TBE_TEMPLATE']->wrapScriptTags('
+                               $this->getDocumentTemplate()->JScode .= $this->getDocumentTemplate()->wrapScriptTags('
                                        if (parent.opener && parent.opener.TYPO3 && parent.opener.TYPO3.LoginRefresh) {
                                                parent.opener.TYPO3.LoginRefresh.startTask();
                                                parent.close();
                                        }
                                ');
                        }
-               } elseif (empty($GLOBALS['BE_USER']->user['uid']) && $this->isLoginInProgress()) {
+               } elseif (empty($this->getBackendUserAuthentication()->user['uid']) && $this->isLoginInProgress()) {
                        // Wrong password, wait for 5 seconds
                        sleep(5);
                }
@@ -456,8 +373,8 @@ class LoginController {
                        if (count($parts) > 1) {
                                // Initialize:
                                $labels = array(
-                                       'backend' => $GLOBALS['LANG']->getLL('interface.backend'),
-                                       'frontend' => $GLOBALS['LANG']->getLL('interface.frontend')
+                                       'backend' => $this->getLanguageService()->getLL('interface.backend'),
+                                       'frontend' => $this->getLanguageService()->getLL('interface.frontend')
                                );
                                $jumpScript = array(
                                        'backend' => 'backend.php',
@@ -484,62 +401,6 @@ class LoginController {
        }
 
        /**
-        * Returns the login box image, whether the default or an image from the rotation folder.
-        *
-        * @return string HTML image tag.
-        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8, see Deprecation-60559-MakeLoginBoxImage.rst
-        */
-       public function makeLoginBoxImage() {
-               GeneralUtility::logDeprecatedFunction();
-               return '';
-       }
-
-       /**
-        * Make login news - renders the HTML content for a list of news shown under
-        * the login form. News data is added through sys_news records
-        *
-        * @return string HTML content
-        * @credits Idea by Jan-Hendrik Heuing
-        */
-       public function makeLoginNews() {
-               $newsContent = '';
-               $systemNews = $this->getSystemNews();
-               // Traverse news array IF there are records in it:
-               if (is_array($systemNews) && count($systemNews) && !GeneralUtility::_GP('loginRefresh')) {
-                       /** @var $htmlParser \TYPO3\CMS\Core\Html\RteHtmlParser */
-                       $htmlParser = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Html\RteHtmlParser::class);
-                       $htmlParser->procOptions['dontHSC_rte'] = TRUE;
-
-                       // Get the main news template, and replace the subpart after looped through
-                       $newsContent = HtmlParser::getSubpart($GLOBALS['TBE_TEMPLATE']->moduleTemplate, '###LOGIN_NEWS###');
-                       $newsItemTemplate = HtmlParser::getSubpart($newsContent, '###NEWS_ITEM###');
-                       $newsItem = '';
-                       $count = 1;
-                       foreach ($systemNews as $newsItemData) {
-                               $additionalClass = '';
-                               if ($count === 1) {
-                                       $additionalClass = ' first-item';
-                               } elseif ($count === count($systemNews)) {
-                                       $additionalClass = ' last-item';
-                               }
-                               $newsItemContent = $htmlParser->TS_transform_rte($htmlParser->TS_links_rte($newsItemData['content']));
-                               $newsItemMarker = array(
-                                       '###HEADER###' => htmlspecialchars($newsItemData['header']),
-                                       '###DATE###' => htmlspecialchars($newsItemData['date']),
-                                       '###CONTENT###' => $newsItemContent,
-                                       '###CLASS###' => $additionalClass
-                               );
-                               $count++;
-                               $newsItem .= HtmlParser::substituteMarkerArray($newsItemTemplate, $newsItemMarker);
-                       }
-                       $title = $GLOBALS['TYPO3_CONF_VARS']['BE']['loginNewsTitle'] ? $GLOBALS['TYPO3_CONF_VARS']['BE']['loginNewsTitle'] : $GLOBALS['LANG']->getLL('newsheadline');
-                       $newsContent = HtmlParser::substituteMarker($newsContent, '###NEWS_HEADLINE###', htmlspecialchars($title));
-                       $newsContent = HtmlParser::substituteSubpart($newsContent, '###NEWS_ITEM###', $newsItem);
-               }
-               return $newsContent;
-       }
-
-       /**
         * Gets news from sys_news and converts them into a format suitable for
         * showing them at the login screen.
         *
@@ -548,7 +409,7 @@ class LoginController {
        protected function getSystemNews() {
                $systemNewsTable = 'sys_news';
                $systemNews = array();
-               $systemNewsRecords = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('title, content, crdate', $systemNewsTable, '1=1' . BackendUtility::BEenableFields($systemNewsTable) . BackendUtility::deleteClause($systemNewsTable), '', 'crdate DESC');
+               $systemNewsRecords = $this->getDatabaseConntection()->exec_SELECTgetRows('title, content, crdate', $systemNewsTable, '1=1' . BackendUtility::BEenableFields($systemNewsTable) . BackendUtility::deleteClause($systemNewsTable), '', 'crdate DESC');
                foreach ($systemNewsRecords as $systemNewsRecord) {
                        $systemNews[] = array(
                                'date' => date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $systemNewsRecord['crdate']),
@@ -610,35 +471,58 @@ class LoginController {
        }
 
        /**
-        * Emits the render login form signal
+        * Get the ObjectManager
         *
-        * @param array $markers Array with markers for the login form
-        * @return array Modified markers array
+        * @return \TYPO3\CMS\Extbase\Object\ObjectManager
         */
-       protected function emitRenderLoginFormSignal(array $markers) {
-               $signalArguments = $this->getSignalSlotDispatcher()->dispatch(\TYPO3\CMS\Backend\Controller\LoginController::class, self::SIGNAL_RenderLoginForm, array($this, $markers));
-               return $signalArguments[1];
+       protected function getObjectManager() {
+               return GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
        }
 
        /**
-        * Get the SignalSlot dispatcher
+        * returns a new standalone view, shorthand function
         *
-        * @return \TYPO3\CMS\Extbase\SignalSlot\Dispatcher
+        * @param string $templatePathAndFileName optional the path to set the template path and filename
+        *
+        * @return StandaloneView
         */
-       protected function getSignalSlotDispatcher() {
-               if (!isset($this->signalSlotDispatcher)) {
-                       $this->signalSlotDispatcher = $this->getObjectManager()->get(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class);
+       protected function getFluidTemplateObject($templatePathAndFileName = NULL) {
+               $this->getLanguageService()->includeLLFile('EXT:backend/Resources/Private/Language/locallang.xlf');
+               $this->getLanguageService()->includeLLFile('EXT:lang/locallang_login.xlf');
+
+               $view = GeneralUtility::makeInstance(StandaloneView::class);
+               if ($templatePathAndFileName) {
+                       $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($templatePathAndFileName));
                }
-               return $this->signalSlotDispatcher;
+               $view->getRequest()->setControllerExtensionName('backend');
+               return $view;
        }
 
        /**
-        * Get the ObjectManager
-        *
-        * @return \TYPO3\CMS\Extbase\Object\ObjectManager
+        * @return LanguageService
         */
-       protected function getObjectManager() {
-               return GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
+       protected function getLanguageService() {
+               return $GLOBALS['LANG'];
        }
 
+       /**
+        * @return BackendUserAuthentication
+        */
+       protected function getBackendUserAuthentication() {
+               return $GLOBALS['BE_USER'];
+       }
+
+       /**
+        * @return DatabaseConnection
+        */
+       protected function getDatabaseConntection() {
+               return $GLOBALS['TYPO3_DB'];
+       }
+
+       /**
+        * @return \TYPO3\CMS\Backend\Template\DocumentTemplate
+        */
+       protected function getDocumentTemplate() {
+               return $GLOBALS['TBE_TEMPLATE'];
+       }
 }
diff --git a/typo3/sysext/backend/Resources/Private/Templates/Login.html b/typo3/sysext/backend/Resources/Private/Templates/Login.html
new file mode 100644 (file)
index 0000000..2510337
--- /dev/null
@@ -0,0 +1,150 @@
+
+<div id="t3-login-wrap">
+       <div class="t3-login-header">
+               <f:format.raw>{logo}</f:format.raw>
+       </div>
+
+       <div class="t3-login-body">
+               <f:render section="{formType}" arguments="{_all}" />
+
+               <div class="t3-login-footer">
+                       <div id="t3-login-form-footer-default">
+                               <f:if condition="{isOpenIdLoaded}">
+                                       <a id="t3-login-switchToOpenId" class="switchToOpenId text-muted">
+                                               <i class="fa fa-openid"></i><f:translate key="{labelPrefixPath}labels.switchToOpenId" />
+                                       </a>
+                               </f:if>
+                       </div>
+                       <f:if condition="{isOpenIdLoaded}">
+                               <div id="t3-login-form-footer-openId" style="display: none;">
+                                       <a id="t3-login-switchToDefault" class="switchToOpenId">
+                                               <i class="fa fa-key"></i><f:translate key="{labelPrefixPath}labels.switchToDefault" />
+                                       </a>
+                               </div>
+                       </f:if>
+               </div>
+       </div>
+       <f:render section="loginNews" arguments="{_all}" />
+</div>
+<div id="t3-login-copyright">
+       <f:format.raw>{copyright}</f:format.raw>
+       <a href="http://typo3.org" target="_blank" class="t3-login-link-typo3">TYPO3.org</a>,
+       <strong><a href="http://typo3.org/donate/" target="_blank" class="t3-login-link-donate"><f:translate key="{labelPrefixPath}labels.donate" /></a></strong>
+</div>
+
+
+
+<f:section name="loginForm">
+       <f:format.raw>{formTag}</f:format.raw>
+               <f:if condition="{hasLoginError}">
+                       <div id="t3-login-error" class="alert alert-danger">
+                               <strong><f:translate key="{labelPrefixPath}error.login.title" /></strong>
+                               <p><f:translate key="{labelPrefixPath}error.login.description" /></p>
+                       </div>
+               </f:if>
+
+               <noscript>
+                       <div id="t3-noscript-error" class="t3-login-alert t3-login-alert-error">
+                               <h4><f:translate key="{labelPrefixPath}error.javascript" /></h4>
+                       </div>
+               </noscript>
+
+               <div id="t3-nocookies-error" class="t3-login-alert alert alert-warning" style="display:none;">
+                       <h4><f:translate key="{labelPrefixPath}error.cookies" /></h4>
+               </div>
+
+               <div class="form-group" id="t3-login-username-section">
+                       <input type="text" id="t3-username" name="username" value="{presetUsername}" placeholder="{f:translate(key: '{labelPrefixPath}labels.username')}" class="form-control t3-username" autofocus="autofocus" required="required">
+
+                       <div class="t3-login-alert-capslock" id="t3-username-alert-capslock" style="display: none;">
+                               <img src="sysext/t3skin/icons/login_capslock.gif" alt="{f:translate(key: '{labelPrefixPath}error.capslock')}" title="{f:translate(key: '{labelPrefixPath}error.capslock')}" />
+                       </div>
+               </div>
+
+               <div class="form-group" id="t3-login-password-section">
+                       <input type="password" id="t3-password" name="p_field" value="{presetPassword}" placeholder="{f:translate(key: '{labelPrefixPath}labels.password')}" class="form-control t3-password" required="required">
+
+                       <div class="t3-login-alert-capslock" id="t3-password-alert-capslock" style="display: none;">
+                               <img src="sysext/t3skin/icons/login_capslock.gif" alt="{f:translate(key: '{labelPrefixPath}error.capslock')}" title="{f:translate(key: '{labelPrefixPath}error.capslock')}" />
+                       </div>
+               </div>
+
+               <f:if condition="{isOpenIdLoaded}">
+                       <div class="form-group" id="t3-login-openid_url-section" style="display: none;">
+                               <div class="input-group">
+                                       <input type="text" id="openid_url" name="openid_url" value="{presetOpenId}" placeholder="{f:translate(key: '{labelPrefixPath}labels.openId')}" class="form-control t3-openidurl" />
+
+                                       <div class="input-group-addon">
+                                               <span class="fa fa-openid"></span>
+                                       </div>
+                               </div>
+                       </div>
+               </f:if>
+
+               <f:if condition="{interfaceSelector}">
+                       <div class="form-group">
+                               <div class="t3-login-interface" id="t3-login-interface-section">
+                                       <f:format.raw>{interfaceSelector}</f:format.raw>
+                               </div>
+                       </div>
+               </f:if>
+
+               <div class="form-group">
+                       <input class="btn btn-block" type="submit" name="commandLI" value="{f:translate(key: '{labelPrefixPath}labels.submitLogin')}" id="t3-login-submit" />
+                       <div id="t3-login-process" style="display: none;">
+                               <i class="fa fa-spin fa-spinner"></i>
+                               <f:translate key="{labelPrefixPath}login_process" />
+                       </div>
+               </div>
+       </form>
+</f:section>
+
+
+
+<f:section name="logoutForm">
+       <form action="index.php" method="post" name="loginform">
+               <input type="hidden" name="login_status" value="logout" />
+               <div class="t3-login-box-body">
+                       <div class="t3-login-logout-form">
+                               <div class="t3-login-username">
+                                       <div class="t3-login-label t3-username">
+                                               <f:translate key="{labelPrefixPath}labels.username" />
+                                       </div>
+                                       <div class="t3-username-current">
+                                               {backendUser.username}
+                                       </div>
+                               </div>
+                               <f:if condition="{showInterfaceSelector}">
+                                       <div class="t3-login-interface">
+                                               <div class="t3-login-label t3-interface-selector">
+                                                       <f:translate key="{labelPrefixPath}labels.interface" />
+                                               </div>
+                                               <f:format.raw>{interfaceSelectorJump}</f:format.raw>
+                                       </div>
+                               </f:if>
+                               <input type="hidden" name="p_field" value="" />
+                               <input class="btn btn-block" type="submit" name="commandLO" value="{f:translate(key: '{labelPrefixPath}labels.submitLogin')}" id="t3-login-submit" />
+                       </div>
+               </div>
+       </form>
+</f:section>
+
+
+
+<f:section name="loginNews">
+       <f:if condition="{loginNewsItems}">
+               <div id="t3-login-news">
+                       <div class="t3-login-box-body">
+                               <dl>
+                                       <f:for each="{loginNewsItems}" as="item">
+                                               <dt>
+                                                       <span class="t3-news-date">{item.date}</span><br>
+                                                       {item.header}
+                                               </dt>
+                                               <dd><f:format.html>{item.content}</f:format.html></dd>
+                                       </f:for>
+                               </dl>
+                       </div>
+               </div>
+       </f:if>
+</f:section>
diff --git a/typo3/sysext/backend/Resources/Private/Templates/login.html b/typo3/sysext/backend/Resources/Private/Templates/login.html
deleted file mode 100644 (file)
index 683410b..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-<!-- ###PAGE### begin -->
-<div id="t3-login-wrap">
-       <div class="t3-login-header">
-               ###LOGO###
-       </div>
-
-       <div class="t3-login-body">
-               ###FORM###
-
-               <div class="t3-login-footer">
-                       <div id="t3-login-form-footer-default">
-                <!-- ###OPENID_LOADED### begin -->
-                               <a id="t3-login-switchToOpenId" class="switchToOpenId text-muted">
-                                       <i class="fa fa-openid"></i>###LABEL_SWITCHOPENID###
-                               </a>
-                <!-- ###OPENID_LOADED### end -->
-                       </div>
-            <!-- ###OPENID_LOADED### begin -->
-                       <div id="t3-login-form-footer-openId" style="display: none;">
-                               <a id="t3-login-switchToDefault" class="switchToOpenId">
-                                       <i class="fa fa-key"></i>###LABEL_SWITCHDEFAULT###
-                               </a>
-                       </div>
-            <!-- ###OPENID_LOADED### end -->
-               </div>
-       </div>
-       ###NEWS###
-</div>
-
-
-<div id="t3-login-copyright">
-       ###COPYRIGHT###
-       <a href="http://typo3.org" target="_blank" class="t3-login-link-typo3">TYPO3.org</a>,
-       <strong><a href="http://typo3.org/donate/" target="_blank" class="t3-login-link-donate">###LABEL_DONATELINK###</a></strong>
-</div>
-<!-- ###PAGE### end -->
-
-
-<!-- ###LOGIN_FORM### begin -->
-       <!-- ###LOGIN_ERROR### begin -->
-       <div id="t3-login-error" class="alert alert-danger">
-               <strong>###ERROR_LOGIN_TITLE###</strong>
-               <p>###ERROR_LOGIN_DESCRIPTION###</p>
-       </div>
-       <!-- ###LOGIN_ERROR### end -->
-
-       <noscript>
-               <div id="t3-noscript-error" class="t3-login-alert t3-login-alert-error">
-                       <h4>###ERROR_JAVASCRIPT###</h4>
-               </div>
-       </noscript>
-
-       <div id="t3-nocookies-error" class="t3-login-alert alert alert-warning" style="display:none;">
-               <h4>###ERROR_COOKIES###</h4>
-       </div>
-
-       <div class="form-group" id="t3-login-username-section">
-               <input type="text" id="t3-username" name="username" value="###VALUE_USERNAME###" placeholder="###LABEL_USERNAME###" class="form-control t3-username" autofocus="autofocus" required="required">
-
-               <div class="t3-login-alert-capslock" id="t3-username-alert-capslock" style="display: none;">
-                       <img src="sysext/t3skin/icons/login_capslock.gif" alt="###ERROR_CAPSLOCK###" title="###ERROR_CAPSLOCK###" />
-               </div>
-       </div>
-
-       <div class="form-group" id="t3-login-password-section">
-               <input type="password" id="t3-password" name="p_field" value="###VALUE_PASSWORD###" placeholder="###LABEL_PASSWORD###" class="form-control t3-password" required="required">
-
-               <div class="t3-login-alert-capslock" id="t3-password-alert-capslock" style="display: none;">
-                       <img src="sysext/t3skin/icons/login_capslock.gif" alt="###ERROR_CAPSLOCK###" title="###ERROR_CAPSLOCK###" />
-               </div>
-       </div>
-
-<!-- ###OPENID_LOADED### begin -->
-       <div class="form-group" id="t3-login-openid_url-section" style="display: none;">
-               <div class="input-group">
-                       <input type="text" id="openid_url" name="openid_url" value="###VALUE_OPENID_URL###" placeholder="###LABEL_OPENID###" class="form-control t3-openidurl" />
-
-                       <div class="input-group-addon">
-                               <span class="fa fa-openid"></span>
-                       </div>
-               </div>
-       </div>
-<!-- ###OPENID_LOADED### end -->
-
-       <div class="form-group">
-               <!-- ###INTERFACE_SELECTOR### begin -->
-               <div class="t3-login-interface" id="t3-login-interface-section">
-                       ###VALUE_INTERFACE###
-               </div>
-               <!-- ###INTERFACE_SELECTOR### end -->
-       </div>
-
-       <div class="form-group">
-               <input class="btn btn-block" type="submit" name="commandLI" value="###VALUE_SUBMIT###" id="t3-login-submit" />
-               <div id="t3-login-process" style="display: none;">
-                       <i class="fa fa-spin fa-spinner"></i>
-                       ###LOGIN_PROCESS###
-               </div>
-       </div>
-<!-- ###LOGIN_FORM### end -->
-
-
-<!-- ###LOGOUT_FORM### begin -->
-<div class="t3-login-box-body">
-       <div class="t3-login-logout-form">
-               <div class="t3-login-username">
-                       <div class="t3-login-label t3-username">
-                               ###LABEL_USERNAME###
-                       </div>
-                       <div class="t3-username-current">
-                               ###VALUE_USERNAME###
-                       </div>
-               </div>
-
-               <!-- ###INTERFACE_SELECTOR### begin -->
-               <div class="t3-login-interface">
-                       <div class="t3-login-label t3-interface-selector">
-                               ###LABEL_INTERFACE###
-                       </div>
-                       ###VALUE_INTERFACE###
-               </div>
-               <!-- ###INTERFACE_SELECTOR### end -->
-
-               <input type="hidden" name="p_field" value="" />
-               <input class="btn btn-block" type="submit" name="commandLO" value="###VALUE_SUBMIT###" id="t3-login-submit" />
-       </div>
-</div>
-<!-- ###LOGOUT_FORM### end -->
-
-
-<!-- ###LOGIN_NEWS### begin -->
-<div id="t3-login-news">
-       <div class="t3-login-box-body">
-               <dl>
-                       <!-- ###NEWS_ITEM### begin -->
-                       <dt>
-                               <span class="t3-news-date">###DATE###</span><br>
-                               ###HEADER###
-                       </dt>
-                       <dd>
-                               ###CONTENT###
-                       </dd>
-                       <!-- ###NEWS_ITEM### end -->
-               </dl>
-       </div>
-</div>
-<!-- ###LOGIN_NEWS### end -->
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-65939-BackendLoginRefactoring.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-65939-BackendLoginRefactoring.rst
new file mode 100644 (file)
index 0000000..93f0c04
--- /dev/null
@@ -0,0 +1,41 @@
+============================================
+Breaking: #65939 - Backend Login Refactoring
+============================================
+
+Description
+===========
+
+For the refactoring of the backend login we introduce Fluid as template engine and remove the old marker template.
+
+It was necessary to remove the signal ``LoginController::SIGNAL_RenderLoginForm`` which will no longer be emitted.
+
+Additional the following methods of ``LoginController`` have been removed:
+
+* ``LoginController::makeLoginBoxImage``
+* ``LoginController::wrapLoginForm``
+* ``LoginController::makeLoginNews``
+* ``LoginController::makeLoginForm``
+* ``LoginController::makeLogoutForm``
+
+
+Impact
+======
+
+The mentioned methods are no longer available and a fatal error will be triggered if used.
+
+
+Affected installations
+======================
+
+All installations which make use of the ``LoginController::SIGNAL_RenderLoginForm`` signal or use the removed methods:
+* ``LoginController::makeLoginBoxImage``
+* ``LoginController::wrapLoginForm``
+* ``LoginController::makeLoginNews``
+* ``LoginController::makeLoginForm``
+* ``LoginController::makeLogoutForm``
+
+
+Migration
+=========
+
+Use the introduced Fluid view to adapt the login screen to your demands.