diff --git a/Classes/Extension.php b/Classes/Extension.php index db58dfa..4766d75 100644 --- a/Classes/Extension.php +++ b/Classes/Extension.php @@ -24,7 +24,10 @@ namespace WerkraumMedia\ThueCat; */ use TYPO3\CMS\Core\Cache\Backend\TransientMemoryBackend; +use TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider; +use TYPO3\CMS\Core\Imaging\IconRegistry; use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; +use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Utility\ExtensionUtility; use WerkraumMedia\ThueCat\Controller\Backend\ImportController; use WerkraumMedia\ThueCat\Controller\Backend\OverviewController; @@ -35,7 +38,9 @@ class Extension public const EXTENSION_NAME = 'Thuecat'; - public const TT_CONTENT_GROUP = 'thuecat'; + public const TCA_SELECT_GROUP_IDENTIFIER = 'thuecat'; + + public const PAGE_DOKTYPE_TOURIST_ATTRACTION = 950; public static function getLanguagePath(): string { @@ -65,6 +70,8 @@ class Extension { self::addCaching(); self::addContentElements(); + self::addPageTypes(); + self::addIcons(); } public static function getIconPath(): string @@ -76,7 +83,6 @@ class Extension { $languagePath = self::getLanguagePath() . 'locallang_tca.xlf:tt_content'; - // TODO: Add Icon ExtensionManagementUtility::addPageTSConfig(' mod.wizards.newContentElement.wizardItems.thuecat { header = ' . $languagePath . '.group @@ -85,6 +91,7 @@ class Extension thuecat_tourist_attraction{ title = ' . $languagePath . '.thuecat_tourist_attraction description = ' . $languagePath . '.thuecat_tourist_attraction.description + iconIdentifier = tx_thuecat_tourist_attraction tt_content_defValues { CType = thuecat_tourist_attraction } @@ -94,6 +101,30 @@ class Extension '); } + private static function addPageTypes(): void + { + ExtensionManagementUtility::addUserTSConfig( + "@import 'EXT:" . self::EXTENSION_KEY . "/Configuration/TSconfig/User/All.tsconfig'" + ); + } + + private static function addIcons(): void + { + $iconFiles = GeneralUtility::getFilesInDir(GeneralUtility::getFileAbsFileName(self::getIconPath())); + if (is_array($iconFiles) === false) { + return; + } + + $iconRegistry = GeneralUtility::makeInstance(IconRegistry::class); + foreach ($iconFiles as $iconFile) { + $iconRegistry->registerIcon( + str_replace('.svg', '', $iconFile), + SvgIconProvider::class, + ['source' => self::getIconPath() . $iconFile] + ); + } + } + private static function addCaching(): void { $cacheIdentifier = 'thuecat_fetchdata'; diff --git a/Classes/Frontend/DataProcessing/ResolveEntities.php b/Classes/Frontend/DataProcessing/ResolveEntities.php index 5223fa0..a058a36 100644 --- a/Classes/Frontend/DataProcessing/ResolveEntities.php +++ b/Classes/Frontend/DataProcessing/ResolveEntities.php @@ -52,6 +52,10 @@ class ResolveEntities implements DataProcessorInterface array $processorConfiguration, array $processedData ) { + if (isset($processorConfiguration['if.']) && !$cObj->checkIf($processorConfiguration['if.'])) { + return $processedData; + } + $as = $cObj->stdWrapValue('as', $processorConfiguration, 'entities'); $tableName = $cObj->stdWrapValue('table', $processorConfiguration, ''); $uids = $cObj->stdWrapValue('uids', $processorConfiguration, ''); diff --git a/Configuration/FlexForm/Pages/tourist_attraction.xml b/Configuration/FlexForm/Pages/tourist_attraction.xml new file mode 100644 index 0000000..317d676 --- /dev/null +++ b/Configuration/FlexForm/Pages/tourist_attraction.xml @@ -0,0 +1,30 @@ + + + 1 + + + + + + LLL:EXT:thuecat/Resources/Private/Language/locallang_flexform.xlf:pages.tourist_attraction.sheetTitle + + array + + + + + + select + selectMultipleSideBySide + tx_thuecat_tourist_attraction + AND {#tx_thuecat_tourist_attraction}.{#sys_language_uid} IN (0,-1) + 1 + 1 + + + + + + + + diff --git a/Configuration/TCA/Overrides/pages.php b/Configuration/TCA/Overrides/pages.php new file mode 100644 index 0000000..0181abf --- /dev/null +++ b/Configuration/TCA/Overrides/pages.php @@ -0,0 +1,39 @@ + [ + 'tx_thuecat_flexform' => [ + 'label' => $languagePath . '.tx_thuecat_flexform', + 'config' => [ + 'type' => 'flex', + 'ds_pointerField' => 'doktype', + 'ds' => [ + 'default' => ' array input 48 ', + ], + ], + ], + ], + 'palettes' => [ + 'tx_thuecat' => [ + 'label' => $languagePath . 'palette.tx_thuecat', + 'showitem' => 'tx_thuecat_flexform', + ], + ], + ]); + + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItemGroup( + $tableName, + 'doktype', + \WerkraumMedia\ThueCat\Extension::TCA_SELECT_GROUP_IDENTIFIER, + $languagePath . '.group' + ); +})( + \WerkraumMedia\ThueCat\Extension::EXTENSION_KEY, + 'pages' +); diff --git a/Configuration/TCA/Overrides/pages_tourist_attraction.php b/Configuration/TCA/Overrides/pages_tourist_attraction.php new file mode 100644 index 0000000..576604e --- /dev/null +++ b/Configuration/TCA/Overrides/pages_tourist_attraction.php @@ -0,0 +1,72 @@ + [ + 'typeicon_classes' => [ + $doktype => $tableName . '_' . $pageIdentifier, + ], + ], + 'types' => [ + $doktype => [ + 'showitem' => '' + . '--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,' + . 'doktype,' + . '--palette--;;title,' + . '--palette--;;tx_thuecat,' + . '--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.metadata,' + . '--palette--;;abstract,' + . '--palette--;;editorial,' + . '--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.appearance,' + . '--palette--;;layout,' + . '--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.behaviour,' + . '--palette--;;links,' + . '--palette--;;miscellaneous,' + . '--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.resources,' + . '--palette--;;media,' + . '--palette--;;config,' + . '--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language,' + . '--palette--;;language,' + . '--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.tabs.access,' + . '--palette--;;visibility,' + . '--palette--;;access,' + . '--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:categories,' + . '--div--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_category.tabs.category,' + . 'categories,' + . '--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:notes,' + . 'rowDescription,' + . '--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:extended', + ], + ], + 'columns' => [ + 'tx_thuecat_flexform' => [ + 'config' => [ + 'ds' => [ + $doktype => 'FILE:EXT:' . $extensionKey . '/Configuration/FlexForm/Pages/' . $pageIdentifier . '.xml', + ], + ], + ], + ], + ]); + + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItem( + $tableName, + 'doktype', + [ + $languagePath, + $doktype, + \WerkraumMedia\ThueCat\Extension::getIconPath() . $tableName . '_' . $pageIdentifier . '.svg', + \WerkraumMedia\ThueCat\Extension::TCA_SELECT_GROUP_IDENTIFIER, + ] + ); +})( + \WerkraumMedia\ThueCat\Extension::EXTENSION_KEY, + 'pages', + \WerkraumMedia\ThueCat\Extension::PAGE_DOKTYPE_TOURIST_ATTRACTION, + 'tourist_attraction' +); diff --git a/Configuration/TCA/Overrides/sys_template.php b/Configuration/TCA/Overrides/sys_template.php index 44ca9d7..379ee9f 100644 --- a/Configuration/TCA/Overrides/sys_template.php +++ b/Configuration/TCA/Overrides/sys_template.php @@ -5,8 +5,13 @@ defined('TYPO3') or die(); (static function (string $extensionKey, string $tableName) { \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile( $extensionKey, - 'Configuration/TypoScript/', - 'ThüCAT' + 'Configuration/TypoScript/ContentElements', + 'ThüCAT - Content Elements' + ); + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile( + $extensionKey, + 'Configuration/TypoScript/PageTypes', + 'ThüCAT - Page Types' ); })( \WerkraumMedia\ThueCat\Extension::EXTENSION_KEY, diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index 7d5e465..dd2cec4 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -9,7 +9,7 @@ defined('TYPO3') or die(); \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItemGroup( $tableName, 'CType', - \WerkraumMedia\ThueCat\Extension::TT_CONTENT_GROUP, + \WerkraumMedia\ThueCat\Extension::TCA_SELECT_GROUP_IDENTIFIER, $languagePath . '.group' ); })( diff --git a/Configuration/TCA/Overrides/tt_content_tourist_attraction.php b/Configuration/TCA/Overrides/tt_content_tourist_attraction.php index bbe8321..e8c2213 100644 --- a/Configuration/TCA/Overrides/tt_content_tourist_attraction.php +++ b/Configuration/TCA/Overrides/tt_content_tourist_attraction.php @@ -8,10 +8,9 @@ defined('TYPO3') or die(); \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA'][$tableName], [ 'ctrl' => [ - // TODO: Add Icon - // 'typeicon_classes' => [ - // $cType => '', - // ], + 'typeicon_classes' => [ + $cType => 'tx_' . $cType, + ], ], 'types' => [ $cType => [ @@ -56,9 +55,8 @@ defined('TYPO3') or die(); [ $languagePath, $cType, - // TODO: Add Icon - '', - \WerkraumMedia\ThueCat\Extension::TT_CONTENT_GROUP, + \WerkraumMedia\ThueCat\Extension::getIconPath() . 'tx_' . $cType . '.svg', + \WerkraumMedia\ThueCat\Extension::TCA_SELECT_GROUP_IDENTIFIER, ] ); })( diff --git a/Configuration/TSconfig/User/All.tsconfig b/Configuration/TSconfig/User/All.tsconfig new file mode 100644 index 0000000..69532db --- /dev/null +++ b/Configuration/TSconfig/User/All.tsconfig @@ -0,0 +1 @@ +@import 'EXT:thuecat/Configuration/TSconfig/User/PageTypes/*.tsconfig' diff --git a/Configuration/TSconfig/User/PageTypes/TouristAttraction.tsconfig b/Configuration/TSconfig/User/PageTypes/TouristAttraction.tsconfig new file mode 100644 index 0000000..23be6f6 --- /dev/null +++ b/Configuration/TSconfig/User/PageTypes/TouristAttraction.tsconfig @@ -0,0 +1 @@ +options.pageTree.doktypesToShowInNewPageDragArea := addToList(950) diff --git a/Configuration/TypoScript/Rendering/TouristAttraction.typoscript b/Configuration/TypoScript/ContentElements/Rendering/TouristAttraction.typoscript similarity index 100% rename from Configuration/TypoScript/Rendering/TouristAttraction.typoscript rename to Configuration/TypoScript/ContentElements/Rendering/TouristAttraction.typoscript diff --git a/Configuration/TypoScript/Rendering/_base.typoscript b/Configuration/TypoScript/ContentElements/Rendering/_base.typoscript similarity index 100% rename from Configuration/TypoScript/Rendering/_base.typoscript rename to Configuration/TypoScript/ContentElements/Rendering/_base.typoscript diff --git a/Configuration/TypoScript/ContentElements/setup.typoscript b/Configuration/TypoScript/ContentElements/setup.typoscript new file mode 100644 index 0000000..3c8b4e5 --- /dev/null +++ b/Configuration/TypoScript/ContentElements/setup.typoscript @@ -0,0 +1 @@ +@import 'EXT:thuecat/Configuration/TypoScript/ContentElements/Rendering/*.typoscript' diff --git a/Configuration/TypoScript/PageTypes/Rendering/TouristAttraction.typoscript b/Configuration/TypoScript/PageTypes/Rendering/TouristAttraction.typoscript new file mode 100644 index 0000000..2c44ac2 --- /dev/null +++ b/Configuration/TypoScript/PageTypes/Rendering/TouristAttraction.typoscript @@ -0,0 +1,16 @@ +page { + 10 { + dataProcessing { + 950 = WerkraumMedia\ThueCat\Frontend\DataProcessing\ResolveEntities + 950 { + as = touristAttraction + if { + isInList.data = page:doktype + value = 950 + } + table = tx_thuecat_tourist_attraction + uids.data = flexform:tx_thuecat_flexform:touristAttraction + } + } + } +} diff --git a/Configuration/TypoScript/PageTypes/setup.typoscript b/Configuration/TypoScript/PageTypes/setup.typoscript new file mode 100644 index 0000000..43b953c --- /dev/null +++ b/Configuration/TypoScript/PageTypes/setup.typoscript @@ -0,0 +1 @@ +@import 'EXT:thuecat/Configuration/TypoScript/PageTypes/Rendering/*.typoscript' diff --git a/Configuration/TypoScript/Rendering.typoscript b/Configuration/TypoScript/Rendering.typoscript deleted file mode 100644 index bcc5032..0000000 --- a/Configuration/TypoScript/Rendering.typoscript +++ /dev/null @@ -1,6 +0,0 @@ -lib.thuecatContentElement =< lib.contentElement -lib.thuecatContentElement { - templateRootPaths { - 9999 = EXT:thuecat/Resources/Private/Templates/Frontend/ContentElement/ - } -} diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript deleted file mode 100644 index beee004..0000000 --- a/Configuration/TypoScript/setup.typoscript +++ /dev/null @@ -1 +0,0 @@ -@import 'EXT:thuecat/Configuration/TypoScript/Rendering/*.typoscript' diff --git a/README.md b/README.md index 6a7a054..2bc98ee 100644 --- a/README.md +++ b/README.md @@ -40,9 +40,9 @@ The extension already allows: * Content element to display tourist attraction -## Short time goals + * Page Type to reference tourist attraction -* Integrate proper icons +## Short time goals * Content element to display town, tourist information and organisation. diff --git a/Resources/Private/Language/locallang_flexform.xlf b/Resources/Private/Language/locallang_flexform.xlf index c0d8e05..a3d39a7 100644 --- a/Resources/Private/Language/locallang_flexform.xlf +++ b/Resources/Private/Language/locallang_flexform.xlf @@ -15,6 +15,13 @@ URL + + + Tourist Attraction + + + Tourist Attraction + diff --git a/Resources/Private/Language/locallang_tca.xlf b/Resources/Private/Language/locallang_tca.xlf index 7c0ebd2..58e1364 100644 --- a/Resources/Private/Language/locallang_tca.xlf +++ b/Resources/Private/Language/locallang_tca.xlf @@ -181,6 +181,19 @@ Renders selected tourist attractions + + + ThüCAT + + + Tourist Attraction + + + ThüCAT + + + Configuration + diff --git a/ext_tables.sql b/ext_tables.sql index 6634efd..cfd3d4f 100644 --- a/ext_tables.sql +++ b/ext_tables.sql @@ -1,3 +1,7 @@ +CREATE TABLE pages ( + tx_thuecat_flexform text, +); + CREATE TABLE tx_thuecat_import_configuration ( title varchar(255) DEFAULT '' NOT NULL, type varchar(255) DEFAULT '' NOT NULL,