From 7317f064d8c0e9013b22d70d5c7671a0cc872e19 Mon Sep 17 00:00:00 2001 From: aeberhard Date: Thu, 16 Feb 2023 21:42:00 +0100 Subject: [PATCH] Version 4.0.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Beim Button **Alles ablehnen** die notwendigen Dienste setzen statt "leer", Ausgabe auch im Consent-Log * Cookies mit www löschen, behebt evtl. #284 @alxndr-w * Fragment `consent_manager_box.php`: Link **Details anzeigen** um `href=#` erweitert, Click-Ereignisse mit return false in `consent_manager_frontend.js` * Fix #286 - Link Datenschutzerklärung nicht lokalisiert @clausbde * removed .php-cs-fixer.dist.php --- .php-cs-fixer.dist.php | 69 -------------------------- CHANGELOG.md | 10 ++++ assets/consent_manager_frontend.js | 22 ++++++++ assets/consent_manager_frontend.min.js | 2 +- fragments/consent_manager_box.php | 2 +- lib/consent_manager_frontend.php | 2 +- package.yml | 2 +- 7 files changed, 36 insertions(+), 73 deletions(-) delete mode 100644 .php-cs-fixer.dist.php diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php deleted file mode 100644 index 175b3d6..0000000 --- a/.php-cs-fixer.dist.php +++ /dev/null @@ -1,69 +0,0 @@ -in([__DIR__]); - -return (new PhpCsFixer\Config()) - ->setUsingCache(true) - ->setRiskyAllowed(true) - ->setRules([ - '@Symfony' => true, - '@Symfony:risky' => false, - '@PHP73Migration' => true, - '@PHP71Migration:risky' => false, - '@PHPUnit84Migration:risky' => false, - 'array_indentation' => true, - 'blank_line_before_statement' => false, - 'braces' => ['allow_single_line_closure' => false], - 'comment_to_phpdoc' => true, - 'concat_space' => false, - 'declare_strict_types' => false, - 'echo_tag_syntax' => false, - 'empty_loop_condition' => false, - 'global_namespace_import' => [ - 'import_constants' => true, - 'import_functions' => true, - 'import_classes' => true, - ], - 'heredoc_to_nowdoc' => true, - 'list_syntax' => ['syntax' => 'short'], - 'method_argument_space' => ['on_multiline' => 'ignore'], - 'native_constant_invocation' => false, - 'no_alternative_syntax' => false, - 'no_blank_lines_after_phpdoc' => false, - 'no_null_property_initialization' => true, - 'no_superfluous_elseif' => true, - 'no_unreachable_default_argument_value' => true, - 'no_useless_else' => true, - 'no_useless_return' => true, - 'ordered_class_elements' => ['order' => [ - 'use_trait', - 'constant_public', - 'constant_protected', - 'constant_private', - 'property', - 'construct', - 'phpunit', - 'method', - ]], - /*'ordered_imports' => ['imports_order' => [ - OrderedImportsFixer::IMPORT_TYPE_CLASS, - OrderedImportsFixer::IMPORT_TYPE_CONST, - OrderedImportsFixer::IMPORT_TYPE_FUNCTION, - ]],*/ - 'php_unit_internal_class' => true, - 'php_unit_test_case_static_method_calls' => true, - 'phpdoc_align' => false, - 'phpdoc_no_package' => false, - 'phpdoc_order' => true, - 'phpdoc_separation' => false, - 'phpdoc_to_comment' => false, - 'phpdoc_types_order' => false, - 'phpdoc_var_annotation_correct_order' => true, - 'psr_autoloading' => false, - 'semicolon_after_instruction' => false, - 'static_lambda' => true, - 'void_return' => false, - ]) - ->setFinder($finder) -; diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fa887a..6ad9d97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # REDAXO consent_manager - Changelog +## Version 4.0.1 – 16.02.2023 + +### Bugfixes + +* Beim Button **Alles ablehnen** die notwendigen Dienste setzen statt "leer", Ausgabe auch im Consent-Log +* Cookies mit www löschen, behebt evtl. #284 @alxndr-w +* Fragment `consent_manager_box.php`: Link **Details anzeigen** um `href=#` erweitert, Click-Ereignisse mit return false in `consent_manager_frontend.js` +* Fix #286 - Link Datenschutzerklärung nicht lokalisiert @clausbde +* removed .php-cs-fixer.dist.php + ## Version 4.0.0 – 20.01.2023 ### Breaking Changes diff --git a/assets/consent_manager_frontend.js b/assets/consent_manager_frontend.js index e07c81f..b05e97c 100644 --- a/assets/consent_manager_frontend.js +++ b/assets/consent_manager_frontend.js @@ -91,12 +91,14 @@ document.querySelector('body').style.overflow = 'auto'; } document.getElementById('consent_manager-background').classList.add('consent_manager-hidden'); + return false; }); }); if (document.getElementById('consent_manager-toggle-details')) { document.getElementById('consent_manager-toggle-details').addEventListener('click', function () { document.getElementById('consent_manager-detail').classList.toggle('consent_manager-hidden'); + return false; }); } @@ -104,6 +106,7 @@ document.getElementById('consent_manager-toggle-details').addEventListener('keydown', function (event) { if (event.key == 'Enter') { document.getElementById('consent_manager-detail').classList.toggle('consent_manager-hidden'); + return false; } }); } @@ -111,6 +114,7 @@ document.querySelectorAll('.consent_manager-show-box, .consent_manager-show-box-reload').forEach(function (el) { el.addEventListener('click', function () { showBox(); + return false; }); }); @@ -138,6 +142,22 @@ }); } }); + } else { + consent_managerBox.querySelectorAll('[data-cookie-uids]').forEach(function (el) { + // array mit cookie uids + var cookieUids = JSON.parse(el.getAttribute('data-cookie-uids')); + if (el.disabled) { + cookieUids.forEach(function (uid) { + consents.push(uid); + addScript(consent_managerBox.querySelector('[data-uid="script-' + uid + '"]')); + }); + } else { + el.checked = false; + cookieUids.forEach(function (uid) { + removeScript(consent_managerBox.querySelector('[data-uid="script-' + uid + '"]')); + }); + } + }); } cookieData.consents = consents; Cookies.set('consent_manager', JSON.stringify(cookieData), { expires: expires, path: '/', domain: consent_manager_parameters.domain, sameSite: 'Lax', secure: false }); @@ -165,6 +185,8 @@ Cookies.remove(encodeURIComponent(key), { 'domain': domain, 'path': '/' }); Cookies.remove(encodeURIComponent(key), { 'domain': ('.' + domain) }); Cookies.remove(encodeURIComponent(key), { 'domain': ('.' + domain), 'path': '/' }); + Cookies.remove(encodeURIComponent(key), { 'domain': ('www.' + domain) }); + Cookies.remove(encodeURIComponent(key), { 'domain': ('www.' + domain), 'path': '/' }); } } diff --git a/assets/consent_manager_frontend.min.js b/assets/consent_manager_frontend.min.js index 7c06a00..98ca0d9 100644 --- a/assets/consent_manager_frontend.min.js +++ b/assets/consent_manager_frontend.min.js @@ -1 +1 @@ -function consent_manager_showBox() { var o = []; void 0 !== Cookies.get("consent_manager") && (cookieData = JSON.parse(Cookies.get("consent_manager")), cookieData.hasOwnProperty("version") && (o = cookieData.consents)), consent_managerBox = document.getElementById("consent_manager-background"), consent_managerBox.querySelectorAll("[data-cookie-uids]").forEach(function (e) { var n = !0; JSON.parse(e.getAttribute("data-cookie-uids")).forEach(function (e) { -1 === o.indexOf(e) && (n = !1) }), n && (e.checked = !0) }), consent_manager_parameters.hidebodyscrollbar && (document.querySelector("body").style.overflow = "hidden"), document.getElementById("consent_manager-background").classList.remove("consent_manager-hidden"); var e = consent_managerBox.querySelectorAll('input[type="checkbox"]')[0]; consent_managerBox.focus(), e && e.focus() } function consent_manager_hasconsent(e) { return void 0 !== Cookies.get("consent_manager") && -1 !== JSON.parse(Cookies.get("consent_manager")).consents.indexOf(e) } !function () { "use strict"; var a, e, r, c = new Date, n = 0, s = {}, i = [], o = -1, t = -1; function d(o) { i = [], s = { consents: [], version: a, consentid: consent_manager_parameters.consentid, cachelogid: consent_manager_parameters.cachelogid }, "none" !== o && r.querySelectorAll("[data-cookie-uids]").forEach(function (e) { var n = JSON.parse(e.getAttribute("data-cookie-uids")); e.checked || "all" === o ? n.forEach(function (e) { i.push(e), l(r.querySelector('[data-uid="script-' + e + '"]')) }) : n.forEach(function (e) { (e = r.querySelector('[data-uid="script-' + e + '"]')) && (e.innerHTML = "") }) }), s.consents = i, Cookies.set("consent_manager", JSON.stringify(s), { expires: c, path: "/", domain: consent_manager_parameters.domain, sameSite: "Lax", secure: !1 }); var e = new XMLHttpRequest, n = consent_manager_parameters.fe_controller + "?rex-api-call=consent_manager", t = "domain=" + consent_manager_parameters.domain + "&consentid=" + consent_manager_parameters.consentid; e.open("POST", n, !1), e.setRequestHeader("Content-type", "application/x-www-form-urlencoded"), e.send(t), document.querySelectorAll(".consent_manager-show-box-reload").length || 1 === consent_manager_parameters.forcereload ? location.reload() : document.dispatchEvent(new CustomEvent("consent_manager-saved", { detail: JSON.stringify(i) })) } function m() { var e, n = consent_manager_parameters.domain; for (e in Cookies.get()) Cookies.remove(encodeURIComponent(e)), Cookies.remove(encodeURIComponent(e), { domain: n }), Cookies.remove(encodeURIComponent(e), { path: "/" }), Cookies.remove(encodeURIComponent(e), { domain: n, path: "/" }), Cookies.remove(encodeURIComponent(e), { domain: "." + n }), Cookies.remove(encodeURIComponent(e), { domain: "." + n, path: "/" }) } function l(e) { var n; if (e && !e.children.length) { n = (new DOMParser).parseFromString(window.atob(e.getAttribute("data-script")), "text/html"); for (var o = 0; o < n.scripts.length; o++) { var t = document.createElement("script"); n.scripts[o].src ? t.src = n.scripts[o].src : t.innerHTML = n.scripts[o].innerHTML, e.appendChild(t) } } } function g() { r.querySelectorAll("[data-cookie-uids]").forEach(function (e) { var n = !0; JSON.parse(e.getAttribute("data-cookie-uids")).forEach(function (e) { -1 === i.indexOf(e) && (n = !1) }), n && (e.checked = !0) }), consent_manager_parameters.hidebodyscrollbar && (document.querySelector("body").style.overflow = "hidden"), document.getElementById("consent_manager-background").classList.remove("consent_manager-hidden"); var e = r.querySelectorAll('input[type="checkbox"]')[0]; r.focus(), e && e.focus() } c.setFullYear(c.getFullYear() + 1), void 0 === Cookies.get("consent_manager") ? (n = 1, Cookies.set("test", "test", { path: "/", sameSite: "Lax", secure: !1 }), void 0 === Cookies.get("test") ? n = 0 : Cookies.remove("test")) : (s = JSON.parse(Cookies.get("consent_manager"))).hasOwnProperty("version") && (i = s.consents, o = parseInt(s.version), t = parseInt(s.cachelogid)), "" !== consent_manager_box_template ? (r = (r = (new DOMParser).parseFromString(consent_manager_box_template, "text/html")).getElementById("consent_manager-background"), document.querySelectorAll("body")[0].appendChild(r), a = parseInt(consent_manager_parameters.version), e = parseInt(consent_manager_parameters.cachelogid), a === o && e === t || (n = 1, i = [], m()), 9 === consent_managerIEVersion() && r.querySelectorAll(".consent_manager-cookiegroup-checkbox").forEach(function (e) { e.classList.remove("pretty"), e.querySelectorAll(".icon").forEach(function (e) { e.remove() }) }), i.forEach(function (e) { l(r.querySelector('[data-uid="script-' + e + '"]')) }), consent_manager_parameters.initially_hidden && (n = 0), n && g(), r.querySelectorAll(".consent_manager-close").forEach(function (e) { e.addEventListener("click", function () { e.classList.contains("consent_manager-save-selection") ? (m(), d("selection")) : e.classList.contains("consent_manager-accept-all") ? (m(), d("all")) : e.classList.contains("consent_manager-accept-none") ? (m(), d("none")) : e.classList.contains("consent_manager-close") && (document.getElementById("consent_manager-detail").classList.contains("consent_manager-hidden") || document.getElementById("consent_manager-detail").classList.toggle("consent_manager-hidden")), consent_manager_parameters.hidebodyscrollbar && (document.querySelector("body").style.overflow = "auto"), document.getElementById("consent_manager-background").classList.add("consent_manager-hidden") }) }), document.getElementById("consent_manager-toggle-details") && document.getElementById("consent_manager-toggle-details").addEventListener("click", function () { document.getElementById("consent_manager-detail").classList.toggle("consent_manager-hidden") }), document.getElementById("consent_manager-toggle-details") && document.getElementById("consent_manager-toggle-details").addEventListener("keydown", function (e) { "Enter" == e.key && document.getElementById("consent_manager-detail").classList.toggle("consent_manager-hidden") }), document.querySelectorAll(".consent_manager-show-box, .consent_manager-show-box-reload").forEach(function (e) { e.addEventListener("click", function () { g() }) })) : console.warn("Addon consent_manager: Keine Cookie-Gruppen / Cookies ausgewählt bzw. keine Domain zugewiesen! (" + location.hostname + ")") }(); \ No newline at end of file +function consent_manager_showBox() { var o = []; void 0 !== Cookies.get("consent_manager") && (cookieData = JSON.parse(Cookies.get("consent_manager")), cookieData.hasOwnProperty("version") && (o = cookieData.consents)), consent_managerBox = document.getElementById("consent_manager-background"), consent_managerBox.querySelectorAll("[data-cookie-uids]").forEach(function (e) { var n = !0; JSON.parse(e.getAttribute("data-cookie-uids")).forEach(function (e) { -1 === o.indexOf(e) && (n = !1) }), n && (e.checked = !0) }), consent_manager_parameters.hidebodyscrollbar && (document.querySelector("body").style.overflow = "hidden"), document.getElementById("consent_manager-background").classList.remove("consent_manager-hidden"); var e = consent_managerBox.querySelectorAll('input[type="checkbox"]')[0]; consent_managerBox.focus(), e && e.focus() } function consent_manager_hasconsent(e) { return void 0 !== Cookies.get("consent_manager") && -1 !== JSON.parse(Cookies.get("consent_manager")).consents.indexOf(e) } !function () { "use strict"; var a, e, r, c = new Date, n = 0, s = {}, i = [], o = -1, t = -1; function d(o) { i = [], s = { consents: [], version: a, consentid: consent_manager_parameters.consentid, cachelogid: consent_manager_parameters.cachelogid }, "none" !== o ? r.querySelectorAll("[data-cookie-uids]").forEach(function (e) { var n = JSON.parse(e.getAttribute("data-cookie-uids")); e.checked || "all" === o ? n.forEach(function (e) { i.push(e), l(r.querySelector('[data-uid="script-' + e + '"]')) }) : n.forEach(function (e) { g(r.querySelector('[data-uid="script-' + e + '"]')) }) }) : r.querySelectorAll("[data-cookie-uids]").forEach(function (e) { var n = JSON.parse(e.getAttribute("data-cookie-uids")); e.disabled ? n.forEach(function (e) { i.push(e), l(r.querySelector('[data-uid="script-' + e + '"]')) }) : (e.checked = !1, n.forEach(function (e) { g(r.querySelector('[data-uid="script-' + e + '"]')) })) }), s.consents = i, Cookies.set("consent_manager", JSON.stringify(s), { expires: c, path: "/", domain: consent_manager_parameters.domain, sameSite: "Lax", secure: !1 }); var e = new XMLHttpRequest, n = consent_manager_parameters.fe_controller + "?rex-api-call=consent_manager", t = "domain=" + consent_manager_parameters.domain + "&consentid=" + consent_manager_parameters.consentid; e.open("POST", n, !1), e.setRequestHeader("Content-type", "application/x-www-form-urlencoded"), e.send(t), document.querySelectorAll(".consent_manager-show-box-reload").length || 1 === consent_manager_parameters.forcereload ? location.reload() : document.dispatchEvent(new CustomEvent("consent_manager-saved", { detail: JSON.stringify(i) })) } function m() { var e, n = consent_manager_parameters.domain; for (e in Cookies.get()) Cookies.remove(encodeURIComponent(e)), Cookies.remove(encodeURIComponent(e), { domain: n }), Cookies.remove(encodeURIComponent(e), { path: "/" }), Cookies.remove(encodeURIComponent(e), { domain: n, path: "/" }), Cookies.remove(encodeURIComponent(e), { domain: "." + n }), Cookies.remove(encodeURIComponent(e), { domain: "." + n, path: "/" }), Cookies.remove(encodeURIComponent(e), { domain: "www." + n }), Cookies.remove(encodeURIComponent(e), { domain: "www." + n, path: "/" }) } function l(e) { var n; if (e && !e.children.length) { n = (new DOMParser).parseFromString(window.atob(e.getAttribute("data-script")), "text/html"); for (var o = 0; o < n.scripts.length; o++) { var t = document.createElement("script"); n.scripts[o].src ? t.src = n.scripts[o].src : t.innerHTML = n.scripts[o].innerHTML, e.appendChild(t) } } } function g(e) { e && (e.innerHTML = "") } function u() { r.querySelectorAll("[data-cookie-uids]").forEach(function (e) { var n = !0; JSON.parse(e.getAttribute("data-cookie-uids")).forEach(function (e) { -1 === i.indexOf(e) && (n = !1) }), n && (e.checked = !0) }), consent_manager_parameters.hidebodyscrollbar && (document.querySelector("body").style.overflow = "hidden"), document.getElementById("consent_manager-background").classList.remove("consent_manager-hidden"); var e = r.querySelectorAll('input[type="checkbox"]')[0]; r.focus(), e && e.focus() } c.setFullYear(c.getFullYear() + 1), void 0 === Cookies.get("consent_manager") ? (n = 1, Cookies.set("test", "test", { path: "/", sameSite: "Lax", secure: !1 }), void 0 === Cookies.get("test") ? n = 0 : Cookies.remove("test")) : (s = JSON.parse(Cookies.get("consent_manager"))).hasOwnProperty("version") && (i = s.consents, o = parseInt(s.version), t = parseInt(s.cachelogid)), "" !== consent_manager_box_template ? (r = (r = (new DOMParser).parseFromString(consent_manager_box_template, "text/html")).getElementById("consent_manager-background"), document.querySelectorAll("body")[0].appendChild(r), a = parseInt(consent_manager_parameters.version), e = parseInt(consent_manager_parameters.cachelogid), a === o && e === t || (n = 1, i = [], m()), 9 === consent_managerIEVersion() && r.querySelectorAll(".consent_manager-cookiegroup-checkbox").forEach(function (e) { e.classList.remove("pretty"), e.querySelectorAll(".icon").forEach(function (e) { e.remove() }) }), i.forEach(function (e) { l(r.querySelector('[data-uid="script-' + e + '"]')) }), consent_manager_parameters.initially_hidden && (n = 0), n && u(), r.querySelectorAll(".consent_manager-close").forEach(function (e) { e.addEventListener("click", function () { return e.classList.contains("consent_manager-save-selection") ? (m(), d("selection")) : e.classList.contains("consent_manager-accept-all") ? (m(), d("all")) : e.classList.contains("consent_manager-accept-none") ? (m(), d("none")) : e.classList.contains("consent_manager-close") && (document.getElementById("consent_manager-detail").classList.contains("consent_manager-hidden") || document.getElementById("consent_manager-detail").classList.toggle("consent_manager-hidden")), consent_manager_parameters.hidebodyscrollbar && (document.querySelector("body").style.overflow = "auto"), document.getElementById("consent_manager-background").classList.add("consent_manager-hidden"), !1 }) }), document.getElementById("consent_manager-toggle-details") && document.getElementById("consent_manager-toggle-details").addEventListener("click", function () { return document.getElementById("consent_manager-detail").classList.toggle("consent_manager-hidden"), !1 }), document.getElementById("consent_manager-toggle-details") && document.getElementById("consent_manager-toggle-details").addEventListener("keydown", function (e) { if ("Enter" == e.key) return document.getElementById("consent_manager-detail").classList.toggle("consent_manager-hidden"), !1 }), document.querySelectorAll(".consent_manager-show-box, .consent_manager-show-box-reload").forEach(function (e) { e.addEventListener("click", function () { return u(), !1 }) })) : console.warn("Addon consent_manager: Keine Cookie-Gruppen / Cookies ausgewählt bzw. keine Domain zugewiesen! (" + location.hostname + ")") }(); \ No newline at end of file diff --git a/fragments/consent_manager_box.php b/fragments/consent_manager_box.php index 7490f43..1fa5c0b 100644 --- a/fragments/consent_manager_box.php +++ b/fragments/consent_manager_box.php @@ -33,7 +33,7 @@ ?>