Skip to content
Snippets Groups Projects
ext_tables.php 6.74 KiB
Newer Older
Stefan Galinski's avatar
Stefan Galinski committed
<?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'
);

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',
		'',
		[
		],
		[
			'access' => 'user,group',
Paul Ilea's avatar
Paul Ilea committed
			'icon' => 'EXT:sg_news/Resources/Public/Icons/module-sgnews.svg',
			'labels' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang.xlf',
		]
	);
}

// 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';

Stefan Galinski's avatar
Stefan Galinski committed
// 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);

Stefan Galinski's avatar
Stefan Galinski committed
###################################
### 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',
Stefan Galinski's avatar
Stefan Galinski committed
	'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'
Stefan Galinski's avatar
Stefan Galinski committed
];

// 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'
Stefan Galinski's avatar
Stefan Galinski committed
];

// 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;
Stefan Galinski's avatar
Stefan Galinski committed

// 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',
Stefan Galinski's avatar
Stefan Galinski committed
	'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'
Stefan Galinski's avatar
Stefan Galinski committed
];

// 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'
Stefan Galinski's avatar
Stefan Galinski committed
];

// register new icon
$iconRegistry->registerIcon(
	'tcarecords-pages-' . $customPageDoktype,
	\TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class,
	['source' => 'EXT:sg_news/Resources/Public/Images/News.png']
);
Paul Ilea's avatar
Paul Ilea committed
$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;
Stefan Galinski's avatar
Stefan Galinski committed

// 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');
}