Skip to content
Snippets Groups Projects
pages.php 16.6 KiB
Newer Older
Stefan Galinski's avatar
Stefan Galinski committed
<?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!
 */
Stefan Galinski's avatar
Stefan Galinski committed

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 (
				\SGalinski\SgNews\Utility\BackendNewsUtility::CATEGORY_DOKTYPE => [
					'icon' => 'EXT:sg_news/Resources/Public/Images/Category.png',
					'locallangIndex' => 'pageType.category'
Stefan Galinski's avatar
Stefan Galinski committed
				],
				\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' => '--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
					--palette--;;standard,
					--palette--;;titleDescriptionAndHighlightFlag,
					--palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:' . $table . '.palettes.editorial;editorialWithNewsAuthor,
					tx_sgnews_content_from_another_page, 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:core/Resources/Private/Language/locallang_tca.xlf:' . $table . '.palettes.visibility;visibility,
					--palette--;LLL:EXT:core/Resources/Private/Language/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.miscellaneous;miscellaneous,
				--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language,
					--palette--;;language
				'
		];

		$GLOBALS['TCA'][$table]['types'][\SGalinski\SgNews\Utility\BackendNewsUtility::CATEGORY_DOKTYPE] = [
			'showitem' => '--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
					--palette--;;standard,
					title, slug, tx_projectbase_path_segment, tx_projectbase_excludefromsluggeneration, 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:core/Resources/Private/Language/locallang_tca.xlf:' . $table . '.palettes.visibility;visibility,
					--palette--;LLL:EXT:core/Resources/Private/Language/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.miscellaneous;miscellaneous,
				--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language,
					--palette--;;language
				'
		];

		\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']
					),
				'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']
					),
Stefan Galinski's avatar
Stefan Galinski committed
				],
					'exclude' => TRUE,
					'l10n_exclude' => TRUE,
					'label' => $localLangDbPath . $table . '.tx_sgnews_news_author',
					'config' => [
						'type' => 'group',
						'internal_type' => 'db',
						'allowed' => 'tx_sgnews_domain_model_author',
						'fieldControl' => [
							'addRecord' => [
								'disabled' => FALSE,
							],
						],
				'tx_sgnews_content_from_another_page' => [
					'exclude' => TRUE,
					'l10n_exclude' => TRUE,
					'label' => $localLangDbPath . $table . '.tx_sgnews_content_from_another_page',
					'config' => [
						'type' => 'group',
						'internal_type' => 'db',
						'allowed' => 'pages',
						'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,
				'tx_sgnews_highlighted' => [
					'displayCond' => 'FIELD:tx_sgnews_never_highlighted:=:0',
					'exclude' => TRUE,
					'l10n_exclude' => TRUE,
					'label' => $localLangDbPath . $table . '.tx_sgnews_highlighted',
					'config' => [
						'type' => 'check',
						'behaviour' => [
							'allowLanguageSynchronization' => TRUE
						]
				'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',
						'behaviour' => [
							'allowLanguageSynchronization' => TRUE
						]
				'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'],
						'behaviour' => [
							'allowLanguageSynchronization' => TRUE,
						]
Kevin Ditscheid's avatar
Kevin Ditscheid committed
				'tx_sgnews_date_end' => [
					'exclude' => TRUE,
					'label' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:pages.tx_sgnews_date_end',
					'config' => [
						'type' => 'input',
						'size' => '13',
						'max' => '20',
						'eval' => 'datetime',
						'default' => $GLOBALS['EXEC_TIME'],
						'behaviour' => [
							'allowLanguageSynchronization' => TRUE,
						]
				'tx_sgnews_location' => [
					'exclude' => TRUE,
					'label' => $localLangDbPath . $table . '.tx_sgnews_location',
					'config' => [
						'type' => 'input',
						'size' => 20,
						'eval' => 'trim',
						'behaviour' => [
							'allowLanguageSynchronization' => TRUE
						]
Stefan Galinski's avatar
Stefan Galinski committed

		$GLOBALS['TCA'][$table]['palettes']['titleDescriptionAndHighlightFlag'] = [
			'showitem' => 'subtitle;' . $localLangDbPath . $table . '.subtitle.inPalette,
			--linebreak--, title,
			--linebreak--, description,
			--linebreak--, tx_projectbase_path_segment, tx_projectbase_excludefromsluggeneration,
			--linebreak--, tx_realurl_pathsegment, tx_realurl_exclude,
			--linebreak--, tx_sgnews_highlighted, tx_sgnews_never_highlighted',
			'canNotCollapse' => 1,
		];
Stefan Galinski's avatar
Stefan Galinski committed

		$GLOBALS['TCA'][$table]['palettes']['editorialWithNewsAuthor'] = [
			--linebreak--, lastUpdated;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:' . $table . '.lastUpdated_formlabel,
Kevin Ditscheid's avatar
Kevin Ditscheid committed
			tx_sgnews_date_end,
			--linebreak--,tx_sgnews_likes,--linebreak--,tx_sgnews_location',
Stefan Galinski's avatar
Stefan Galinski committed

		foreach (
			$GLOBALS['TCA'][$table]['columns'] as $languageExcludeField => $_
		) {
			if (
			!\in_array(
				$languageExcludeField, [
				'doktype',
				'title',
				'subtitle',
				'description',
				'slug',
				'tx_projectbase_path_segment',
				'tx_projectbase_excludefromsluggeneration',
				'tx_sgnews_location',
				'tx_sgnews_teaser1_image',
				'tx_sgnews_teaser2_image',
				'tx_sgnews_tags',
				'abstract',
				'tx_projectbase_seo_titletag',
				'tx_projectbase_seo_canonicaltag',
				'hidden',
				'sys_language_uid',
				'tx_languagevisibility_visibility',
				'lastUpdated',
				'tx_sgnews_date_end',
				'tx_sgnews_highlighted',
				'tx_sgnews_never_highlighted',
			]
			)
				$GLOBALS['TCA'][$table]['types'][\SGalinski\SgNews\Utility\BackendNewsUtility::NEWS_DOKTYPE]['columnsOverrides'][$languageExcludeField]['l10n_mode'] = 'exclude';

		$GLOBALS['TCA'][$table]['types'][\SGalinski\SgNews\Utility\BackendNewsUtility::NEWS_DOKTYPE]['columnsOverrides']['title']['label'] =
			'LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_db.xlf:' . $table . '.title';
		$GLOBALS['TCA'][$table]['types'][\SGalinski\SgNews\Utility\BackendNewsUtility::NEWS_DOKTYPE]['columnsOverrides']['subtitle']['label'] =
			'LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_db.xlf:' . $table . '.subtitle';
		$GLOBALS['TCA'][$table]['types'][\SGalinski\SgNews\Utility\BackendNewsUtility::NEWS_DOKTYPE]['columnsOverrides']['slug']['label'] =
			'LLL:EXT:' . $extKey . '/Resources/Private/Language/locallang_db.xlf:' . $table . '.slug';