Commit 1d088f92 authored by Benni Mack's avatar Benni Mack Committed by Andreas Wolf
Browse files

[TASK] Use shorthand syntax for global variable $LANG consistently

TYPO3 uses $GLOBALS['LANG'] directly in some places, but since
TYPO3 v7, new code started to use a short hand protected method
"getLanguageService" in order to get IDE code completion and better
analysis of code.

This patch replaces all left-over places of $GLOBALS['LANG']
and encapsulates this into a short-hand method to streamline
TYPO3 Core's code base.

Resolves: #87571
Releases: master
Change-Id: Ie15e320713fe65d40552a19e0a517d5739abbb41
Reviewed-on: https://review.typo3.org/59578


Tested-by: default avatarTYPO3com <noreply@typo3.com>
Reviewed-by: Mona Muzaffar's avatarMona Muzaffar <mona.muzaffar@gmx.de>
Tested-by: Mona Muzaffar's avatarMona Muzaffar <mona.muzaffar@gmx.de>
Reviewed-by: Andreas Wolf's avatarAndreas Wolf <andreas.wolf@typo3.org>
Reviewed-by: Frank Nägler's avatarFrank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Nägler's avatarFrank Naegler <frank.naegler@typo3.org>
Tested-by: Andreas Wolf's avatarAndreas Wolf <andreas.wolf@typo3.org>
parent b70a86cc
......@@ -20,6 +20,7 @@ use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\CommandUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -306,7 +307,7 @@ class SystemInformationToolbarItem implements ToolbarItemInterface
$this->systemInformation[] = [
'title' => 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:toolbarItems.sysinfo.composerMode',
'value' => $GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.enabled'),
'value' => $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.enabled'),
'iconIdentifier' => 'information-composer-mode'
];
}
......@@ -407,6 +408,14 @@ class SystemInformationToolbarItem implements ToolbarItemInterface
return $GLOBALS['BE_USER'];
}
/**
* @return LanguageService|null
*/
protected function getLanguageService(): ?LanguageService
{
return $GLOBALS['LANG'] ?? null;
}
/**
* Returns current PageRenderer
*
......
......@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Backend\Controller;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Localization\LocalizationFactory;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -100,7 +101,7 @@ abstract class AbstractFormEngineAjaxController
{
/** @var LocalizationFactory $languageFactory */
$languageFactory = GeneralUtility::makeInstance(LocalizationFactory::class);
$language = $GLOBALS['LANG']->lang;
$language = $this->getLanguageService()->lang;
$localizationArray = $languageFactory->getParsedData($file, $language);
if (is_array($localizationArray) && !empty($localizationArray)) {
if (!empty($localizationArray[$language])) {
......@@ -122,4 +123,12 @@ abstract class AbstractFormEngineAjaxController
}
return $labelArray;
}
/**
* @return LanguageService|null
*/
protected function getLanguageService(): ?LanguageService
{
return $GLOBALS['LANG'] ?? null;
}
}
......@@ -26,6 +26,7 @@ use TYPO3\CMS\Core\Exception\SiteNotFoundException;
use TYPO3\CMS\Core\Http\JsonResponse;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Site\PseudoSiteFinder;
use TYPO3\CMS\Core\Site\SiteFinder;
use TYPO3\CMS\Core\Type\Bitmask\JsConfirmation;
......@@ -153,7 +154,7 @@ class TreeController
if (!$isAdmin && !in_array($doktype, $allowedDoktypes, true)) {
continue;
}
$label = htmlspecialchars($GLOBALS['LANG']->sL($doktypeLabelMap[$doktype]));
$label = htmlspecialchars($this->getLanguageService()->sL($doktypeLabelMap[$doktype]));
$output[] = [
'nodeType' => $doktype,
'icon' => $GLOBALS['TCA']['pages']['ctrl']['typeicon_classes'][$doktype] ?? '',
......@@ -263,7 +264,7 @@ class TreeController
$visibleText = $page['nav_title'];
}
if (trim($visibleText) === '') {
$visibleText = htmlspecialchars('[' . $GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.no_title') . ']');
$visibleText = htmlspecialchars('[' . $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.no_title') . ']');
}
$visibleText = GeneralUtility::fixed_lgd_cs($visibleText, (int)$this->getBackendUser()->uc['titleLen'] ?: 40);
......@@ -471,4 +472,12 @@ class TreeController
{
return $GLOBALS['BE_USER'];
}
/**
* @return LanguageService|null
*/
protected function getLanguageService(): ?LanguageService
{
return $GLOBALS['LANG'] ?? null;
}
}
......@@ -26,6 +26,7 @@ use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction;
use TYPO3\CMS\Core\Database\Query\Restriction\StartTimeRestriction;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
......@@ -290,7 +291,7 @@ class LiveSearch
*/
protected function getTitleOfCurrentRecordType($tableName)
{
return $GLOBALS['LANG']->sL($GLOBALS['TCA'][$tableName]['ctrl']['title']);
return $this->getLanguageService()->sL($GLOBALS['TCA'][$tableName]['ctrl']['title']);
}
/**
......@@ -492,4 +493,12 @@ class LiveSearch
$tree->ids[] = -1;
return implode(',', $tree->ids);
}
/**
* @return LanguageService|null
*/
protected function getLanguageService(): ?LanguageService
{
return $GLOBALS['LANG'] ?? null;
}
}
......@@ -23,6 +23,7 @@ use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Service\MarkerBasedTemplateService;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
......@@ -266,7 +267,7 @@ function jumpToUrl(URL) {
protected function initPageRenderer()
{
$this->pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$this->pageRenderer->setLanguage($GLOBALS['LANG']->lang);
$this->pageRenderer->setLanguage($this->getLanguageService()->lang);
$this->pageRenderer->enableConcatenateCss();
$this->pageRenderer->enableConcatenateJavascript();
$this->pageRenderer->enableCompressCss();
......@@ -305,7 +306,7 @@ function jumpToUrl(URL) {
} else {
$motherModule = '\'\'';
}
$confirmationText = GeneralUtility::quoteJSvalue($GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.makeBookmark'));
$confirmationText = GeneralUtility::quoteJSvalue($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.makeBookmark'));
$shortcutUrl = $pathInfo['path'] . '?' . $storeUrl;
$shortcutRepository = GeneralUtility::makeInstance(ShortcutRepository::class);
......@@ -320,7 +321,7 @@ function jumpToUrl(URL) {
', ' . $url . ', ' . $confirmationText . ', ' . $motherModule . ', this);return false;';
return '<a href="#" class="' . htmlspecialchars($classes) . '" onclick="' . htmlspecialchars($onClick) . '" title="' .
htmlspecialchars($GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.makeBookmark')) . '">' .
htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.makeBookmark')) . '">' .
$this->iconFactory->getIcon('actions-system-shortcut-new', Icon::SIZE_SMALL)->render() . '</a>';
}
......@@ -800,7 +801,7 @@ function jumpToUrl(URL) {
$title = '';
}
// Setting the path of the page
$pagePath = htmlspecialchars($GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.path')) . ': <span class="typo3-docheader-pagePath">';
$pagePath = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.path')) . ': <span class="typo3-docheader-pagePath">';
// crop the title to title limit (or 50, if not defined)
$cropLength = empty($GLOBALS['BE_USER']->uc['titleLen']) ? 50 : $GLOBALS['BE_USER']->uc['titleLen'];
$croppedTitle = GeneralUtility::fixed_lgd_cs($title, -$cropLength);
......@@ -896,4 +897,12 @@ function jumpToUrl(URL) {
{
return $GLOBALS['BE_USER'] ?? null;
}
/**
* @return LanguageService|null
*/
protected function getLanguageService(): ?LanguageService
{
return $GLOBALS['LANG'] ?? null;
}
}
......@@ -293,7 +293,7 @@ class ModuleTemplate
// Yes, hardcoded on purpose
$this->pageRenderer->setXmlPrologAndDocType('<!DOCTYPE html>');
$this->pageRenderer->setCharSet('utf-8');
$this->pageRenderer->setLanguage($GLOBALS['LANG']->lang);
$this->pageRenderer->setLanguage($this->getLanguageService()->lang);
$this->pageRenderer->setMetaTag('name', 'viewport', 'width=device-width, initial-scale=1');
}
......
......@@ -19,6 +19,7 @@ use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
......@@ -251,7 +252,7 @@ class DatabaseTreeDataProvider extends AbstractTableConfigurationTreeDataProvide
if ($basicNode->getId() == 0) {
$node->setSelected(false);
$node->setExpanded(true);
$node->setLabel($GLOBALS['LANG']->sL($GLOBALS['TCA'][$this->tableName]['ctrl']['title']));
$node->setLabel($this->getLanguageService()->sL($GLOBALS['TCA'][$this->tableName]['ctrl']['title']));
} else {
$row = BackendUtility::getRecordWSOL($this->tableName, $basicNode->getId(), '*', '', false);
$node->setLabel(BackendUtility::getRecordTitle($this->tableName, $row) ?: $basicNode->getId());
......@@ -539,4 +540,12 @@ class DatabaseTreeDataProvider extends AbstractTableConfigurationTreeDataProvide
{
return GeneralUtility::makeInstance(ObjectManager::class);
}
/**
* @return LanguageService|null
*/
protected function getLanguageService(): ?LanguageService
{
return $GLOBALS['LANG'] ?? null;
}
}
......@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Felogin\Hooks;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Core\Localization\LanguageService;
/**
* Hook to display verbose information about the felogin plugin
* @internal this is a TYPO3 hook implementation and solely used for EXT:felogin and not part of TYPO3's Core API.
......@@ -33,7 +35,15 @@ class CmsLayout implements \TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInt
{
if ($row['CType'] === 'login') {
$drawItem = false;
$itemContent .= $parentObject->linkEditContent('<strong>' . htmlspecialchars($GLOBALS['LANG']->sL('LLL:EXT:backend/Resources/Private/Language/locallang_db_new_content_el.xlf:forms_login_title')) . '</strong>', $row);
$itemContent .= $parentObject->linkEditContent('<strong>' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang_db_new_content_el.xlf:forms_login_title')) . '</strong>', $row);
}
}
/**
* @return LanguageService|null
*/
protected function getLanguageService(): ?LanguageService
{
return $GLOBALS['LANG'] ?? null;
}
}
......@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Fluid\ViewHelpers\Be;
*/
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
......@@ -75,7 +76,7 @@ class PagePathViewHelper extends AbstractBackendViewHelper
$title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
}
// Setting the path of the page
$pagePath = htmlspecialchars($GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.path')) . ': <span class="typo3-docheader-pagePath">';
$pagePath = htmlspecialchars(static::getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.path')) . ': <span class="typo3-docheader-pagePath">';
// crop the title to title limit (or 50, if not defined)
$cropLength = empty($GLOBALS['BE_USER']->uc['titleLen']) ? 50 : $GLOBALS['BE_USER']->uc['titleLen'];
$croppedTitle = GeneralUtility::fixed_lgd_cs($title, -$cropLength);
......@@ -87,4 +88,12 @@ class PagePathViewHelper extends AbstractBackendViewHelper
$pagePath .= '</span>';
return $pagePath;
}
/**
* @return LanguageService|null
*/
protected static function getLanguageService(): ?LanguageService
{
return $GLOBALS['LANG'] ?? null;
}
}
......@@ -15,6 +15,7 @@ namespace TYPO3\CMS\IndexedSearch\Hook;
*/
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Core\Bootstrap;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
......@@ -57,8 +58,7 @@ class CrawlerHook
{
// To make sure the backend charset is available:
if (!is_object($GLOBALS['LANG'])) {
$GLOBALS['LANG'] = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Localization\LanguageService::class);
$GLOBALS['LANG']->init($GLOBALS['BE_USER']->uc['lang']);
Bootstrap::initializeLanguageObject();
}
}
......
......@@ -73,7 +73,7 @@ class PageInformationController
$dblist->script = (string)$uriBuilder->buildUriFromRoute('web_info');
$dblist->showIcon = 0;
$dblist->setLMargin = 0;
$dblist->agePrefixes = $GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.minutesHoursDaysYears');
$dblist->agePrefixes = $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.minutesHoursDaysYears');
$dblist->pI_showUser = true;
if (isset($this->fieldConfiguration[$this->pObj->MOD_SETTINGS['pages']])) {
......@@ -115,12 +115,12 @@ class PageInformationController
$menu = [
'pages' => [],
'depth' => [
0 => $GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_0'),
1 => $GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_1'),
2 => $GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_2'),
3 => $GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_3'),
4 => $GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_4'),
999 => $GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_infi')
0 => $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_0'),
1 => $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_1'),
2 => $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_2'),
3 => $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_3'),
4 => $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_4'),
999 => $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_infi')
]
];
......@@ -184,7 +184,7 @@ class PageInformationController
}
$key = trim($key, '.');
$this->fieldConfiguration[$key] = [
'label' => $item['label'] ? $GLOBALS['LANG']->sL($item['label']) : $key,
'label' => $item['label'] ? $this->getLanguageService()->sL($item['label']) : $key,
'fields' => $fields
];
}
......@@ -199,10 +199,10 @@ class PageInformationController
}
/**
* @return LanguageService
* @return LanguageService|null
*/
protected function getLanguageService(): LanguageService
protected function getLanguageService(): ?LanguageService
{
return $GLOBALS['LANG'];
return $GLOBALS['LANG'] ?? null;
}
}
......@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Install\Report;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Messaging\FlashMessageQueue;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -110,13 +111,13 @@ class EnvironmentStatusReport implements StatusProviderInterface, ExtendedStatus
$type = 'info';
}
if (!$verbose) {
$message = $GLOBALS['LANG']->sL($pathToXliff . ':environment.status.message.' . $type);
$message = $this->getLanguageService()->sL($pathToXliff . ':environment.status.message.' . $type);
}
$severity = constant('\TYPO3\CMS\Reports\Status::' . strtoupper($type));
$statusArray[] = GeneralUtility::makeInstance(
Status::class,
$GLOBALS['LANG']->sL($pathToXliff . ':environment.status.title'),
sprintf($GLOBALS['LANG']->sL($pathToXliff . ':environment.status.value'), $value),
$this->getLanguageService()->sL($pathToXliff . ':environment.status.title'),
sprintf($this->getLanguageService()->sL($pathToXliff . ':environment.status.value'), $value),
$message,
$severity
);
......@@ -125,4 +126,12 @@ class EnvironmentStatusReport implements StatusProviderInterface, ExtendedStatus
return $statusArray;
}
/**
* @return LanguageService|null
*/
protected function getLanguageService(): ?LanguageService
{
return $GLOBALS['LANG'] ?? null;
}
}
......@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Install\Report;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Crypto\PasswordHashing\InvalidPasswordHashException;
use TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashFactory;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Install\Service\EnableFileService;
use TYPO3\CMS\Reports\Status;
......@@ -49,7 +50,7 @@ class SecurityStatusReport implements \TYPO3\CMS\Reports\StatusProviderInterface
protected function getInstallToolPasswordStatus()
{
// @todo @deprecated: This should be removed in TYPO3 v10.0 when install tool allows proper hashes only
$value = $GLOBALS['LANG']->getLL('status_ok');
$value = $this->getLanguageService()->getLL('status_ok');
$message = '';
$severity = Status::OK;
$validPassword = true;
......@@ -67,20 +68,20 @@ class SecurityStatusReport implements \TYPO3\CMS\Reports\StatusProviderInterface
$validPassword = false;
}
if (!$validPassword) {
$value = $GLOBALS['LANG']->getLL('status_insecure');
$value = $this->getLanguageService()->getLL('status_insecure');
$severity = Status::ERROR;
/** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
$uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
$changeInstallToolPasswordUrl = (string)$uriBuilder->buildUriFromRoute('tools_toolssettings');
$message = sprintf(
$GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:warning.installtool_default_password'),
$this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:warning.installtool_default_password'),
'<a href="' . htmlspecialchars($changeInstallToolPasswordUrl) . '">',
'</a>'
);
}
return GeneralUtility::makeInstance(
Status::class,
$GLOBALS['LANG']->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_installToolPassword'),
$this->getLanguageService()->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_installToolPassword'),
$value,
$message,
$severity
......@@ -95,40 +96,40 @@ class SecurityStatusReport implements \TYPO3\CMS\Reports\StatusProviderInterface
protected function getInstallToolProtectionStatus()
{
$enableInstallToolFile = Environment::getPublicPath() . '/' . EnableFileService::INSTALL_TOOL_ENABLE_FILE_PATH;
$value = $GLOBALS['LANG']->getLL('status_disabled');
$value = $this->getLanguageService()->getLL('status_disabled');
$message = '';
$severity = Status::OK;
if (EnableFileService::installToolEnableFileExists()) {
if (EnableFileService::isInstallToolEnableFilePermanent()) {
$severity = Status::WARNING;
$disableInstallToolUrl = GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL') . '&adminCmd=remove_ENABLE_INSTALL_TOOL';
$value = $GLOBALS['LANG']->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_enabledPermanently');
$value = $this->getLanguageService()->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_enabledPermanently');
$message = sprintf(
$GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:warning.install_enabled'),
$this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:warning.install_enabled'),
'<code style="white-space: nowrap;">' . $enableInstallToolFile . '</code>'
);
$message .= ' <a href="' . htmlspecialchars($disableInstallToolUrl) . '">' .
$GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:warning.install_enabled_cmd') . '</a>';
$this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:warning.install_enabled_cmd') . '</a>';
} else {
if (EnableFileService::installToolEnableFileLifetimeExpired()) {
EnableFileService::removeInstallToolEnableFile();
} else {
$severity = Status::NOTICE;
$disableInstallToolUrl = GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL') . '&adminCmd=remove_ENABLE_INSTALL_TOOL';
$value = $GLOBALS['LANG']->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_enabledTemporarily');
$value = $this->getLanguageService()->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_enabledTemporarily');
$message = sprintf(
$GLOBALS['LANG']->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_installEnabledTemporarily'),
$this->getLanguageService()->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_installEnabledTemporarily'),
'<code style="white-space: nowrap;">' . $enableInstallToolFile . '</code>',
floor((@filemtime($enableInstallToolFile) + EnableFileService::INSTALL_TOOL_ENABLE_FILE_LIFETIME - time()) / 60)
);
$message .= ' <a href="' . htmlspecialchars($disableInstallToolUrl) . '">' .
$GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:warning.install_enabled_cmd') . '</a>';
$this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:warning.install_enabled_cmd') . '</a>';
}
}
}
return GeneralUtility::makeInstance(
Status::class,
$GLOBALS['LANG']->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_installTool'),
$this->getLanguageService()->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_installTool'),
$value,
$message,
$severity
......@@ -149,4 +150,12 @@ class SecurityStatusReport implements \TYPO3\CMS\Reports\StatusProviderInterface
// Do nothing
}
}
/**
* @return LanguageService|null
*/
protected function getLanguageService(): ?LanguageService
{
return $GLOBALS['LANG'] ?? null;
}
}
......@@ -15,7 +15,6 @@ namespace TYPO3\CMS\Linkvalidator\Task;
*/
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Mail\MailMessage;
use TYPO3\CMS\Core\Service\MarkerBasedTemplateService;
use TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser;
......@@ -611,12 +610,4 @@ class ValidatorTask extends AbstractTask
$this->countInARun
];
}
/**
* @return LanguageService
*/
protected function getLanguageService()
{
return $GLOBALS['LANG'];
}
}
......@@ -163,12 +163,4 @@ class CleanerTask extends AbstractTask
{
return $this->tcaTables;
}
/**
* @return \TYPO3\CMS\Core\Localization\LanguageService
*/
protected function getLanguageService()
{
return $GLOBALS['LANG'];
}
}
......@@ -14,7 +14,6 @@ namespace TYPO3\CMS\Reports\Task;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Mail\MailMessage;
use TYPO3\CMS\Core\Registry;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -136,12 +135,4 @@ class SystemStatusUpdateTask extends AbstractTask
{
$this->notificationAll = $notificationAll;
}
/**
* @return LanguageService
*/
protected function getLanguageService()
{
return $GLOBALS['LANG'];
}
}
......@@ -51,6 +51,6 @@ class SleepTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask
*/
public function getAdditionalInformation()
{
return $GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.sleepTime') . ': ' . $this->sleepTime;
return $this->getLanguageService()->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.sleepTime') . ': ' . $this->sleepTime;
}
}
......@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Scheduler\Example;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Scheduler\AbstractAdditionalFieldProvider;
use TYPO3\CMS\Scheduler\Controller\SchedulerModuleController;
......@@ -77,7 +78,7 @@ class SleepTaskAdditionalFieldProvider extends AbstractAdditionalFieldProvider
{
$submittedData['sleepTime'] = (int)$submittedData['sleepTime'];
if ($submittedData['sleepTime'] < 0) {
$this->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.invalidSleepTime'), FlashMessage::ERROR);
$this->addMessage($this->getLanguageService()->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.invalidSleepTime'), FlashMessage::ERROR);
$result = false;
} else {
$result = true;
......@@ -96,4 +97,12 @@ class SleepTaskAdditionalFieldProvider extends AbstractAdditionalFieldProvider
{
$task->sleepTime = $submittedData['sleepTime'];
}
/**
* @return LanguageService|null