From 7bc73893c38b95059cea08afad9628d3184f05cd Mon Sep 17 00:00:00 2001 From: MarkusGaertner Date: Thu, 8 Aug 2024 10:21:22 +0200 Subject: [PATCH 1/6] Prevent "OXID Logger.ERROR: D3\GoogleAnalytics4\Modules\Application\Controller\d3GtmStartController is not an instance of OxidEsales\Eshop\Application\Component\Widget\WidgetController" --- .../Component/Widget/d3GtmStartWidget.php | 10 ++++ Modules/Core/WidgetControl.php | 59 +++++++++++++++++++ metadata.php | 1 + 3 files changed, 70 insertions(+) create mode 100644 Application/Component/Widget/d3GtmStartWidget.php create mode 100644 Modules/Core/WidgetControl.php diff --git a/Application/Component/Widget/d3GtmStartWidget.php b/Application/Component/Widget/d3GtmStartWidget.php new file mode 100644 index 0000000..9403e84 --- /dev/null +++ b/Application/Component/Widget/d3GtmStartWidget.php @@ -0,0 +1,10 @@ + '2pistlaubiq58qtg3moudei0la', + 'lang' => '0', + 'actcontrol' => 'details', + 'anid' => '064471', + 'cl' => 'oxwarticledetails', + 'cnid' => '159dd0f2fb2bd6e24ace53a0f1913797', + 'listtype' => 'list', + 'nocookie' => '1', + 'oxwparent' => 'details', + 'sid' => '2pistlaubiq58qtg3moudei0la', + 'stoken' => 'A22D0F9E', + 'varselid' => + array ( + 0 => 'b842982bf522aa839bd88221f562fce8', + ), + ) + */ + + $aParameter = $_GET; + if( is_null($aParameter['actcontrol']) + && is_null($aParameter['actcontrol']) + && is_null($aParameter['actcontrol']) + ) + { + return 'D3\GoogleAnalytics4\Application\Component\Widget\d3GtmStartWidget'; + } + + return $this->getStartControllerKey(); + } + + protected function getStartControllerKey() + { + $controllerKey = Registry::getConfig()->getRequestControllerId(); + + // Use default route in case no controller id is given + if (!$controllerKey) { + $session = \OxidEsales\Eshop\Core\Registry::getSession(); + if ($this->isAdmin()) { + $controllerKey = $session->getVariable("auth") ? 'admin_start' : 'login'; + } else { + $controllerKey = $this->getFrontendStartControllerKey(); + } + $session->setVariable('cl', $controllerKey); + } + + return $controllerKey; + } +} \ No newline at end of file diff --git a/metadata.php b/metadata.php index 9addf64..4c311a9 100755 --- a/metadata.php +++ b/metadata.php @@ -60,6 +60,7 @@ $aModule = [ 'extend' => [ // Core OEViewConfig::class => ViewConfig::class, + \OxidEsales\Eshop\Core\WidgetControl::class => \D3\GoogleAnalytics4\Modules\Core\WidgetControl::class, // Model OECategory::class => Category::class, From 2a1f8f57949c78260520335e71bbb10e404e62d3 Mon Sep 17 00:00:00 2001 From: MarkusGaertner Date: Thu, 8 Aug 2024 10:36:55 +0200 Subject: [PATCH 2/6] Erweiterung verschieben --- Modules/Core/{WidgetControl.php => ShopControl.php} | 2 +- metadata.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename Modules/Core/{WidgetControl.php => ShopControl.php} (97%) diff --git a/Modules/Core/WidgetControl.php b/Modules/Core/ShopControl.php similarity index 97% rename from Modules/Core/WidgetControl.php rename to Modules/Core/ShopControl.php index b4c20c7..eeb04e5 100644 --- a/Modules/Core/WidgetControl.php +++ b/Modules/Core/ShopControl.php @@ -4,7 +4,7 @@ namespace D3\GoogleAnalytics4\Modules\Core; use OxidEsales\EshopCommunity\Core\Registry; -class WidgetControl extends WidgetControl_parent{ +class ShopControl extends ShopControl_parent{ protected function _getStartController() // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore { /* diff --git a/metadata.php b/metadata.php index 4c311a9..1de6d53 100755 --- a/metadata.php +++ b/metadata.php @@ -60,7 +60,7 @@ $aModule = [ 'extend' => [ // Core OEViewConfig::class => ViewConfig::class, - \OxidEsales\Eshop\Core\WidgetControl::class => \D3\GoogleAnalytics4\Modules\Core\WidgetControl::class, + \OxidEsales\Eshop\Core\ShopControl::class => \D3\GoogleAnalytics4\Modules\Core\ShopControl::class, // Model OECategory::class => Category::class, From bc1dafbbfaec6ee35f8815989c9ff03e45054f29 Mon Sep 17 00:00:00 2001 From: MarkusGaertner Date: Thu, 8 Aug 2024 14:16:25 +0200 Subject: [PATCH 3/6] Erweiterung verschieben --- .../{ShopControl.php => WidgetControl.php} | 33 ++++++------------- metadata.php | 2 +- 2 files changed, 11 insertions(+), 24 deletions(-) rename Modules/Core/{ShopControl.php => WidgetControl.php} (55%) diff --git a/Modules/Core/ShopControl.php b/Modules/Core/WidgetControl.php similarity index 55% rename from Modules/Core/ShopControl.php rename to Modules/Core/WidgetControl.php index eeb04e5..ce6940b 100644 --- a/Modules/Core/ShopControl.php +++ b/Modules/Core/WidgetControl.php @@ -4,7 +4,7 @@ namespace D3\GoogleAnalytics4\Modules\Core; use OxidEsales\EshopCommunity\Core\Registry; -class ShopControl extends ShopControl_parent{ +class WidgetControl extends WidgetControl_parent{ protected function _getStartController() // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore { /* @@ -27,33 +27,20 @@ class ShopControl extends ShopControl_parent{ ) */ + $sScriptName = $_SERVER['SCRIPT_NAME']; + if($sScriptName != '/widget.php') + { + return parent::getFrontendStartControllerKey(); + } + $aParameter = $_GET; - if( is_null($aParameter['actcontrol']) - && is_null($aParameter['actcontrol']) + if(is_null($aParameter['actcontrol']) && is_null($aParameter['actcontrol']) + && is_null($aParameter['oxwparent']) ) { return 'D3\GoogleAnalytics4\Application\Component\Widget\d3GtmStartWidget'; } - - return $this->getStartControllerKey(); - } - - protected function getStartControllerKey() - { - $controllerKey = Registry::getConfig()->getRequestControllerId(); - - // Use default route in case no controller id is given - if (!$controllerKey) { - $session = \OxidEsales\Eshop\Core\Registry::getSession(); - if ($this->isAdmin()) { - $controllerKey = $session->getVariable("auth") ? 'admin_start' : 'login'; - } else { - $controllerKey = $this->getFrontendStartControllerKey(); - } - $session->setVariable('cl', $controllerKey); - } - - return $controllerKey; + return parent::getFrontendStartControllerKey(); } } \ No newline at end of file diff --git a/metadata.php b/metadata.php index 1de6d53..4c311a9 100755 --- a/metadata.php +++ b/metadata.php @@ -60,7 +60,7 @@ $aModule = [ 'extend' => [ // Core OEViewConfig::class => ViewConfig::class, - \OxidEsales\Eshop\Core\ShopControl::class => \D3\GoogleAnalytics4\Modules\Core\ShopControl::class, + \OxidEsales\Eshop\Core\WidgetControl::class => \D3\GoogleAnalytics4\Modules\Core\WidgetControl::class, // Model OECategory::class => Category::class, From 48a598da515b77b552fe060e57296d5e4bd64345 Mon Sep 17 00:00:00 2001 From: MarkusGaertner Date: Thu, 8 Aug 2024 15:03:48 +0200 Subject: [PATCH 4/6] =?UTF-8?q?render()=20erg=C3=A4nzen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Component/Widget/d3GtmStartWidget.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Application/Component/Widget/d3GtmStartWidget.php b/Application/Component/Widget/d3GtmStartWidget.php index 9403e84..92a7a79 100644 --- a/Application/Component/Widget/d3GtmStartWidget.php +++ b/Application/Component/Widget/d3GtmStartWidget.php @@ -6,5 +6,10 @@ namespace D3\GoogleAnalytics4\Application\Component\Widget; class d3GtmStartWidget extends \OxidEsales\Eshop\Application\Component\Widget\WidgetController { + public function render() + { + parent::render(); + return ''; + } } \ No newline at end of file From 98ddc51a4d80073240ee087cee3102499fd99d7c Mon Sep 17 00:00:00 2001 From: MaxBuhe01 Date: Sun, 18 Aug 2024 16:40:49 +0200 Subject: [PATCH 5/6] [Changed] clean code --- Modules/Core/WidgetControl.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Modules/Core/WidgetControl.php b/Modules/Core/WidgetControl.php index ce6940b..f79c6c2 100644 --- a/Modules/Core/WidgetControl.php +++ b/Modules/Core/WidgetControl.php @@ -28,19 +28,17 @@ class WidgetControl extends WidgetControl_parent{ */ $sScriptName = $_SERVER['SCRIPT_NAME']; - if($sScriptName != '/widget.php') + if($sScriptName !== '/widget.php') { return parent::getFrontendStartControllerKey(); } $aParameter = $_GET; - if(is_null($aParameter['actcontrol']) - && is_null($aParameter['actcontrol']) - && is_null($aParameter['oxwparent']) - ) + if(is_null($aParameter['actcontrol']) and is_null($aParameter['oxwparent'])) { return 'D3\GoogleAnalytics4\Application\Component\Widget\d3GtmStartWidget'; } + return parent::getFrontendStartControllerKey(); } } \ No newline at end of file From 48e2dc58adb6a7d74ba384cd8bdecb9d1c0527ed Mon Sep 17 00:00:00 2001 From: MarkusGaertner Date: Tue, 27 Aug 2024 14:25:55 +0200 Subject: [PATCH 6/6] Methode umbenannt --- Modules/Core/WidgetControl.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Modules/Core/WidgetControl.php b/Modules/Core/WidgetControl.php index f79c6c2..a326a2b 100644 --- a/Modules/Core/WidgetControl.php +++ b/Modules/Core/WidgetControl.php @@ -5,7 +5,7 @@ namespace D3\GoogleAnalytics4\Modules\Core; use OxidEsales\EshopCommunity\Core\Registry; class WidgetControl extends WidgetControl_parent{ - protected function _getStartController() // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore + protected function getFrontendStartControllerKey() // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore { /* * array ( @@ -26,7 +26,6 @@ class WidgetControl extends WidgetControl_parent{ ), ) */ - $sScriptName = $_SERVER['SCRIPT_NAME']; if($sScriptName !== '/widget.php') {