Skip to content

Commit

Permalink
* compatibility TYPO3 10.4: make a new TaxajaxController which does n…
Browse files Browse the repository at this point in the history
…ot initialize the front end
  • Loading branch information
franzholz committed Mar 4, 2021
1 parent 703f223 commit 0c632e5
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 23 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2021-03-04 Franz Holzinger <[email protected]>
* compatibility TYPO3 10.4: make a new TaxajaxController which does not initialize the front end
* compatibility TYPO3 10.4: Ajax bugfix

2021-03-03 Franz Holzinger <[email protected]>
* compatibility TYPO3 9.5: replace $GLOBALS['TSFE']->loginUser by \JambageCom\Div2007\Utility\CompatibilityUtility::isLoggedIn().

Expand Down
109 changes: 109 additions & 0 deletions Classes/Controller/OldTaxajaxController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?php

namespace JambageCom\TtProducts\Controller;


/***************************************************************
* Copyright notice
*
* (c) 2007-2020 Kasper Skårhøj ([email protected])
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Part of the tt_products (Shop System) extension.
*
* main class for taxajax
*
* @author Kasper Skårhøj <[email protected]>
* @author Franz Holzinger <[email protected]>
* @maintainer Franz Holzinger <[email protected]>
* @package TYPO3
* @subpackage tt_products
*
*
*/

use TYPO3\CMS\Core\Utility\GeneralUtility;



use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;



class OldTaxajaxController {

/**
* @param ServerRequestInterface $request
* @param ResponseInterface $response
* @return ResponseInterface
*/
public function processRequest (
ServerRequestInterface $request,
ResponseInterface $response): ResponseInterface
{
global $TSFE, $BE_USER, $TYPO3_CONF_VARS, $error;

$pageId = '';
if (
defined('TYPO3_version') &&
version_compare(TYPO3_version, '9.0.0', '>=')
) {
$pageId = \JambageCom\Div2007\Utility\FrontendUtility::getPageId($request);
if (!$pageId) {
throw new \RuntimeException('Error in tt_products: No page id for Ajax call.');
}
}

\JambageCom\Div2007\Utility\FrontendUtility::init($pageId);

// ******************************************************
// Start with tt_products
// ******************************************************

$conf = $GLOBALS['TSFE']->tmpl->setup['plugin.'][TT_PRODUCTS_EXT . '.'];
$config = array();
$config['LLkey'] = '';

// tt_products specific parts

// Make instance:
$ajax = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_ttproducts_ajax');
$ajax->init();

$SOBE = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_ttproducts_db');
$errorCode = '';
$SOBE->init($conf, $config, $ajax, $tmp = '', $errorCode);

if($_POST['xajax']) {
$ajax->taxajax->processRequests();
$SOBE->destruct();
exit();
}
$SOBE->main();
$SOBE->printContent();
$SOBE->destruct();
return $response;
}
}

27 changes: 11 additions & 16 deletions Classes/Controller/TaxajaxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@
*
*/

use TYPO3\CMS\Core\Utility\GeneralUtility;



use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

use TYPO3\CMS\Core\Http\NullResponse;
use TYPO3\CMS\Core\Utility\GeneralUtility;



class TaxajaxController {
Expand All @@ -59,27 +60,20 @@ class TaxajaxController {
* @return ResponseInterface
*/
public function processRequest (
ServerRequestInterface $request,
ResponseInterface $response): ResponseInterface
ServerRequestInterface $request
)
{
global $TSFE, $BE_USER, $TYPO3_CONF_VARS, $error;

$pageId = '';
if (
defined('TYPO3_version') &&
version_compare(TYPO3_version, '9.0.0', '>=')
) {
$pageId = \JambageCom\Div2007\Utility\FrontendUtility::getPageId($request);
if (!$pageId) {
throw new \RuntimeException('Error in tt_products: No page id for Ajax call.');
}
$pageId = \JambageCom\Div2007\Utility\FrontendUtility::getPageId($request);
if (!$pageId) {
throw new \RuntimeException('Error in tt_products: No page id for Ajax call.');
}

\JambageCom\Div2007\Utility\FrontendUtility::init($pageId);

// ******************************************************
// Start with tt_products
// ******************************************************
$GLOBALS['TSFE']->getConfigArray($request);

$conf = $GLOBALS['TSFE']->tmpl->setup['plugin.'][TT_PRODUCTS_EXT . '.'];
$config = array();
Expand All @@ -103,7 +97,8 @@ public function processRequest (
$SOBE->main();
$SOBE->printContent();
$SOBE->destruct();
return $response;

return new NullResponse();
}
}

2 changes: 1 addition & 1 deletion control/class.tx_ttproducts_javascript.php
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ function doFetchRow(table, view, uid) {
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath(TAXAJAX_EXT)
);
} else {
$path = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath(TAXAJAX_EXT));
$path = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath(TAXAJAX_EXT);
}

$code = $this->ajax->taxajax->getJavascript($path);
Expand Down
4 changes: 0 additions & 4 deletions eid/class.tx_ttproducts_db.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ public function fetchRow ($data) {
$priceTaxArray = $priceObj->getPriceTaxArray(
$this->conf['discountPriceMode'], $basketExtra, 'price', tx_ttproducts_control_basket::getRoundFormat(), tx_ttproducts_control_basket::getRoundFormat('discount'), $tmpRow, $totalDiscountField, $priceTaxArray);

$csConvObj = $GLOBALS['TSFE']->csConvObj;
$field = 'price';
foreach ($priceTaxArray as $priceKey => $priceValue) {
$displayTax = $priceViewObj->convertKey($priceKey, $field);
Expand Down Expand Up @@ -230,10 +229,7 @@ public function fetchRow ($data) {
return $rc;
}


protected function generateResponse ($view, &$rowArray, $rowArticle, &$variantArray) {
$csConvObj = $GLOBALS['TSFE']->csConvObj;

$theCode = strtoupper($view);
$languageObj = GeneralUtility::makeInstance(\JambageCom\TtProducts\Api\Localization::class);
$imageObj = GeneralUtility::makeInstance('tx_ttproducts_field_image');
Expand Down
3 changes: 1 addition & 2 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,12 @@
if (
version_compare(TYPO3_version, '9.5.0', '<')
) {
$GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include'][TT_PRODUCTS_EXT] = \JambageCom\TtProducts\Controller\TaxajaxController::class . '::processRequest';
$GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include'][TT_PRODUCTS_EXT] = \JambageCom\TtProducts\Controller\OldTaxajaxController::class . '::processRequest';
} else {
$GLOBALS['TYPO3_CONF_VARS']['FE']['taxajax_include'][TT_PRODUCTS_EXT] = \JambageCom\TtProducts\Controller\TaxajaxController::class . '::processRequest';
}
}


\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig('options.saveDocNew.tt_products=1');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig( 'options.saveDocNew.tt_products_language=1');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig('options.saveDocNew.tt_products_cat=1');
Expand Down

0 comments on commit 0c632e5

Please sign in to comment.