diff --git a/ChangeLog b/ChangeLog index a02dc13bd..bf5b14d8f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ ChangeLog Upcoming version [TASK] Switch to PHP based rendering for documentation. Thanks to Chris Müller. https://github.com/tpwd/ke_search/pull/265 [TASK] Migrate outdated TCA configurations in FlexForms. https://github.com/tpwd/ke_search/issues/264 +[TASK] Migrate usage of $GLOBALS['TSFE']->tmpl for TYPO3 13. https://github.com/tpwd/ke_search/issues/258 Version 6.1.3, 20 December 2024 [FEATURE] Show additional fields which are registered by other extensions in "Indexed content" function of the backend module diff --git a/Classes/Lib/SearchHelper.php b/Classes/Lib/SearchHelper.php index 46a0743e7..91f08efd0 100644 --- a/Classes/Lib/SearchHelper.php +++ b/Classes/Lib/SearchHelper.php @@ -76,13 +76,13 @@ public static function getExtConf() } else { $extConf['prePostTagChar'] = '#'; } - $extConf['multiplyValueToTitle'] = ($extConf['multiplyValueToTitle']) ? $extConf['multiplyValueToTitle'] : 1; - $extConf['searchWordLength'] = ($extConf['searchWordLength']) ? $extConf['searchWordLength'] : 4; + $extConf['multiplyValueToTitle'] = $extConf['multiplyValueToTitle'] ?: 1; + $extConf['searchWordLength'] = $extConf['searchWordLength'] ?: 4; // override extConf with TS Setup - if (is_array($GLOBALS['TSFE']->tmpl->setup['ke_search.']['extconf.']['override.'] ?? null) - && count($GLOBALS['TSFE']->tmpl->setup['ke_search.']['extconf.']['override.'])) { - foreach ($GLOBALS['TSFE']->tmpl->setup['ke_search.']['extconf.']['override.'] as $key => $value) { + $typoScriptSetup = self::getTypoScriptSetup(); + if (count($typoScriptSetup['ke_search.']['extconf.']['override.'] ?? [])) { + foreach ($typoScriptSetup['ke_search.']['extconf.']['override.'] as $key => $value) { $extConf[$key] = $value; } } @@ -112,9 +112,9 @@ public static function getExtConfPremium() } // override extConfPremium with TS Setup - if (is_array($GLOBALS['TSFE']->tmpl->setup['ke_search_premium.']['extconf.']['override.'] ?? null) - && count($GLOBALS['TSFE']->tmpl->setup['ke_search_premium.']['extconf.']['override.'])) { - foreach ($GLOBALS['TSFE']->tmpl->setup['ke_search_premium.']['extconf.']['override.'] as $key => $value) { + $typoScriptSetup = self::getTypoScriptSetup(); + if (count($typoScriptSetup['ke_search_premium.']['extconf.']['override.'] ?? [])) { + foreach ($typoScriptSetup['ke_search_premium.']['extconf.']['override.'] as $key => $value) { $extConfPremium[$key] = $value; } } @@ -509,7 +509,8 @@ public static function getAllowedPiVars($additionalAllowedPiVars = ''): array */ public static function getSearchWordParameter(): string { - return htmlspecialchars($GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_kesearch_pi1.']['searchWordParameter'] ?? 'tx_kesearch_pi1[sword]'); + $typoScriptSetup = self::getTypoScriptSetup(); + return htmlspecialchars($typoScriptSetup['plugin.']['tx_kesearch_pi1.']['searchWordParameter'] ?? 'tx_kesearch_pi1[sword]'); } /** @@ -534,4 +535,21 @@ public static function rmFromList($element, $list) } return implode(',', $items); } + + public static function getTypoScriptSetup(): array + { + $request = self::getRequest(); + if ($request === null) { + return []; + } + if (ApplicationType::fromRequest($request)->isBackend()) { + return []; + } + return $request->getAttribute('frontend.typoscript')->getSetupArray(); + } + + private static function getRequest(): ?ServerRequestInterface + { + return $GLOBALS['TYPO3_REQUEST'] ?? null; + } } diff --git a/Documentation/Configuration/Notes.rst b/Documentation/Configuration/Notes.rst index a5cc4c2af..0d2b9124c 100755 --- a/Documentation/Configuration/Notes.rst +++ b/Documentation/Configuration/Notes.rst @@ -25,14 +25,15 @@ or you can define the result page with help of an URL param if you want: Notes on TypoScript and extension configuration =============================================== -In :guilabel:`Admin Tools` > :guilabel:`Settings` > :guilabel:`Extension Configuration` you can define basic options +In :guilabel:`Admin Tools` > :guilabel:`Settings` > +:guilabel:`Extension Configuration` you can define basic options like the minimal length of searchwords. You can overwrite this configuration in your page TypoScript setup: .. code-block:: typoscript - ke_search_premium.extconf.override.searchWordLength = 3 + ke_search.extconf.override.searchWordLength = 3 or