From 84b4023e1964e3f3e7428947041651bb4824e82c Mon Sep 17 00:00:00 2001 From: fredtempez Date: Mon, 22 Nov 2021 13:46:16 +0100 Subject: [PATCH 1/5] Nom du cookie + nettoyage --- core/core.js.php | 38 ++++++++++++++++++-------------------- core/core.php | 4 ++-- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/core/core.js.php b/core/core.js.php index abe89d1f..8b554b1b 100644 --- a/core/core.js.php +++ b/core/core.js.php @@ -219,30 +219,28 @@ core.start = function() { } }); - /** + /** * Traitement du formulaire cookies */ - $("#cookieForm").submit(function(event){ - const ga = document.getElementById('googleAnalytics'); - var samesite = "samesite=lax"; - var expires = new Date(); - expires.setFullYear(expires.getFullYear() + 1); - expires = "expires=" + expires.toUTCString(); + $("#cookieForm").submit(function(event){ + var samesite = "samesite=lax"; + var getUrl = window.location; + var domain = "domain=" + getUrl.host; + var path = "path=" + getUrl.pathname.split('/')[1]; + var samesite = "samesite=lax"; + var e = new Date(); + e.setFullYear(e.getFullYear() + 1); + var expires = "expires=" + e.toUTCString(); + // Crée le cookie d'acceptation Google Analytics si nécessaire - getData(['config', 'seo', 'analyticsId']);?> - - if(ga.checked){ - document.cookie = "=true;" + expires +";"+ samesite; - } - else{ - document.cookie = "=false;" + expires +";"+ samesite; - } - - document.cookie = "=true;" + expires +";"+ samesite; + var analytics = "getData(['config', 'seo', 'analyticsId']);?>"; + console.log(analytics.length ); + if( analytics.length > 0){ + document.cookie = "ZWII_COOKIE_CONSENT_GA=" + $("#googleAnalytics").prop("checked") + ";" + domain + ";" + path + ";" + samesite + ";" + expires; + } + document.cookie = "ZWII_COOKIE_CONSENT=true;" + domain + ";" + path + ";" + samesite + ";" + expires; }); + $("#cookieConsent .cookieClose").on("click", function() { $(this).parents("#cookieConsent").fadeOut(); }); diff --git a/core/core.php b/core/core.php index ad04608a..3adce250 100644 --- a/core/core.php +++ b/core/core.php @@ -1190,8 +1190,8 @@ class common { * Affiche le consentement aux cookies */ public function showCookies() { - $cookieName = 'ZWII_COOKIE_CONSENT'.str_replace('_index.php','',str_replace( '/','_',$_SERVER['PHP_SELF'])); - if($this->getInput($cookieName) !== 'true' AND $this->getData(['config','cookieConsent']) === true){ ?> + //$cookieName = 'ZWII_COOKIE_CONSENT'.str_replace('_index.php','',str_replace( '/','_',$_SERVER['PHP_SELF'])); + if($this->getInput('ZWII_COOKIE_CONSENT') !== 'true' AND $this->getData(['config','cookieConsent']) === true){ ?>
X

getData(['config', 'cookies', 'cookiesTitleText']); ?>

From 462b7b9ed62247eabc8db9602658bea65128ce96 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Mon, 22 Nov 2021 13:50:08 +0100 Subject: [PATCH 2/5] log en moins --- core/core.js.php | 1 - 1 file changed, 1 deletion(-) diff --git a/core/core.js.php b/core/core.js.php index 8b554b1b..497669b1 100644 --- a/core/core.js.php +++ b/core/core.js.php @@ -234,7 +234,6 @@ core.start = function() { // Crée le cookie d'acceptation Google Analytics si nécessaire var analytics = "getData(['config', 'seo', 'analyticsId']);?>"; - console.log(analytics.length ); if( analytics.length > 0){ document.cookie = "ZWII_COOKIE_CONSENT_GA=" + $("#googleAnalytics").prop("checked") + ";" + domain + ";" + path + ";" + samesite + ";" + expires; } From 2e9402f1c8e3ae81b413109de42ad94857a0b2a9 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Mon, 22 Nov 2021 13:50:43 +0100 Subject: [PATCH 3/5] alignements --- core/core.js.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/core.js.php b/core/core.js.php index 497669b1..a93327a0 100644 --- a/core/core.js.php +++ b/core/core.js.php @@ -224,9 +224,9 @@ core.start = function() { */ $("#cookieForm").submit(function(event){ var samesite = "samesite=lax"; - var getUrl = window.location; + var getUrl = window.location; var domain = "domain=" + getUrl.host; - var path = "path=" + getUrl.pathname.split('/')[1]; + var path = "path=" + getUrl.pathname.split('/')[1]; var samesite = "samesite=lax"; var e = new Date(); e.setFullYear(e.getFullYear() + 1); From bb8d7c42942fc498c01b01a540fe985151c546e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Tempez?= Date: Mon, 22 Nov 2021 16:23:13 +0100 Subject: [PATCH 4/5] showcookie propre --- core/core.php | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/core/core.php b/core/core.php index 3adce250..ba52687e 100644 --- a/core/core.php +++ b/core/core.php @@ -1191,26 +1191,29 @@ class common { */ public function showCookies() { //$cookieName = 'ZWII_COOKIE_CONSENT'.str_replace('_index.php','',str_replace( '/','_',$_SERVER['PHP_SELF'])); - if($this->getInput('ZWII_COOKIE_CONSENT') !== 'true' AND $this->getData(['config','cookieConsent']) === true){ ?> -
-
X
-

getData(['config', 'cookies', 'cookiesTitleText']); ?>

- getData(['config', 'seo', 'analyticsId']);?> -

getData(['config', 'cookies', 'cookiesZwiiText']); ?>

- getData(['locale','legalPageId']) ==='none'? 'mentions-legales' : $this->getData(['locale','legalPageId']); ?> -

getData(['config', 'cookies', 'cookiesLinkMlText']); ?>

- -

getData(['config', 'cookies', 'cookiesGaText']); ?>

- -
- - -

- -
-
- getInput('ZWII_COOKIE_CONSENT') !== 'true' AND $this->getData(['config','cookieConsent']) === true){ + + $analytics = $this->getData(['config', 'seo', 'analyticsId']); + $legalPage = $this->getData(['locale','legalPageId']) ==='none'? 'mentions-legales' : $this->getData(['locale','legalPageId']); + + $item = '
'; + $item .= '
X
'; + $item .= '

'. $this->getData(['config', 'cookies', 'cookiesTitleText']) . '

'; + $item .= '

' . $this->getData(['config', 'cookies', 'cookiesZwiiText']) . '

'; + $item .= '

' . $this->getData(['config', 'cookies', 'cookiesLinkMlText']) . '

'; + if( $analytics !== null AND $analytics !=='' ){ + $item .= '

' . $this->getData(['config', 'cookies', 'cookiesGaText']) . '

'; + } + $item .= '
'; + if( $analytics !== null AND $analytics !=='' ) { + $item .= ''; + $item .= ''; + } + $item .= '

'; + $item .= ''; + $item .= '
'; } + echo $item; } /** From 7d3634cd50b4ea5d64c5ba8c3a35eaed4cd3d039 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Tempez?= Date: Mon, 22 Nov 2021 19:32:32 +0100 Subject: [PATCH 5/5] Cooike Sylvain + croix --- core/core.js.php | 3 ++- core/core.php | 14 +++++++++----- core/layout/main.php | 4 ++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/core/core.js.php b/core/core.js.php index a93327a0..0d9f7e64 100644 --- a/core/core.js.php +++ b/core/core.js.php @@ -237,7 +237,8 @@ core.start = function() { if( analytics.length > 0){ document.cookie = "ZWII_COOKIE_CONSENT_GA=" + $("#googleAnalytics").prop("checked") + ";" + domain + ";" + path + ";" + samesite + ";" + expires; } - document.cookie = "ZWII_COOKIE_CONSENT=true;" + domain + ";" + path + ";" + samesite + ";" + expires; + //document.cookie = "ZWII_COOKIE_CONSENT=true;" + domain + ";" + path + ";" + samesite + ";" + expires; + document.cookie = "ZWII_COOKIE_CONSENT=;" + domain + ";" + path + ";" + samesite + ";" + expires; }); $("#cookieConsent .cookieClose").on("click", function() { diff --git a/core/core.php b/core/core.php index ba52687e..50b43db5 100644 --- a/core/core.php +++ b/core/core.php @@ -1190,14 +1190,17 @@ class common { * Affiche le consentement aux cookies */ public function showCookies() { - //$cookieName = 'ZWII_COOKIE_CONSENT'.str_replace('_index.php','',str_replace( '/','_',$_SERVER['PHP_SELF'])); - if($this->getInput('ZWII_COOKIE_CONSENT') !== 'true' AND $this->getData(['config','cookieConsent']) === true){ + + if( $this->getInput('ZWII_COOKIE_CONSENT') !== str_replace('index.php','',str_replace( '/','',$_SERVER['PHP_SELF'])) AND + $this->getData(['config','cookieConsent']) === true + ){ $analytics = $this->getData(['config', 'seo', 'analyticsId']); $legalPage = $this->getData(['locale','legalPageId']) ==='none'? 'mentions-legales' : $this->getData(['locale','legalPageId']); - $item = '
'; - $item .= '
X
'; + $item .= '
'; + $item .= template::ico('cancel'); + $item .= '
'; $item .= '

'. $this->getData(['config', 'cookies', 'cookiesTitleText']) . '

'; $item .= '

' . $this->getData(['config', 'cookies', 'cookiesZwiiText']) . '

'; $item .= '

' . $this->getData(['config', 'cookies', 'cookiesLinkMlText']) . '

'; @@ -1212,8 +1215,9 @@ class common { $item .= '

'; $item .= ''; $item .= '
'; + echo $item; } - echo $item; + } /** diff --git a/core/layout/main.php b/core/layout/main.php index 6ad6327f..d17b3c5a 100644 --- a/core/layout/main.php +++ b/core/layout/main.php @@ -174,7 +174,7 @@ showSection();?> - + showFooter();?> @@ -183,7 +183,7 @@
- + showCookies(); ?> showScript();?>