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; ...@@ -31,6 +31,7 @@ use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Site\SiteFinder;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility; use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
...@@ -85,13 +86,22 @@ class Language { ...@@ -85,13 +86,22 @@ class Language {
* @return array * @return array
*/ */
public function getFallbackOrder(Element $contextElement): array { public function getFallbackOrder(Element $contextElement): array {
// determine and explode only once // determine and explode only once
if (!isset($this->defaultFallBackOrderArray)) { if (!isset($this->defaultFallBackOrderArray)) {
// unfortunatly defaultlangauge is 999 instead of 0 (reason in formrendering of typo3):
$tx_languagevisibility_fallbackorder = str_replace( $siteFinder = GeneralUtility::makeInstance(SiteFinder::class);
'999', '0', $this->row['tx_languagevisibility_fallbackorder']
); try {
$this->defaultFallBackOrderArray = GeneralUtility::trimExplode(',', $tx_languagevisibility_fallbackorder); $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); return $this->triggerFallbackHooks('getFallbackOrder', $this->defaultFallBackOrderArray, $contextElement);
} }
...@@ -105,16 +115,7 @@ class Language { ...@@ -105,16 +115,7 @@ class Language {
public function getFallbackOrderElement(Element $contextElement): array { public function getFallbackOrderElement(Element $contextElement): array {
// determine and explode only once // determine and explode only once
if (!isset($this->elementFallBackOrderArray)) { if (!isset($this->elementFallBackOrderArray)) {
if ($this->usesComplexFallbackSettings()) { $this->elementFallBackOrderArray = $this->getFallbackOrder($contextElement);
$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);
}
} }
return $this->triggerFallbackHooks( return $this->triggerFallbackHooks(
...@@ -135,7 +136,7 @@ class Language { ...@@ -135,7 +136,7 @@ class Language {
'fallbackorder' => $fallbackorder, 'fallbackorder' => $fallbackorder,
]; ];
$fallback = $result; $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) { foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['languagevisibility'][$key] as $classRef) {
$hookObj = GeneralUtility::makeInstance($classRef); $hookObj = GeneralUtility::makeInstance($classRef);
...@@ -150,15 +151,6 @@ class Language { ...@@ -150,15 +151,6 @@ class Language {
return $fallback['fallbackorder']; 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. * Method to read the defaultVisibility setting of pages.
* *
......
...@@ -27,55 +27,18 @@ ...@@ -27,55 +27,18 @@
call_user_func( call_user_func(
function ($extKey, $table) { function ($extKey, $table) {
$tempColumns = [ $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' => [ 'tx_languagevisibility_defaultvisibility' => [
'exclude' => 0, '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' => [ 'config' => [
'type' => 'select', 'type' => 'select',
'renderType' => 'selectSingle', 'renderType' => 'selectSingle',
'items' => [ '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.-', ''],
['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.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.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.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.no', 'no'],
], ],
'default' => 'f', 'default' => 'f',
'size' => 1, 'size' => 1,
...@@ -84,32 +47,27 @@ call_user_func( ...@@ -84,32 +47,27 @@ call_user_func(
], ],
'tx_languagevisibility_defaultvisibilityel' => [ 'tx_languagevisibility_defaultvisibilityel' => [
'exclude' => 0, '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' => [ 'config' => [
'type' => 'select', 'type' => 'select',
'renderType' => 'selectSingle', 'renderType' => 'selectSingle',
'items' => [ '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.-', ''],
['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.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.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.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.no', 'no'],
], ],
'default' => 'f', 'default' => 'f',
'size' => 1, 'size' => 1,
'maxitems' => 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::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' }, 'languagevisibility', 'sys_language'
); );
...@@ -67,10 +67,6 @@ ...@@ -67,10 +67,6 @@
<source>OK</source> <source>OK</source>
<target>OK</target> <target>OK</target>
</trans-unit> </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"> <trans-unit id="sys_language.tx_languagevisibility_defaultvisibility" approved="yes">
<source>default visibility for pages</source> <source>default visibility for pages</source>
<target>Standard-Sichtbarkeit für Seiten</target> <target>Standard-Sichtbarkeit für Seiten</target>
...@@ -79,14 +75,6 @@ ...@@ -79,14 +75,6 @@
<source>default visibility for other elements</source> <source>default visibility for other elements</source>
<target>Standard-Sichtbarkeit für Elemente</target> <target>Standard-Sichtbarkeit für Elemente</target>
</trans-unit> </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"> <trans-unit id="tabname" approved="yes">
<source>Language</source> <source>Language</source>
<target>Sprache</target> <target>Sprache</target>
......
...@@ -52,21 +52,12 @@ ...@@ -52,21 +52,12 @@
<trans-unit id="reports.ok.value"> <trans-unit id="reports.ok.value">
<source>OK</source> <source>OK</source>
</trans-unit> </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"> <trans-unit id="sys_language.tx_languagevisibility_defaultvisibility">
<source>default visibility for pages</source> <source>default visibility for pages</source>
</trans-unit> </trans-unit>
<trans-unit id="sys_language.tx_languagevisibility_defaultvisibilityel"> <trans-unit id="sys_language.tx_languagevisibility_defaultvisibilityel">
<source>default visibility for other elements</source> <source>default visibility for other elements</source>
</trans-unit> </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"> <trans-unit id="tabname">
<source>Language</source> <source>Language</source>
</trans-unit> </trans-unit>
......
...@@ -2,9 +2,6 @@ ...@@ -2,9 +2,6 @@
# Table structure for table 'sys_language' # Table structure for table 'sys_language'
# #
CREATE 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_defaultvisibility varchar(11) DEFAULT 't' NOT NULL,
tx_languagevisibility_defaultvisibilityel 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