From 554d9c50b641b6975276820ed8c33fb303900e3b Mon Sep 17 00:00:00 2001
From: Kevin Ditscheid <kevin.ditscheid@sgalinski.de>
Date: Wed, 19 Dec 2018 11:46:23 +0100
Subject: [PATCH] [TASK] Restructuring of TCA, ext_tables and ext_localconf

---
 Classes/Hooks/PageLayoutController.php        |  30 +-
 Classes/Utility/BackendNewsUtility.php        |  36 +
 Classes/Utility/VersionUtility.php            |  83 --
 Configuration/TCA/Overrides/pages.php         | 746 ++++++++----------
 .../TCA/Overrides/pages_language_overlay.php  | 200 +++++
 Configuration/TCA/Overrides/sys_template.php  |  34 +
 Configuration/TCA/Overrides/tt_content.php    |  82 ++
 .../Common/{setup.txt => setup.typoscript}    |   0
 .../{constants.txt => constants.typoscript}   |   0
 .../Frontend/{setup.txt => setup.typoscript}  |   0
 Resources/Public/JavaScript/Backend.js        |  16 +-
 ext_localconf.php                             | 238 +++---
 ext_tables.php                                | 218 ++---
 13 files changed, 884 insertions(+), 799 deletions(-)
 delete mode 100644 Classes/Utility/VersionUtility.php
 create mode 100644 Configuration/TCA/Overrides/pages_language_overlay.php
 create mode 100644 Configuration/TCA/Overrides/sys_template.php
 create mode 100644 Configuration/TCA/Overrides/tt_content.php
 rename Configuration/TypoScript/Common/{setup.txt => setup.typoscript} (100%)
 rename Configuration/TypoScript/Frontend/{constants.txt => constants.typoscript} (100%)
 rename Configuration/TypoScript/Frontend/{setup.txt => setup.typoscript} (100%)

diff --git a/Classes/Hooks/PageLayoutController.php b/Classes/Hooks/PageLayoutController.php
index 3c961ba..41f62c7 100644
--- a/Classes/Hooks/PageLayoutController.php
+++ b/Classes/Hooks/PageLayoutController.php
@@ -30,6 +30,7 @@ use SGalinski\SgNews\Utility\BackendNewsUtility;
 use TYPO3\CMS\Backend\Controller\PageLayoutController as CorePageLayoutController;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Imaging\IconFactory;
+use TYPO3\CMS\Core\Page\PageRenderer;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
 
@@ -68,29 +69,10 @@ class PageLayoutController {
 		) {
 			return $out;
 		}
-		$moduleTemplate = $controller->getModuleTemplate();
-		$moduleTemplate->addJavaScriptCode(
-			'newsModuleLink', '
-			function newsModuleLinkGotToPageCallbackNoFollow(path){
-				var callback = top.Ext.createDelegate(top.nav.mainTree.selectPath, top.nav.mainTree);
-				callback.apply(this, arguments);
-			}
-			
-			function sgNewsGoToNewsModule(uid, path) {
-				if (top.nav) {
-					top.nav.invokePageId(uid, newsModuleLinkGotToPageCallbackNoFollow);
-				} else {
-					var tree = top.Ext.getCmp(\'typo3-pagetree\');
-					if (tree) {
-						tree.activeTree.selectPath(path);
-					}
-				}
-				parent.fsMod.recentIds[\'web\'] = uid;
-				parent.TYPO3.ModuleMenu.App.showModule(\'web_SgNewsNews\');
-				return false;
-			}
-		'
-		);
+
+		$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
+		$pageRenderer->loadRequireJsModule('TYPO3/CMS/SgNews/Backend');
+
 		/** @var IconFactory $iconFactory */
 		$iconFactory = GeneralUtility::makeInstance(IconFactory::class);
 		$icon = $iconFactory->getIcon('sg_news-module-transparent');
@@ -105,7 +87,7 @@ class PageLayoutController {
 			$path .= '/p' . dechex($page['uid']);
 		}
 
-		$onclick = 'return sgNewsGoToNewsModule(' . $categoryRow['uid'] . ', \'' . $path . '\');';
+		$onclick = 'TYPO3.SgNewsModule.sgNewsGoToNewsModule(' . $categoryRow['uid'] . ', \'' . $path . '\'); return false;';
 		$wrap = ' <div class="btn-group" role="group">%s</div>';
 		$link = '<a href="#" onclick="' . $onclick . '" class="btn btn-primary">%s</a>';
 		$link = sprintf($link, $icon . ' ' . $buttonLabel);
diff --git a/Classes/Utility/BackendNewsUtility.php b/Classes/Utility/BackendNewsUtility.php
index a7cd4c2..7d239e6 100644
--- a/Classes/Utility/BackendNewsUtility.php
+++ b/Classes/Utility/BackendNewsUtility.php
@@ -34,6 +34,9 @@ use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Database\DatabaseConnection;
 use TYPO3\CMS\Core\Database\QueryGenerator;
+use TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider;
+use TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider;
+use TYPO3\CMS\Core\Imaging\IconRegistry;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\VersionNumberUtility;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
@@ -512,4 +515,37 @@ class BackendNewsUtility {
 		}
 		return NULL;
 	}
+
+	/**
+	 * Register the extension icons
+	 * For use in ext_localconf.php
+	 */
+	public static function registerIcons() {
+		$iconRegistry = GeneralUtility::makeInstance(IconRegistry::class);
+		$iconRegistry->registerIcon(
+			'actions-document-open-white',
+			SvgIconProvider::class,
+			['source' => 'EXT:sg_news/Resources/Public/Icons/actions-document-open-white.svg']
+		);
+		$iconRegistry->registerIcon(
+			'sg_news-module',
+			SvgIconProvider::class,
+			['source' => 'EXT:sg_news/Resources/Public/Icons/module-sgnews.svg']
+		);
+		$iconRegistry->registerIcon(
+			'sg_news-module-transparent',
+			SvgIconProvider::class,
+			['source' => 'EXT:sg_news/Resources/Public/Icons/module-sgnews-transparent.svg']
+		);
+		$iconRegistry->registerIcon(
+			'tcarecords-pages-' . self::CATEGORY_DOKTYPE,
+			BitmapIconProvider::class,
+			['source' => 'EXT:sg_news/Resources/Public/Images/Category.png']
+		);
+		$iconRegistry->registerIcon(
+			'tcarecords-pages-' . self::NEWS_DOKTYPE,
+			BitmapIconProvider::class,
+			['source' => 'EXT:sg_news/Resources/Public/Images/News.png']
+		);
+	}
 }
diff --git a/Classes/Utility/VersionUtility.php b/Classes/Utility/VersionUtility.php
deleted file mode 100644
index e771445..0000000
--- a/Classes/Utility/VersionUtility.php
+++ /dev/null
@@ -1,83 +0,0 @@
-<?php
-
-namespace SGalinski\SgNews\Utility;
-
-/***************************************************************
- *  Copyright notice
- *
- *  (c) sgalinski Internet Services (https://www.sgalinski.de)
- *
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
- *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
-
-use TYPO3\CMS\Core\Utility\VersionNumberUtility;
-
-/**
- * Helper class to detect the used TYPO3 version.
- */
-class VersionUtility {
-	/**
-	 * Returns true if the current version ts TYPO3 6.2.
-	 *
-	 * @return bool
-	 */
-	public static function isVersion62(): bool {
-		$versionNumber = self::getVersion();
-		return ($versionNumber >= 6002000 && $versionNumber < 7000000);
-	}
-
-	/**
-	 * Returns true if the current version ts TYPO3 7.6 and less version 8
-	 *
-	 * @return bool
-	 */
-	public static function isVersion76(): bool {
-		$versionNumber = self::getVersion();
-		return ($versionNumber >= 7006000 && $versionNumber < 8000000);
-	}
-
-	/**
-	 * Returns true if the current version ts TYPO3 7.6 or later
-	 *
-	 * @return bool
-	 */
-	public static function isVersion76OOrHigher(): bool {
-		return (self::getVersion() >= 7006000);
-	}
-
-	/**
-	 * Returns true if the current version ts TYPO3 8.7 or later
-	 *
-	 * @return bool
-	 */
-	public static function isVersion870OrHigher(): bool {
-		return (self::getVersion() >= 8007000);
-	}
-
-	/**
-	 * Returns the current version as an integer.
-	 *
-	 * @return int
-	 */
-	protected static function getVersion(): int {
-		return VersionNumberUtility::convertVersionNumberToInteger(
-			VersionNumberUtility::getNumericTypo3Version()
-		);
-	}
-}
diff --git a/Configuration/TCA/Overrides/pages.php b/Configuration/TCA/Overrides/pages.php
index d82d914..84b47b2 100644
--- a/Configuration/TCA/Overrides/pages.php
+++ b/Configuration/TCA/Overrides/pages.php
@@ -1,434 +1,356 @@
 <?php
+/**
+ *
+ * Copyright notice
+ *
+ * (c) sgalinski Internet Services (https://www.sgalinski.de)
+ *
+ * All rights reserved
+ *
+ * This script is part of the TYPO3 project. The TYPO3 project is
+ * free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * The GNU General Public License can be found at
+ * http://www.gnu.org/copyleft/gpl.html.
+ *
+ * This script is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * This copyright notice MUST APPEAR in all copies of the script!
+ */
 
-$imageColumns = [
-	'tx_sgnews_teaser1_image' => [
-		'exclude' => TRUE,
-		'label' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_teaser1_image',
-		'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
-			'tx_sgnews_teaser1_image',
+call_user_func(
+	function ($extKey, $table) {
+		$localLangDbPath = 'LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_db.xlf:';
+		$localLangBackendPath = 'LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_backend.xlf:';
+		foreach (
 			[
-				'maxitems' => 9999,
-				'foreign_types' => [
-					'0' => [
-						'showitem' => '
-							--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
-							--palette--;;filePalette'
-					],
-					\TYPO3\CMS\Core\Resource\File::FILETYPE_TEXT => [
-						'showitem' => '
-							--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
-							--palette--;;filePalette'
-					],
-					\TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [
-						'showitem' => '
-							--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
-							--palette--;;filePalette'
-					],
-					\TYPO3\CMS\Core\Resource\File::FILETYPE_AUDIO => [
-						'showitem' => '
-							--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
-							--palette--;;filePalette'
-					],
-					\TYPO3\CMS\Core\Resource\File::FILETYPE_VIDEO => [
-						'showitem' => '
-							--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
-							--palette--;;filePalette'
-					],
-					\TYPO3\CMS\Core\Resource\File::FILETYPE_APPLICATION => [
-						'showitem' => '
-							--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
-							--palette--;;filePalette'
-					]
+				\SGalinski\SgNews\Utility\BackendNewsUtility::CATEGORY_DOKTYPE => [
+					'icon' => 'EXT:sg_news/Resources/Public/Images/Category.png',
+					'locallangIndex' => 'pageType.category'
 				],
-				'appearance' => [
-					'showPossibleLocalizationRecords' => TRUE,
-					'showRemovedLocalizationRecords' => TRUE,
-					'showSynchronizationLink' => TRUE,
-					'showAllLocalizationLink' => TRUE,
+				\SGalinski\SgNews\Utility\BackendNewsUtility::NEWS_DOKTYPE => [
+					'icon' => 'EXT:sg_news/Resources/Public/Images/News.png',
+					'locallangIndex' => 'pageType.news'
+				]
+			] as $doktype => $configuration) {
+
+			// add the new doktype to the page type selector
+			$GLOBALS['TCA'][$table]['columns']['doktype']['config']['items'][] = [
+				$localLangBackendPath . $configuration['locallangIndex'],
+				$doktype,
+				$configuration['icon']
+			];
+
+			// also add the new doktype to the page language overlays type selector (so that translations can inherit the same type)
+			$GLOBALS['TCA']['' . $table . '_language_overlay']['columns']['doktype']['config']['items'][] = [
+				$localLangBackendPath . $configuration['locallangIndex'],
+				$doktype,
+				$configuration['icon']
+			];
+
+			$GLOBALS['TCA'][$table]['ctrl']['typeicon_classes'][$doktype] = 'tcarecords-' . $table . '-' . $doktype;
+
+			// add the new doktype to the list of page types
+			$GLOBALS['PAGES_TYPES'][$doktype] = [
+				'type' => 'sys',
+				'icon' => $configuration['icon'],
+				'allowedTables' => '*',
+			];
+		}
+
+		$GLOBALS['TCA'][$table]['types'][\SGalinski\SgNews\Utility\BackendNewsUtility::NEWS_DOKTYPE] = [
+			'showitem' => '--palette--;LLL:EXT:cms/locallang_tca.xlf:' . $table . '.palettes.standard;standard,
+					--palette--;;titleDescriptionAndHighlightFlag,
+					--palette--;LLL:EXT:cms/locallang_tca.xlf:' . $table . '.palettes.editorial;editorialWithNewsAuthor,
+					tx_sgnews_related_news, tx_sgnews_tags,
+				--div--;' . $localLangDbPath . $table . '.tabs.images,
+					tx_sgnews_teaser2_image, tx_sgnews_teaser1_image,
+				--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.tabs.metadata,
+					tx_projectbase_devnullrobots_flags,
+					--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.palettes.abstract;abstract,
+					tx_projectbase_seo_titletag,tx_projectbase_seo_canonicaltag,
+				--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.tabs.appearance,
+					--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.palettes.layout;layout,
+				--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,
+					--palette--;LLL:EXT:cms/locallang_tca.xlf:' . $table . '.palettes.visibility;visibility,
+					--palette--;LLL:EXT:cms/locallang_tca.xlf:' . $table . '.palettes.access;access,
+				--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.tabs.behaviour,
+					--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.palettes.caching;caching,
+					--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.palettes.language;language,
+					--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.palettes.miscellaneous;miscellaneous,
+				'
+		];
+
+		$GLOBALS['TCA'][$table]['types'][\SGalinski\SgNews\Utility\BackendNewsUtility::CATEGORY_DOKTYPE] = [
+			'showitem' => '--palette--;LLL:EXT:cms/locallang_tca.xlf:' . $table . '.palettes.standard;standard,
+					title, tx_realurl_pathsegment, tx_realurl_exclude,
+				--div--;' . $localLangDbPath . $table . '.tabs.images,
+					tx_sgnews_teaser2_image, tx_sgnews_teaser1_image,
+				--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.tabs.metadata,
+					tx_projectbase_devnullrobots_flags,
+					--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.palettes.abstract;abstract,
+					tx_projectbase_seo_titletag,tx_projectbase_seo_canonicaltag, description,
+				--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.tabs.appearance,
+					--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.palettes.layout;layout,
+				--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,
+					--palette--;LLL:EXT:cms/locallang_tca.xlf:' . $table . '.palettes.visibility;visibility,
+					--palette--;LLL:EXT:cms/locallang_tca.xlf:' . $table . '.palettes.access;access,
+				--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.tabs.behaviour,
+					--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.palettes.caching;caching,
+					--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.palettes.language;language,
+					--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.palettes.miscellaneous;miscellaneous,
+				'
+		];
+
+		\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
+			$table, [
+				'tx_sgnews_teaser1_image' => [
+					'exclude' => TRUE,
+					'label' => $localLangDbPath . $table . '.tx_sgnews_teaser1_image',
+					'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
+						'tx_sgnews_teaser1_image',
+						[
+							'maxitems' => 9999,
+							'foreign_types' => [
+								'0' => [
+									'showitem' => '
+								--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
+								--palette--;;filePalette'
+								],
+								\TYPO3\CMS\Core\Resource\File::FILETYPE_TEXT => [
+									'showitem' => '
+								--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
+								--palette--;;filePalette'
+								],
+								\TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [
+									'showitem' => '
+								--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
+								--palette--;;filePalette'
+								],
+								\TYPO3\CMS\Core\Resource\File::FILETYPE_AUDIO => [
+									'showitem' => '
+								--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
+								--palette--;;filePalette'
+								],
+								\TYPO3\CMS\Core\Resource\File::FILETYPE_VIDEO => [
+									'showitem' => '
+								--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
+								--palette--;;filePalette'
+								],
+								\TYPO3\CMS\Core\Resource\File::FILETYPE_APPLICATION => [
+									'showitem' => '
+								--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
+								--palette--;;filePalette'
+								]
+							],
+							'appearance' => [
+								'showPossibleLocalizationRecords' => TRUE,
+								'showRemovedLocalizationRecords' => TRUE,
+								'showSynchronizationLink' => TRUE,
+								'showAllLocalizationLink' => TRUE,
+							],
+						],
+						$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
+					),
 				],
-			],
-			$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
-		),
-	],
-	'tx_sgnews_teaser2_image' => [
-		'exclude' => TRUE,
-		'label' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_teaser2_image',
-		'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
-			'tx_sgnews_teaser2_image',
-			[
-				'maxitems' => 9999,
-				'foreign_types' => [
-					'0' => [
-						'showitem' => '
-							--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
-							--palette--;;filePalette'
-					],
-					\TYPO3\CMS\Core\Resource\File::FILETYPE_TEXT => [
-						'showitem' => '
-							--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
-							--palette--;;filePalette'
-					],
-					\TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [
-						'showitem' => '
-							--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
-							--palette--;;filePalette'
-					],
-					\TYPO3\CMS\Core\Resource\File::FILETYPE_AUDIO => [
-						'showitem' => '
-							--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
-							--palette--;;filePalette'
-					],
-					\TYPO3\CMS\Core\Resource\File::FILETYPE_VIDEO => [
-						'showitem' => '
-							--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
-							--palette--;;filePalette'
-					],
-					\TYPO3\CMS\Core\Resource\File::FILETYPE_APPLICATION => [
-						'showitem' => '
-							--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
-							--palette--;;filePalette'
-					]
+				'tx_sgnews_teaser2_image' => [
+					'exclude' => TRUE,
+					'label' => $localLangDbPath . $table . '.tx_sgnews_teaser2_image',
+					'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
+						'tx_sgnews_teaser2_image',
+						[
+							'maxitems' => 9999,
+							'foreign_types' => [
+								'0' => [
+									'showitem' => '
+								--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
+								--palette--;;filePalette'
+								],
+								\TYPO3\CMS\Core\Resource\File::FILETYPE_TEXT => [
+									'showitem' => '
+								--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
+								--palette--;;filePalette'
+								],
+								\TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [
+									'showitem' => '
+								--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
+								--palette--;;filePalette'
+								],
+								\TYPO3\CMS\Core\Resource\File::FILETYPE_AUDIO => [
+									'showitem' => '
+								--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
+								--palette--;;filePalette'
+								],
+								\TYPO3\CMS\Core\Resource\File::FILETYPE_VIDEO => [
+									'showitem' => '
+								--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
+								--palette--;;filePalette'
+								],
+								\TYPO3\CMS\Core\Resource\File::FILETYPE_APPLICATION => [
+									'showitem' => '
+								--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
+								--palette--;;filePalette'
+								]
+							],
+							'appearance' => [
+								'showPossibleLocalizationRecords' => TRUE,
+								'showRemovedLocalizationRecords' => TRUE,
+								'showSynchronizationLink' => TRUE,
+								'showAllLocalizationLink' => TRUE,
+							],
+						],
+						$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
+					),
 				],
-				'appearance' => [
-					'showPossibleLocalizationRecords' => TRUE,
-					'showRemovedLocalizationRecords' => TRUE,
-					'showSynchronizationLink' => TRUE,
-					'showAllLocalizationLink' => TRUE,
+				'tx_sgnews_author' => [
+					'exclude' => TRUE,
+					'l10n_exclude' => TRUE,
+					'label' => $localLangDbPath . $table . '.tx_sgnews_author',
+					'config' => [
+						'type' => 'group',
+						'internal_type' => 'db',
+						'allowed' => 'fe_users',
+						'size' => 1,
+						'minitems' => 0,
+						'maxitems' => 1,
+						'items' => [
+							['', ''],
+						],
+						'wizards' => [
+							'suggest' => [
+								'type' => 'suggest',
+							],
+						],
+					],
 				],
-			],
-			$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
-		),
-	],
-];
-
-$columns = array_merge(
-	[
-		'tx_sgnews_author' => [
-			'exclude' => TRUE,
-			'l10n_exclude' => TRUE,
-			'label' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_author',
-			'config' => [
-				'type' => 'group',
-				'internal_type' => 'db',
-				'allowed' => 'fe_users',
-				'size' => 1,
-				'minitems' => 0,
-				'maxitems' => 1,
-				'items' => [
-					['', ''],
+				'tx_sgnews_related_news' => [
+					'exclude' => TRUE,
+					'l10n_exclude' => TRUE,
+					'label' => $localLangDbPath . $table . '.tx_sgnews_related_news',
+					'config' => [
+						'type' => 'group',
+						'internal_type' => 'db',
+						'allowed' => $table,
+						'size' => 5,
+						'minitems' => 0,
+						'maxitems' => 99,
+						'wizards' => [
+							'suggest' => [
+								'type' => 'suggest',
+							],
+						],
+					],
 				],
-				'wizards' => [
-					'suggest' => [
-						'type' => 'suggest',
+				'tx_sgnews_highlighted' => [
+					'displayCond' => 'FIELD:tx_sgnews_never_highlighted:=:0',
+					'exclude' => TRUE,
+					'l10n_exclude' => TRUE,
+					'label' => $localLangDbPath . $table . '.tx_sgnews_highlighted',
+					'config' => [
+						'type' => 'check',
 					],
 				],
-			],
-		],
-		'tx_sgnews_related_news' => [
-			'exclude' => TRUE,
-			'l10n_exclude' => TRUE,
-			'label' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_related_news',
-			'config' => [
-				'type' => 'group',
-				'internal_type' => 'db',
-				'allowed' => 'pages',
-				'size' => 5,
-				'minitems' => 0,
-				'maxitems' => 99,
-				'wizards' => [
-					'suggest' => [
-						'type' => 'suggest',
+				'tx_sgnews_never_highlighted' => [
+					'displayCond' => 'FIELD:tx_sgnews_highlighted:=:0',
+					'exclude' => TRUE,
+					'l10n_exclude' => TRUE,
+					'label' => $localLangDbPath . $table . '.tx_sgnews_never_highlighted',
+					'config' => [
+						'type' => 'check',
 					],
 				],
-			],
-		],
-		'tx_sgnews_highlighted' => [
-			'displayCond' => 'FIELD:tx_sgnews_never_highlighted:=:0',
-			'exclude' => TRUE,
-			'l10n_exclude' => TRUE,
-			'label' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_highlighted',
-			'config' => [
-				'type' => 'check',
-			],
-		],
-		'tx_sgnews_never_highlighted' => [
-			'displayCond' => 'FIELD:tx_sgnews_highlighted:=:0',
-			'exclude' => TRUE,
-			'l10n_exclude' => TRUE,
-			'label' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_never_highlighted',
-			'config' => [
-				'type' => 'check',
-			],
-		],
-		'tx_sgnews_tags' => [
-			'exclude' => 1,
-			'label' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_tags',
-			'config' => [
-				'type' => 'select',
-				'maxitems' => 9999,
-				'size' => 10,
-				'foreign_table' => 'sys_category',
-				'foreign_table_where' => 'AND (IF (###PAGE_TSCONFIG_ID### = 0, 1, sys_category.pid = ###PAGE_TSCONFIG_ID###)) AND sys_category.sys_language_uid IN (-1, 0) ORDER BY sys_category.sorting ASC',
-				'MM' => 'sys_category_record_mm',
-				'MM_match_fields' => [
-					'fieldname' => 'tx_sgnews_tags',
-					'tablenames' => 'pages'
+				'tx_sgnews_tags' => [
+					'exclude' => 1,
+					'label' => $localLangDbPath . $table . '.tx_sgnews_tags',
+					'config' => [
+						'type' => 'select',
+						'maxitems' => 9999,
+						'size' => 10,
+						'foreign_table' => 'sys_category',
+						'foreign_table_where' => 'AND (IF (###PAGE_TSCONFIG_ID### = 0, 1, sys_category.pid = ###PAGE_TSCONFIG_ID###)) AND sys_category.sys_language_uid IN (-1, 0) ORDER BY sys_category.sorting ASC',
+						'MM' => 'sys_category_record_mm',
+						'MM_match_fields' => [
+							'fieldname' => 'tx_sgnews_tags',
+							'tablenames' => $table
+						],
+						'MM_opposite_field' => 'items',
+						'renderType' => 'selectTree',
+						'treeConfig' => [
+							'parentField' => 'parent',
+							'appearance' => [
+								'expandAll' => 1,
+								'maxLevels' => 99,
+								'showHeader' => 1
+							]
+						]
+					]
+				],
+				'tx_sgnews_likes' => [
+					'label' => $localLangDbPath . $table . '.tx_sgnews_likes',
+					'config' => [
+						'type' => 'input',
+						'size' => '20',
+						'eval' => 'trim',
+					]
+				],
+				'lastUpdated' => [
+					'exclude' => TRUE,
+					'label' => 'LLL:EXT:cms/locallang_tca.xlf:' . $table . '.lastUpdated',
+					'config' => [
+						'type' => 'input',
+						'size' => '13',
+						'max' => '20',
+						'eval' => 'datetime',
+						'default' => $GLOBALS['EXEC_TIME'],
+					]
 				],
-				'MM_opposite_field' => 'items',
-				'renderType' => 'selectTree',
-				'treeConfig' => [
-					'parentField' => 'parent',
-					'appearance' => [
-						'expandAll' => 1,
-						'maxLevels' => 99,
-						'showHeader' => 1
+				'tx_sgnews_location' => [
+					'exclude' => TRUE,
+					'label' => $localLangDbPath . $table . '.tx_sgnews_location',
+					'config' => [
+						'type' => 'input',
+						'size' => 20,
+						'eval' => 'trim'
 					]
 				]
 			]
-		],
-		'tx_sgnews_likes' => [
-			'label' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_likes',
-			'config' => [
-				'type' => 'input',
-				'size' => '20',
-				'eval' => 'trim',
-			]
-		],
-		'lastUpdated' => [
-			'exclude' => TRUE,
-			'label' => 'LLL:EXT:cms/locallang_tca.xlf:pages.lastUpdated',
-			'config' => [
-				'type' => 'input',
-				'size' => '13',
-				'max' => '20',
-				'eval' => 'datetime',
-				'default' => $GLOBALS['EXEC_TIME'],
-			]
-		],
-		'tx_sgnews_location' => [
-			'exclude' => TRUE,
-			'label' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_location',
-			'config' => [
-				'type' => 'input',
-				'size' => 20,
-				'eval' => 'trim'
-			]
-		]
-	], $imageColumns
-);
-$languageOverlayColumns = array_merge(
-	[
-		'tx_sgnews_location' => [
-			'exclude' => TRUE,
-			'label' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_location',
-			'config' => [
-				'type' => 'input',
-				'size' => 20,
-				'eval' => 'trim'
-			]
-		]
-	], $imageColumns
-);
-\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('pages', $columns);
-\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('pages_language_overlay', $languageOverlayColumns);
+		);
 
-$GLOBALS['TCA']['pages']['palettes']['titleDescriptionAndHighlightFlag'] = [
-	'showitem' => 'subtitle;LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.subtitle.inPalette,
-		--linebreak--, description,
-		--linebreak--, tx_realurl_pathsegment, tx_realurl_exclude,
-		--linebreak--, tx_sgnews_highlighted, tx_sgnews_never_highlighted',
-	'canNotCollapse' => 1,
-];
+		$GLOBALS['TCA'][$table]['palettes']['titleDescriptionAndHighlightFlag'] = [
+			'showitem' => 'subtitle;' . $localLangDbPath . $table . '.subtitle.inPalette,
+			--linebreak--, description,
+			--linebreak--, tx_realurl_pathsegment, tx_realurl_exclude,
+			--linebreak--, tx_sgnews_highlighted, tx_sgnews_never_highlighted',
+			'canNotCollapse' => 1,
+		];
 
-
-if (\SGalinski\SgNews\Utility\VersionUtility::isVersion870OrHigher()) {
-	$GLOBALS['TCA']['pages']['palettes']['editorialWithNewsAuthor'] = [
-		'showitem' => 'tx_sgnews_author;LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_author.inPalette,
+		$GLOBALS['TCA'][$table]['palettes']['editorialWithNewsAuthor'] = [
+			'showitem' => 'tx_sgnews_author;' . $localLangDbPath . $table . '.tx_sgnews_author.inPalette,
 			--linebreak--, 
-			author;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.author_formlabel,
-			author_email;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.author_email_formlabel,
-			--linebreak--, lastUpdated;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.lastUpdated_formlabel,
+			author;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.author_formlabel,
+			author_email;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.author_email_formlabel,
+			--linebreak--, lastUpdated;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.lastUpdated_formlabel,
 			tx_sgnews_likes,--linebreak--,tx_sgnews_location',
-		'canNotCollapse' => 1,
-	];
-
-	#
-	# Pages
-	#
-	$GLOBALS['TCA']['pages']['types'][116] = [
-		'showitem' => '--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.standard;standard,
-		--palette--;;titleDescriptionAndHighlightFlag,
-		--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.editorial;editorialWithNewsAuthor,
-		tx_sgnews_related_news, tx_sgnews_tags,
-	--div--;LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tabs.images,
-		tx_sgnews_teaser2_image, tx_sgnews_teaser1_image,
-	--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.metadata,
-		tx_projectbase_devnullrobots_flags,
-		--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.abstract;abstract,
-		tx_projectbase_seo_titletag,tx_projectbase_seo_canonicaltag,
-	--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.appearance,
-		--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.layout;layout,
-	--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,
-		--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.visibility;visibility,
-		--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.access;access,
-	--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.behaviour,
-		--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.caching;caching,
-		--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.language;language,
-		--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.miscellaneous;miscellaneous,
-	'
-	];
-
-	$GLOBALS['TCA']['pages']['types'][117] = [
-		'showitem' => '--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.standard;standard,
-		title, tx_realurl_pathsegment, tx_realurl_exclude,
-	--div--;LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tabs.images,
-		tx_sgnews_teaser2_image, tx_sgnews_teaser1_image,
-	--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.metadata,
-		tx_projectbase_devnullrobots_flags,
-		--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.abstract;abstract,
-		tx_projectbase_seo_titletag,tx_projectbase_seo_canonicaltag, description,
-	--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.appearance,
-		--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.layout;layout,
-	--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,
-		--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.visibility;visibility,
-		--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.access;access,
-	--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.behaviour,
-		--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.caching;caching,
-		--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.language;language,
-		--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.miscellaneous;miscellaneous,
-	'
-	];
+			'canNotCollapse' => 1,
+		];
 
-	#
-	# Pages Overlay
-	#
-	$GLOBALS['TCA']['pages_language_overlay']['types'][116] = [
-		'showitem' => '--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.standard;standard,
-			subtitle;LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.subtitle.inPalette,
-			description, tx_realurl_pathsegment, author, tx_sgnews_location,
-		--div--;LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tabs.images,
-			tx_sgnews_teaser2_image, tx_sgnews_teaser1_image,
-		--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.metadata,
-			--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.abstract;abstract,
-			tx_projectbase_seo_titletag,tx_projectbase_seo_canonicaltag,
-		--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language,
-			sys_language_uid,
-		--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,
-			--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.visibility;hiddenonly,
-			--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.access;access'
-	];
-
-	$GLOBALS['TCA']['pages_language_overlay']['types'][117] = [
-		'showitem' => '--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.standard;standard,
-			title, tx_realurl_pathsegment,
-		--div--;LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tabs.images,
-			tx_sgnews_teaser2_image, tx_sgnews_teaser1_image,
-		--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.metadata,
-			--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.abstract;abstract,
-			tx_projectbase_seo_titletag,tx_projectbase_seo_canonicaltag, description,
-		--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language,
-			sys_language_uid,
-		--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,
-			--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.visibility;hiddenonly,
-			--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.access;access'
-	];
-} else {
-	$GLOBALS['TCA']['pages']['palettes']['editorialWithNewsAuthor'] = [
-		'showitem' => 'tx_sgnews_author;LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_author.inPalette,
-			--linebreak--, 
-			author;LLL:EXT:cms/locallang_tca.xlf:pages.author_formlabel,
-			author_email;LLL:EXT:cms/locallang_tca.xlf:pages.author_email_formlabel,
-			--linebreak--, lastUpdated;LLL:EXT:cms/locallang_tca.xlf:pages.lastUpdated_formlabel,
-			tx_sgnews_likes,--linebreak--,tx_sgnews_location',
-		'canNotCollapse' => 1,
-	];
-
-	#
-	# Pages
-	#
-	$GLOBALS['TCA']['pages']['types'][116] = [
-		'showitem' => '--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.standard;standard,
-		--palette--;;titleDescriptionAndHighlightFlag,
-		--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.editorial;editorialWithNewsAuthor,
-		tx_sgnews_related_news, tx_sgnews_tags,
-	--div--;LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tabs.images,
-		tx_sgnews_teaser2_image, tx_sgnews_teaser1_image,
-	--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.metadata,
-		tx_projectbase_devnullrobots_flags,
-		--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.abstract;abstract,
-		tx_projectbase_seo_titletag,tx_projectbase_seo_canonicaltag,
-	--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.appearance,
-		--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.layout;layout,
-	--div--;LLL:EXT:cms/locallang_tca.xlf:pages.tabs.access,
-		--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.visibility;visibility,
-		--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.access;access,
-	--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.behaviour,
-		--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.caching;caching,
-		--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.language;language,
-		--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.miscellaneous;miscellaneous,
-	'
-	];
-
-	$GLOBALS['TCA']['pages']['types'][117] = [
-		'showitem' => '--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.standard;standard,
-		title, tx_realurl_pathsegment, tx_realurl_exclude,
-	--div--;LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tabs.images,
-		tx_sgnews_teaser2_image, tx_sgnews_teaser1_image,
-	--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.metadata,
-		tx_projectbase_devnullrobots_flags,
-		--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.abstract;abstract,
-		tx_projectbase_seo_titletag,tx_projectbase_seo_canonicaltag, description,
-	--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.appearance,
-		--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.layout;layout,
-	--div--;LLL:EXT:cms/locallang_tca.xlf:pages.tabs.access,
-		--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.visibility;visibility,
-		--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.access;access,
-	--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.behaviour,
-		--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.caching;caching,
-		--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.language;language,
-		--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.miscellaneous;miscellaneous,
-	'
-	];
-
-	#
-	# Pages Overlay
-	#
-	$GLOBALS['TCA']['pages_language_overlay']['types'][116] = [
-		'showitem' => '--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.standard;standard,
-			subtitle;LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.subtitle.inPalette,
-			description, tx_realurl_pathsegment, author, tx_sgnews_location,
-		--div--;LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tabs.images,
-			tx_sgnews_teaser2_image, tx_sgnews_teaser1_image,
-		--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.metadata,
-			--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.abstract;abstract,
-			tx_projectbase_seo_titletag,tx_projectbase_seo_canonicaltag,
-		--div--;LLL:EXT:cms/locallang_tca.xlf:pages.tabs.access,
-			--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.visibility;hiddenonly,
-			--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.access;access'
-	];
-
-	$GLOBALS['TCA']['pages_language_overlay']['types'][117] = [
-		'showitem' => '--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.standard;standard,
-			title, tx_realurl_pathsegment,
-		--div--;LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tabs.images,
-			tx_sgnews_teaser2_image, tx_sgnews_teaser1_image,
-		--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.metadata,
-			--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.abstract;abstract,
-			tx_projectbase_seo_titletag,tx_projectbase_seo_canonicaltag, description,
-		--div--;LLL:EXT:cms/locallang_tca.xlf:pages.tabs.access,
-			--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.visibility;hiddenonly,
-			--palette--;LLL:EXT:cms/locallang_tca.xlf:pages.palettes.access;access'
-	];
-}
+		// Removal of the realurl fields, if the extension isn't installed.
+		if (!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('realurl')) {
+			$GLOBALS['TCA'][$table]['palettes']['titleDescriptionAndHighlightFlag'] = str_replace(
+				'--linebreak--, tx_realurl_pathsegment, tx_realurl_exclude,', '',
+				$GLOBALS['TCA'][$table]['palettes']['titleDescriptionAndHighlightFlag']
+			);
+			$GLOBALS['TCA'][$table]['types'][117] = str_replace(
+				'tx_realurl_pathsegment, tx_realurl_exclude,', '',
+				$GLOBALS['TCA'][$table]['types'][117]
+			);
+		}
+	}, 'sg_news', 'pages'
+);
 
-// Removal of the realurl fields, if the extension isn't installed.
-if (!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('realurl')) {
-	$GLOBALS['TCA']['pages']['palettes']['titleDescriptionAndHighlightFlag'] = str_replace(
-		'--linebreak--, tx_realurl_pathsegment, tx_realurl_exclude,', '',
-		$GLOBALS['TCA']['pages']['palettes']['titleDescriptionAndHighlightFlag']
-	);
-	$GLOBALS['TCA']['pages']['types'][117] = str_replace(
-		'tx_realurl_pathsegment, tx_realurl_exclude,', '',
-		$GLOBALS['TCA']['pages']['types'][117]
-	);
-}
diff --git a/Configuration/TCA/Overrides/pages_language_overlay.php b/Configuration/TCA/Overrides/pages_language_overlay.php
new file mode 100644
index 0000000..0c0151b
--- /dev/null
+++ b/Configuration/TCA/Overrides/pages_language_overlay.php
@@ -0,0 +1,200 @@
+<?php
+/**
+ *
+ * Copyright notice
+ *
+ * (c) sgalinski Internet Services (https://www.sgalinski.de)
+ *
+ * All rights reserved
+ *
+ * This script is part of the TYPO3 project. The TYPO3 project is
+ * free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * The GNU General Public License can be found at
+ * http://www.gnu.org/copyleft/gpl.html.
+ *
+ * This script is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * This copyright notice MUST APPEAR in all copies of the script!
+ */
+
+if (\version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) {
+	call_user_func(
+		function ($extKey, $table) {
+			$pagesTable = 'pages';
+			$localLangDbPath = 'LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_db.xlf:';
+			$localLangBackendPath = 'LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_backend.xlf:';
+
+			$GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields'] .= ',tx_sgnews_teaser1_image,tx_sgnews_teaser2_image';
+
+			foreach (
+				[
+					\SGalinski\SgNews\Utility\BackendNewsUtility::CATEGORY_DOKTYPE => [
+						'icon' => 'EXT:sg_news/Resources/Public/Images/Category.png',
+						'locallangIndex' => 'pageType.category'
+					],
+					\SGalinski\SgNews\Utility\BackendNewsUtility::NEWS_DOKTYPE => [
+						'icon' => 'EXT:sg_news/Resources/Public/Images/News.png',
+						'locallangIndex' => 'pageType.news'
+					]
+				] as $doktype => $configuration) {
+				// also add the new doktype to the page language overlays type selector (so that translations can inherit the same type)
+				$GLOBALS['TCA'][$table]['columns']['doktype']['config']['items'][] = [
+					$localLangBackendPath . $configuration['locallangIndex'],
+					$doktype,
+					$configuration['icon']
+				];
+			}
+
+			$GLOBALS['TCA'][$table]['types'][\SGalinski\SgNews\Utility\BackendNewsUtility::NEWS_DOKTYPE] = [
+				'showitem' => '--palette--;LLL:EXT:cms/locallang_tca.xlf:' . $pagesTable . '.palettes.standard;standard,
+					subtitle;' . $localLangDbPath . $pagesTable . '.subtitle.inPalette,
+					description, tx_realurl_pathsegment, author, tx_sgnews_location,
+				--div--;' . $localLangDbPath . $pagesTable . '.tabs.images,
+					tx_sgnews_teaser2_image, tx_sgnews_teaser1_image,
+				--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $pagesTable . '.tabs.metadata,
+					--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $pagesTable . '.palettes.abstract;abstract,
+					tx_projectbase_seo_titletag,tx_projectbase_seo_canonicaltag,
+				--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language,
+					sys_language_uid,
+				--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,
+					--palette--;LLL:EXT:cms/locallang_tca.xlf:' . $pagesTable . '.palettes.visibility;hiddenonly,
+					--palette--;LLL:EXT:cms/locallang_tca.xlf:' . $pagesTable . '.palettes.access;access'
+			];
+
+			$GLOBALS['TCA'][$table]['types'][\SGalinski\SgNews\Utility\BackendNewsUtility::CATEGORY_DOKTYPE] = [
+				'showitem' => '--palette--;LLL:EXT:cms/locallang_tca.xlf:' . $pagesTable . '.palettes.standard;standard,
+					title, tx_realurl_pathsegment,
+				--div--;' . $localLangDbPath . $table . '.tabs.images,
+					tx_sgnews_teaser2_image, tx_sgnews_teaser1_image,
+				--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $pagesTable . '.tabs.metadata,
+					--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $pagesTable . '.palettes.abstract;abstract,
+					tx_projectbase_seo_titletag,tx_projectbase_seo_canonicaltag, description,
+				--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language,
+					sys_language_uid,
+				--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,
+					--palette--;LLL:EXT:cms/locallang_tca.xlf:' . $pagesTable . '.palettes.visibility;hiddenonly,
+					--palette--;LLL:EXT:cms/locallang_tca.xlf:' . $pagesTable . '.palettes.access;access'
+			];
+
+			\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
+				$table, [
+					'tx_sgnews_teaser1_image' => [
+						'exclude' => TRUE,
+						'label' => $localLangDbPath . $pagesTable . '.tx_sgnews_teaser1_image',
+						'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
+							'tx_sgnews_teaser1_image',
+							[
+								'maxitems' => 9999,
+								'foreign_types' => [
+									'0' => [
+										'showitem' => '
+										--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
+										--palette--;;filePalette'
+									],
+									\TYPO3\CMS\Core\Resource\File::FILETYPE_TEXT => [
+										'showitem' => '
+										--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
+										--palette--;;filePalette'
+									],
+									\TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [
+										'showitem' => '
+										--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
+										--palette--;;filePalette'
+									],
+									\TYPO3\CMS\Core\Resource\File::FILETYPE_AUDIO => [
+										'showitem' => '
+										--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
+										--palette--;;filePalette'
+									],
+									\TYPO3\CMS\Core\Resource\File::FILETYPE_VIDEO => [
+										'showitem' => '
+										--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
+										--palette--;;filePalette'
+									],
+									\TYPO3\CMS\Core\Resource\File::FILETYPE_APPLICATION => [
+										'showitem' => '
+										--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
+										--palette--;;filePalette'
+									]
+								],
+								'appearance' => [
+									'showPossibleLocalizationRecords' => TRUE,
+									'showRemovedLocalizationRecords' => TRUE,
+									'showSynchronizationLink' => TRUE,
+									'showAllLocalizationLink' => TRUE,
+								],
+							],
+							$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
+						),
+					],
+					'tx_sgnews_teaser2_image' => [
+						'exclude' => TRUE,
+						'label' => $localLangDbPath . $pagesTable . '.tx_sgnews_teaser2_image',
+						'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
+							'tx_sgnews_teaser2_image',
+							[
+								'maxitems' => 9999,
+								'foreign_types' => [
+									'0' => [
+										'showitem' => '
+										--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
+										--palette--;;filePalette'
+									],
+									\TYPO3\CMS\Core\Resource\File::FILETYPE_TEXT => [
+										'showitem' => '
+										--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
+										--palette--;;filePalette'
+									],
+									\TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => [
+										'showitem' => '
+										--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
+										--palette--;;filePalette'
+									],
+									\TYPO3\CMS\Core\Resource\File::FILETYPE_AUDIO => [
+										'showitem' => '
+										--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
+										--palette--;;filePalette'
+									],
+									\TYPO3\CMS\Core\Resource\File::FILETYPE_VIDEO => [
+										'showitem' => '
+										--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
+										--palette--;;filePalette'
+									],
+									\TYPO3\CMS\Core\Resource\File::FILETYPE_APPLICATION => [
+										'showitem' => '
+										--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,
+										--palette--;;filePalette'
+									]
+								],
+								'appearance' => [
+									'showPossibleLocalizationRecords' => TRUE,
+									'showRemovedLocalizationRecords' => TRUE,
+									'showSynchronizationLink' => TRUE,
+									'showAllLocalizationLink' => TRUE,
+								],
+							],
+							$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
+						),
+					],
+					'tx_sgnews_location' => [
+						'exclude' => TRUE,
+						'label' => $localLangDbPath . $pagesTable . '.tx_sgnews_location',
+						'config' => [
+							'type' => 'input',
+							'size' => 20,
+							'eval' => 'trim'
+						]
+					]
+				]
+			);
+
+		}, 'sg_news', 'pages_language_overlay'
+	);
+}
diff --git a/Configuration/TCA/Overrides/sys_template.php b/Configuration/TCA/Overrides/sys_template.php
new file mode 100644
index 0000000..99fb39b
--- /dev/null
+++ b/Configuration/TCA/Overrides/sys_template.php
@@ -0,0 +1,34 @@
+<?php
+/**
+ *
+ * Copyright notice
+ *
+ * (c) sgalinski Internet Services (https://www.sgalinski.de)
+ *
+ * All rights reserved
+ *
+ * This script is part of the TYPO3 project. The TYPO3 project is
+ * free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * The GNU General Public License can be found at
+ * http://www.gnu.org/copyleft/gpl.html.
+ *
+ * This script is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * This copyright notice MUST APPEAR in all copies of the script!
+ */
+
+call_user_func(
+	function ($extKey, $table) {
+		\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
+			$extKey, 'Configuration/TypoScript/Frontend', 'News System'
+		);
+
+	}, 'sg_news', 'sys_template'
+);
diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php
new file mode 100644
index 0000000..f77c0df
--- /dev/null
+++ b/Configuration/TCA/Overrides/tt_content.php
@@ -0,0 +1,82 @@
+<?php
+/**
+ *
+ * Copyright notice
+ *
+ * (c) sgalinski Internet Services (https://www.sgalinski.de)
+ *
+ * All rights reserved
+ *
+ * This script is part of the TYPO3 project. The TYPO3 project is
+ * free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * The GNU General Public License can be found at
+ * http://www.gnu.org/copyleft/gpl.html.
+ *
+ * This script is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * This copyright notice MUST APPEAR in all copies of the script!
+ */
+
+call_user_func(
+	function ($extKey, $table) {
+		\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
+			$extKey,
+			'Overview',
+			'LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_backend.xlf:titleOverviewPlugin'
+		);
+
+		\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
+			$extKey,
+			'Latest',
+			'LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_backend.xlf:titleLatestPlugin'
+		);
+
+		\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
+			$extKey,
+			'SingleView',
+			'LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_backend.xlf:titleSingleViewPlugin'
+		);
+
+		\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
+			$extKey,
+			'ListByCategory',
+			'LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_backend.xlf:titleListByCategoryPlugin'
+		);
+
+		// Removal of the unused plugin setting fields
+		$GLOBALS['TCA'][$table]['types']['list']['subtypes_excludelist']['sgnews_overview'] = 'select_key,pages,recursive';
+		$GLOBALS['TCA'][$table]['types']['list']['subtypes_excludelist']['sgnews_listbycategory'] = 'select_key,pages,recursive';
+		$GLOBALS['TCA'][$table]['types']['list']['subtypes_excludelist']['sgnews_latest'] = 'select_key,pages,recursive';
+		$GLOBALS['TCA'][$table]['types']['list']['subtypes_excludelist']['sgnews_singleview'] = 'select_key,pages,recursive';
+
+		// Flex form assignment
+		$pluginSignature = str_replace('_', '', $extKey) . '_overview';
+		$GLOBALS['TCA'][$table]['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
+		\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue(
+			$pluginSignature, 'FILE:EXT:' . $extKey . '/Configuration/FlexForms/Overview.xml'
+		);
+
+		$pluginSignature = str_replace('_', '', $extKey) . '_listbycategory';
+		$GLOBALS['TCA'][$table]['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
+		\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue(
+			$pluginSignature, 'FILE:EXT:' . $extKey . '/Configuration/FlexForms/ListByCategory.xml'
+		);
+
+		$pluginSignature = str_replace('_', '', $extKey) . '_latest';
+		$GLOBALS['TCA'][$table]['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
+		\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue(
+			$pluginSignature, 'FILE:EXT:' . $extKey . '/Configuration/FlexForms/Latest.xml'
+		);
+
+		if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('sg_ajax')) {
+			\SGalinski\SgAjax\Service\AjaxRegistration::registerAjaxFrontendPlugin($extKey);
+		}
+	}, 'sg_news', 'tt_content'
+);
diff --git a/Configuration/TypoScript/Common/setup.txt b/Configuration/TypoScript/Common/setup.typoscript
similarity index 100%
rename from Configuration/TypoScript/Common/setup.txt
rename to Configuration/TypoScript/Common/setup.typoscript
diff --git a/Configuration/TypoScript/Frontend/constants.txt b/Configuration/TypoScript/Frontend/constants.typoscript
similarity index 100%
rename from Configuration/TypoScript/Frontend/constants.txt
rename to Configuration/TypoScript/Frontend/constants.typoscript
diff --git a/Configuration/TypoScript/Frontend/setup.txt b/Configuration/TypoScript/Frontend/setup.typoscript
similarity index 100%
rename from Configuration/TypoScript/Frontend/setup.txt
rename to Configuration/TypoScript/Frontend/setup.typoscript
diff --git a/Resources/Public/JavaScript/Backend.js b/Resources/Public/JavaScript/Backend.js
index 06ea6e8..f149bf4 100644
--- a/Resources/Public/JavaScript/Backend.js
+++ b/Resources/Public/JavaScript/Backend.js
@@ -39,15 +39,25 @@ define([
 				this.form.submit();
 			});
 		},
-		sgNewsGoToPageModule: function(uid) {
-			ModuleMenu.App.showModule('web_layout', 'id=' + uid);
+
+		goTo: function(module, id) {
 			var pageTreeNodes = Viewport.NavigationContainer.PageTree.instance.nodes;
 			for (var nodeIndex in pageTreeNodes) {
-				if (pageTreeNodes[nodeIndex].identifier === uid) {
+				if (pageTreeNodes.hasOwnProperty(nodeIndex) && pageTreeNodes[nodeIndex].identifier === id) {
 					Viewport.NavigationContainer.PageTree.selectNode(pageTreeNodes[nodeIndex]);
 					break;
 				}
 			}
+			ModuleMenu.App.showModule(module, 'id=' + id);
+		},
+
+		sgNewsGoToNewsModule: function(uid) {
+			this.goTo('web_SgNewsNews', uid);
+			return false;
+		},
+
+		sgNewsGoToPageModule: function(uid) {
+			this.goTo('web_layout', uid);
 			return false;
 		}
 	};
diff --git a/ext_localconf.php b/ext_localconf.php
index 5ff9bb5..981b2f7 100644
--- a/ext_localconf.php
+++ b/ext_localconf.php
@@ -1,106 +1,136 @@
 <?php
-
-if (!defined('TYPO3_MODE')) {
-	die('Access denied.');
-}
-
-$GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields'] .= ',tx_sgnews_teaser1_image,tx_sgnews_teaser2_image';
-
-/** @noinspection PhpUndefinedVariableInspection */
-$extPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('sg_news');
-
-// common typoscript configuration
-$tsPath = $extPath . 'Configuration/TypoScript/Common/';
-\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScriptSetup(file_get_contents($tsPath . 'setup.txt'));
-
-// plugin configurations
-\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
-	'SGalinski.sg_news',
-	'Overview',
-	['Overview' => 'overview',],
-	['Overview' => '',]
-);
-
-\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
-	'SGalinski.sg_news',
-	'ListByCategory',
-	['ListByCategory' => 'index',],
-	['ListByCategory' => '',]
-);
-
-\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
-	'SGalinski.sg_news',
-	'SingleView',
-	['SingleView' => 'singleView',],
-	['SingleView' => '',]
-);
-
-\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
-	'SGalinski.sg_news',
-	'NewsFeed',
-	['NewsFeed' => 'index',],
-	['NewsFeed' => '',]
+/**
+ *
+ * Copyright notice
+ *
+ * (c) sgalinski Internet Services (https://www.sgalinski.de)
+ *
+ * All rights reserved
+ *
+ * This script is part of the TYPO3 project. The TYPO3 project is
+ * free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * The GNU General Public License can be found at
+ * http://www.gnu.org/copyleft/gpl.html.
+ *
+ * This script is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * This copyright notice MUST APPEAR in all copies of the script!
+ */
+
+call_user_func(
+	function ($extKey) {
+		// common typoscript configuration
+		\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScriptSetup(
+			'<INCLUDE_TYPOSCRIPT: source="FILE:EXT:' . $extKey . '/Configuration/TypoScript/Common/setup.typoscript">'
+		);
+
+		// plugin configurations
+		\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
+			'SGalinski.' . $extKey,
+			'Overview',
+			['Overview' => 'overview',],
+			['Overview' => '',]
+		);
+
+		\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
+			'SGalinski.' . $extKey,
+			'ListByCategory',
+			['ListByCategory' => 'index',],
+			['ListByCategory' => '',]
+		);
+
+		\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
+			'SGalinski.' . $extKey,
+			'SingleView',
+			['SingleView' => 'singleView',],
+			['SingleView' => '',]
+		);
+
+		\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
+			'SGalinski.' . $extKey,
+			'NewsFeed',
+			['NewsFeed' => 'index',],
+			['NewsFeed' => '',]
+		);
+
+		\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
+			'SGalinski.' . $extKey,
+			'Latest',
+			['Latest' => 'index',],
+			['Latest' => '',]
+		);
+
+		\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
+			'SGalinski.' . $extKey,
+			'ListByCategory',
+			['ListByCategory' => 'index',],
+			['ListByCategory' => '',]
+		);
+
+		\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
+			'SGalinski.' . $extKey,
+			'PageBrowser',
+			['PageBrowser' => 'index',],
+			['PageBrowser' => '',]
+		);
+
+		if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('sg_ajax')) {
+			\SGalinski\SgAjax\Service\AjaxRegistration::configureAjaxFrontendPlugin(
+				$extKey, [
+					'Ajax\Like' => 'addLike',
+				]
+			);
+		}
+
+		// hook registration
+		$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] =
+			'SGalinski\SgNews\TCA\TcaProvider';
+
+		// Xclasses
+		$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['TYPO3\CMS\Core\Page\PageRenderer'] =
+			['className' => 'SGalinski\SgNews\Xclass\PageRenderer'];
+
+		// add realurl configuration
+		if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('realurl')) {
+			$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/realurl/class.tx_realurl_autoconfgen.php']['extensionConfiguration']['sgnews'] =
+				\SGalinski\SgNews\Hooks\RealUrlAutoConfiguration::class . '->addNewsConfig';
+		}
+
+		/** @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher $signalSlotDispatcher */
+		$signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
+			\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class
+		);
+
+		$signalSlotDispatcher->connect(
+			\TYPO3\CMS\Backend\Controller\EditDocumentController::class,
+			'preInitAfter',
+			\SGalinski\SgNews\Hooks\EditDocumentController::class,
+			'preInitAfter'
+		);
+
+		if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/db_layout.php']['drawHeaderHook'])) {
+			$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/db_layout.php']['drawHeaderHook'] = [];
+		}
+		$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/db_layout.php']['drawHeaderHook'][] =
+			\SGalinski\SgNews\Hooks\PageLayoutController::class . '->addNewsModuleLink';
+
+		// register command controllers
+		$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['extbase']['commandControllers'][] =
+			'SGalinski\SgNews\Command\MigrateNewsCommandController';
+
+		// add the new doktype to the list of types available from the new page menu at the top of the page tree
+		\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig(
+			'options.pageTree.doktypesToShowInNewPageDragArea := addToList(' . \SGalinski\SgNews\Utility\BackendNewsUtility::NEWS_DOKTYPE . ')' . PHP_EOL
+			. 'options.pageTree.doktypesToShowInNewPageDragArea := addToList(' . \SGalinski\SgNews\Utility\BackendNewsUtility::CATEGORY_DOKTYPE . ')'
+		);
+
+		\SGalinski\SgNews\Utility\BackendNewsUtility::registerIcons();
+	}, 'sg_news'
 );
-
-\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
-	'SGalinski.sg_news',
-	'Latest',
-	['Latest' => 'index',],
-	['Latest' => '',]
-);
-
-\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
-	'SGalinski.sg_news',
-	'ListByCategory',
-	['ListByCategory' => 'index',],
-	['ListByCategory' => '',]
-);
-
-\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
-	'SGalinski.sg_news',
-	'PageBrowser',
-	['PageBrowser' => 'index',],
-	['PageBrowser' => '',]
-);
-
-if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('sg_ajax')) {
-	\SGalinski\SgAjax\Service\AjaxRegistration::configureAjaxFrontendPlugin('sg_news', [
-			'Ajax\Like' => 'addLike',
-		]
-	);
-}
-
-// hook registration
-$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] =
-	'SGalinski\SgNews\TCA\TcaProvider';
-
-// Xclasses
-$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['TYPO3\CMS\Core\Page\PageRenderer'] =
-	['className' => 'SGalinski\SgNews\Xclass\PageRenderer'];
-
-// add realurl configuration
-if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('realurl')) {
-	$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/realurl/class.tx_realurl_autoconfgen.php']['extensionConfiguration']['sgnews'] =
-		\SGalinski\SgNews\Hooks\RealUrlAutoConfiguration::class . '->addNewsConfig';
-}
-
-/** @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher $signalSlotDispatcher */
-$signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class);
-
-$signalSlotDispatcher->connect(
-	\TYPO3\CMS\Backend\Controller\EditDocumentController::class,
-	'preInitAfter',
-	\SGalinski\SgNews\Hooks\EditDocumentController::class,
-	'preInitAfter'
-);
-
-if(!is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/db_layout.php']['drawHeaderHook'])) {
-	$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/db_layout.php']['drawHeaderHook'] = [];
-}
-$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/db_layout.php']['drawHeaderHook'][] =
-	\SGalinski\SgNews\Hooks\PageLayoutController::class . '->addNewsModuleLink';
-
-
-// register command controllers
-$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['extbase']['commandControllers'][] =
-	'SGalinski\SgNews\Command\MigrateNewsCommandController';
diff --git a/ext_tables.php b/ext_tables.php
index 07f142c..3d3b1c0 100644
--- a/ext_tables.php
+++ b/ext_tables.php
@@ -1,175 +1,47 @@
 <?php
-
-if (!defined('TYPO3_MODE')) {
-	die('Access denied.');
-}
-
-\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
-	'sg_news', 'Configuration/TypoScript/Frontend', 'News System'
-);
-
-TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
-	'sg_news', 'Overview',
-	'LLL:EXT:sg_news/Resources/Private/Language/locallang_backend.xlf:titleOverviewPlugin'
-);
-
-TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
-	'sg_news', 'Latest',
-	'LLL:EXT:sg_news/Resources/Private/Language/locallang_backend.xlf:titleLatestPlugin'
+/**
+ *
+ * Copyright notice
+ *
+ * (c) sgalinski Internet Services (https://www.sgalinski.de)
+ *
+ * All rights reserved
+ *
+ * This script is part of the TYPO3 project. The TYPO3 project is
+ * free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * The GNU General Public License can be found at
+ * http://www.gnu.org/copyleft/gpl.html.
+ *
+ * This script is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * This copyright notice MUST APPEAR in all copies of the script!
+ */
+
+call_user_func(
+	function ($extKey) {
+		if (TYPO3_MODE === 'BE') {
+			\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule(
+				'SGalinski.' . $extKey,
+				'web',
+				'News',
+				'',
+				[
+					'Backend' => 'index',
+				],
+				[
+					'access' => 'user,group',
+					'icon' => 'EXT:' . $extKey . '/Resources/Public/Icons/module-sgnews.svg',
+					'labels' => 'LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang.xlf',
+					'navigationComponentId' => 'TYPO3/CMS/Backend/PageTree/PageTreeElement'
+				]
+			);
+		}
+	}, 'sg_news'
 );
-
-TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
-	'sg_news', 'SingleView',
-	'LLL:EXT:sg_news/Resources/Private/Language/locallang_backend.xlf:titleSingleViewPlugin'
-);
-
-TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
-	'sg_news', 'ListByCategory',
-	'LLL:EXT:sg_news/Resources/Private/Language/locallang_backend.xlf:titleListByCategoryPlugin'
-);
-
-if (TYPO3_MODE === 'BE') {
-	\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule(
-		'SGalinski.sg_news',
-		'web',
-		'News',
-		'',
-		[
-			'Backend' => 'index',
-		],
-		[
-			'access' => 'user,group',
-			'icon' => 'EXT:sg_news/Resources/Public/Icons/module-sgnews.svg',
-			'labels' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang.xlf',
-			'navigationComponentId' => 'TYPO3/CMS/Backend/PageTree/PageTreeElement'
-		]
-	);
-}
-
-// Removal of the unused plugin setting fields
-$TCA['tt_content']['types']['list']['subtypes_excludelist']['sgnews_overview'] = 'select_key,pages,recursive';
-$TCA['tt_content']['types']['list']['subtypes_excludelist']['sgnews_listbycategory'] = 'select_key,pages,recursive';
-$TCA['tt_content']['types']['list']['subtypes_excludelist']['sgnews_latest'] = 'select_key,pages,recursive';
-$TCA['tt_content']['types']['list']['subtypes_excludelist']['sgnews_singleview'] = 'select_key,pages,recursive';
-
-// Flex form assignment
-$pluginSignature = str_replace('_', '', 'sg_news') . '_overview';
-$TCA['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
-\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue(
-	$pluginSignature, 'FILE:EXT:sg_news/Configuration/FlexForms/Overview.xml'
-);
-
-$pluginSignature = str_replace('_', '', 'sg_news') . '_listbycategory';
-$TCA['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
-\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue(
-	$pluginSignature, 'FILE:EXT:sg_news/Configuration/FlexForms/ListByCategory.xml'
-);
-
-$pluginSignature = str_replace('_', '', 'sg_news') . '_latest';
-$TCA['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
-\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue(
-	$pluginSignature, 'FILE:EXT:sg_news/Configuration/FlexForms/Latest.xml'
-);
-
-// Define the new doktypes
-/** @var \TYPO3\CMS\Core\Imaging\IconRegistry $iconRegistry */
-$iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);
-
-###################################
-### Define the Category Doktype ###
-###################################
-
-$customPageDoktype = 117;
-
-// add the new doktype to the list of page types
-$GLOBALS['PAGES_TYPES'][$customPageDoktype] = [
-	'type' => 'sys',
-	'icon' => 'EXT:sg_news/Resources/Public/Images/Category.png',
-	'allowedTables' => '*',
-];
-
-// add the new doktype to the page type selector
-$GLOBALS['TCA']['pages']['columns']['doktype']['config']['items'][] = [
-	'LLL:EXT:sg_news/Resources/Private/Language/locallang_backend.xlf:pageType.category',
-	$customPageDoktype,
-	'EXT:sg_news/Resources/Public/Images/Category.png'
-];
-
-// also add the new doktype to the page language overlays type selector (so that translations can inherit the same type)
-$GLOBALS['TCA']['pages_language_overlay']['columns']['doktype']['config']['items'][] = [
-	'LLL:EXT:sg_news/Resources/Private/Language/locallang_backend.xlf:pageType.category',
-	$customPageDoktype,
-	'EXT:sg_news/Resources/Public/Images/Category.png'
-];
-
-// register new icon
-$iconRegistry->registerIcon(
-	'tcarecords-pages-' . $customPageDoktype,
-	\TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class,
-	['source' => 'EXT:sg_news/Resources/Public/Images/Category.png']
-);
-$GLOBALS['TCA']['pages']['ctrl']['typeicon_classes'][$customPageDoktype] = 'tcarecords-pages-' . $customPageDoktype;
-
-// add the new doktype to the list of types available from the new page menu at the top of the page tree
-\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig(
-	'options.pageTree.doktypesToShowInNewPageDragArea := addToList(' . $customPageDoktype . ')'
-);
-
-###############################
-### Define the News Doktype ###
-###############################
-
-$customPageDoktype = 116;
-
-// add the new doktype to the list of page types
-$GLOBALS['PAGES_TYPES'][$customPageDoktype] = [
-	'type' => 'sys',
-	'icon' => 'EXT:sg_news/Resources/Public/Images/News.png',
-	'allowedTables' => '*',
-];
-
-// add the new doktype to the page type selector
-$GLOBALS['TCA']['pages']['columns']['doktype']['config']['items'][] = [
-	'LLL:EXT:sg_news/Resources/Private/Language/locallang_backend.xlf:pageType.news',
-	$customPageDoktype,
-	'EXT:sg_news/Resources/Public/Images/News.png'
-];
-
-// also add the new doktype to the page language overlays type selector (so that translations can inherit the same type)
-$GLOBALS['TCA']['pages_language_overlay']['columns']['doktype']['config']['items'][] = [
-	'LLL:EXT:sg_news/Resources/Private/Language/locallang_backend.xlf:pageType.news',
-	$customPageDoktype,
-	'EXT:sg_news/Resources/Public/Images/News.png'
-];
-
-// register new icon
-$iconRegistry->registerIcon(
-	'tcarecords-pages-' . $customPageDoktype,
-	\TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class,
-	['source' => 'EXT:sg_news/Resources/Public/Images/News.png']
-);
-$iconRegistry->registerIcon(
-	'actions-document-open-white',
-	\TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class,
-	['source' => 'EXT:sg_news/Resources/Public/Icons/actions-document-open-white.svg']
-);
-$iconRegistry->registerIcon(
-	'sg_news-module',
-	\TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class,
-	['source' => 'EXT:sg_news/Resources/Public/Icons/module-sgnews.svg']
-);
-$iconRegistry->registerIcon(
-	'sg_news-module-transparent',
-	\TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class,
-	['source' => 'EXT:sg_news/Resources/Public/Icons/module-sgnews-transparent.svg']
-);
-$GLOBALS['TCA']['pages']['ctrl']['typeicon_classes'][$customPageDoktype] = 'tcarecords-pages-' . $customPageDoktype;
-
-// add the new doktype to the list of types available from the new page menu at the top of the page tree
-\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig(
-	'options.pageTree.doktypesToShowInNewPageDragArea := addToList(' . $customPageDoktype . ')'
-);
-
-if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('sg_ajax')) {
-	\SGalinski\SgAjax\Service\AjaxRegistration::registerAjaxFrontendPlugin('sg_news');
-}
-- 
GitLab