Skip to content
Snippets Groups Projects
Commit b69b688f authored by Benni Mack's avatar Benni Mack Committed by Andreas Fernandez
Browse files

[TASK] Remove leftover code from PseudoSite Handling

The SiteMatcher object now always returns a Site / NullSite, so there
will never be an exception "SiteNotFoundException" thrown.

This dead code, which is never executed, can be removed.

Resolves: #88461
Releases: master
Change-Id: I458b46f3beea2ea7934a4557acac67453a819784
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60843


Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: default avatarGeorg Ringer <georg.ringer@gmail.com>
Tested-by: default avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: default avatarGeorg Ringer <georg.ringer@gmail.com>
Reviewed-by: default avatarAndreas Fernandez <a.fernandez@scripting-base.de>
parent f26fa344
Branches
Tags
No related merge requests found
......@@ -20,10 +20,7 @@ use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\Exception\SiteNotFoundException;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Routing\SiteMatcher;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
......@@ -34,15 +31,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
class TranslationConfigurationProvider
{
/**
* @return LanguageService
*/
protected function getLanguageService()
{
return $GLOBALS['LANG'];
}
/**
* Returns array of system languages
* Returns array of languages given for a specific site (or "nullSite" if on page=0)
* The property flagIcon returns a string <flags-xx>.
*
* @param int $pageId Page id (used to get TSconfig configuration setting flag and label for default language)
......@@ -50,62 +39,18 @@ class TranslationConfigurationProvider
*/
public function getSystemLanguages($pageId = 0)
{
try {
$siteMatcher = GeneralUtility::makeInstance(SiteMatcher::class)->matchByPageId((int)$pageId);
$siteLanguages = $siteMatcher->getAvailableLanguages($this->getBackendUserAuthentication(), true);
$siteMatcher = GeneralUtility::makeInstance(SiteMatcher::class)->matchByPageId((int)$pageId);
$siteLanguages = $siteMatcher->getAvailableLanguages($this->getBackendUserAuthentication(), true);
$languages = [];
foreach ($siteLanguages as $id => $siteLanguage) {
$languages[$id] = [
'uid' => $id,
'title' => $siteLanguage->getTitle(),
'ISOcode' => $siteLanguage->getTwoLetterIsoCode(),
'flagIcon' => $siteLanguage->getFlagIdentifier(),
];
}
} catch (SiteNotFoundException $e) {
// default language and "all languages" are always present
$modSharedTSconfig = BackendUtility::getPagesTSconfig($pageId)['mod.']['SHARED.'] ?? [];
$languages = [
// 0: default language
0 => [
'uid' => 0,
'title' => $this->getDefaultLanguageLabel($modSharedTSconfig),
'ISOcode' => 'DEF',
'flagIcon' => $this->getDefaultLanguageFlag($modSharedTSconfig),
],
// -1: all languages
-1 => [
'uid' => -1,
'title' => $this->getLanguageService()->getLL('multipleLanguages'),
'ISOcode' => 'DEF',
'flagIcon' => 'flags-multiple',
],
$languages = [];
foreach ($siteLanguages as $id => $siteLanguage) {
$languages[$id] = [
'uid' => $id,
'title' => $siteLanguage->getTitle(),
'ISOcode' => $siteLanguage->getTwoLetterIsoCode(),
'flagIcon' => $siteLanguage->getFlagIdentifier(),
];
// add the additional languages from database records
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_language');
$languageRecords = $queryBuilder
->select('*')
->from('sys_language')
->orderBy('sorting')
->execute()
->fetchAll();
foreach ($languageRecords as $languageRecord) {
$languages[$languageRecord['uid']] = $languageRecord;
// @todo: this should probably resolve language_isocode too and throw a deprecation if not filled
if ($languageRecord['static_lang_isocode'] && ExtensionManagementUtility::isLoaded('static_info_tables')) {
$staticLangRow = BackendUtility::getRecord('static_languages', $languageRecord['static_lang_isocode'], 'lg_iso_2');
if ($staticLangRow['lg_iso_2']) {
$languages[$languageRecord['uid']]['ISOcode'] = $staticLangRow['lg_iso_2'];
}
}
if ($languageRecord['flag'] !== '') {
$languages[$languageRecord['uid']]['flagIcon'] = 'flags-' . $languageRecord['flag'];
}
}
}
return $languages;
}
......@@ -204,34 +149,6 @@ class TranslationConfigurationProvider
];
}
/**
* @param array $modSharedTSconfig
* @return string
*/
protected function getDefaultLanguageFlag(array $modSharedTSconfig)
{
if (strlen($modSharedTSconfig['defaultLanguageFlag'])) {
$defaultLanguageFlag = 'flags-' . $modSharedTSconfig['defaultLanguageFlag'];
} else {
$defaultLanguageFlag = 'empty-empty';
}
return $defaultLanguageFlag;
}
/**
* @param array $modSharedTSconfig
* @return string
*/
protected function getDefaultLanguageLabel(array $modSharedTSconfig)
{
if (strlen($modSharedTSconfig['defaultLanguageLabel'])) {
$defaultLanguageLabel = $modSharedTSconfig['defaultLanguageLabel'] . ' (' . $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:defaultLanguage') . ')';
} else {
$defaultLanguageLabel = $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:defaultLanguage');
}
return $defaultLanguageLabel;
}
protected function getBackendUserAuthentication(): BackendUserAuthentication
{
return $GLOBALS['BE_USER'];
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment