diff --git a/core/core.js.php b/core/core.js.php index 1e6ee3a8..0d9f7e64 100644 --- a/core/core.js.php +++ b/core/core.js.php @@ -219,28 +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(); - // Crée le cookie d'acceptation Google Analytics si nécessaire - getData(['config', 'seo', 'analyticsId']);?> - - if(ga.checked){ - document.cookie = "ZWII_COOKIE_GA_CONSENT=true_;" + expires +";"+ samesite; - } - else{ - document.cookie = "ZWII_COOKIE_GA_CONSENT=false_;" + expires +";"+ samesite; - } - - document.cookie = "ZWII_COOKIE_CONSENT=true_;" + expires +";"+ samesite; + */ + $("#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 + var analytics = "getData(['config', 'seo', 'analyticsId']);?>"; + 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=;" + domain + ";" + path + ";" + samesite + ";" + expires; }); + $("#cookieConsent .cookieClose").on("click", function() { $(this).parents("#cookieConsent").fadeOut(); }); diff --git a/core/core.php b/core/core.php index 650a8a81..09286b13 100644 --- a/core/core.php +++ b/core/core.php @@ -1189,26 +1189,34 @@ class common { * Affiche le consentement aux cookies */ public function showCookies() { - if($this->getInput('ZWII_COOKIE_CONSENT') !== 'true_'.str_replace('index.php','',str_replace( '/','',$_SERVER['PHP_SELF'])) 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') !== 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 .= '
'; + $item .= template::ico('cancel'); + $item .= '
'; + $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; } + } /** 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();?>