diff --git a/Classes/Slot/GetSystemInformationSlot.php b/Classes/Slot/GetSystemInformationSlot.php new file mode 100644 index 00000000..2b695aa5 --- /dev/null +++ b/Classes/Slot/GetSystemInformationSlot.php @@ -0,0 +1,154 @@ +getThemeMode($sysInfoToolbarItem); + } + + /** + * Get theme mode to system information + * + * @param SystemInformationToolbarItem $sysInfoToolbarItem sysInfoToolbarItem + * + * @return void + */ + protected function getThemeMode($sysInfoToolbarItem) + { + if (ExtensionManagementUtility::isLoaded('themes')) { + + $rootSysTemplates = $this->getRootSysTemplates(); + + if (!empty($rootSysTemplates) && is_array($rootSysTemplates)) { + foreach ($rootSysTemplates as $index => $rootSysTemplate) { + + $themeConfiguration = $this->getThemeConfiguration( + $rootSysTemplate + ); + if (!empty($themeConfiguration) + && is_array($themeConfiguration) + ) { + + $inProductionMode + = $themeConfiguration['isDevelopment'] === '0'; + + $themeMode = $inProductionMode + ? 'Production' + : 'Development'; + + $themeStatus = $inProductionMode + ? InformationStatus::STATUS_OK + : InformationStatus::STATUS_WARNING; + + $sysInfoToolbarItem->addSystemInformation( + 'Theme mode [' . $rootSysTemplate['pid'] . ']', + $themeMode, + 'sysinfo-application-context', + $themeStatus + ); + } + } + } + } + } + + /** + * Get root templates + * + * @return array + */ + protected function getRootSysTemplates() + { + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) + ->getQueryBuilderForTable('sys_template'); + $rootSysTemplates = $queryBuilder + ->select('*') + ->from('sys_template') + ->where( + $queryBuilder->expr()->eq( + 'root', + $queryBuilder->createNamedParameter(1, \PDO::PARAM_INT) + ) + ) + ->execute() + ->fetchAll(); + return $rootSysTemplates; + } + + /** + * Fetch theme configuration constants + * + * @param array $sysTemplate System Template + * + * @return array + */ + protected function getThemeConfiguration($sysTemplate) + { + $themeConfiguration = false; + $templateService = GeneralUtility::makeInstance( + ExtendedTemplateService::class + ); + $typoScriptService = GeneralUtility::makeInstance( + TypoScriptService::class + ); + $templateService->init(); + + $templateUid = $sysTemplate['uid']; + $pageId = $sysTemplate['pid']; + + $rootlineUtility = GeneralUtility::makeInstance( + RootlineUtility::class, + $pageId + ); + $rootLine = $rootlineUtility->get(); + + $templateService->runThroughTemplates($rootLine, $templateUid); + $templateService->generateConfig(); + + $themeConfiguration = $templateService + ->setup_constants['themes.']['configuration.']; + + if (!empty($themeConfiguration) && is_array($themeConfiguration)) { + $themeConfiguration = $typoScriptService + ->convertTypoScriptArrayToPlainArray( + $themeConfiguration + ); + } + + return $themeConfiguration; + } +} diff --git a/ext_localconf.php b/ext_localconf.php index e89c923e..effca47a 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -60,3 +60,15 @@ = \T3kit\themeT3kit\Xclass\Realurl\Utility::class; $GLOBALS['TYPO3_CONF_VARS']['BE']['interfaces'] = 'frontend,backend'; + +// register to signal slot from SystemInformationToolbarItem to include +// Themes Development Mode constant setting per "siteroot" to system information +$signalSlotDispatcher = TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( + \TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class +); +$signalSlotDispatcher->connect( + \TYPO3\CMS\Backend\Backend\ToolbarItems\SystemInformationToolbarItem::class, + 'getSystemInformation', + \T3kit\themeT3kit\Slot\GetSystemInformationSlot::class, + 'getSystemInformation' +);