Merge branch '11200_cookies_clean' into 11200_cookies_fusion
This commit is contained in:
commit
39aaa035b4
@ -223,24 +223,24 @@ core.start = function() {
|
|||||||
* Traitement du formulaire cookies
|
* Traitement du formulaire cookies
|
||||||
*/
|
*/
|
||||||
$("#cookieForm").submit(function(event){
|
$("#cookieForm").submit(function(event){
|
||||||
const ga = document.getElementById('googleAnalytics');
|
|
||||||
var samesite = "samesite=lax";
|
var samesite = "samesite=lax";
|
||||||
var expires = new Date();
|
var getUrl = window.location;
|
||||||
expires.setFullYear(expires.getFullYear() + 1);
|
var domain = "domain=" + getUrl.host;
|
||||||
expires = "expires=" + expires.toUTCString();
|
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
|
// Crée le cookie d'acceptation Google Analytics si nécessaire
|
||||||
<?php $analytics = $this->getData(['config', 'seo', 'analyticsId']);?>
|
var analytics = "<?php echo $this->getData(['config', 'seo', 'analyticsId']);?>";
|
||||||
<?php if( $analytics !== null AND $analytics !=='' ){
|
if( analytics.length > 0){
|
||||||
$path = str_replace('index.php','',str_replace( '/','',$_SERVER['PHP_SELF']));?>
|
document.cookie = "ZWII_COOKIE_CONSENT_GA=" + $("#googleAnalytics").prop("checked") + ";" + domain + ";" + path + ";" + samesite + ";" + expires;
|
||||||
if(ga.checked){
|
|
||||||
document.cookie = "ZWII_COOKIE_GA_CONSENT=true_<?php echo $path;?>;" + expires +";"+ samesite;
|
|
||||||
}
|
}
|
||||||
else{
|
//document.cookie = "ZWII_COOKIE_CONSENT=true;" + domain + ";" + path + ";" + samesite + ";" + expires;
|
||||||
document.cookie = "ZWII_COOKIE_GA_CONSENT=false_<?php echo $path;?>;" + expires +";"+ samesite;
|
document.cookie = "ZWII_COOKIE_CONSENT=<?php echo str_replace('index.php','',str_replace( '/','',$_SERVER['PHP_SELF'])); ?>;" + domain + ";" + path + ";" + samesite + ";" + expires;
|
||||||
}
|
|
||||||
<?php } ?>
|
|
||||||
document.cookie = "ZWII_COOKIE_CONSENT=true_<?php echo str_replace('index.php','',str_replace( '/','',$_SERVER['PHP_SELF'])); ?>;" + expires +";"+ samesite;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#cookieConsent .cookieClose").on("click", function() {
|
$("#cookieConsent .cookieClose").on("click", function() {
|
||||||
$(this).parents("#cookieConsent").fadeOut();
|
$(this).parents("#cookieConsent").fadeOut();
|
||||||
});
|
});
|
||||||
|
@ -1189,26 +1189,34 @@ class common {
|
|||||||
* Affiche le consentement aux cookies
|
* Affiche le consentement aux cookies
|
||||||
*/
|
*/
|
||||||
public function showCookies() {
|
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){ ?>
|
|
||||||
<div id="cookieConsent">
|
if( $this->getInput('ZWII_COOKIE_CONSENT') !== str_replace('index.php','',str_replace( '/','',$_SERVER['PHP_SELF'])) AND
|
||||||
<div class="cookieClose">X</div>
|
$this->getData(['config','cookieConsent']) === true
|
||||||
<h3><?php echo $this->getData(['config', 'cookies', 'cookiesTitleText']); ?></h3>
|
){
|
||||||
<?php $analytics = $this->getData(['config', 'seo', 'analyticsId']);?>
|
|
||||||
<p><?php echo $this->getData(['config', 'cookies', 'cookiesZwiiText']); ?></p>
|
$analytics = $this->getData(['config', 'seo', 'analyticsId']);
|
||||||
<?php $legalPage = $this->getData(['locale','legalPageId']) ==='none'? 'mentions-legales' : $this->getData(['locale','legalPageId']); ?>
|
$legalPage = $this->getData(['locale','legalPageId']) ==='none'? 'mentions-legales' : $this->getData(['locale','legalPageId']);
|
||||||
<p><a href=" <?php echo helper::baseUrl() . $legalPage ?> "><?php echo $this->getData(['config', 'cookies', 'cookiesLinkMlText']); ?></a></p>
|
$item = '<div id="cookieConsent">';
|
||||||
<?php if( $analytics !== null AND $analytics !=='' ){ ?>
|
$item .= '<div class="cookieClose">';
|
||||||
<p><?php echo $this->getData(['config', 'cookies', 'cookiesGaText']); ?></p>
|
$item .= template::ico('cancel');
|
||||||
<?php } ?>
|
$item .= '</div>';
|
||||||
<form method="POST" action="" id="cookieForm">
|
$item .= '<h3>'. $this->getData(['config', 'cookies', 'cookiesTitleText']) . '</h3>';
|
||||||
<?php if( $analytics !== null AND $analytics !=='' ){ ?>
|
$item .= '<p>' . $this->getData(['config', 'cookies', 'cookiesZwiiText']) . '</p>';
|
||||||
<input type="checkbox" id="googleAnalytics" name="googleAnalytics" value="GA">
|
$item .= '<p><a href="' . helper::baseUrl() . $legalPage . '">' . $this->getData(['config', 'cookies', 'cookiesLinkMlText']) . '</a></p>';
|
||||||
<label for="googleAnalytics"><?php echo $this->getData(['config', 'cookies', 'cookiesCheckboxGaText']); ?></label> <?php } ?><br><br>
|
if( $analytics !== null AND $analytics !=='' ){
|
||||||
<input type="submit" id="cookieConsentConfirm" value="Valider">
|
$item .= '<p>' . $this->getData(['config', 'cookies', 'cookiesGaText']) . '</p>';
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
}
|
}
|
||||||
|
$item .= '<form method="POST" action="" id="cookieForm">';
|
||||||
|
if( $analytics !== null AND $analytics !=='' ) {
|
||||||
|
$item .= '<input type="checkbox" id="googleAnalytics" name="googleAnalytics" value="GA">';
|
||||||
|
$item .= '<label for="googleAnalytics">' . $this->getData(['config', 'cookies', 'cookiesCheckboxGaText']) . '</label>';
|
||||||
|
}
|
||||||
|
$item .= '<br><br>';
|
||||||
|
$item .= '<input type="submit" id="cookieConsentConfirm" value="Valider">';
|
||||||
|
$item .= '</form></div>';
|
||||||
|
echo $item;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user