[Added] new Admin-UI

This commit is contained in:
MaxBUhe 2024-05-29 11:39:53 +02:00
parent 96f6321b14
commit 91e0c5c0c9
5 changed files with 383 additions and 0 deletions

View File

@ -0,0 +1,97 @@
<?php
declare(strict_types=1);
namespace D3\GoogleAnalytics4\Application\Controller\Admin;
use D3\GoogleAnalytics4\Application\Model\Constants;
use D3\GoogleAnalytics4\Application\Model\ManagerTypes;
use OxidEsales\Eshop\Core\Registry;
class GA4AdminUserInterface_main extends \OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController
{
protected $_sThisTemplate = 'ga4/admin/d3ga4uimain.tpl';
public function render()
{
$return = parent::render();
$oConf = Registry::getConfig();
$this->addTplParam('d3ConfigObject', $oConf);
$this->addTplParam('d3ViewObject', $this);
$this->addTplParam('d3ManagerTypeArray', oxNew(ManagerTypes::class)->getManagerList());
return $return;
}
public function save()
{
parent::save();
$aParams = Registry::getRequest()->getRequestEscapedParameter('editval');
$aCheckBoxParams = [
'_blEnableGa4',
'_blEnableDebug',
'_blEnableConsentMode',
'_blEnableOwnCookieManager',
];
foreach ($aCheckBoxParams as $checkBoxName){
if (isset($aParams['bool'][$checkBoxName])){
$aParams['bool'][$checkBoxName] = true;
}else{
$aParams['bool'][$checkBoxName] = false;
}
}
$this->d3SaveShopConfigVars($aParams);
}
/**
* @param array $aParams
* @return void
*/
protected function d3SaveShopConfigVars(array $aParams)
{
$oConfig = Registry::getConfig();
foreach ($aParams as $sConfigType => $aConfigParams) {
foreach ($aConfigParams as $sParamName => $sParamValue){
if($this->d3GetModuleConfigParam($sParamName) !== $sParamValue){
$oConfig->saveShopConfVar(
$sConfigType,
Constants::OXID_MODULE_ID.$sParamName,
$sParamValue,
$oConfig->getShopId(),
Constants::OXID_MODULE_ID
);
}
}
}
}
/**
* @param array $postArray
* @param array $toExcludeArray
* @return array
*/
public function clearOffPostParams(array $postArray, array $toExcludeArray) :array
{
foreach ($toExcludeArray as $excludeThis){
if (in_array($excludeThis, array_keys($postArray))){
unset($postArray[$excludeThis]);
}
}
return $postArray;
}
/**
* @param string $configParamName
* @return mixed
*/
public function d3GetModuleConfigParam(string $configParamName)
{
return Registry::getConfig()->getShopConfVar(Constants::OXID_MODULE_ID.$configParamName, null, Constants::OXID_MODULE_ID);
}
}

View File

@ -0,0 +1,77 @@
<?php
$sLangName = "Deutsch";
// -------------------------------
// RESOURCE IDENTITFIER = STRING
// -------------------------------
$aLang = array(
'charset' => 'UTF-8',
'd3mxgoogleanalytics4' => 'Google Analytics 4',
'd3mxgoogleanalytics4set' => 'Modulverwaltung',
// Base Translations
'D3BASECONFIG' => 'Grundeinstellungen',
'D3CLOSE' => 'Schließen',
'D3NONE' => '- keinen -',
'D3CONTAINERID' => 'Container-ID',
'D3ACTIVATEMOD' => 'Modul aktivieren',
'D3CNTRLPARAM' => 'Steuerungsparameter',
// Use debug mode?
'D3USEDEBUGMODE' => "Debug-Modus aktivieren",
// Use Consentmode?
'D3USEGOOGLECONSENTMODE' => "Google Consent Mode 'Default Values' akivieren",
// Use CMP?
'D3CMPTABTITLE' => 'Cookie Manager Einstellungen',
'D3CMPUSEQ' => 'Cookie Manager nutzen?',
'D3CMP' => 'Consent Management Platform ( CMP )',
// Additional Config
// Server-Side tagging
'D3SERVERSIDETAGGING' => 'Server-Side tagging',
'D3DETAILED_DESC' => 'Detailliertere Erklärung der Funktion',
'D3SERVERSIDETAGGING_HINT' => 'Die Conatiner-ID wird weiterhin unter "Grundeinstellungen" eingetragen!<br><br>
"Serverseitiges Tagging ist eine neue Möglichkeit, mit Google Tag Manager Ihre Anwendung geräteübergreifend zu verwalten.<br>
Servercontainer verwenden dasselbe Tag-, Trigger- und Variablenmodell, das Sie gewohnt sind.<br>
Außerdem bieten sie neue Tools, mit denen Sie Nutzeraktivitäten überall messen können." <br>
<br>
- Quelle <a href="https://developers.google.com/tag-platform/tag-manager/server-side/intro">Developers-Google Server-Side tagging</a><br>
<br>
<strong>Verändern Sie die Werte nur, wenn Sie Server-Side tagging verwenden wollen! Gegebenenfalls fragen Sie einen technischen Ansprechpartner.</strong>
',
'D3SERVERSIDETAGGING_TITLE_ACTIVE' => 'Ausführender code',
'D3SERVERSIDETAGGING_ACTIVE' => 'Diese Domain wird im <strong>aktiven</strong>-code ausgefüht. Das heißt,
dass es sich hierbei um das HTML-Tag <code>script</code> handelt.
Dieses kümmert sich darum, dass die im DataLayer
zusammengefassten Daten an den GTM weitergeleitet werden.<br>
<br>
<h4>Folgend eine Darstellung, was genau ausgetauscht wird</h4>
<pre>
<code>
Vorher:
https://www.googletagmanager.com/gtm.js?id=
Nachher:
{Domain}?id=
</code>
</pre>',
'D3SERVERSIDETAGGING_TITLE_PASSIVE' => '<u>nicht</u>&nbsp;Ausführneder code',
'D3SERVERSIDETAGGING_PASSIVE' => 'Diese Domain wird im <strong>passiven</strong>-code ausgefüht. Das heißt,
dass es sich hierbei um das HTML-Tag <code>noscript</code> handelt.
Dieses wird ausgeführt, wenn aus einem bestimmten Grund
das Javascript nicht ausgeführt wird.<br>
( keine Cookies erlaubt, JavaScript-Unterbindung, ... )
<br>
<h4>Folgend eine Darstellung, was genau ausgetauscht wird</h4>
<pre>
<code>
Vorher:
src="https://www.googletagmanager.com/ns.html?id={Container-ID}"
Nachher:
src="{Domain}?id={Container-ID}"
</code>
</pre>',
);

View File

@ -0,0 +1,194 @@
[{include file="headitem.tpl" title="GENERAL_ADMIN_TITLE"|oxmultilangassign}]
<style>
body {
background-image: linear-gradient(to top, #d5d4d0 0%, #d5d4d0 1%, #eeeeec 31%, #efeeec 75%, #e9e9e7 100%);
}
</style>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
[{if $readonly}]
[{assign var="readonly" value="readonly disabled"}]
[{else}]
[{assign var="readonly" value=""}]
[{/if}]
<div>
<form name="d3gtmformedit" id="d3gtmformedit" action="[{$oViewConf->getSelfLink()}]" enctype="multipart/form-data" method="post">
<div class="row">
<div class="col-6">
[{$oViewConf->getHiddenSid()}]
<input type="hidden" name="cl" value="[{$oViewConf->getActiveClassName()}]">
<input type="hidden" name="fnc" value="">
<input type="hidden" name="editlanguage" value="[{$editlanguage}]">
<div class="card mb-5">
<div class="card-header">
[{oxmultilang ident="D3BASECONFIG"}]
</div>
<div class="card-body">
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" value="" name="editval[bool][_blEnableGa4]" [{if $d3ViewObject->d3GetModuleConfigParam('_blEnableGa4')}]checked[{/if}] id="blGA4enab">
<label class="form-check-label" for="flexCheckDefault">
[{oxmultilang ident="D3ACTIVATEMOD"}]
</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>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="_blEnableDebug" name="editval[bool][_blEnableDebug]" [{if $d3ViewObject->d3GetModuleConfigParam('_blEnableDebug')}]checked[{/if}]>
<label class="form-check-label" for="flexCheckDefault">
[{oxmultilang ident="D3USEDEBUGMODE"}]
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="_blActivateConsentMode" name="editval[bool][_blEnableConsentMode]" [{if $d3ViewObject->d3GetModuleConfigParam('_blEnableConsentMode')}]checked[{/if}]>
<label class="form-check-label" for="flexCheckChecked">
[{oxmultilang ident="D3USEGOOGLECONSENTMODE"}]
</label>
</div>
</div>
<button type="submit" name="save" class="btn btn-light" onClick="Javascript:document.d3gtmformedit.fnc.value='save'">[{oxmultilang ident="GENERAL_SAVE"}]</button>
</div>
</div>
<div class="col-6">
<div class="card border border-0">
<div class="accordion" id="accordionPanelsStayOpenExample">
<div class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#panelsStayOpen-collapseOne" aria-expanded="true" aria-controls="panelsStayOpen-collapseOne">
[{oxmultilang ident="D3CMPTABTITLE"}]
</button>
</h2>
<div id="panelsStayOpen-collapseOne" class="accordion-collapse collapse show">
<div class="accordion-body">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="editval[bool][_blEnableOwnCookieManager]" value="" id="_hasOwnCookieManager" [{if $d3ViewObject->d3GetModuleConfigParam('_blEnableOwnCookieManager')}]checked[{/if}]>
<label class="form-check-label" for="flexCheckChecked">
[{oxmultilang ident="D3CMPUSEQ"}]
</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>
<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>
</div>
</div>
<div class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#panelsStayOpen-collapseTwo" aria-expanded="false" aria-controls="panelsStayOpen-collapseTwo">
[{oxmultilang ident="D3SERVERSIDETAGGING"}]
</button>
</h2>
<div id="panelsStayOpen-collapseTwo" class="accordion-collapse collapse">
<div class="accordion-body">
<div class="card bg-light rounded mb-3">
<div class="card-body">
[{oxmultilang ident="D3SERVERSIDETAGGING_HINT"}]
</div>
</div>
<div class="input-group mb-3">
<span class="input-group-text w-25" id="basic-addon3">[{oxmultilang ident="D3SERVERSIDETAGGING_TITLE_ACTIVE"}]</span>
<input type="text" class="form-control" id="_serversidetagging_js" name="editval[str][_sServersidetagging_js]" value="[{$d3ViewObject->d3GetModuleConfigParam('_sServersidetagging_js')}]" aria-describedby="basic-addon3">
</div>
<div class="input-group mb-3">
<span class="input-group-text w-25" id="basic-addon3">[{oxmultilang ident="D3SERVERSIDETAGGING_TITLE_PASSIVE"}]</span>
<input type="text" class="form-control" id="_serversidetagging_nojs" name="editval[str][_sServersidetagging_nojs]" value="[{$d3ViewObject->d3GetModuleConfigParam('_sServersidetagging_nojs')}]" aria-describedby="basic-addon3">
</div>
<div>
<button type="button" class="btn btn-light mt-3" data-bs-toggle="modal" data-bs-target="#exampleModal">
[{oxmultilang ident="D3DETAILED_DESC"}]
</button>
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<h4>[{oxmultilang ident="D3SERVERSIDETAGGING_TITLE_ACTIVE"}]</h4>
[{oxmultilang ident="D3SERVERSIDETAGGING_ACTIVE"}]
<hr>
<h4>[{oxmultilang ident="D3SERVERSIDETAGGING_TITLE_PASSIVE"}]</h4>
[{oxmultilang ident="D3SERVERSIDETAGGING_PASSIVE"}]
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">[{oxmultilang ident="D3CLOSE"}]</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
<script>
// Active-Button and it's placed
let activeButton = document.querySelector('input[name="_blEnableGa4"]');
let containerIdInput = document.querySelector('input[name="_sContainerID"]');
let debugModeCheckbox = document.querySelector('input[name="_blEnableDebug"]');
let GConsentModeCheckbox = document.querySelector('input[name="_blEnableConsentMode"]');
let inputs = [containerIdInput, debugModeCheckbox, GConsentModeCheckbox];
let d3Disable = true;
if (activeButton.checked){
d3Disable = false;
}
// Initial setup
inputs.forEach(function(input) {
input.disabled = d3Disable;
});
activeButton.addEventListener('change', function() {
d3Disable = !activeButton.checked;
inputs.forEach(function(input) {
input.disabled = d3Disable;
});
});
// Cookie Manager-Button and it's placed
let usingCMP = document.querySelector('input[name="_blEnableOwnCookieManager"]');
let controlParam = document.querySelector('input[name="_sControlParameter"]');
let cmp = document.querySelector('select[name="_HAS_STD_MANAGER"]');
let usingCmpInputs = [controlParam, cmp];
d3Disable = true;
if (usingCMP.checked){
d3Disable = false;
}
// Initial setup
usingCmpInputs.forEach(function(input) {
input.disabled = d3Disable;
});
usingCMP.addEventListener('change', function() {
d3Disable = !usingCMP.checked;
usingCmpInputs.forEach(function(input) {
input.disabled = d3Disable;
});
});
</script>

8
menu.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="ISO-8859-15"?>
<OX>
<OXMENU id="d3mxd3modules">
<MAINMENU id="d3mxgoogleanalytics4">
<SUBMENU id="d3mxgoogleanalytics4set" cl="d3googleanalytics4_main"/>
</MAINMENU>
</OXMENU>
</OX>

View File

@ -1,5 +1,6 @@
<?php <?php
use D3\GoogleAnalytics4\Application\Controller\Admin\GA4AdminUserInterface_main as GA4AdminUserInterfaceMainController;
use D3\GoogleAnalytics4\Application\Model\Constants as Constants; use D3\GoogleAnalytics4\Application\Model\Constants as Constants;
use D3\GoogleAnalytics4\Modules\Application\Component\d3GtmBasketComponentExtension; use D3\GoogleAnalytics4\Modules\Application\Component\d3GtmBasketComponentExtension;
use D3\GoogleAnalytics4\Modules\Application\Component\Widget\d3GtmWidgetArticleDetails as d3GtmWidgetArticleDetails; use D3\GoogleAnalytics4\Modules\Application\Component\Widget\d3GtmWidgetArticleDetails as d3GtmWidgetArticleDetails;
@ -53,6 +54,9 @@ $aModule = [
'author' => 'Data Development (Inh.: Thomas Dartsch)', 'author' => 'Data Development (Inh.: Thomas Dartsch)',
'email' => 'support@shopmodule.com', 'email' => 'support@shopmodule.com',
'url' => 'https://www.oxidmodule.com/', 'url' => 'https://www.oxidmodule.com/',
'controllers' => [
'd3googleanalytics4_main' => GA4AdminUserInterfaceMainController::class
],
'extend' => [ 'extend' => [
// Core // Core
OEViewConfig::class => ViewConfig::class, OEViewConfig::class => ViewConfig::class,
@ -93,6 +97,9 @@ $aModule = [
'page/account/d3gtmnoticelist.tpl' => 'd3/googleanalytics4/Application/views/tpl/page/account/d3gtmnoticelist.tpl', 'page/account/d3gtmnoticelist.tpl' => 'd3/googleanalytics4/Application/views/tpl/page/account/d3gtmnoticelist.tpl',
'page/account/d3gtmrecommendationlist.tpl' => 'd3/googleanalytics4/Application/views/tpl/page/account/d3gtmrecommendationlist.tpl', 'page/account/d3gtmrecommendationlist.tpl' => 'd3/googleanalytics4/Application/views/tpl/page/account/d3gtmrecommendationlist.tpl',
'page/account/d3gtmwishlist.tpl' => 'd3/googleanalytics4/Application/views/tpl/page/account/d3gtmwishlist.tpl', 'page/account/d3gtmwishlist.tpl' => 'd3/googleanalytics4/Application/views/tpl/page/account/d3gtmwishlist.tpl',
// Admin Templates
'ga4/admin/d3ga4uimain.tpl' => 'd3/googleanalytics4/Application/views/admin/tpl/d3googleanalytics4_main.tpl',
], ],
'blocks' => [ 'blocks' => [
// tag manager js // tag manager js