From dc0dfad31e9809f5ef08538b058cfef061ad6253 Mon Sep 17 00:00:00 2001 From: Franz Holzinger Date: Thu, 3 Oct 2024 18:26:30 +0200 Subject: [PATCH] use tmpl->setup only for TYPO3 11 --- Classes/Controller/ActivityController.php | 20 ++++++++++++++++--- Classes/Controller/TaxajaxController.php | 12 ++++++++++- Classes/Hooks/ContentPostProcessor.php | 12 ++++++++++- api/class.tx_ttproducts_ts.php | 10 +++++++++- pi1/class.tx_ttproducts_pi1.php | 11 +++++++++- pi_int/class.tx_ttproducts_pi_int.php | 12 ++++++++++- .../class.tx_ttproducts_pi_search_base.php | 12 ++++++++++- 7 files changed, 80 insertions(+), 9 deletions(-) diff --git a/Classes/Controller/ActivityController.php b/Classes/Controller/ActivityController.php index af01fcaee..1162ec02b 100644 --- a/Classes/Controller/ActivityController.php +++ b/Classes/Controller/ActivityController.php @@ -48,6 +48,7 @@ use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\MathUtility; +use TYPO3\CMS\Core\Utility\VersionNumberUtility; use JambageCom\Div2007\Utility\FrontendUtility; use JambageCom\Div2007\Utility\HtmlUtility; @@ -341,6 +342,9 @@ public function getErrorLabel( $context = GeneralUtility::makeInstance(Context::class); $languageSubpath = '/Resources/Private/Language/'; $parameterApi = GeneralUtility::makeInstance(ParameterApi::class); + $typo3VersionArray = + VersionNumberUtility::convertVersionStringToArray(VersionNumberUtility::getCurrentTypo3Version()); + $typo3VersionMain = $typo3VersionArray['version_main']; if ($checkRequired || $checkAllowed) { $check = ($checkRequired ?: $checkAllowed); @@ -363,7 +367,12 @@ public function getErrorLabel( $languageKey = 'missing_' . $check; } $label = $GLOBALS['TSFE']->sL('LLL:EXT:agency/pi/locallang.xml:' . $languageKey); - $editPID = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_agency.']['editPID'] ?? 0; + $editPID = 0; + if ($typo3VersionMain < 12) { + $editPID = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_agency.']['editPID'] ?? 0; + } else { + $editPID = $GLOBALS['TYPO3_REQUEST']->getAttribute('frontend.typoscript')->getSetupArray()['plugin.'][TT_PRODUCTS_EXT . '.']['editPID'] ?? 0;; + } if ($context->getPropertyFromAspect('frontend.user', 'isLoggedIn') && $editPID) { $addParams = ['products_payment' => 1]; @@ -397,8 +406,13 @@ public function getErrorLabel( if (!$languageKey) { $languageKey = 'missing_' . $check; } - $label = $GLOBALS['TSFE']->sL('LLL:EXT:sr_feuser_register' . $languageSubpath . 'locallang.xlf:' . $languageKey); - $editPID = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_srfeuserregister_pi1.']['editPID'] ?? 0; + $label = $GLOBALS['TSFE']->sL('LLL:EXT:sr_feuser_register' . $languageSubpath + $editPID = 0; + if ($typo3VersionMain < 12) { + $editPID = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_srfeuserregister_pi1.']['editPID'] ?? 0; + } else { + $editPID = $GLOBALS['TYPO3_REQUEST']->getAttribute('frontend.typoscript')->getSetupArray()['plugin.']['tx_srfeuserregister_pi1.']['editPID'] ?? 0;; + } if ($context->getPropertyFromAspect('frontend.user', 'isLoggedIn') && $editPID) { $cObj = ControlApi::getCObj(); diff --git a/Classes/Controller/TaxajaxController.php b/Classes/Controller/TaxajaxController.php index d2a268c0b..17d70523c 100644 --- a/Classes/Controller/TaxajaxController.php +++ b/Classes/Controller/TaxajaxController.php @@ -45,6 +45,7 @@ use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Core\Http\NullResponse; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core\Utility\VersionNumberUtility; class TaxajaxController { @@ -61,7 +62,16 @@ public function processRequest( $GLOBALS['TSFE']->getConfigArray($request); } - $conf = $GLOBALS['TSFE']->tmpl->setup['plugin.'][TT_PRODUCTS_EXT . '.'] ?? null; + $typo3VersionArray = + VersionNumberUtility::convertVersionStringToArray(VersionNumberUtility::getCurrentTypo3Version()); + $typo3VersionMain = $typo3VersionArray['version_main']; + $conf = []; + if ($typo3VersionMain < 12) { + $conf = $GLOBALS['TSFE']->tmpl->setup['plugin.'][TT_PRODUCTS_EXT . '.'] ?? null; + } else { + $conf = $GLOBALS['TYPO3_REQUEST']->getAttribute('frontend.typoscript')->getSetupArray()['plugin.'][TT_PRODUCTS_EXT . '.'] ?? null; + } + if (!isset($conf)) { throw new \RuntimeException('Error in tt_products: No plugin setup found!', 1720723255); } diff --git a/Classes/Hooks/ContentPostProcessor.php b/Classes/Hooks/ContentPostProcessor.php index 50e1052b1..d49aeb7d3 100644 --- a/Classes/Hooks/ContentPostProcessor.php +++ b/Classes/Hooks/ContentPostProcessor.php @@ -40,14 +40,24 @@ * @subpackage tt_products */ +use TYPO3\CMS\Core\Utility\VersionNumberUtility; + use JambageCom\TtProducts\Api\ParameterApi; class ContentPostProcessor { public function setPageTitle(&$params, TypoScriptFrontendController &$pObj): void { + $typo3VersionArray = + VersionNumberUtility::convertVersionStringToArray(VersionNumberUtility::getCurrentTypo3Version()); + $typo3VersionMain = $typo3VersionArray['version_main']; + $conf = []; + if ($typo3VersionMain < 12) { + $conf = $GLOBALS['TSFE']->tmpl->setup['plugin.'][TT_PRODUCTS_EXT . '.'] ?? null; + } else { + $conf = $GLOBALS['TYPO3_REQUEST']->getAttribute('frontend.typoscript')->getSetupArray()['plugin.'][TT_PRODUCTS_EXT . '.'] ?? null; + } $parameterApi = GeneralUtility::makeInstance(ParameterApi::class); - $conf = $GLOBALS['TSFE']->tmpl->setup['plugin.'][TT_PRODUCTS_EXT . '.'] ?? []; $piVars = $parameterApi->getPiVars(); $funcTablename = 'tt_products'; $piVar = $parameterApi->getPiVar($funcTablename); diff --git a/api/class.tx_ttproducts_ts.php b/api/class.tx_ttproducts_ts.php index c088106c6..c9d0f1ef2 100644 --- a/api/class.tx_ttproducts_ts.php +++ b/api/class.tx_ttproducts_ts.php @@ -189,7 +189,15 @@ public function pageProductCount_IProcFunc($I, $conf) public function processMemo(): void { $funcTablename = 'tt_products'; - $conf = $GLOBALS['TSFE']->tmpl->setup['plugin.'][TT_PRODUCTS_EXT . '.'] ?? []; + $typo3VersionArray = + VersionNumberUtility::convertVersionStringToArray(VersionNumberUtility::getCurrentTypo3Version()); + $typo3VersionMain = $typo3VersionArray['version_main']; + $conf = []; + if ($typo3VersionMain < 12) { + $conf = $GLOBALS['TSFE']->tmpl->setup['plugin.'][TT_PRODUCTS_EXT . '.'] ?? null; + } else { + $conf = $GLOBALS['TYPO3_REQUEST']->getAttribute('frontend.typoscript')->getSetupArray()['plugin.'][TT_PRODUCTS_EXT . '.'] ?? null; + } $parameterApi = GeneralUtility::makeInstance(ParameterApi::class); $piVars = $parameterApi->getParameterMerged('tt_products'); diff --git a/pi1/class.tx_ttproducts_pi1.php b/pi1/class.tx_ttproducts_pi1.php index 3f4562a5a..a160e0d0a 100644 --- a/pi1/class.tx_ttproducts_pi1.php +++ b/pi1/class.tx_ttproducts_pi1.php @@ -43,6 +43,7 @@ */ use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core\Utility\VersionNumberUtility; use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; class tx_ttproducts_pi1 implements SingletonInterface @@ -81,7 +82,15 @@ public function main($content, $conf) */ public function getUserFunc($content, $conf) { - $conf = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tt_products.'] ?? []; + $typo3VersionArray = + VersionNumberUtility::convertVersionStringToArray(VersionNumberUtility::getCurrentTypo3Version()); + $typo3VersionMain = $typo3VersionArray['version_main']; + $conf = []; + if ($typo3VersionMain < 12) { + $conf = $GLOBALS['TSFE']->tmpl->setup['plugin.'][TT_PRODUCTS_EXT . '.'] ?? null; + } else { + $conf = $GLOBALS['TYPO3_REQUEST']->getAttribute('frontend.typoscript')->getSetupArray()['plugin.'][TT_PRODUCTS_EXT . '.'] ?? null; + } if ( isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][TT_PRODUCTS_EXT]['getUserFunc']) && diff --git a/pi_int/class.tx_ttproducts_pi_int.php b/pi_int/class.tx_ttproducts_pi_int.php index de5231d3f..77be59886 100644 --- a/pi_int/class.tx_ttproducts_pi_int.php +++ b/pi_int/class.tx_ttproducts_pi_int.php @@ -41,6 +41,7 @@ use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\Utility\ArrayUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core\Utility\VersionNumberUtility; use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; class tx_ttproducts_pi_int implements SingletonInterface @@ -59,7 +60,16 @@ public function main($content, $conf) { $pibaseObj = GeneralUtility::makeInstance('tx_ttproducts_pi_int_base'); $pibaseObj->setContentObjectRenderer($this->cObj); - $confMain = $GLOBALS['TSFE']->tmpl->setup['plugin.'][TT_PRODUCTS_EXT . '.'] ?? []; + $typo3VersionArray = + VersionNumberUtility::convertVersionStringToArray(VersionNumberUtility::getCurrentTypo3Version()); + $typo3VersionMain = $typo3VersionArray['version_main']; + $confMain = []; + if ($typo3VersionMain < 12) { + $confMain = $GLOBALS['TSFE']->tmpl->setup['plugin.'][TT_PRODUCTS_EXT . '.'] ?? []; + } else { + $confMain = $GLOBALS['TYPO3_REQUEST']->getAttribute('frontend.typoscript')->getSetupArray()['plugin.'][TT_PRODUCTS_EXT . '.'] ?? []; + } + ArrayUtility::mergeRecursiveWithOverrule($confMain, $conf); $conf = $confMain; $languageSubpath = '/Resources/Private/Language/'; diff --git a/pi_search/class.tx_ttproducts_pi_search_base.php b/pi_search/class.tx_ttproducts_pi_search_base.php index 18f40d55f..cf9fb6e73 100644 --- a/pi_search/class.tx_ttproducts_pi_search_base.php +++ b/pi_search/class.tx_ttproducts_pi_search_base.php @@ -42,6 +42,7 @@ use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core\Utility\VersionNumberUtility; use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; use JambageCom\Div2007\Compatibility\AbstractPlugin; @@ -73,7 +74,16 @@ public function main($content, $conf) $parameterApi->setPrefixId($this->prefixId); PluginApi::init($conf); - $confMain = $GLOBALS['TSFE']->tmpl->setup['plugin.'][TT_PRODUCTS_EXT . '.'] ?? []; + $typo3VersionArray = + VersionNumberUtility::convertVersionStringToArray(VersionNumberUtility::getCurrentTypo3Version()); + $typo3VersionMain = $typo3VersionArray['version_main']; + $confMain = []; + if ($typo3VersionMain < 12) { + $confMain = $GLOBALS['TSFE']->tmpl->setup['plugin.'][TT_PRODUCTS_EXT . '.'] ?? []; + } else { + $confMain = $GLOBALS['TYPO3_REQUEST']->getAttribute('frontend.typoscript')->getSetupArray()['plugin.'][TT_PRODUCTS_EXT . '.'] ?? []; + } + $this->conf = array_merge($confMain, $conf); $config = []; $mainObj = GeneralUtility::makeInstance('tx_ttproducts_control_search'); // fetch and store it as persistent object