Skip to content

Commit

Permalink
Release version 4.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Achim Strohm committed Feb 8, 2024
1 parent 62c78fd commit 6002046
Show file tree
Hide file tree
Showing 30 changed files with 1,940 additions and 1,151 deletions.
29 changes: 26 additions & 3 deletions Classes/Controller/BackendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

namespace Websedit\WeCookieConsent\Controller;

use TYPO3\CMS\Backend\Attribute\Controller;
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/***
*
* This file is part of the "we_cookie_consent" Extension for TYPO3 CMS.
Expand Down Expand Up @@ -35,14 +40,20 @@ public function injectServiceRepository(\Websedit\WeCookieConsent\Domain\Reposit
$this->serviceRepository = $serviceRepository;
}

// Prepared for TYPO3 12 compatibility
#public function __construct(protected readonly ModuleTemplateFactory $moduleTemplateFactory){}

/**
* Action initializer
*
* @return void
*/
protected function initializeAction()
{
// @extensionScannerIgnoreLine
$pageId = (int)\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id');
// Use this, when support for V10 is dropped
# $pageUid = (int)($this->request->getQueryParams()['id'] ?? $this->request->getParsedBody()['id'] ?? 0);
$frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
$persistenceConfiguration = array('persistence' => array('storagePid' => $pageId));
$this->configurationManager->setConfiguration(array_merge($frameworkConfiguration, $persistenceConfiguration));
Expand All @@ -51,7 +62,7 @@ protected function initializeAction()
/**
* Preview the config
*
* @return void
* @return \Psr\Http\Message\ResponseInterface
*/
public function gtmWizardAction()
{
Expand All @@ -63,18 +74,25 @@ public function gtmWizardAction()
'services' => $services,
'gtmArray' => $this->createGtmArray($services, $blocks)
]);

if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() > 10) {
$moduleTemplateFactory = GeneralUtility::makeInstance(ModuleTemplateFactory::class);
$moduleTemplate = $moduleTemplateFactory->create($this->request);
$moduleTemplate->setContent($this->view->render());
return $this->htmlResponse($moduleTemplate->renderContent());
}
}

/**
* Download the config as JSON File
*
* @param array $blocks
*
* @return void
* @return \Psr\Http\Message\ResponseInterface
*/
public function jsonDownloadAction($blocks)
{
if($this->response){
if ($this->response) {
$this->response->setHeader('Content-type', 'application/json');
$this->response->setHeader('Content-Disposition', 'attachment; filename=import-this-to-gtm.json');
} else {
Expand All @@ -87,6 +105,11 @@ public function jsonDownloadAction($blocks)
$this->view->assignMultiple([
'gtmArray' => $this->createGtmArray($services, $blocks)
]);

// Backwards compatibility for TYPO3 V10
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() > 10) {
return $this->htmlResponse();
}
}

/**
Expand Down
35 changes: 24 additions & 11 deletions Classes/Controller/ConsentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Websedit\WeCookieConsent\Controller;

use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;

/***
Expand Down Expand Up @@ -43,7 +45,7 @@ public function injectServiceRepository(\Websedit\WeCookieConsent\Domain\Reposit
* Generate JSON data for the consent Modal
*
* @param Websedit\WeCookieConsent\Domain\Model\Service
* @return void
* @return \Psr\Http\Message\ResponseInterface
*/
public function consentAction()
{
Expand All @@ -58,13 +60,17 @@ public function consentAction()
// 'klaroConfig' => $klaroConfig,
// 'typo3Version' => $typo3Version
// ]);
// Backwards compatibility for TYPO3 V10
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() > 10) {
return $this->htmlResponse();
}
}

/**
* Show used cookies at the data privacy page
*
* @param Websedit\WeCookieConsent\Domain\Model\Service
* @return void
* @return \Psr\Http\Message\ResponseInterface
*/
public function listAction()
{
Expand All @@ -79,12 +85,17 @@ public function listAction()
$this->view->assignMultiple([
'services' => $services
]);

// Backwards compatibility for TYPO3 V10
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() > 10) {
return $this->htmlResponse();
}
}

/**
* @param \TYPO3\CMS\Extbase\Mvc\RequestInterface $request
*/
protected function renderAssetsForRequest($request)
protected function renderAssetsForRequest($request): void
{
if (!$this->view instanceof \TYPO3\CMS\Fluid\View\TemplateView) {
return;
Expand All @@ -93,7 +104,7 @@ protected function renderAssetsForRequest($request)
$services = $this->serviceRepository->findAll();
$klaroConfig = $this->klaroConfigBuild($services);

$pageRenderer = $this->objectManager->get(\TYPO3\CMS\Core\Page\PageRenderer::class);
$pageRenderer = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Page\PageRenderer::class);
$variables = [
'request' => $request,
'arguments' => $this->arguments,
Expand Down Expand Up @@ -159,7 +170,7 @@ private function klaroConfigBuild(\TYPO3\CMS\Extbase\Persistence\Generic\QueryRe
'storageName' => $this->settings['klaro']['storageName'],
'stylePrefix' => $this->settings['klaro']['stylePrefix'],
'testing' => $this->settings['klaro']['testing'] === '1',
'consentMode' => $this->settings['klaro']['consentMode'] === '1',
'consentMode' => $this->settings['klaro']['consentMode'] === '1',
'translations' => [
'en' => [
'consentModal' => [
Expand Down Expand Up @@ -219,12 +230,14 @@ private function klaroConfigBuild(\TYPO3\CMS\Extbase\Persistence\Generic\QueryRe
];

foreach ($services as $service) {
foreach ($service->getCategories() as $category) {
$klaroConfig['translations']['en']['purposes'][strtolower($category->getTitle())]['title'] = $category->getTitle();
$klaroConfig['translations']['en']['purposes'][strtolower($category->getTitle())]['description'] = $category->getDescription();

// Sorting the sys_categories
$klaroConfig['purposeOrder'][$category->getUid()] = strtolower($category->getTitle());
if ($service->getCategories()->count()) {
foreach ($service->getCategories() as $category) {
$klaroConfig['translations']['en']['purposes'][strtolower($category->getTitle())]['title'] = $category->getTitle();
$klaroConfig['translations']['en']['purposes'][strtolower($category->getTitle())]['description'] = $category->getDescription();

// Sorting the sys_categories
$klaroConfig['purposeOrder'][$category->getUid()] = strtolower($category->getTitle());
}
}
}

Expand Down
21 changes: 18 additions & 3 deletions Classes/Resource/Rendering/VimeoRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,23 @@

class VimeoRenderer extends \TYPO3\CMS\Core\Resource\Rendering\VimeoRenderer
{
/**
* @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
*/
protected $configurationManager;

/**
* Injects the Configuration Manager and loads the settings
*
* @param \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager An instance of the Configuration Manager
*/
public function injectConfigurationManager(
ConfigurationManagerInterface $configurationManager
): void
{
$this->configurationManager = $configurationManager;
}

/**
* Returns the priority of the renderer
* This way it is possible to define/overrule a renderer
Expand All @@ -34,9 +51,7 @@ public function getPriority()
*/
public function render(FileInterface $file, $width, $height, array $options = [], $usedPathsRelativeToCurrentScript = false)
{
$objectManager = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
$configurationManager = $objectManager->get(\TYPO3\CMS\Extbase\Configuration\ConfigurationManager::class);
$extbaseFrameworkConfiguration = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
$extbaseFrameworkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
$testing = $extbaseFrameworkConfiguration['plugin.']['tx_wecookieconsent_pi1.']['settings.']['klaro.']['testing'];

if(!$testing) {
Expand Down
23 changes: 19 additions & 4 deletions Classes/Resource/Rendering/YouTubeRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,23 @@

class YouTubeRenderer extends \TYPO3\CMS\Core\Resource\Rendering\YouTubeRenderer
{
/**
* @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
*/
protected $configurationManager;

/**
* Injects the Configuration Manager and loads the settings
*
* @param \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager An instance of the Configuration Manager
*/
public function injectConfigurationManager(
ConfigurationManagerInterface $configurationManager
): void
{
$this->configurationManager = $configurationManager;
}

/**
* Returns the priority of the renderer
* This way it is possible to define/overrule a renderer
Expand All @@ -34,12 +51,10 @@ public function getPriority()
*/
public function render(FileInterface $file, $width, $height, array $options = [], $usedPathsRelativeToCurrentScript = false)
{
$objectManager = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
$configurationManager = $objectManager->get(\TYPO3\CMS\Extbase\Configuration\ConfigurationManager::class);
$extbaseFrameworkConfiguration = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
$extbaseFrameworkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
$testing = $extbaseFrameworkConfiguration['plugin.']['tx_wecookieconsent_pi1.']['settings.']['klaro.']['testing'];

if(!$testing) {
if (!$testing) {
$options = $this->collectOptions($options, $file);
$iframe = str_replace(' src="', ' data-name="youtube" data-src="', parent::render($file, $width, $height, $options, $usedPathsRelativeToCurrentScript));
} else {
Expand Down
2 changes: 1 addition & 1 deletion Configuration/TCA/Overrides/tt_content.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
defined('TYPO3') or die();

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'Websedit.WeCookieConsent',
'WeCookieConsent',
'Pi1',
'Cookie List'
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,67 @@
<?php
defined('TYPO3') || die();
defined('TYPO3') || die();

use TYPO3\CMS\Core\Utility\VersionNumberUtility;

$typo3VersionNumber = VersionNumberUtility::convertVersionNumberToInteger(
VersionNumberUtility::getNumericTypo3Version()
);

if ($typo3VersionNumber < 11000000) {
// If TYPO3 version is previous version 11. Can be removed when TYO3 V10 support is dropped.

// Change Language field. Required for TYO3 10 support.
$GLOBALS['TCA']['tx_wecookieconsent_domain_model_cookie']['columns']['sys_language_uid']['config'] = [
'type' => 'select',
'renderType' => 'selectSingle',
'special' => 'languages',
'items' => [
[
'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.allLanguages',
-1,
'flags-multiple'
]
],
'default' => 0,
];

// Change Start Stop field. Required for TYPO3 10 support.
$GLOBALS['TCA']['tx_wecookieconsent_domain_model_cookie']['columns']['starttime']['config']['type'] = 'input';
$GLOBALS['TCA']['tx_wecookieconsent_domain_model_cookie']['columns']['starttime']['config']['renderType'] = 'inputDateTime';
$GLOBALS['TCA']['tx_wecookieconsent_domain_model_cookie']['columns']['starttime']['config']['eval'] = 'datetime,int';

$GLOBALS['TCA']['tx_wecookieconsent_domain_model_cookie']['columns']['endtime']['config']['type'] = 'input';
$GLOBALS['TCA']['tx_wecookieconsent_domain_model_cookie']['columns']['endtime']['config']['renderType'] = 'inputDateTime';
$GLOBALS['TCA']['tx_wecookieconsent_domain_model_cookie']['columns']['endtime']['config']['eval'] = 'datetime,int';
}

if ($typo3VersionNumber < 12000000) {
// If TYPO3 version is previous version 12. Can be removed when TYO3 V10 and V11 support is dropped.

// @extensionScannerIgnoreLine
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_wecookieconsent_domain_model_cookie');

//Breaking: #98024
$GLOBALS['TCA']['tx_wecookieconsent_domain_model_cookie']['ctr']['cruser_id'] = 'cruser_id';

// Change start/stop field. Required for TYPO3 V10 and V11 support.
$GLOBALS['TCA']['tx_wecookieconsent_domain_model_cookie']['columns']['starttime']['config']['type'] = 'input';
$GLOBALS['TCA']['tx_wecookieconsent_domain_model_cookie']['columns']['starttime']['config']['renderType'] = 'inputDateTime';
$GLOBALS['TCA']['tx_wecookieconsent_domain_model_cookie']['columns']['starttime']['config']['eval'] = 'datetime,int';

$GLOBALS['TCA']['tx_wecookieconsent_domain_model_cookie']['columns']['endtime']['config']['type'] = 'input';
$GLOBALS['TCA']['tx_wecookieconsent_domain_model_cookie']['columns']['endtime']['config']['renderType'] = 'inputDateTime';
$GLOBALS['TCA']['tx_wecookieconsent_domain_model_cookie']['columns']['endtime']['config']['eval'] = 'datetime,int';

// Feature: #97035: Required migrated to own array key.
$GLOBALS['TCA']['tx_wecookieconsent_domain_model_cookie']['columns']['title']['config']['eval'] .= ',required';

// Change Checkboxes
$GLOBALS['TCA']['tx_wecookieconsent_domain_model_cookie']['columns']['hidden']['config']['items'] = [
[
0 => '',
1 => '',
'invertStateDisplay' => true
]
];
}
Loading

0 comments on commit 6002046

Please sign in to comment.