Skip to content

Commit

Permalink
[TASK] Migrate usage of $GLOBALS['TSFE']->tmpl, closes #258
Browse files Browse the repository at this point in the history
  • Loading branch information
christianbltr committed Jan 10, 2025
1 parent 53c1b2e commit cf0ecef
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 27 additions & 9 deletions Classes/Lib/SearchHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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]');
}

/**
Expand All @@ -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;
}
}
5 changes: 3 additions & 2 deletions Documentation/Configuration/Notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit cf0ecef

Please sign in to comment.