Revert "Google Translate Cookie."

This reverts commit df18c2441a.
This commit is contained in:
fredtempez 2021-11-29 11:30:54 +01:00
parent df18c2441a
commit 91aea4d17c
6 changed files with 45 additions and 75 deletions

View File

@ -223,20 +223,17 @@ core.start = function() {
var expires = "expires=" + e.toUTCString(); var expires = "expires=" + e.toUTCString();
// Crée le cookie d'acceptation Google Analytics si l'ID a été saisie // Crée le cookie d'acceptation Google Analytics si l'ID a été saisie
// Traitement du retour de la checkbox var analytics = "<?php echo $this->getData(['config', 'seo', 'analyticsId']);?>";
if ($("#googleAnalytics").is(":checked")) { // l'Id GA est défini dans la configuration, afficher la checkbox d'acceptation
// L'URL du serveur faut TRUE if( analytics.length > 0){
document.cookie = "ZWII_COOKIE_GA_CONSENT=" + "<?php echo $_SERVER['PHP_SELF']; ?>" + ";" + domain + ";" + path + ";" + samesite + ";" + expires; // Traitement du retour de la checkbox
} else { if ($("#googleAnalytics").is(":checked")) {
document.cookie = "ZWII_COOKIE_GA_CONSENT=false;" + domain + ";" + path + ";" + samesite + ";" + expires; // L'URL du serveur faut TRUE
} document.cookie = "ZWII_COOKIE_GA_CONSENT=" + "<?php echo $_SERVER['PHP_SELF']; ?>" + ";" + domain + ";" + path + ";" + samesite + ";" + expires;
// Traitement du retour de la checkbox } else {
if ($("#googleTranslate").is(":checked")) { document.cookie = "ZWII_COOKIE_GA_CONSENT=false;" + domain + ";" + path + ";" + samesite + ";" + expires;
// L'URL du serveur faut TRUE }
document.cookie = "ZWII_COOKIE_GT_CONSENT=" + "<?php echo $_SERVER['PHP_SELF']; ?>" + ";" + domain + ";" + path + ";" + samesite + ";" + expires;
} else {
document.cookie = "ZWII_COOKIE_GT_CONSENT=false;" + domain + ";" + path + ";" + samesite + ";" + expires;
document.cookie = "googtrans=fr/fr;" + domain + ";" + path + ";" + samesite + ";" + expires;
} }
// Stocke le cookie d'acceptation // Stocke le cookie d'acceptation
@ -279,7 +276,7 @@ core.start = function() {
* Commande de gestion des cookies dans le footer * Commande de gestion des cookies dans le footer
*/ */
$(".footerShowCookieConsent").on("click", function() { $("#footerLinkCookie").on("click", function() {
$("#cookieConsent").removeClass("displayNone"); $("#cookieConsent").removeClass("displayNone");
}); });

View File

@ -256,7 +256,6 @@ class common {
if ( $this->getData(['config', 'i18n', 'enable']) === true if ( $this->getData(['config', 'i18n', 'enable']) === true
AND $this->getData(['config', 'i18n','scriptGoogle']) === true AND $this->getData(['config', 'i18n','scriptGoogle']) === true
AND $this->getData(['config', 'i18n','autoDetect']) === true AND $this->getData(['config', 'i18n','autoDetect']) === true
AND $this->getInput('ZWII_COOKIE_GT_CONSENT') === $_SERVER['PHP_SELF']
AND $this->getInput('ZWII_I18N_SITE') !== '' AND $this->getInput('ZWII_I18N_SITE') !== ''
AND !empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) ) AND !empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) )
{ {
@ -1188,15 +1187,15 @@ class common {
} }
/** /**
* Affiche le consentement des cookies * Affiche le consentement aux cookies
*/ */
public function showCookies() { public function showCookies() {
// Gestion des cookies interne active // Gestion des cookies intégrée
if ($this->getData(['config', 'cookieConsent']) === true ) if ($this->getData(['config', 'cookieConsent']) === true )
{ {
// Détermine si le bloc doit être affiché selon la validité du cookie : l'URL du serveur faut TRUE // Détermine si le bloc doit être affiché selon la validité du cookie
// Pour éviter la propagation (à revoir avec Sylvain) // L'URL du serveur faut TRUE
$item = '<div id="cookieConsent"'; $item = '<div id="cookieConsent"';
$item .= $this->getInput('ZWII_COOKIE_CONSENT') !== $_SERVER['PHP_SELF'] ? '>' : ' class="displayNone">'; $item .= $this->getInput('ZWII_COOKIE_CONSENT') !== $_SERVER['PHP_SELF'] ? '>' : ' class="displayNone">';
// Bouton de fermeture // Bouton de fermeture
@ -1208,26 +1207,17 @@ class common {
$item .= '<p>' . $this->getData(['locale', 'cookies', 'cookiesZwiiText']) . '</p>'; $item .= '<p>' . $this->getData(['locale', 'cookies', 'cookiesZwiiText']) . '</p>';
// Formulaire de réponse // Formulaire de réponse
$item .= '<form method="POST" action="" id="cookieForm">'; $item .= '<form method="POST" action="" id="cookieForm">';
// Checkbox Google Analytics
$analytics = $this->getData(['config', 'seo', 'analyticsId']); $analytics = $this->getData(['config', 'seo', 'analyticsId']);
$stateCookieGA = $this->getInput('ZWII_COOKIE_GA_CONSENT') === $_SERVER['PHP_SELF'] ? 'checked="checked"' : ''; $stateCookieGA = $this->getInput('ZWII_COOKIE_GA_CONSENT') === $_SERVER['PHP_SELF'] ? 'checked="checked"' : '';
if( $analytics !== null AND $analytics !== '' ) { if( $analytics !== null AND $analytics !== '' ) {
$item .= '<p>' . $this->getData(['locale', 'cookies', 'cookiesGaText']) . '</p>'; $item .= '<p>' . $this->getData(['locale', 'cookies', 'cookiesGaText']) . '</p>';
$item .= '<input type="checkbox" id="googleAnalytics" name="googleAnalytics" value="GA" ' . $stateCookieGA . '>'; $item .= '<input type="checkbox" id="googleAnalytics" name="googleAnalytics" value="GA" ' . $stateCookieGA . '>';
$item .= '<label for="googleAnalytics">' . $this->getData(['locale', 'cookies', 'cookiesCheckboxGaText']) . '</label>'; $item .= '<label for="googleAnalytics">' . $this->getData(['locale', 'cookies', 'cookiesCheckboxGaText']) . '</label>';
}
// Traduction automatique active
if ( $this->getData(['config', 'i18n','scriptGoogle']) === true ) {
// Checkbox Google Translate
$stateCookieGT = $this->getInput('ZWII_COOKIE_GT_CONSENT') === $_SERVER['PHP_SELF'] ? 'checked="checked"' : '';
$item .= '<p>' . $this->getData(['locale', 'cookies', 'cookiesGtText']) . '</p>';
$item .= '<input type="checkbox" id="googleTranslate" name="googleTranslate" value="GT" ' . $stateCookieGT . '>';
$item .= '<label for="googleTranslate">' . $this->getData(['locale', 'cookies', 'cookiesCheckboxGtText']) . '</label>';
} }
$item .= '<br><br>'; $item .= '<br><br>';
$item .= '<input type="submit" id="cookieConsentConfirm" value="' . $this->getData(['locale', 'cookies', 'cookiesButtonText']) . '">'; $item .= '<input type="submit" id="cookieConsentConfirm" value="' . $this->getData(['locale', 'cookies', 'cookiesButtonText']) . '">';
$item .= '</form>'; $item .= '</form>';
// Mentions légales si une page est définie // mentions légales si la page est définie
$legalPage = $this->getData(['locale', 'legalPageId']); $legalPage = $this->getData(['locale', 'legalPageId']);
if ($legalPage !== 'none') { if ($legalPage !== 'none') {
$item .= '<p><a href="' . helper::baseUrl() . $legalPage . '">' . $this->getData(['locale', 'cookies', 'cookiesLinkMlText']) . '</a></p>'; $item .= '<p><a href="' . helper::baseUrl() . $legalPage . '">' . $this->getData(['locale', 'cookies', 'cookiesLinkMlText']) . '</a></p>';
@ -1502,7 +1492,7 @@ class common {
$items .= '<span id="footerDisplayCookie"'; $items .= '<span id="footerDisplayCookie"';
$items .= ($this->getData(['config', 'cookieConsent']) === false && $this->getData(['theme', 'footer', 'displayCookie']) === false)? ' class="displayNone" >' : '>'; $items .= ($this->getData(['config', 'cookieConsent']) === false && $this->getData(['theme', 'footer', 'displayCookie']) === false)? ' class="displayNone" >' : '>';
$label = empty($this->getData(['locale', 'cookies', 'cookiesFooterText'])) ? 'Confidentialité' : $this->getData(['locale', 'cookies', 'cookiesFooterText']) ; $label = empty($this->getData(['locale', 'cookies', 'cookiesFooterText'])) ? 'Confidentialité' : $this->getData(['locale', 'cookies', 'cookiesFooterText']) ;
$items .= '<wbr>&nbsp;|&nbsp;<a href="javascript:void(0)" class="footerShowCookieConsent">'. $label .'</a>'; $items .= '<wbr>&nbsp;|&nbsp;<a href="javascript:void(0)" id="footerLinkCookie">'. $label .'</a>';
$items .= '</span>'; $items .= '</span>';
// Affichage du lien de connexion // Affichage du lien de connexion
if( if(
@ -1763,9 +1753,8 @@ class common {
} }
// Retourne les items du menu // Retourne les items du menu
echo '<ul class="navMain" id="menuLeft">' . $itemsLeft . '</ul><ul class="navMain" id="menuRight">' . $itemsRight; echo '<ul class="navMain" id="menuLeft">' . $itemsLeft . '</ul><ul class="navMain" id="menuRight">' . $itemsRight;
if ($this->getData(['config', 'i18n', 'enable']) === true if ($this->getData(['config', 'i18n', 'enable']) === true) {
) { echo $this->showi18n();
echo $this->showi18n();
} }
echo '</ul>'; echo '</ul>';
} }
@ -2125,7 +2114,6 @@ class common {
OR ( OR (
$this->getData(['config', 'i18n','scriptGoogle']) === true $this->getData(['config', 'i18n','scriptGoogle']) === true
AND $this->getData(['config', 'i18n',$key]) === 'script' AND $this->getData(['config', 'i18n',$key]) === 'script'
AND $this->getInput('ZWII_COOKIE_GT_CONSENT') === $_SERVER['PHP_SELF']
) )
) { ) {
if ( if (
@ -2803,34 +2791,33 @@ class core extends common {
} }
// Chargement de la bibliothèque googtrans // Chargement de la bibliothèque googtrans
// Le script de traduction est sélectionné // Le script de traduction est sélectionné
if ($this->getData(['config', 'i18n', 'enable']) === true) { if ($this->getData(['config', 'i18n', 'enable']) === true) {
// Trad auto
if ( $this->getData(['config', 'i18n','scriptGoogle']) === true if ( $this->getData(['config', 'i18n','scriptGoogle']) === true
// et la traduction de la langue courante est automatique // et la traduction de la langue courante est automatique
AND ( $this->getInput('ZWII_I18N_SCRIPT') !== '' AND ( $this->getInput('ZWII_I18N_SCRIPT') !== ''
// Ou traduction automatique // Ou traduction automatique
OR $this->getData(['config', 'i18n','autoDetect']) === true OR $this->getData(['config', 'i18n','autoDetect']) === true
) )
// Le cookie est accepté par le client // Cas des pages d'administration
AND $this->getInput('ZWII_COOKIE_GT_CONSENT') === $_SERVER['PHP_SELF'] // Pas connecté
// Cas des pages d'administration AND $this->getUser('password') !== $this->getInput('ZWII_USER_PASSWORD')
// Pas connecté AND $this->getUrl(1) !== 'login'
AND $this->getUser('password') !== $this->getInput('ZWII_USER_PASSWORD') // Ou connecté avec option active
AND $this->getUrl(1) !== 'login' OR ($this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD')
// Ou connecté avec option active AND $this->getData(['config', 'i18n','admin']) === true
OR ($this->getUser('password') === $this->getInput('ZWII_USER_PASSWORD') )
AND $this->getData(['config', 'i18n','admin']) === true
)
) { ) {
// Paramètre du script // Paramètre du script
setrawcookie("googtrans", '/fr/'. $this->getInput('ZWII_I18N_SCRIPT') , time() + 3600, helper::baseUrl()); setrawcookie("googtrans", '/fr/'. $this->getInput('ZWII_I18N_SCRIPT') , time() + 3600, helper::baseUrl());
// Chargement de la librairie // Chargement de la librairie
$this->addOutput([ $this->addOutput([
'vendor' => array_merge($this->output['vendor'], ['i18n']) 'vendor' => array_merge($this->output['vendor'], ['i18n'])
]); ]);
}
}
} }
// Erreurs // Erreurs
if($access === 'login') { if($access === 'login') {

View File

@ -707,7 +707,6 @@ if ($this->getData(['core', 'dataVersion']) < 11200) {
$this->setData(['locale', 'cookies', 'cookieTitleText', 'Gérer les cookies']); $this->setData(['locale', 'cookies', 'cookieTitleText', 'Gérer les cookies']);
$this->setData(['locale', 'cookies', 'cookieLinkMlText', 'Consulter les mentions légales']); $this->setData(['locale', 'cookies', 'cookieLinkMlText', 'Consulter les mentions légales']);
$this->setData(['locale', 'cookies', 'cookieCheckboxGaText', 'Autorisation des cookies Google Analytics']); $this->setData(['locale', 'cookies', 'cookieCheckboxGaText', 'Autorisation des cookies Google Analytics']);
$this->setData(['locale', 'cookies', 'cookieCheckboxGtText', 'Autorisation des cookies Google Translate']);
$this->setData(['locale', 'cookies', 'cookiesButtonText', 'J\'ai compris']); $this->setData(['locale', 'cookies', 'cookiesButtonText', 'J\'ai compris']);
// Mise à jour // Mise à jour

View File

@ -445,7 +445,6 @@ class config extends common {
'cookiesTitleText' => $this->getInput('localeCookiesTitleText', helper::FILTER_STRING_SHORT, $this->getData(['config', 'cookieConsent'])), 'cookiesTitleText' => $this->getInput('localeCookiesTitleText', helper::FILTER_STRING_SHORT, $this->getData(['config', 'cookieConsent'])),
'cookiesLinkMlText' => $this->getInput('localeCookiesLinkMlText', helper::FILTER_STRING_SHORT, $this->getData(['config', 'cookieConsent'])), 'cookiesLinkMlText' => $this->getInput('localeCookiesLinkMlText', helper::FILTER_STRING_SHORT, $this->getData(['config', 'cookieConsent'])),
'cookiesCheckboxGaText' => $this->getInput('localeCookiesCheckboxGaText', helper::FILTER_STRING_SHORT, $this->getData(['config', 'cookieConsent'])), 'cookiesCheckboxGaText' => $this->getInput('localeCookiesCheckboxGaText', helper::FILTER_STRING_SHORT, $this->getData(['config', 'cookieConsent'])),
'cookiesCheckboxGtText' => $this->getInput('localeCookiesCheckboxGtText', helper::FILTER_STRING_SHORT, $this->getData(['config', 'cookieConsent'])),
'cookiesFooterText' => $this->getInput('localeCookiesFooterText', helper::FILTER_STRING_SHORT, $this->getData(['config', 'cookieConsent'])), 'cookiesFooterText' => $this->getInput('localeCookiesFooterText', helper::FILTER_STRING_SHORT, $this->getData(['config', 'cookieConsent'])),
'cookiesButtonText' =>$this->getInput('localeCookiesButtonText', helper::FILTER_STRING_SHORT, $this->getData(['config', 'cookieConsent'])) 'cookiesButtonText' =>$this->getInput('localeCookiesButtonText', helper::FILTER_STRING_SHORT, $this->getData(['config', 'cookieConsent']))
] ]

View File

@ -200,30 +200,19 @@
<div class="col8"> <div class="col8">
<?php echo template::textarea('localeCookiesGaText', [ <?php echo template::textarea('localeCookiesGaText', [
'help' => 'Saisissez le message pour les cookies déposés par Google Analytics, le consentement est requis.', 'help' => 'Saisissez le message pour les cookies déposés par Google Analytics, le consentement est requis.',
'label' => 'Cookies Google Analytics et Translate', 'label' => 'Cookies Google Analytics',
'value' => $this->getData(['locale', 'cookies', 'cookiesGaText']), 'value' => $this->getData(['locale', 'cookies', 'cookiesGaText']),
'placeHolder' => 'Il utilise également des cookies permettant de réaliser des statistiques de visites pour améliorer votre expérience utilisateur, ces cookies déposés par Google Analytics ont besoin de votre consentement.' 'placeHolder' => 'Il utilise également des cookies permettant de réaliser des statistiques de visites pour améliorer votre expérience utilisateur, ces cookies déposés par Google Analytics ont besoin de votre consentement.'
]); ?> ]); ?>
</div> </div>
<div class="col4"> <div class="col4">
<div class="row"> <?php echo template::text('localeCookiesCheckboxGaText', [
<div class="col12"> 'help' => 'Saisissez le texte de la case à cocher Google Analytics.',
<?php echo template::text('localeCookiesCheckboxGaText', [ 'label' => 'Checkbox Google Analytics',
'help' => 'Saisissez le texte de la case à cocher Google Analytics.', 'value' => $this->getData(['locale', 'cookies', 'cookiesCheckboxGaText']),
'label' => 'Checkbox Google Analytics', 'placeHolder' => 'Autorisation des cookies Google Analytics'
'value' => $this->getData(['locale', 'cookies', 'cookiesCheckboxGaText']), ]); ?>
'placeHolder' => 'Autorisation des cookies Google Analytics'
]); ?>
</div>
<div class="col12">
<?php echo template::text('localeCookiesCheckboxGtText', [
'help' => 'Saisissez le texte de la case à cocher Google Translate.',
'label' => 'Checkbox Google Translate',
'value' => $this->getData(['locale', 'cookies', 'cookiesCheckboxGtText']),
'placeHolder' => 'Autorisation des cookies Google Translate'
]); ?>
</div>
</div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">

View File

@ -80,7 +80,6 @@ class init extends common {
'cookiesTitleText' => 'Gérer les cookies', 'cookiesTitleText' => 'Gérer les cookies',
'cookiesLinkMlText' => 'Consulter les mentions légales', 'cookiesLinkMlText' => 'Consulter les mentions légales',
'cookiesCheckboxGaText' => 'Autorisation des cookies Google Analytics', 'cookiesCheckboxGaText' => 'Autorisation des cookies Google Analytics',
'cookiesCheckboxGtText' => 'Autorisation des cookies Google Translate',
'cookiesFooterText' => 'Confidentialité', 'cookiesFooterText' => 'Confidentialité',
'cookiesButtonText' => 'J\'ai compris' 'cookiesButtonText' => 'J\'ai compris'
] ]