From f60ef0ef22ac462b4413a05059c7bb42491b0b3a Mon Sep 17 00:00:00 2001
From: Kevin Ditscheid <kevin.ditscheid@sgalinski.de>
Date: Tue, 12 Feb 2019 15:01:57 +0100
Subject: [PATCH] [BUGFIX] Fix the fields in news localizations in the backend

---
 Configuration/TCA/Overrides/pages.php | 33 ++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)

diff --git a/Configuration/TCA/Overrides/pages.php b/Configuration/TCA/Overrides/pages.php
index e5ae54c..027e67c 100644
--- a/Configuration/TCA/Overrides/pages.php
+++ b/Configuration/TCA/Overrides/pages.php
@@ -338,10 +338,9 @@ call_user_func(
 		);
 
 		$GLOBALS['TCA'][$table]['palettes']['titleDescriptionAndHighlightFlag'] = [
-			'showitem' => 'title,
-			--linebreak--, slug,
-			--linebreak--, subtitle;' . $localLangDbPath . $table . '.subtitle.inPalette,
+			'showitem' => 'subtitle;' . $localLangDbPath . $table . '.subtitle.inPalette,
 			--linebreak--, description,
+			--linebreak--, slug,
 			--linebreak--, tx_realurl_pathsegment, tx_realurl_exclude,
 			--linebreak--, tx_sgnews_highlighted, tx_sgnews_never_highlighted',
 			'canNotCollapse' => 1,
@@ -369,6 +368,34 @@ call_user_func(
 				$GLOBALS['TCA'][$table]['types'][117]
 			);
 		}
+
+		if (\version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '>')) {
+			// if TYPO3 9.5, exclude a lot of fields from the news doktype in localizations
+			foreach (
+				$GLOBALS['TCA'][$table]['columns'] as $languageExcludeField => $_
+			) {
+				if (
+					!\in_array($languageExcludeField, [
+						'doktype',
+						'subtitle',
+						'description',
+						'slug',
+						'author',
+						'tx_sgnews_location',
+						'tx_sgnews_teaser1_image',
+						'tx_sgnews_teaser2_image',
+						'abstract',
+						'tx_projectbase_seo_titletag',
+						'tx_projectbase_seo_canonicaltag',
+						'hidden',
+						'starttime',
+						'endtime'
+					])
+				) {
+					$GLOBALS['TCA'][$table]['types'][\SGalinski\SgNews\Utility\BackendNewsUtility::NEWS_DOKTYPE]['columnsOverrides'][$languageExcludeField]['l10n_mode'] = 'exclude';
+				}
+			}
+		}
 	}, 'sg_news', 'pages'
 );
 
-- 
GitLab