Merge remote-tracking branch 'remotes/origin/rel_2.x' into dev_2.x_remove_from_cart_integration

Cette révision appartient à :
MaxBUhe 2024-07-30 14:51:51 +02:00
révision 44d89a667b
12 fichiers modifiés avec 225 ajouts et 66 suppressions

Voir le fichier

@ -5,6 +5,7 @@ declare(strict_types=1);
namespace D3\GoogleAnalytics4\Application\Controller\Admin;
use D3\GoogleAnalytics4\Application\Model\Constants;
use D3\GoogleAnalytics4\Application\Model\ManagerHandler;
use D3\GoogleAnalytics4\Application\Model\ManagerTypes;
use OxidEsales\Eshop\Core\Registry;
use OxidEsales\Eshop\Core\ViewConfig;
@ -20,6 +21,7 @@ class GA4AdminUserInterface_main extends \OxidEsales\Eshop\Application\Controlle
$this->addTplParam('d3ViewObject', $this);
$this->addTplParam('d3ViewConfObject', Registry::get(ViewConfig::class));
$this->addTplParam('d3ManagerTypeArray', oxNew(ManagerTypes::class)->getManagerList());
$this->addTplParam('d3CurrentCMP', oxNew(ManagerHandler::class)->getCurrManager());
return $return;
}

Voir le fichier

@ -7,8 +7,19 @@ namespace D3\GoogleAnalytics4\Application\Model\CMP;
use D3\GoogleAnalytics4\Application\Model\ManagerTypes;
/**
* Used the OXID Module.
*
* Further information's:
* https://docs.oxid-esales.com/modules/usercentrics/de/latest/einfuehrung.html
*
* Usercentrics homepage:
* https://usercentrics.com
*/
class Usercentrics extends ConsentManagementPlatformBaseModel
{
const sCMPName = ManagerTypes::USERCENTRICS_MANUALLY;
const sAlternatename = ManagerTypes::USERCENTRICS_MODULE;
const sExternalIncludationPublicName = "( Externe Einbindung ) Usercentrics";
const sExternalIncludationInternalName = "usercentrics";
const sModuleIncludationPublicName = "( Modul ) Usercentrics";
const sModuleIncludationInternalName = "oxps_usercentrics";
}

Voir le fichier

@ -22,13 +22,32 @@ class ManagerHandler
$aManagerList = $oManagerTypes->getManagerList();
foreach ($aManagerList as $managerName){
if ($oViewConfig->isModuleActive($managerName)){
return $managerName;
if ($this->getModuleSettingExplicitManagerSelectValue()){
return $this->getExplicitManager();
}
foreach ($aManagerList as $shopModuleId => $publicCMPName){
if ($oViewConfig->isModuleActive($shopModuleId)){
$this->d3SaveShopConfVar($shopModuleId);
return $shopModuleId;
}
}
return $this->getExplicitManager();
return "";
}
/**
* @param string $sParam
* @return void
*/
public function d3SaveShopConfVar(string $sParam){
Registry::getConfig()->saveShopConfVar(
'select',
Constants::OXID_MODULE_ID."_HAS_STD_MANAGER",
$sParam,
Registry::getConfig()->getShopId(),
Constants::OXID_MODULE_ID
);
}
/**
@ -36,7 +55,7 @@ class ManagerHandler
*/
public function getModuleSettingExplicitManagerSelectValue() :string
{
return Registry::get(ViewConfig::class)->d3GetModuleConfigParam('_HAS_STD_MANAGER');
return Registry::get(ViewConfig::class)->d3GetModuleConfigParam('_HAS_STD_MANAGER')?:"";
}
/**
@ -48,8 +67,12 @@ class ManagerHandler
/** @var ManagerTypes $oManagerTypes */
$oManagerTypes = oxNew(ManagerTypes::class);
return $oManagerTypes->isManagerInList($sPotentialManagerName)
$sCMPName = $oManagerTypes->isManagerInList($sPotentialManagerName)
? $sPotentialManagerName
: "NONE";
$this->d3SaveShopConfVar($sCMPName);
return $sCMPName;
}
}

Voir le fichier

@ -2,41 +2,24 @@
namespace D3\GoogleAnalytics4\Application\Model;
use D3\GoogleAnalytics4\Application\Model\CMP\Usercentrics;
class ManagerTypes
{
#ToDo: make own classes for each of the manager
const EXTERNAL_SERVICE = "externalService";
const NET_COOKIE_MANAGER = "net_cookie_manager";
const EXTERNAL_SERVICE = "eigener Service";
const NET_COOKIE_MANAGER = "Netensio Cookie Manager";
/**
* Further information's:
* https://github.com/aggrosoft/oxid-cookie-compliance
*/
const AGCOOKIECOMPLIANCE = "agcookiecompliance";
const AGCOOKIECOMPLIANCE = "Aggrosoft Cookie Compliance";
/**
* Used the OXID Module.
*
* Further information's:
* https://docs.oxid-esales.com/modules/usercentrics/de/latest/einfuehrung.html
*
* Usercentrics homepage:
* https://usercentrics.com
*/
const USERCENTRICS_MODULE = "oxps_usercentrics";
const CONSENTMANAGER = "Consentmanager";
/**
* manually included usercentrics script
*/
const USERCENTRICS_MANUALLY = "USERCENTRICS";
const COOKIEFIRST = "Cookiefirst";
const CONSENTMANAGER = "CONSENTMANAGER";
const COOKIEFIRST = "COOKIEFIRST";
const COOKIEBOT = "COOKIEBOT";
const COOKIEBOT = "Cookiebot";
/**
* @return array
@ -47,9 +30,9 @@ class ManagerTypes
"externalService" => self::EXTERNAL_SERVICE,
"agcookiecompliance" => self::AGCOOKIECOMPLIANCE,
"net_cookie_manager" => self::NET_COOKIE_MANAGER,
"oxps_usercentrics" => self::USERCENTRICS_MODULE,
"usercentrics" => self::USERCENTRICS_MANUALLY,
"consentmanager" => self::CONSENTMANAGER,
Usercentrics::sModuleIncludationInternalName => Usercentrics::sModuleIncludationPublicName,
Usercentrics::sExternalIncludationInternalName => Usercentrics::sExternalIncludationPublicName,
"cmconsentmanager" => self::CONSENTMANAGER,
"cookiefirst" => self::COOKIEFIRST,
"cookiebot" => self::COOKIEBOT,
];
@ -61,6 +44,6 @@ class ManagerTypes
*/
public function isManagerInList(string $sManager) :bool
{
return in_array($sManager, $this->getManagerList(), true);
return in_array($sManager, array_keys($this->getManagerList()), true);
}
}

Voir le fichier

@ -15,8 +15,10 @@ $aLang = array(
'D3CLOSE' => 'Schließen',
'D3NONE' => '- keinen -',
'D3CONTAINERID' => 'Container-ID',
'D3CONTAINERID_HELP' => '<a target="_blank" href="https://github.com/d3datadevelopment/GoogleAnalytics4/blob/master/Docs/README.md#Container-ID" class="text-muted text-decoration-none"><i class="bi bi-book-half"></i> Was ist die <strong>Container-ID</strong>?</a>',
'D3ACTIVATEMOD' => 'Modul aktivieren',
'D3CNTRLPARAM' => 'Steuerungsparameter',
'D3CNTRLPARAM_HELP' => '<a target="_blank" href="https://github.com/d3datadevelopment/GoogleAnalytics4/blob/master/Docs/README.md#steuerungsparameter" class="text-muted text-decoration-none"><i class="bi bi-book-half"></i> Was ist der <strong>Steuerungsparameter</strong>?</a>',
'D3INACTIVATEMOD' => 'Modul ist nicht aktiv! Es werde keine Funktionen ausgespielt!',
// Usercentrics Dynamische Optionen
'D3USRCNTRCSDYNOPT' => 'Usercentrics Dynamische Optionen',
@ -57,7 +59,7 @@ $aLang = array(
<a target="_blank" href="https://cmppartnerprogram.withgoogle.com/">offizieller Partnerschaft mit Google ( Liste der Partner )</a>
und unterliegen strengen Vorschriften, um ein ordnungsgemäßes Senden und
Verarbeiten der Zustimmung unterliegenden Daten sicher zu stellen.',
'D3CMP' => 'Consent Management Platform ( CMP )',
'D3CMP' => 'Consent Management Platform ( CMP ) wählen',
// Usercentrics Config
// activate Individual Default Values

Voir le fichier

@ -35,9 +35,12 @@
[{oxmultilang ident="D3ACTIVATEMOD"}] [{if false === $d3ViewObject->d3GetModuleConfigParam('_blEnableGa4')}]<span style="color: red">[{oxmultilang ident="D3INACTIVATEMOD"}]</span>[{/if}]
</label>
</div>
<div class="input-group mb-3 w-50">
<span class="input-group-text" id="basic-addon3">[{oxmultilang ident="D3CONTAINERID"}]</span>
<input type="text" class="form-control" id="_sContainerID" name="editval[str][_sContainerID]" aria-describedby="basic-addon3" value="[{$d3ViewObject->d3GetModuleConfigParam('_sContainerID')}]">
<div class="mb-3">
<div class="input-group w-50">
<span class="input-group-text" id="basic-addon3">[{oxmultilang ident="D3CONTAINERID"}]</span>
<input type="text" class="form-control" id="_sContainerID" name="editval[str][_sContainerID]" aria-describedby="basic-addon3" value="[{$d3ViewObject->d3GetModuleConfigParam('_sContainerID')}]">
</div>
<div class="text-muted">[{oxmultilang ident="D3CONTAINERID_HELP"}]</div>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="_blEnableDebug" name="editval[bool][_blEnableDebug]" [{if $d3ViewObject->d3GetModuleConfigParam('_blEnableDebug')}]checked[{/if}]>
@ -72,19 +75,24 @@
[{oxmultilang ident="D3CMPUSEQ"}][{oxinputhelp ident="D3CMPUSEQ_HELP"}]
</label>
</div>
<div class="input-group mb-3 w-75">
<span class="input-group-text" id="basic-addon3">[{oxmultilang ident="D3CNTRLPARAM"}]</span>
<input type="text" class="form-control" id="_controlParameter" name="editval[str][_sControlParameter]" value="[{$d3ViewObject->d3GetModuleConfigParam('_sControlParameter')}]" aria-describedby="basic-addon3">
<div class="mb-3">
<label>
[{oxmultilang ident="D3CMP"}]
</label>
<select class="form-select w-50" name="editval[select][_HAS_STD_MANAGER]" aria-label="Default select example">
<option value="NONE" selected>[{oxmultilang ident="D3NONE"}]</option>
[{foreach from=$d3ManagerTypeArray key="sInternalName" item="sPublicName" name="editval[aCmpNameArray]"}]
<option value="[{$sInternalName}]" [{if $sInternalName === $d3CurrentCMP}]SELECTED[{/if}]>[{$sPublicName}]</option>
[{/foreach}]
</select>
</div>
<div>
<div class="input-group w-75">
<span class="input-group-text" id="basic-addon3">[{oxmultilang ident="D3CNTRLPARAM"}]</span>
<input type="text" class="form-control" id="_controlParameter" name="editval[str][_sControlParameter]" value="[{$d3ViewObject->d3GetModuleConfigParam('_sControlParameter')}]" aria-describedby="basic-addon3">
</div>
<div class="text-muted">[{oxmultilang ident="D3CNTRLPARAM_HELP"}]</div>
</div>
<label>
[{oxmultilang ident="D3CMP"}]
</label>
<select class="form-select w-50" name="editval[select][_HAS_STD_MANAGER]" aria-label="Default select example">
<option value="NONE" selected>[{oxmultilang ident="D3NONE"}]</option>
[{foreach from=$d3ManagerTypeArray key="sManagerName" item="sCmpName" name="editval[aCmpNameArray]"}]
<option value="[{$sCmpName}]" [{if $sCmpName === $d3ViewObject->d3GetModuleConfigParam('_HAS_STD_MANAGER')}]SELECTED[{/if}]>[{$sManagerName}]</option>
[{/foreach}]
</select>
</div>
<button type="submit" name="save" class="btn btn-light w-100" onClick="Javascript:document.d3gtmformedit.fnc.value='save'">[{oxmultilang ident="GENERAL_SAVE"}]</button>
</div>

Voir le fichier

@ -5,8 +5,43 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [unreleased](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.17.2...rel_2.x) - 2024-x
## [2.18.2](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.18.0...2.18.1) - 2024-06-25
### Fixed
- oe-console apply-configuration triggers on-activate and overwrites existing values
## [2.18.1](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.18.0...2.18.1) - 2024-06-04
### Fixed
- missing return statement, on null/ none
## [2.18.0](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.17.2...2.18.0) - 2024-06-03
### Added
- trait for generalized method
- new admin UI
- additional check for properly activated module
- admin headitem alternative
- usercentrips step/ option 2
- group CMP-Functionalities/ properties into own Model
- additional help texts, translations, explanations
- extended docs
- auto safe on first approach ga4 + cmp-mod
- onActivate/ onDeactivate
## Changed
- declare module settings consistency
- configParamGetter
- clear dead code
- template code upgrade
- lang text
- amount of save-buttons
- Usercentrics-Class constants and adjust global-module-code to it
- CMP-output in tpl
- clear code and adjust Naming
## Fixed
- false class-property declaration
- wrong to-save param
## Removed
- deprecated and obsolete module-settings
- false composer xml-excludation
## [2.17.2](https://git.d3data.de/D3Public/GoogleAnalytics4/compare/2.17.1...2.17.2) - 2024-04-11
### Fixed

Voir le fichier

@ -5,6 +5,13 @@ Die Einbindung dieser Event-Templates erfolgt über TPL-Blöcke unter `source/mo
*Hinweis: nicht alle templates sind bereits gefüllt. Wünschen Sie die Implementierung eines unausgefüllten templates?
Kommen Sie auf uns zu unter https://www.d3data.de/
## Container-ID
Diese finden Sie im "Google-Tag-Manager"-Arbeitsbereich in der Navigationsleiste.
Sie beginnt mit GTM, gefolgt von einem Bindestrich und einer Zeichenkette.
Diese ID wird benötigt, um Google anzuweise, zu welchem "Google Tag Manager"-Arbeitsbereich die
gesammelten Daten im Daten-Stream geleitet werden sollen.
## Steuerungsparameter
Tragen Sie hier im Normalfall die ID des zu prüfenden Cookies ein.
In bestimmten Fällen, müssen Sie hier alternative Werte eintragen. Diese Fälle sind bedingt

Voir le fichier

@ -79,7 +79,7 @@ class ViewConfig extends ViewConfig_parent
}
// No Cookie Manager in use
if (!$this->shallUseOwnCookieManager()) {
if (false === $this->shallUseOwnCookieManager()) {
return true;
}
@ -104,8 +104,8 @@ class ViewConfig extends ViewConfig_parent
// UserCentrics or consentmanager
if (
$this->sCookieManagerType === ManagerTypes::USERCENTRICS_MODULE
or $this->sCookieManagerType === ManagerTypes::USERCENTRICS_MANUALLY
$this->sCookieManagerType === Usercentrics::sModuleIncludationInternalName
or $this->sCookieManagerType === Usercentrics::sExternalIncludationInternalName
or $this->sCookieManagerType === ManagerTypes::CONSENTMANAGER
or $this->sCookieManagerType === ManagerTypes::COOKIEFIRST
or $this->sCookieManagerType === ManagerTypes::COOKIEBOT
@ -134,8 +134,8 @@ class ViewConfig extends ViewConfig_parent
}
if (
$this->sCookieManagerType === ManagerTypes::USERCENTRICS_MODULE
or $this->sCookieManagerType === ManagerTypes::USERCENTRICS_MANUALLY
$this->sCookieManagerType === Usercentrics::sModuleIncludationInternalName
or $this->sCookieManagerType === Usercentrics::sExternalIncludationInternalName
)
{
return 'data-usercentrics="' . $sControlParameter . '" type="text/plain" async=""';
@ -173,7 +173,7 @@ class ViewConfig extends ViewConfig_parent
public function isGtmConsentModeSetActivated() :bool
{
return $this->d3GetModuleConfigParam("_blEnableConsentMode");
return $this->d3GetModuleConfigParam("_blEnableConsentMode")?: false;
}
public function getGtmDataLayer()
@ -215,7 +215,7 @@ class ViewConfig extends ViewConfig_parent
public function isDebugModeOn() :bool
{
return $this->d3GetModuleConfigParam("_blEnableDebug");
return $this->d3GetModuleConfigParam("_blEnableDebug")?: false;
}
/**
@ -225,7 +225,7 @@ class ViewConfig extends ViewConfig_parent
*/
public function getServerSidetaggingJsDomain() :string
{
return $this->d3GetModuleConfigParam("_sServersidetagging_js");
return $this->d3GetModuleConfigParam("_sServersidetagging_js")?: "";
}
/**
@ -235,7 +235,7 @@ class ViewConfig extends ViewConfig_parent
*/
public function getServerSidetaggingNoJsDomain() :string
{
return $this->d3GetModuleConfigParam('_sServersidetagging_nojs');
return $this->d3GetModuleConfigParam('_sServersidetagging_nojs')?: "";
}
/**
@ -252,7 +252,10 @@ class ViewConfig extends ViewConfig_parent
*/
public function d3IsUsercentricsCMPChosen() :bool
{
return (bool) ($this->d3GetModuleConfigParam('_HAS_STD_MANAGER') === Usercentrics::sCMPName
or $this->d3GetModuleConfigParam('_HAS_STD_MANAGER') === Usercentrics::sAlternatename);
$sCMPPubName = $this->d3GetModuleConfigParam('_HAS_STD_MANAGER');
$aPossibleCMP = (oxNew(ManagerTypes::class))->getManagerList();
return (bool) ($sCMPPubName === Usercentrics::sExternalIncludationInternalName
or $sCMPPubName === Usercentrics::sModuleIncludationInternalName);
}
}

44
Setup/Actions.php Fichier normal
Voir le fichier

@ -0,0 +1,44 @@
<?php
declare(strict_types=1);
namespace D3\GoogleAnalytics4\Setup;
use D3\GoogleAnalytics4\Application\Model\Constants;
use OxidEsales\Eshop\Core\Registry;
use OxidEsales\Eshop\Core\ViewConfig;
class Actions
{
/**
* @param string $sVarType
* @param string $sSettingName
* @param string $sSettingValue
* @return void
*/
public function d3SaveDefaultSettings(string $sVarType, string $sSettingName, string $sSettingValue){
$oConfig = Registry::getConfig();
if (trim($this->d3GetModuleConfigParam($sSettingName)) !== trim($sSettingValue)){
$sSettingValue = trim($this->d3GetModuleConfigParam($sSettingName));
}
$oConfig->saveShopConfVar(
$sVarType,
Constants::OXID_MODULE_ID.$sSettingName,
$sSettingValue,
$oConfig->getShopId(),
Constants::OXID_MODULE_ID
);
}
/**
* @param string $configParamName
* @return mixed
*/
public function d3GetModuleConfigParam(string $configParamName)
{
return Registry::get(ViewConfig::class)->d3GetModuleConfigParam($configParamName);
}
}

37
Setup/Events.php Fichier normal
Voir le fichier

@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace D3\GoogleAnalytics4\Setup;
class Events
{
/**
* @return void
*/
public static function onActivate()
{
$oActions = oxNew(Actions::class);
$oActions->d3SaveDefaultSettings(
'str',
'_sServersidetagging_js',
'https://www.googletagmanager.com/gtm.js'
);
$oActions->d3SaveDefaultSettings(
'str',
'_sServersidetagging_nojs',
'https://www.googletagmanager.com/ns.html'
);
$oActions->d3SaveDefaultSettings(
'str',
'_sContainerID',
'GTM-'
);
}
/**
* @return void
*/
public static function onDeactivate(){}
}

Voir le fichier

@ -50,7 +50,7 @@ $aModule = [
Die Entwicklung basiert auf einem Fork von Marat Bedoev - <a href='https://github.com/vanilla-thunder/oxid-module-gtm'>Github-Link</a>
",
'thumbnail' => 'thumbnail.png',
'version' => 'Dev-2.18.0',
'version' => '2.18.2',
'author' => 'Data Development (Inh.: Thomas Dartsch)',
'email' => 'support@shopmodule.com',
'url' => 'https://www.oxidmodule.com/',
@ -175,5 +175,9 @@ $aModule = [
'file' => '/Application/views/blocks/remove_from_cart.tpl',
'position' => 150
]
]
],
'events' => [
'onActivate' => '\D3\GoogleAnalytics4\Setup\Events::onActivate',
'onDeactivate' => '\D3\GoogleAnalytics4\Setup\Events::onDeactivate',
],
];