Skip to content

Commit

Permalink
Merge pull request #299 from franzholz/develop
Browse files Browse the repository at this point in the history
use tmpl->setup only for TYPO3 11
  • Loading branch information
franzholz authored Oct 3, 2024
2 parents c358a27 + dc0dfad commit 34ba0da
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 9 deletions.
20 changes: 17 additions & 3 deletions Classes/Controller/ActivityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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];
Expand Down Expand Up @@ -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();
Expand Down
12 changes: 11 additions & 1 deletion Classes/Controller/TaxajaxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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);
}
Expand Down
12 changes: 11 additions & 1 deletion Classes/Hooks/ContentPostProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 9 additions & 1 deletion api/class.tx_ttproducts_ts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
11 changes: 10 additions & 1 deletion pi1/class.tx_ttproducts_pi1.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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']) &&
Expand Down
12 changes: 11 additions & 1 deletion pi_int/class.tx_ttproducts_pi_int.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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/';
Expand Down
12 changes: 11 additions & 1 deletion pi_search/class.tx_ttproducts_pi_search_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 34ba0da

Please sign in to comment.