From 3adecebce17d783bd633d4dc94522ca6a829a60a Mon Sep 17 00:00:00 2001 From: Pawel Cieslik <p.cieslik@macopedia.pl> Date: Wed, 29 Nov 2017 13:03:54 +0100 Subject: [PATCH] [!!!][TASK] Remove TYPO3.LLL usages in TYPO3 core Remove TYPO3.LLL after moving to new JS API for translations TYPO3.lang Resolves: #83161 Releases: master Change-Id: I815b15349c8bfe6ca71f4d1ce59b7b01e670eae2 Reviewed-on: https://review.typo3.org/54860 Reviewed-by: Markus Klein <markus.klein@typo3.org> Tested-by: Markus Klein <markus.klein@typo3.org> Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Benni Mack <benni@typo3.org> Tested-by: Benni Mack <benni@typo3.org> --- .../Classes/Controller/BackendController.php | 115 +----------------- ...-83161-RemoveTYPO3LLLUsagesInTYPO3Core.rst | 37 ++++++ .../Classes/FrontendEditAssetLoader.php | 64 ---------- typo3/sysext/feedit/ext_localconf.php | 7 -- 4 files changed, 38 insertions(+), 185 deletions(-) create mode 100644 typo3/sysext/core/Documentation/Changelog/master/Breaking-83161-RemoveTYPO3LLLUsagesInTYPO3Core.rst delete mode 100644 typo3/sysext/feedit/Classes/FrontendEditAssetLoader.php diff --git a/typo3/sysext/backend/Classes/Controller/BackendController.php b/typo3/sysext/backend/Classes/Controller/BackendController.php index 6b64917d8a89..224ef97cc4eb 100644 --- a/typo3/sysext/backend/Classes/Controller/BackendController.php +++ b/typo3/sysext/backend/Classes/Controller/BackendController.php @@ -109,6 +109,7 @@ class BackendController public function __construct() { $this->getLanguageService()->includeLLFile('EXT:lang/Resources/Private/Language/locallang_misc.xlf'); + $this->backendModuleRepository = GeneralUtility::makeInstance(BackendModuleRepository::class); $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class); @@ -124,7 +125,6 @@ class BackendController $this->pageRenderer->addExtDirectCode(); // Add default BE javascript $this->jsFiles = [ - 'locallang' => $this->getLocalLangFileName(), 'md5' => 'EXT:backend/Resources/Public/JavaScript/md5.js', 'evalfield' => 'EXT:backend/Resources/Public/JavaScript/jsfunc.evalfield.js', 'backend' => 'EXT:backend/Resources/Public/JavaScript/backend.js', @@ -499,119 +499,6 @@ class BackendController return implode(LF, $toolbar); } - /** - * Returns the file name to the LLL JavaScript, containing the localized labels, - * which can be used in JavaScript code. - * - * @return string File name of the JS file, relative to TYPO3_mainDir - * @throws \RuntimeException - */ - protected function getLocalLangFileName() - { - $code = $this->generateLocalLang(); - $filePath = 'typo3temp/assets/js/backend-' . sha1($code) . '.js'; - if (!file_exists(PATH_site . $filePath)) { - // writeFileToTypo3tempDir() returns NULL on success (please double-read!) - $error = GeneralUtility::writeFileToTypo3tempDir(PATH_site . $filePath, $code); - if ($error !== null) { - throw new \RuntimeException('Locallang JS file could not be written to ' . $filePath . '. Reason: ' . $error, 1295193026); - } - } - return '../' . $filePath; - } - - /** - * Reads labels required in JavaScript code from the localization system and returns them as JSON - * array in TYPO3.LLL. - * - * @return string JavaScript code containing the LLL labels in TYPO3.LLL - */ - protected function generateLocalLang() - { - $lang = $this->getLanguageService(); - $coreLabels = [ - 'waitTitle' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.refresh_login_logging_in'), - 'refresh_login_failed' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.refresh_login_failed'), - 'refresh_login_failed_message' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.refresh_login_failed_message'), - 'refresh_login_title' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.refresh_login_title'), - 'login_expired' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.login_expired'), - 'refresh_login_username' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.refresh_login_username'), - 'refresh_login_password' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.refresh_login_password'), - 'refresh_login_emptyPassword' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.refresh_login_emptyPassword'), - 'refresh_login_button' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.refresh_login_button'), - 'refresh_exit_button' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.refresh_exit_button'), - 'please_wait' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.please_wait'), - 'be_locked' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.be_locked'), - 'login_about_to_expire' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.login_about_to_expire'), - 'login_about_to_expire_title' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.login_about_to_expire_title'), - 'refresh_login_logout_button' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.refresh_login_logout_button'), - 'refresh_login_refresh_button' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:mess.refresh_login_refresh_button'), - 'csh_tooltip_loading' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:csh_tooltip_loading') - ]; - $labels = [ - 'fileUpload' => [ - 'windowTitle', - 'buttonSelectFiles', - 'buttonCancelAll', - 'infoComponentMaxFileSize', - 'infoComponentFileUploadLimit', - 'infoComponentFileTypeLimit', - 'infoComponentOverrideFiles', - 'processRunning', - 'uploadWait', - 'uploadStarting', - 'uploadProgress', - 'uploadSuccess', - 'errorQueueLimitExceeded', - 'errorQueueFileSizeLimit', - 'errorQueueZeroByteFile', - 'errorQueueInvalidFiletype', - 'errorUploadHttp', - 'errorUploadMissingUrl', - 'errorUploadIO', - 'errorUploadSecurityError', - 'errorUploadLimit', - 'errorUploadFailed', - 'errorUploadFileIDNotFound', - 'errorUploadFileValidation', - 'errorUploadFileCancelled', - 'errorUploadStopped', - 'allErrorMessageTitle', - 'allErrorMessageText', - 'allError401', - 'allError2038' - ], - 'liveSearch' => [ - 'title', - 'helpTitle', - 'emptyText', - 'loadingText', - 'listEmptyText', - 'showAllResults', - 'helpDescription', - 'helpDescriptionPages', - 'helpDescriptionContent' - ], - 'viewPort' => [ - 'tooltipModuleMenuSplit', - 'tooltipNavigationContainerSplitDrag', - 'tooltipNavigationContainerSplitClick', - 'tooltipDebugPanelSplitDrag' - ] - ]; - $generatedLabels = []; - $generatedLabels['core'] = $coreLabels; - // First loop over all categories (fileUpload, liveSearch, ..) - foreach ($labels as $categoryName => $categoryLabels) { - // Then loop over every single label - foreach ($categoryLabels as $label) { - // LLL identifier must be called $categoryName_$label, e.g. liveSearch_loadingText - $generatedLabels[$categoryName][$label] = $this->getLanguageService()->getLL($categoryName . '_' . $label); - } - } - return 'TYPO3.LLL = ' . json_encode($generatedLabels) . ';'; - } - /** * Generates the JavaScript code for the backend. */ diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-83161-RemoveTYPO3LLLUsagesInTYPO3Core.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-83161-RemoveTYPO3LLLUsagesInTYPO3Core.rst new file mode 100644 index 000000000000..9fa85cb8746a --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Breaking-83161-RemoveTYPO3LLLUsagesInTYPO3Core.rst @@ -0,0 +1,37 @@ +.. include:: ../../Includes.txt + +======================================================== +Breaking: #83161 - Remove TYPO3.LLL usages in TYPO3 core +======================================================== + +See :issue:`83161` + +Description +=========== + +After moving to the :js:`TYPO3.lang` API for javascript, the :js:`TYPO3.LLL` is not needed anymore. + + +Impact +====== + +All extensions which are using :js:`TYPO3.LLL` for translation in javascript should be checked and updated accordingly. + + +Affected Installations +====================== + +Any installation using extensions, which are using :js:`TYPO3.LLL`. + + +Migration +========= + +Use :js:`TYPO3.lang['label']` from javascript. To make custom language labels available in javascript, +add :php:`$this->pageRenderer->addInlineLanguageLabelFile('EXT:foo/Resources/Private/Language/locallang.xlf');` +in your backend controller. + +The class typo3/sysext/feedit/Classes/FrontendEditAssetLoader.php was removed, so if you used it in your code you have to remove the dependency. + +.. index:: Backend, JavaScript, PHP-API, NotScanned + diff --git a/typo3/sysext/feedit/Classes/FrontendEditAssetLoader.php b/typo3/sysext/feedit/Classes/FrontendEditAssetLoader.php deleted file mode 100644 index 46b65ad53c55..000000000000 --- a/typo3/sysext/feedit/Classes/FrontendEditAssetLoader.php +++ /dev/null @@ -1,64 +0,0 @@ -<?php -namespace TYPO3\CMS\Feedit; - -/* - * This file is part of the TYPO3 CMS project. - * - * It is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, either version 2 - * of the License, or any later version. - * - * For the full copyright and license information, please read the - * LICENSE.txt file that was distributed with this source code. - * - * The TYPO3 project - inspiring people to share! - */ - -use TYPO3\CMS\Backend\Controller\EditDocumentController; -use TYPO3\CMS\Core\Page\PageRenderer; -use TYPO3\CMS\Core\Utility\GeneralUtility; - -/** - * Class FrontendEditAssetLoader - */ -class FrontendEditAssetLoader -{ - /** - * @param EditDocumentController $controller - */ - public function attachAssets(EditDocumentController $controller) - { - if ((int)GeneralUtility::_GP('feEdit') === 1) { - $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); - // We have to load some locallang strings and push them into TYPO3.LLL if this request was - // triggered by feedit. Originally, this object is fed by BackendController which is not - // called here. This block of code is intended to be removed at a later point again. - $lang = $this->getLanguageService(); - $coreLabels = [ - 'csh_tooltip_loading' => $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:csh_tooltip_loading') - ]; - $generatedLabels = []; - $generatedLabels['core'] = $coreLabels; - $code = 'TYPO3.LLL = ' . json_encode($generatedLabels) . ';'; - $filePath = 'typo3temp/assets/js/backend-' . sha1($code) . '.js'; - if (!file_exists(PATH_site . $filePath)) { - // writeFileToTypo3tempDir() returns NULL on success (please double-read!) - $error = GeneralUtility::writeFileToTypo3tempDir(PATH_site . $filePath, $code); - if ($error !== null) { - throw new \RuntimeException('Locallang JS file could not be written to ' . $filePath . '. Reason: ' . $error, 1446118286); - } - } - $pageRenderer->addJsFile('../' . $filePath); - } - } - - /** - * Returns LanguageService - * - * @return \TYPO3\CMS\Core\Localization\LanguageService - */ - protected function getLanguageService() - { - return $GLOBALS['LANG']; - } -} diff --git a/typo3/sysext/feedit/ext_localconf.php b/typo3/sysext/feedit/ext_localconf.php index c531b71762e6..943ffcd78f70 100644 --- a/typo3/sysext/feedit/ext_localconf.php +++ b/typo3/sysext/feedit/ext_localconf.php @@ -3,10 +3,3 @@ defined('TYPO3_MODE') or die(); // Register the edit panel view. $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/classes/class.frontendedit.php']['edit'] = \TYPO3\CMS\Feedit\FrontendEditPanel::class; - -\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class)->connect( - \TYPO3\CMS\Backend\Controller\EditDocumentController::class, - 'initAfter', - \TYPO3\CMS\Feedit\FrontendEditAssetLoader::class, - 'attachAssets' -); -- GitLab