Initial commit
- Functional module
This commit is contained in:
227
views/css/gdpr_cookie.css
Normal file
227
views/css/gdpr_cookie.css
Normal file
@ -0,0 +1,227 @@
|
||||
/**
|
||||
* GDPR Cookie Consent Module for PrestaShop
|
||||
*
|
||||
* @author Walzen665
|
||||
* @copyright Copyright (c) 2025
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
*/
|
||||
|
||||
/* Banner styles */
|
||||
.gdpr-cookie-banner {
|
||||
display: none;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background-color: rgba(33, 41, 52, 0.95);
|
||||
color: #fff;
|
||||
padding: 15px;
|
||||
z-index: 9999;
|
||||
box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.gdpr-cookie-banner-content {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.gdpr-cookie-banner-content p {
|
||||
flex: 1;
|
||||
margin: 0 20px 10px 0;
|
||||
font-size: 14px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.gdpr-cookie-banner-buttons {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
/* Modal styles */
|
||||
.gdpr-cookie-modal {
|
||||
display: none;
|
||||
position: fixed;
|
||||
z-index: 10000;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.gdpr-cookie-modal-content {
|
||||
background-color: #fff;
|
||||
margin: 5% auto;
|
||||
padding: 20px;
|
||||
border-radius: 5px;
|
||||
width: 90%;
|
||||
max-width: 800px;
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
||||
max-height: 80vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.gdpr-cookie-modal-header {
|
||||
border-bottom: 1px solid #e5e5e5;
|
||||
margin-bottom: 15px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
.gdpr-cookie-modal-header h4 {
|
||||
margin: 0;
|
||||
color: #333;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.gdpr-cookie-modal-body {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.gdpr-cookie-categories {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.gdpr-cookie-category {
|
||||
margin-bottom: 15px;
|
||||
padding: 10px;
|
||||
border: 1px solid #eee;
|
||||
border-radius: 5px;
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
|
||||
.gdpr-cookie-category label {
|
||||
font-weight: bold;
|
||||
display: inline-block;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
.gdpr-cookie-category p {
|
||||
margin-top: 5px;
|
||||
margin-bottom: 0;
|
||||
font-size: 13px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.gdpr-cookie-modal-footer {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
border-top: 1px solid #e5e5e5;
|
||||
padding-top: 15px;
|
||||
}
|
||||
|
||||
.gdpr-cookie-more-info {
|
||||
color: #555;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.gdpr-cookie-buttons {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
/* Button styles */
|
||||
.gdpr-cookie-decline,
|
||||
.gdpr-cookie-banner-decline {
|
||||
background-color: #f1f1f1;
|
||||
color: #333;
|
||||
border: none;
|
||||
padding: 8px 15px;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
border-radius: 3px;
|
||||
transition: background-color 0.3s;
|
||||
}
|
||||
|
||||
.gdpr-cookie-decline:hover,
|
||||
.gdpr-cookie-banner-decline:hover {
|
||||
background-color: #ddd;
|
||||
}
|
||||
|
||||
.gdpr-cookie-accept-selected {
|
||||
background-color: #4285f4;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 8px 15px;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
border-radius: 3px;
|
||||
transition: background-color 0.3s;
|
||||
}
|
||||
|
||||
.gdpr-cookie-accept-selected:hover {
|
||||
background-color: #2b6edb;
|
||||
}
|
||||
|
||||
.gdpr-cookie-accept-all,
|
||||
.gdpr-cookie-banner-accept {
|
||||
background-color: #4caf50;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 8px 15px;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
border-radius: 3px;
|
||||
transition: background-color 0.3s;
|
||||
}
|
||||
|
||||
.gdpr-cookie-accept-all:hover,
|
||||
.gdpr-cookie-banner-accept:hover {
|
||||
background-color: #45a049;
|
||||
}
|
||||
|
||||
.gdpr-cookie-banner-settings {
|
||||
background-color: transparent;
|
||||
color: white;
|
||||
border: 1px solid white;
|
||||
padding: 8px 15px;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
border-radius: 3px;
|
||||
transition: background-color 0.3s;
|
||||
}
|
||||
|
||||
.gdpr-cookie-banner-settings:hover {
|
||||
background-color: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
/* Responsive adjustments */
|
||||
@media (max-width: 768px) {
|
||||
.gdpr-cookie-banner-content {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.gdpr-cookie-banner-content p {
|
||||
margin-right: 0;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.gdpr-cookie-modal-content {
|
||||
width: 95%;
|
||||
margin: 10% auto;
|
||||
}
|
||||
|
||||
.gdpr-cookie-modal-footer {
|
||||
flex-direction: column;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.gdpr-cookie-more-info {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
7
views/css/index.php
Normal file
7
views/css/index.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
header('Strict-Transport-Security: max-age=31536000; includeSubDomains');
|
||||
header("X-Content-Type-Options: nosniff");
|
||||
header("X-Frame-Options: DENY");
|
||||
header("X-XSS-Protection: 1; mode=block");
|
||||
header('Location: ../');
|
||||
exit;
|
7
views/index.php
Normal file
7
views/index.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
header('Strict-Transport-Security: max-age=31536000; includeSubDomains');
|
||||
header("X-Content-Type-Options: nosniff");
|
||||
header("X-Frame-Options: DENY");
|
||||
header("X-XSS-Protection: 1; mode=block");
|
||||
header('Location: ../');
|
||||
exit;
|
198
views/js/gdpr_cookie.js
Normal file
198
views/js/gdpr_cookie.js
Normal file
@ -0,0 +1,198 @@
|
||||
/**
|
||||
* GDPR Cookie Consent Module for PrestaShop
|
||||
*
|
||||
* @author Walzen665
|
||||
* @copyright Copyright (c) 2025
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
*/
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Cookie functions
|
||||
function setCookie(name, value, days) {
|
||||
var expires = '';
|
||||
if (days) {
|
||||
var date = new Date();
|
||||
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
|
||||
expires = '; expires=' + date.toUTCString();
|
||||
}
|
||||
document.cookie = name + '=' + (value || '') + expires + '; path=/; SameSite=Lax';
|
||||
}
|
||||
|
||||
function getCookie(name) {
|
||||
var nameEQ = name + '=';
|
||||
var ca = document.cookie.split(';');
|
||||
for (var i = 0; i < ca.length; i++) {
|
||||
var c = ca[i];
|
||||
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
|
||||
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Check if cookie consent is already set
|
||||
var cookieConsent = getCookie('gdpr_cookie_consent');
|
||||
|
||||
if (!cookieConsent) {
|
||||
// Show the cookie banner if consent is not set
|
||||
document.getElementById('gdpr-cookie-banner').style.display = 'block';
|
||||
} else {
|
||||
// Apply cookie preferences
|
||||
var consentPreferences = JSON.parse(cookieConsent);
|
||||
applyConsentPreferences(consentPreferences);
|
||||
}
|
||||
|
||||
// Banner buttons
|
||||
document.getElementById('gdpr-cookie-banner-accept').addEventListener('click', function() {
|
||||
acceptAllCookies();
|
||||
});
|
||||
|
||||
document.getElementById('gdpr-cookie-banner-decline').addEventListener('click', function() {
|
||||
declineAllCookies();
|
||||
});
|
||||
|
||||
document.getElementById('gdpr-cookie-banner-settings').addEventListener('click', function() {
|
||||
showModal();
|
||||
});
|
||||
|
||||
// Modal buttons
|
||||
document.getElementById('gdpr-cookie-accept-all').addEventListener('click', function() {
|
||||
acceptAllCookies();
|
||||
});
|
||||
|
||||
document.getElementById('gdpr-cookie-decline').addEventListener('click', function() {
|
||||
declineAllCookies();
|
||||
});
|
||||
|
||||
document.getElementById('gdpr-cookie-accept-selected').addEventListener('click', function() {
|
||||
acceptSelectedCookies();
|
||||
});
|
||||
|
||||
// Functions
|
||||
function showModal() {
|
||||
document.getElementById('gdpr-cookie-banner').style.display = 'none';
|
||||
document.getElementById('gdpr-cookie-modal').style.display = 'block';
|
||||
|
||||
// Load saved preferences if they exist
|
||||
var cookieConsent = getCookie('gdpr_cookie_consent');
|
||||
if (cookieConsent) {
|
||||
var preferences = JSON.parse(cookieConsent);
|
||||
|
||||
// Set checkboxes based on saved preferences
|
||||
document.querySelectorAll('.gdpr-cookie-checkbox').forEach(function(checkbox) {
|
||||
var category = checkbox.getAttribute('data-cookie-category');
|
||||
if (preferences[category]) {
|
||||
checkbox.checked = true;
|
||||
} else {
|
||||
checkbox.checked = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function hideModal() {
|
||||
document.getElementById('gdpr-cookie-modal').style.display = 'none';
|
||||
}
|
||||
|
||||
function acceptAllCookies() {
|
||||
var preferences = {
|
||||
necessary: true,
|
||||
functional: true,
|
||||
analytics: true,
|
||||
marketing: true
|
||||
};
|
||||
|
||||
setCookie('gdpr_cookie_consent', JSON.stringify(preferences), 365);
|
||||
applyConsentPreferences(preferences);
|
||||
hideModal();
|
||||
document.getElementById('gdpr-cookie-banner').style.display = 'none';
|
||||
}
|
||||
|
||||
function declineAllCookies() {
|
||||
var preferences = {
|
||||
necessary: true, // Necessary cookies are always accepted
|
||||
functional: false,
|
||||
analytics: false,
|
||||
marketing: false
|
||||
};
|
||||
|
||||
setCookie('gdpr_cookie_consent', JSON.stringify(preferences), 365);
|
||||
applyConsentPreferences(preferences);
|
||||
hideModal();
|
||||
document.getElementById('gdpr-cookie-banner').style.display = 'none';
|
||||
}
|
||||
|
||||
function acceptSelectedCookies() {
|
||||
var preferences = {
|
||||
necessary: true // Necessary cookies are always accepted
|
||||
};
|
||||
|
||||
// Get selected preferences
|
||||
document.querySelectorAll('.gdpr-cookie-checkbox').forEach(function(checkbox) {
|
||||
var category = checkbox.getAttribute('data-cookie-category');
|
||||
preferences[category] = checkbox.checked;
|
||||
});
|
||||
|
||||
setCookie('gdpr_cookie_consent', JSON.stringify(preferences), 365);
|
||||
applyConsentPreferences(preferences);
|
||||
hideModal();
|
||||
document.getElementById('gdpr-cookie-banner').style.display = 'none';
|
||||
}
|
||||
|
||||
function applyConsentPreferences(preferences) {
|
||||
// Example implementation
|
||||
// You would need to adapt this based on your specific cookie usage
|
||||
|
||||
// Functional cookies
|
||||
if (!preferences.functional) {
|
||||
// Disable functional cookies
|
||||
removeFunctionalCookies();
|
||||
}
|
||||
|
||||
// Analytics cookies
|
||||
if (!preferences.analytics) {
|
||||
// Disable analytics cookies (like Google Analytics)
|
||||
disableAnalytics();
|
||||
} else {
|
||||
// Enable analytics
|
||||
enableAnalytics();
|
||||
}
|
||||
|
||||
// Marketing cookies
|
||||
if (!preferences.marketing) {
|
||||
// Disable marketing cookies
|
||||
disableMarketing();
|
||||
} else {
|
||||
// Enable marketing
|
||||
enableMarketing();
|
||||
}
|
||||
}
|
||||
|
||||
// Helper functions to implement consent preferences
|
||||
function removeFunctionalCookies() {
|
||||
// This is just an example - implement based on your specific needs
|
||||
var functionalCookies = ['prefs', 'language', 'theme'];
|
||||
functionalCookies.forEach(function(cookie) {
|
||||
document.cookie = cookie + '=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
|
||||
});
|
||||
}
|
||||
|
||||
function disableAnalytics() {
|
||||
// Example: Disable Google Analytics
|
||||
window['ga-disable-UA-XXXXXXXX-X'] = true;
|
||||
}
|
||||
|
||||
function enableAnalytics() {
|
||||
// Example: Enable Google Analytics
|
||||
window['ga-disable-UA-XXXXXXXX-X'] = false;
|
||||
}
|
||||
|
||||
function disableMarketing() {
|
||||
// Example implementation
|
||||
// You would implement according to your specific marketing cookies
|
||||
}
|
||||
|
||||
function enableMarketing() {
|
||||
// Example implementation
|
||||
// You would implement according to your specific marketing cookies
|
||||
}
|
||||
});
|
7
views/js/index.php
Normal file
7
views/js/index.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
header('Strict-Transport-Security: max-age=31536000; includeSubDomains');
|
||||
header("X-Content-Type-Options: nosniff");
|
||||
header("X-Frame-Options: DENY");
|
||||
header("X-XSS-Protection: 1; mode=block");
|
||||
header('Location: ../');
|
||||
exit;
|
60
views/templates/hook/footer.tpl
Normal file
60
views/templates/hook/footer.tpl
Normal file
@ -0,0 +1,60 @@
|
||||
{*
|
||||
* GDPR Cookie Consent Module for PrestaShop
|
||||
*
|
||||
* @author Walzen665
|
||||
* @copyright Copyright (c) 2025
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
*}
|
||||
|
||||
<div id="gdpr-cookie-modal" class="gdpr-cookie-modal">
|
||||
<div class="gdpr-cookie-modal-content">
|
||||
<div class="gdpr-cookie-modal-header">
|
||||
<h4>{l s='Cookie Settings' mod='gdprcookieconsent'}</h4>
|
||||
</div>
|
||||
<div class="gdpr-cookie-modal-body">
|
||||
<p>{$gdprCookieMessage}</p>
|
||||
|
||||
<div class="gdpr-cookie-categories">
|
||||
<div class="gdpr-cookie-category">
|
||||
<input type="checkbox" id="gdpr-cookie-necessary" checked disabled>
|
||||
<label for="gdpr-cookie-necessary">{l s='Necessary' mod='gdprcookieconsent'}</label>
|
||||
<p>{l s='Necessary cookies help make a website usable by enabling basic functions like page navigation. The website cannot function properly without these cookies.' mod='gdprcookieconsent'}</p>
|
||||
</div>
|
||||
<div class="gdpr-cookie-category">
|
||||
<input type="checkbox" id="gdpr-cookie-functional" class="gdpr-cookie-checkbox" data-cookie-category="functional">
|
||||
<label for="gdpr-cookie-functional">{l s='Functional' mod='gdprcookieconsent'}</label>
|
||||
<p>{l s='Functional cookies enable a website to remember information that changes the way the website behaves or looks, like your preferred language or the region you are in.' mod='gdprcookieconsent'}</p>
|
||||
</div>
|
||||
<div class="gdpr-cookie-category">
|
||||
<input type="checkbox" id="gdpr-cookie-analytics" class="gdpr-cookie-checkbox" data-cookie-category="analytics">
|
||||
<label for="gdpr-cookie-analytics">{l s='Analytics' mod='gdprcookieconsent'}</label>
|
||||
<p>{l s='Analytics cookies help website owners understand how visitors interact with websites by collecting and reporting information anonymously.' mod='gdprcookieconsent'}</p>
|
||||
</div>
|
||||
<div class="gdpr-cookie-category">
|
||||
<input type="checkbox" id="gdpr-cookie-marketing" class="gdpr-cookie-checkbox" data-cookie-category="marketing">
|
||||
<label for="gdpr-cookie-marketing">{l s='Marketing' mod='gdprcookieconsent'}</label>
|
||||
<p>{l s='Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user.' mod='gdprcookieconsent'}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gdpr-cookie-modal-footer">
|
||||
<a href="{$gdprCookieMoreInfoUrl}" class="gdpr-cookie-more-info">{$gdprCookieMoreInfo}</a>
|
||||
<div class="gdpr-cookie-buttons">
|
||||
<button id="gdpr-cookie-decline" class="gdpr-cookie-decline">{$gdprCookieDecline}</button>
|
||||
<button id="gdpr-cookie-accept-selected" class="gdpr-cookie-accept-selected">{l s='Accept Selected' mod='gdprcookieconsent'}</button>
|
||||
<button id="gdpr-cookie-accept-all" class="gdpr-cookie-accept-all">{$gdprCookieAccept}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="gdpr-cookie-banner" class="gdpr-cookie-banner">
|
||||
<div class="gdpr-cookie-banner-content">
|
||||
<p>{$gdprCookieMessage}</p>
|
||||
<div class="gdpr-cookie-banner-buttons">
|
||||
<button id="gdpr-cookie-banner-decline" class="gdpr-cookie-banner-decline">{$gdprCookieDecline}</button>
|
||||
<button id="gdpr-cookie-banner-settings" class="gdpr-cookie-banner-settings">{$gdprCookieSettings}</button>
|
||||
<button id="gdpr-cookie-banner-accept" class="gdpr-cookie-banner-accept">{$gdprCookieAccept}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
7
views/templates/hook/index.php
Normal file
7
views/templates/hook/index.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
header('Strict-Transport-Security: max-age=31536000; includeSubDomains');
|
||||
header("X-Content-Type-Options: nosniff");
|
||||
header("X-Frame-Options: DENY");
|
||||
header("X-XSS-Protection: 1; mode=block");
|
||||
header('Location: ../');
|
||||
exit;
|
7
views/templates/index.php
Normal file
7
views/templates/index.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
header('Strict-Transport-Security: max-age=31536000; includeSubDomains');
|
||||
header("X-Content-Type-Options: nosniff");
|
||||
header("X-Frame-Options: DENY");
|
||||
header("X-XSS-Protection: 1; mode=block");
|
||||
header('Location: ../');
|
||||
exit;
|
Reference in New Issue
Block a user