Commit 9d956fd4 authored by Fabio Stegmeyer's avatar Fabio Stegmeyer

[TASK] Drop fallback configuration in DB and use the fallback configuration...

[TASK] Drop fallback configuration in DB and use the fallback configuration from the site configuration
parent 7920ceac
......@@ -31,6 +31,7 @@ use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Site\SiteFinder;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
......@@ -85,13 +86,22 @@ class Language {
* @return array
*/
public function getFallbackOrder(Element $contextElement): array {
// determine and explode only once
if (!isset($this->defaultFallBackOrderArray)) {
// unfortunatly defaultlangauge is 999 instead of 0 (reason in formrendering of typo3):
$tx_languagevisibility_fallbackorder = str_replace(
'999', '0', $this->row['tx_languagevisibility_fallbackorder']
);
$this->defaultFallBackOrderArray = GeneralUtility::trimExplode(',', $tx_languagevisibility_fallbackorder);
$siteFinder = GeneralUtility::makeInstance(SiteFinder::class);
try {
$site = $siteFinder->getSiteByPageId($contextElement->getPid());
} catch (\Exception $e) {
return [];
}
$siteLanguage = $site->getLanguageById($this->getUid());
$fallbackLanguageIds = $siteLanguage->getFallbackLanguageIds();
$this->defaultFallBackOrderArray = $fallbackLanguageIds;
}
return $this->triggerFallbackHooks('getFallbackOrder', $this->defaultFallBackOrderArray, $contextElement);
}
......@@ -105,16 +115,7 @@ class Language {
public function getFallbackOrderElement(Element $contextElement): array {
// determine and explode only once
if (!isset($this->elementFallBackOrderArray)) {
if ($this->usesComplexFallbackSettings()) {
$tx_languagevisibility_fallbackorderel = str_replace(
'999', '0', $this->row['tx_languagevisibility_fallbackorderel']
);
$this->elementFallBackOrderArray = GeneralUtility::trimExplode(
',', $tx_languagevisibility_fallbackorderel
);
} else {
$this->elementFallBackOrderArray = $this->getFallbackOrder($contextElement);
}
$this->elementFallBackOrderArray = $this->getFallbackOrder($contextElement);
}
return $this->triggerFallbackHooks(
......@@ -135,7 +136,7 @@ class Language {
'fallbackorder' => $fallbackorder,
];
$fallback = $result;
if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['languagevisibility'][$key])) {
if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['languagevisibility']['$key'])) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['languagevisibility'][$key] as $classRef) {
$hookObj = GeneralUtility::makeInstance($classRef);
......@@ -150,15 +151,6 @@ class Language {
return $fallback['fallbackorder'];
}
/**
* Method to check if complex fallback settings should be used.
*
* @return bool
*/
public function usesComplexFallbackSettings(): bool {
return (int) $this->row['tx_languagevisibility_complexfallbacksetting'] > 0;
}
/**
* Method to read the defaultVisibility setting of pages.
*
......
......@@ -27,55 +27,18 @@
call_user_func(
function ($extKey, $table) {
$tempColumns = [
'tx_languagevisibility_fallbackorder' => [
'exclude' => 0,
'label' => 'LLL:EXT:' . $extKey .'/Resources/Private/Language/locallang_db.xlf:' . $table .'.tx_languagevisibility_fallbackorder',
'l10n_display' => 'hideDiff',
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'foreign_table' => $table,
'foreign_table_where' => ' ORDER BY ' . $table .'.title',
'items' => [
['default', '999'],
],
'multiple' => TRUE,
'size' => 10,
'minitems' => 0,
'maxitems' => 10,
]
],
'tx_languagevisibility_fallbackorderel' => [
'exclude' => 0,
'label' => 'LLL:EXT:' . $extKey .'/Resources/Private/Language/locallang_db.xlf:' . $table .'.tx_languagevisibility_fallbackorderel',
'displayCond' => 'FIELD:tx_languagevisibility_complexfallbacksetting:>=:1',
'l10n_display' => 'hideDiff',
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'foreign_table' => $table,
'foreign_table_where' => ' ORDER BY ' . $table .'.title',
'items' => [
['default', '999'],
],
'multiple' => TRUE,
'size' => 10,
'minitems' => 0,
'maxitems' => 10,
]
],
'tx_languagevisibility_defaultvisibility' => [
'exclude' => 0,
'label' => 'LLL:EXT:' . $extKey .'/Resources/Private/Language/locallang_db.xlf:' . $table .'.tx_languagevisibility_defaultvisibility',
'label' => 'LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_db.xlf:' . $table . '.tx_languagevisibility_defaultvisibility',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'items' => [
['LLL:EXT:' . $extKey .'/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.-', ''],
['LLL:EXT:' . $extKey .'/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.t', 't'],
['LLL:EXT:' . $extKey .'/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.f', 'f'],
['LLL:EXT:' . $extKey .'/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.yes', 'yes'],
['LLL:EXT:' . $extKey .'/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.no', 'no'],
['LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.-', ''],
['LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.t', 't'],
['LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.f', 'f'],
['LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.yes', 'yes'],
['LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.no', 'no'],
],
'default' => 'f',
'size' => 1,
......@@ -84,32 +47,27 @@ call_user_func(
],
'tx_languagevisibility_defaultvisibilityel' => [
'exclude' => 0,
'label' => 'LLL:EXT:' . $extKey .'/Resources/Private/Language/locallang_db.xlf:' . $table .'.tx_languagevisibility_defaultvisibilityel',
'label' => 'LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_db.xlf:' . $table . '.tx_languagevisibility_defaultvisibilityel',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'items' => [
['LLL:EXT:' . $extKey .'/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.-', ''],
['LLL:EXT:' . $extKey .'/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.t', 't'],
['LLL:EXT:' . $extKey .'/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.f', 'f'],
['LLL:EXT:' . $extKey .'/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.yes', 'yes'],
['LLL:EXT:' . $extKey .'/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.no', 'no'],
['LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.-', ''],
['LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.t', 't'],
['LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.f', 'f'],
['LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.yes', 'yes'],
['LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_db.xlf:tx_languagevisibility_visibility.I.no', 'no'],
],
'default' => 'f',
'size' => 1,
'maxitems' => 1,
]
],
'tx_languagevisibility_complexfallbacksetting' => [
'exclude' => 0,
'label' => 'LLL:EXT:' . $extKey .'/Resources/Private/Language/locallang_db.xlf:' . $table .'.tx_languagevisibility_complexfallbacksetting',
'config' => [
'type' => 'check'
]
],
];
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns($table, $tempColumns);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes($table, 'tx_languagevisibility_defaultvisibility, tx_languagevisibility_fallbackorder;;;;1-1-1,tx_languagevisibility_complexfallbacksetting, tx_languagevisibility_defaultvisibilityel, tx_languagevisibility_fallbackorderel;;;;1-1-1');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
$table, 'tx_languagevisibility_defaultvisibility, tx_languagevisibility_defaultvisibilityel'
);
}, 'languagevisibility', 'sys_language'
);
......@@ -67,10 +67,6 @@
<source>OK</source>
<target>OK</target>
</trans-unit>
<trans-unit id="sys_language.tx_languagevisibility_complexfallbacksetting" approved="yes">
<source>Use multiple fallbacks for Pages/Elements</source>
<target>Benutze mehrere Fallbacks für Seiten/Inhalt</target>
</trans-unit>
<trans-unit id="sys_language.tx_languagevisibility_defaultvisibility" approved="yes">
<source>default visibility for pages</source>
<target>Standard-Sichtbarkeit für Seiten</target>
......@@ -79,14 +75,6 @@
<source>default visibility for other elements</source>
<target>Standard-Sichtbarkeit für Elemente</target>
</trans-unit>
<trans-unit id="sys_language.tx_languagevisibility_fallbackorder" approved="yes">
<source>fallback order - The ordering is correctly saved in the database, but it's displayed wrong after saving. (TYPO3 Bug)</source>
<target>Fallback-Reihenfolge - Die Sortierung wird korrekt in der Datenbank gespeichert, aber es wird nach dem speichern falsch dargestellt. (TYPO3 Bug)</target>
</trans-unit>
<trans-unit id="sys_language.tx_languagevisibility_fallbackorderel" approved="yes">
<source>fallback order for other elements</source>
<target>Fallback-Reihenfolge für andere Elemente</target>
</trans-unit>
<trans-unit id="tabname" approved="yes">
<source>Language</source>
<target>Sprache</target>
......
......@@ -52,21 +52,12 @@
<trans-unit id="reports.ok.value">
<source>OK</source>
</trans-unit>
<trans-unit id="sys_language.tx_languagevisibility_complexfallbacksetting">
<source>Use multiple fallbacks for Pages/Elements</source>
</trans-unit>
<trans-unit id="sys_language.tx_languagevisibility_defaultvisibility">
<source>default visibility for pages</source>
</trans-unit>
<trans-unit id="sys_language.tx_languagevisibility_defaultvisibilityel">
<source>default visibility for other elements</source>
</trans-unit>
<trans-unit id="sys_language.tx_languagevisibility_fallbackorder">
<source>fallback order - The ordering is correctly saved in the database, but it's displayed wrong after saving. (TYPO3 Bug)</source>
</trans-unit>
<trans-unit id="sys_language.tx_languagevisibility_fallbackorderel">
<source>fallback order for other elements</source>
</trans-unit>
<trans-unit id="tabname">
<source>Language</source>
</trans-unit>
......
......@@ -2,9 +2,6 @@
# Table structure for table 'sys_language'
#
CREATE TABLE sys_language (
tx_languagevisibility_fallbackorder text,
tx_languagevisibility_fallbackorderel text,
tx_languagevisibility_complexfallbacksetting smallint(6) DEFAULT '0' NOT NULL,
tx_languagevisibility_defaultvisibility varchar(11) DEFAULT 't' NOT NULL,
tx_languagevisibility_defaultvisibilityel varchar(11) DEFAULT 't' NOT NULL
);
......
Markdown is supported
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