ltsecurityinc安防产品在线商城代码

This commit is contained in:
2026-09-14 17:47:10 +08:00
parent 57d8444c15
commit 6a3c9c5bd8
14539 changed files with 1775310 additions and 0 deletions
@@ -0,0 +1,27 @@
<?php
/**
* Plumrocket Inc.
*
* NOTICE OF LICENSE
*
* This source file is subject to the End-user License Agreement
* that is available through the world-wide-web at this URL:
* http://wiki.plumrocket.net/wiki/EULA
* If you are unable to obtain it through the world-wide-web, please
* send an email to support@plumrocket.com so we can send you a copy immediately.
*
* @package Plumrocket_CookieConsent
* @copyright Copyright (c) 2021 Plumrocket Inc. (http://www.plumrocket.com)
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
*/
/** @var \Magento\Framework\View\Element\Template $block */
?>
<li class="prgdpr__item">
<a class="prgdpr__link pr-open-cookie-settings" href="#">
<svg class="prgdpr__icon" id="icons" xmlns="http://www.w3.org/2000/svg" width="70" height="70" viewBox="0 0 100 100"><defs><style>.cls-1{fill:#2a5082;}.cls-2{fill:#a3d4ff;}.cls-3{fill:#fff;}</style></defs><path class="cls-1" d="M53,80H10.07A7.48,7.48,0,0,1,2.6,72.53V21.74a7.48,7.48,0,0,1,7.47-7.47H77.29a7.48,7.48,0,0,1,7.47,7.47V46.2h-3V21.74a4.49,4.49,0,0,0-4.49-4.49H10.07a4.49,4.49,0,0,0-4.48,4.49V72.53A4.49,4.49,0,0,0,10.07,77H53Z"/><rect class="cls-1" x="4.09" y="26.4" width="79.18" height="2.99"/><rect class="cls-1" x="49.57" y="20.62" width="28.01" height="2.99"/><rect class="cls-1" x="49.57" y="42.26" width="28.01" height="2.99"/><rect class="cls-1" x="49.57" y="35.53" width="21.76" height="2.99"/><rect class="cls-1" x="11" y="20.62" width="3.55" height="2.99"/><rect class="cls-1" x="19.03" y="20.62" width="3.55" height="2.99"/><rect class="cls-1" x="27.06" y="20.62" width="3.55" height="2.99"/><path class="cls-1" d="M49.57,49v3H63.75a23.57,23.57,0,0,1,5.66-3Z"/><path class="cls-1" d="M49.57,55.72v3h7.85a23.32,23.32,0,0,1,2.21-3Z"/><path class="cls-1" d="M49.57,62.45v3h5a23.66,23.66,0,0,1,1-3Z"/><path class="cls-2" d="M96.26,74.19V66.71h-5a10.05,10.05,0,0,0-1.36-3.34l3.53-3.55-5.28-5.29-3.53,3.52a14.07,14.07,0,0,0-3.3-1.36V51.77H73.85v4.92a13.66,13.66,0,0,0-3.3,1.36L67,54.52,61.74,59.8l3.53,3.57a10.27,10.27,0,0,0-1.37,3.34h-5v7.48h5a9.65,9.65,0,0,0,1.37,3.25L61.74,81,67,86.22l3.53-3.53a14.07,14.07,0,0,0,3.3,1.36v5.08h7.47V84.05a14.1,14.1,0,0,0,3.3-1.37l3.53,3.53,5.28-5.28L89.9,77.44a9.45,9.45,0,0,0,1.36-3.25Z"/><path class="cls-1" d="M82.81,90.62H72.35V85.15a15.66,15.66,0,0,1-1.52-.63L67,88.34,59.62,81l3.79-3.77a8.77,8.77,0,0,1-.65-1.5H57.41V65.22h5.35a10.45,10.45,0,0,1,.66-1.59L59.63,59.8,67,52.41l3.81,3.81a13.5,13.5,0,0,1,1.52-.63V50.28H82.81v5.31a14.48,14.48,0,0,1,1.53.63l3.81-3.8,7.39,7.4-3.79,3.81a9.89,9.89,0,0,1,.66,1.59h5.34V75.68H92.41a8.77,8.77,0,0,1-.65,1.5l3.79,3.75-7.4,7.4-3.81-3.81q-.75.35-1.53.63Zm-7.47-3h4.49V82.91l1.1-.3a13.19,13.19,0,0,0,2.95-1.22l1-.57,3.28,3.28,3.16-3.16L88,77.7l.67-1.19a7.74,7.74,0,0,0,1.09-2.63l.26-1.19h4.71V68.21H90.06L89.8,67a8.5,8.5,0,0,0-1.2-2.91l-.56-1,3.28-3.31-3.17-3.18-3.28,3.28-1-.57a13,13,0,0,0-2.95-1.22l-1.1-.3V53.27H75.34v4.56l-1.1.3a12.32,12.32,0,0,0-2.95,1.22l-1,.56L67,56.63l-3.18,3.18,3.29,3.32-.57,1A8.66,8.66,0,0,0,65.37,67l-.26,1.18H60.4v4.48h4.71l.26,1.19a7.8,7.8,0,0,0,1.09,2.64l.67,1.18L63.85,81,67,84.11l3.28-3.29,1,.57a12.82,12.82,0,0,0,2.95,1.22l1.1.3Z"/><circle class="cls-3" cx="77.58" cy="70.45" r="5.23"/><path class="cls-1" d="M77.58,77.17a6.72,6.72,0,1,1,6.73-6.72A6.73,6.73,0,0,1,77.58,77.17Zm0-10.45a3.74,3.74,0,1,0,3.74,3.73A3.73,3.73,0,0,0,77.58,66.72Z"/><path class="cls-1" d="M27.06,68.69a16.72,16.72,0,0,1,0-33.43,1.49,1.49,0,0,1,1.26,2.31c-1,1.48-.85,1.92-.85,1.93h0a.85.85,0,0,0,.27.19,3.54,3.54,0,0,0,1.2.21,3.67,3.67,0,0,1,2.85,1.17,4.63,4.63,0,0,1,.53,3.59c0,.13,0,.25,0,.34l.62-.07a8,8,0,0,1,4.32.3c2,.82,2.54,2.82,2.92,4.28a5.56,5.56,0,0,0,.5,1.46,4.37,4.37,0,0,0,1-.35A1.5,1.5,0,0,1,43.78,52,16.74,16.74,0,0,1,27.06,68.69ZM24.6,38.47A13.73,13.73,0,1,0,40.66,53.93a2.94,2.94,0,0,1-1.33-.27c-1.38-.65-1.76-2.11-2.09-3.4s-.57-2-1.16-2.27a5.41,5.41,0,0,0-2.8-.1c-1.12.15-2.39.32-3.3-.62a3.51,3.51,0,0,1-.61-3.09A3.6,3.6,0,0,0,29.43,43a6.58,6.58,0,0,0-.72-.08,5.76,5.76,0,0,1-2.32-.53,3.31,3.31,0,0,1-1.81-2.08A3.66,3.66,0,0,1,24.6,38.47Z"/><circle class="cls-1" cx="29.9" cy="58.62" r="2.83"/><circle class="cls-1" cx="19.52" cy="54.18" r="1.79"/><circle class="cls-1" cx="23.11" cy="45.5" r="1.79"/></svg>
<b class="prgdpr__name"><?= $block->escapeHtml($block->getData('label')) ?></b>
<p class="prgdpr__text"><?= $block->escapeHtml($block->getData('description')) ?></p>
</a>
</li>
@@ -0,0 +1,124 @@
<?php
/**
* @package Plumrocket_CookieConsent
* @copyright Copyright (c) 2020 Plumrocket Inc. (https://plumrocket.com)
* @license https://plumrocket.com/license End-user License Agreement
*/
?>
<?php
/** @var \Plumrocket\CookieConsent\Block\RestrictionConfig $block */
/** @var \Plumrocket\Base\ViewModel\CspNonce $cspNonceViewModel */
$cspNonceViewModel = $block->getData('cspNonceViewModel');
?>
<script <?= /* @noEscape */ $cspNonceViewModel->getNonce() ?>>
var prCookieService = {
defaultAttributes: {path: '/'},
converter: {
write: function (value) {
return encodeURIComponent(value);
},
read: function (value) {
return decodeURIComponent(value)
}
},
decode: function(string)
{
return string.replace(/(%[0-9A-Z]{2})+/g, decodeURIComponent);
},
set: function (key, value, attributes)
{
if (typeof document === 'undefined') {
return;
}
attributes = Object.assign(this.defaultAttributes, attributes);
if (typeof attributes.expires === 'number') {
attributes.expires = new Date(new Date() * 1 + attributes.expires * 864e+5);
}
attributes.expires = attributes.expires ? attributes.expires.toUTCString() : '';
try {
var result = JSON.stringify(value);
if (/^[\{\[]/.test(result)) {
value = result;
}
} catch (e) {}
value = this.converter.write(value);
key = this.converter.write(String(key))
.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent)
.replace(/[\(\)]/g, escape);
var stringifiedAttributes = '';
for (var attributeName in attributes) {
if (!attributes[attributeName]) {
continue;
}
stringifiedAttributes += '; ' + attributeName;
if (attributes[attributeName] === true) {
continue;
}
// Considers RFC 6265 section 5.2:
// ...
// 3. If the remaining unparsed-attributes contains a %x3B (";")
// character:
// Consume the characters of the unparsed-attributes up to,
// not including, the first %x3B (";") character.
// ...
stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];
}
return (document.cookie = key + '=' + value + stringifiedAttributes);
},
remove: function (key, attributes) {
this.set(key, '', {...attributes, ...{
expires: -1
}});
},
get: function (key, json = false)
{
if (typeof document === 'undefined') {
return;
}
var jar = {};
var cookies = document.cookie ? document.cookie.split('; ') : [];
var i = 0;
for (; i < cookies.length; i++) {
var parts = cookies[i].split('=');
var cookie = parts.slice(1).join('=');
if (!json && cookie.charAt(0) === '"') {
cookie = cookie.slice(1, -1);
}
try {
var name = this.converter.write(parts[0]);
cookie = this.converter.read(cookie);
if (json) {
try {
cookie = JSON.parse(cookie);
} catch (e) {}
}
jar[name] = cookie;
if (key === name) {
break;
}
} catch (e) {}
}
return key ? jar[key] : jar;
}
}
</script>
@@ -0,0 +1,57 @@
<?php
/**
* @package Plumrocket_CookieConsent
* @copyright Copyright (c) 2020 Plumrocket Inc. (https://plumrocket.com)
* @license https://plumrocket.com/license End-user License Agreement
*/
?>
<?php
/** @var \Plumrocket\CookieConsent\Block\Gtm $block */
/** @var \Plumrocket\Base\ViewModel\CspNonce $cspNonceViewModel */
$cspNonceViewModel = $block->getData('cspNonceViewModel');
?>
<!-- Google Tag Manager -->
<script type="text/javascript" <?= /* @noEscape */ $cspNonceViewModel->getNonce() ?>>
(function (config) {
function runGtm(config)
{
(function (w,d,s,l,i) {
w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'<?= $block->escapeJs($block->getGtmServerBaseUrl()) ?>/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer',config.containerId);
}
if (! config.consentMode) {
document.addEventListener('pr-cookie-consent-api:configured', () => {
prCookieConsentApi.isAllowedCategory(config.categoryKey) && runGtm(config);
});
return;
}
window.dataLayer = window.dataLayer || [];
function gtag() {dataLayer.push(arguments);}
gtag('consent', 'default', config.defaultConsentTypes);
runGtm(config);
document.addEventListener('pr-cookie-consent-api:configured', () => {
const updateGtmConsents = () => {
let updatedConsentTypes = { ...config.defaultConsentTypes };
for (const [key, categoryKey] of Object.entries(config.consentTypesCategories)) {
updatedConsentTypes[key] = prCookieConsentApi.isAllowedCategory(categoryKey) ? 'granted' : 'denied'
}
gtag('consent', 'update', updatedConsentTypes);
}
updateGtmConsents();
prCookieConsentApi.consent.addCallback(updateGtmConsents);
});
})(<?= /* @noEscape */ $block->getJsonConfig() ?>);
</script>
<!-- End Google Tag Manager -->
@@ -0,0 +1,52 @@
<?php
/**
* @package Plumrocket_CookieConsent
* @copyright Copyright (c) 2020 Plumrocket Inc. (https://plumrocket.com)
* @license https://plumrocket.com/license End-user License Agreement
*/
?>
<?php
/** @var \Plumrocket\CookieConsent\Block\Html\BodyScripts $block */
$essentialCategoriesWithScripts = $block->getEssentialCategoriesWithScripts();
$optionalCategoriesWithScripts = $block->getOptionalCategoriesWithScripts();
/** @var \Plumrocket\Base\ViewModel\CspNonce $cspNonceViewModel */
$cspNonceViewModel = $block->getData('cspNonceViewModel');
?>
<?php foreach ($essentialCategoriesWithScripts as $category): ?>
<?= /* @noEscape */ $category->getFooterMiscellaneousHtml() ?>
<?php endforeach; ?>
<?php if ($optionalCategoriesWithScripts): ?>
<?php foreach ($optionalCategoriesWithScripts as $category): ?>
<div id="pr-cookie-absolute-footer-<?= $block->escapeHtmlAttr($category->getKey()) ?>"></div>
<?php endforeach; ?>
<script <?= /* @noEscape */ $cspNonceViewModel->getNonce() ?>>
requirejs(['prCookieConsentApi', 'prCookieBodyScripts'], function (prCookieConsentApi, prCookieBodyScripts) {
'use strict';
var container;
<?php foreach ($optionalCategoriesWithScripts as $category): ?>
container = document.getElementById(
'pr-cookie-absolute-footer-' + '<?= $block->escapeJs($category->getKey()) ?>'
);
if (container && prCookieConsentApi.isAllowedCategory('<?= $block->escapeJs($category->getKey()) ?>')) {
container.innerHTML = '<?= $block->prepareHtml($category->getFooterMiscellaneousHtml()) ?>';
prCookieBodyScripts.execute(container, 'pr-cookie-footer-script');
}
<?php endforeach; ?>
});
</script>
<?php endif; ?>
<?php /** Activate all scripts like <script type="pr_cookie_category/..."> */ ?>
<script id="pr_cookie_consent_on_load_activate" <?= /* @noEscape */ $cspNonceViewModel->getNonce() ?>>
requirejs(['prCookieBodyScripts', 'domReady!'], function (bodyScripts) {
'use strict';
var scripts = document.querySelectorAll('script[type^="pr_cookie_category"]');
[].forEach.call(scripts, function (notActiveScript) {
bodyScripts.activatePrCookieCategoryScript(notActiveScript);
});
});
</script>
@@ -0,0 +1,51 @@
<?php
/**
* Plumrocket Inc.
*
* NOTICE OF LICENSE
*
* This source file is subject to the End-user License Agreement
* that is available through the world-wide-web at this URL:
* http://wiki.plumrocket.net/wiki/EULA
* If you are unable to obtain it through the world-wide-web, please
* send an email to support@plumrocket.com so we can send you a copy immediately.
*
* @package Plumrocket_CookieConsent
* @copyright Copyright (c) 2020 Plumrocket Inc. (http://www.plumrocket.com)
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
*/
?>
<?php
/** @var \Plumrocket\CookieConsent\Block\Html\BodyScripts $block */
$essentialCategoriesWithScripts = $block->getEssentialCategoriesWithScripts();
$optionalCategoriesWithScripts = $block->getOptionalCategoriesWithScripts();
/** @var \Plumrocket\Base\ViewModel\CspNonce $cspNonceViewModel */
$cspNonceViewModel = $block->getData('cspNonceViewModel');
?>
<?php foreach ($essentialCategoriesWithScripts as $category): ?>
<?= /* @noEscape */ $category->getHeadScripts() ?>
<?php endforeach; ?>
<?php if ($optionalCategoriesWithScripts): ?>
<?php foreach ($optionalCategoriesWithScripts as $category): ?>
<div id="pr-cookie-absolute-header-<?= $block->escapeHtmlAttr($category->getKey()) ?>"></div>
<?php endforeach; ?>
<script <?= /* @noEscape */ $cspNonceViewModel->getNonce() ?>>
requirejs(['prCookieConsentApi', 'prCookieBodyScripts'], function (prCookieConsentApi, prCookieBodyScripts) {
'use strict';
var container;
<?php foreach ($optionalCategoriesWithScripts as $category): ?>
container = document.getElementById(
'pr-cookie-absolute-header-' + '<?= $block->escapeJs($category->getKey()) ?>'
);
if (container && prCookieConsentApi.isAllowedCategory('<?= $block->escapeJs($category->getKey()) ?>')) {
container.innerHTML = '<?= $block->prepareHtml($category->getHeadScripts()) ?>';
prCookieBodyScripts.execute(container, 'pr-cookie-header-script');
}
<?php endforeach; ?>
});
</script>
<?php endif; ?>
@@ -0,0 +1,53 @@
<?php
/**
* @package Plumrocket_CookieConsent
* @copyright Copyright (c) 2025 Plumrocket Inc. (https://plumrocket.com)
* @license https://plumrocket.com/license End-user License Agreement
*/
?>
<?php
/** @var \Magento\Framework\View\Element\Template $block */
/** @var \Plumrocket\Base\ViewModel\CspNonce $cspNonceViewModel */
$cspNonceViewModel = $block->getData('cspNonceViewModel');
/** @var \Plumrocket\CookieConsent\ViewModel\Integration\AdobeCommerce\DataCollection $dataCollectionViewModel */
$dataCollectionViewModel = $block->getData('dataCollectionViewModel');
?>
<?php if ($dataCollectionViewModel->isEnabled()): ?>
<script type="text/javascript" <?= /* @noEscape */ $cspNonceViewModel->getNonce() ?>>
(() => {
document.addEventListener('pr-cookie-consent-api:cookie-blocking:validation', (event) => {
if ('mg_dnt' !== event.detail.cookieName) {
return;
}
setTimeout(() => {
const categoryKey = '<?= $block->escapeJs($dataCollectionViewModel->getAssociatedCategoryKey()) ?>';
let cookieValue = (event.detail.cookie.match(/^[^=]+=(.*?)(?:$|;)/) || [])[1]?.trim();
if (prCookieConsentApi.isAllowedCategory(categoryKey) && cookieValue.length) {
prCookieService.remove('mg_dnt', prCookieConsentApi.config.cookie);
return;
}
if (! prCookieConsentApi.isAllowedCategory(categoryKey) && ! cookieValue.length) {
prCookieService.set('mg_dnt', true, { ...prCookieConsentApi.config.cookie, expires: null });
}
}, 100);
});
let handleCookieConsent = () => {
const categoryKey = '<?= $block->escapeJs($dataCollectionViewModel->getAssociatedCategoryKey()) ?>';
if (prCookieConsentApi.isAllowedCategory(categoryKey)) {
prCookieService.remove('mg_dnt', prCookieConsentApi.config.cookie);
} else {
prCookieService.set('mg_dnt', true, { ...prCookieConsentApi.config.cookie, expires: null });
}
};
prCookieConsentApi.consent.addCallback(handleCookieConsent);
handleCookieConsent();
})();
</script>
<?php endif; ?>
@@ -0,0 +1,47 @@
<?php
/**
* @package Plumrocket_CookieConsent
* @copyright Copyright (c) 2025 Plumrocket Inc. (https://plumrocket.com)
* @license https://plumrocket.com/license End-user License Agreement
*/
?>
<?php
/** @var \Plumrocket\CookieConsent\Block\Html\HeadScripts $block */
/** @var \Plumrocket\Base\ViewModel\CspNonce $cspNonceViewModel */
$cspNonceViewModel = $block->getData('cspNonceViewModel');
/** @var \Plumrocket\CookieConsent\ViewModel\Integration\AdobeCommerce\DataCollection $dataCollectionViewModel */
$dataCollectionViewModel = $block->getData('dataCollectionViewModel');
?>
<?php if ($dataCollectionViewModel->isEnabled()): ?>
<script type="text/javascript" <?= /* @noEscape */ $cspNonceViewModel->getNonce() ?>>
(() => {
let userAllowedCookies = prCookieService.get('user_allowed_save_cookie');
if (! userAllowedCookies) {
return;
}
let customerConsent = prCookieService.get('pr-cookie-consent');
if (! customerConsent) {
return;
}
try {
customerConsent = JSON.parse(customerConsent);
} catch (error) {
return;
}
const categoryKey = '<?= $block->escapeJs($dataCollectionViewModel->getAssociatedCategoryKey()) ?>';
if (customerConsent.includes('all') || customerConsent.includes(categoryKey)) {
return;
}
let intervalId = setInterval(prCookieService.set.bind(prCookieService, 'mg_dnt', true, {expires: null}), 500);
document.addEventListener('pr-cookie-consent-api:configured', () => {
clearInterval(intervalId);
});
})();
</script>
<?php endif; ?>
@@ -0,0 +1,33 @@
<?php
/**
* Plumrocket Inc.
*
* NOTICE OF LICENSE
*
* This source file is subject to the End-user License Agreement
* that is available through the world-wide-web at this URL:
* http://wiki.plumrocket.net/wiki/EULA
* If you are unable to obtain it through the world-wide-web, please
* send an email to support@plumrocket.com so we can send you a copy immediately.
*
* @package Plumrocket_CookieConsent
* @copyright Copyright (c) 2020 Plumrocket Inc. (http://www.plumrocket.com)
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
*/
/** @var \Plumrocket\CookieConsent\Block\CookieNotice $block */
?>
<?php if ($block->isAllowedPage()): ?>
<div data-bind="scope: 'pr-cookie-notice'" class="pr-cookie-notice-wrapper">
<!-- ko template: getTemplate() --><!-- /ko -->
</div>
<script type="text/x-magento-init">
{
"*": {
"Magento_Ui/js/core/app": <?= $block->getJsLayout() ?>
}
}
</script>
<?php endif; ?>
@@ -0,0 +1,438 @@
<?php
/**
* @package Plumrocket_CookieConsent
* @copyright Copyright (c) 2020 Plumrocket Inc. (https://plumrocket.com)
* @license https://plumrocket.com/license End-user License Agreement
*/
?>
<?php
/** @var \Plumrocket\CookieConsent\Block\RestrictionConfig $block */
/** @var \Plumrocket\Base\ViewModel\CspNonce $cspNonceViewModel */
$cspNonceViewModel = $block->getData('cspNonceViewModel');
?>
<script <?= /* @noEscape */ $cspNonceViewModel->getNonce() ?>>
var prCookieConsentApi = {
CUSTOMER_CONSENT: 'pr-cookie-consent',
SYSTEM_COOKIES: [
'PHPSESSID',
this.CUSTOMER_CONSENT,
'user_allowed_save_cookie',
],
config: {},
whitelist: {},
isConfigured: false,
/**
* Contains callbacks that run after all configuration come.
*
* @type {function[]}
*/
configuredCallbacks: [],
initCookieBlocking: function () {
var cookieDesc = Object.getOwnPropertyDescriptor(Document.prototype, 'cookie')
|| Object.getOwnPropertyDescriptor(HTMLDocument.prototype, 'cookie');
if (cookieDesc && cookieDesc.configurable) {
var api = this;
Object.defineProperty(document, 'cookie', {
get: function () {
return cookieDesc.get.call(document);
},
set: function (cookie) {
let cookieName = cookie.substring(0, cookie.indexOf('=')).trim();
document.dispatchEvent(new CustomEvent('pr-cookie-consent-api:cookie-blocking:validation', {
detail: {cookieName: cookieName, isAllowed: api.isAllowed(cookieName), cookie: cookie}
}));
if (! api.isAllowed(cookieName)) {
api.logger.warn('CookieConsent: blocked cookie "' + cookieName + '"');
return;
}
cookieDesc.set.call(document, cookie);
}
});
}
},
getCookieValue: function (name) {
var values = document.cookie.match('(^|;)\\s*' + name + '\\s*=\\s*([^;]+)');
return values ? decodeURIComponent(values.pop()) : '';
},
configure: function (configJson) {
this.logger.init();
this.userScript.init();
try {
this.config = JSON.parse(configJson);
} catch (e) {
console.error('CookieConsent: error has happened during parse JSON');
return false;
}
var finalizeConfiguration = () => {
this.isConfigured = true;
this.configuredCallbacks.forEach(function (callback) {
callback();
}.bind(this));
this.clearRejectedCookie();
document.dispatchEvent(new Event('pr-cookie-consent-api:configured'));
};
null === this.canManageCookie()
? this.fetchRestrictionState(finalizeConfiguration)
: finalizeConfiguration();
},
canManageCookie: function () {
if (null !== this.config.canManageCookie) {
return this.config.canManageCookie;
}
if (undefined !== prCookieService.get('pr-can-manage-cookie')) {
this.config.canManageCookie = prCookieService.get('pr-can-manage-cookie') === "true";
return this.config.canManageCookie;
}
return null;
},
fetchRestrictionState: function (callback) {
var url = this.config.canManageCookieApiUrl + '?_=' + Date.now();
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.setRequestHeader('Accept', 'application/json');
xhr.onreadystatechange = function () {
if (xhr.readyState !== 4) {
return;
}
if (xhr.status >= 200 && xhr.status < 300) {
var body = xhr.responseText || '';
var parsed;
try { parsed = JSON.parse(body); } catch (_) { parsed = body; }
var status = String(parsed).toLowerCase() === "true";
prCookieService.set('pr-can-manage-cookie', status, {
path: prCookieConsentApi.config.cookie.path,
expires: prCookieConsentApi.config.mage.lifetime
? Math.ceil(prCookieConsentApi.config.mage.lifetime / 86400)
: 0
});
prCookieConsentApi.config.canManageCookie = status;
} else {
console.error('CookieConsent: restriction config is invalid');
}
callback();
};
xhr.send(null);
},
/**
* @param {function} callback
* @returns {prCookieConsentApi}
*/
addConfiguredCallback: function (callback) {
this.configuredCallbacks.push(callback);
return this;
},
<?php // This logic has php alternative in \Plumrocket\CookieConsent\Model\Category\IsAllowed ?>
isAllowedCategory: function (categoryKey) {
if (! this.canManageCookie()) {
return true;
}
if (this.isEssentialCategory(categoryKey)) {
return true;
}
if (this.isOptIn()) {
if (this.isAllCategoriesAllowed()) {
return true;
}
return this.consent.get().includes(categoryKey);
}
return this.config.canUseCookieBeforeOptIn;
},
getDomain: function (cookieName) {
return this.config.cookies[cookieName] ? this.config.cookies[cookieName].domain : null;
},
<?php // This logic has php alternative in \Plumrocket\CookieConsent\Model\Cookie\IsAllowed ?>
isAllowed: function (cookieName) {
if (this.isSystemCookie(cookieName)) {
return true;
}
if (! this.canManageCookie()) {
return true;
}
if (this.whitelist[cookieName]) {
return true;
}
cookieName = this.getTrueCookieName(cookieName);
if (! this.isOptIn()) {
if (this.config.canUseCookieBeforeOptIn) {
return true;
}
if (this.isKnownCookie(cookieName)) {
return this.isInEssentialCategory(cookieName);
}
return false;
}
if (! this.isKnownCookie(cookieName)) {
return ! this.config.canBlockUnknownCookie;
}
return this.isInAllowedCategory(cookieName);
},
isAllCategoriesAllowed: function () {
if (null === this.cache.get('allowAllCategories')) {
var customerConsent = this.consent.get();
if (customerConsent && customerConsent.includes('all') ) {
this.cache.set('allowAllCategories', true);
} else {
var allowedWebsites = this.websiteRestriction.getAllowed();
this.cache.set('allowAllCategories', allowedWebsites[this.config.mage.website] === 1);
}
}
return this.cache.get('allowAllCategories');
},
isEssentialCategory: function (categoryKey) {
return this.config.essentialCategoryKeys.includes(categoryKey);
},
isInEssentialCategory: function (cookieName) {
return this.isEssentialCategory(this.getCookieCategory(cookieName));
},
isInAllowedCategory: function (cookieName) {
return this.isAllowedCategory(this.getCookieCategory(cookieName));
},
getCookieCategory: function (cookieName) {
return this.config.cookieToCategoryMapping[cookieName];
},
isOptIn: function () {
var allowedWithDefaultCookie = this.websiteRestriction.getAllowed()[this.config.mage.website] === 1;
return Boolean(this.consent.get()) || allowedWithDefaultCookie;
},
isSystemCookie: function (cookieName) {
return this.SYSTEM_COOKIES.includes(cookieName);
},
isKnownCookie: function (cookieName) {
return this.config.cookieToCategoryMapping.hasOwnProperty(cookieName);
},
getTrueCookieName: function (cookieName) {
var keys = Object.keys(this.config.dynamicNamesPatterns), key;
for (var i = 0, length = keys.length; i < length; i++) {
key = keys[i];
if (new RegExp(this.config.dynamicNamesPatterns[key]).test(cookieName)) {
return key;
}
}
return cookieName;
},
clearRejectedCookie: function () {
let cookies = prCookieService.get();
Object.keys(cookies).forEach(function(cookieName) {
if (this.isAllowed(cookieName)) {
return;
}
var encodedCookieName = cookieName = encodeURIComponent(String(cookieName))
.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent)
.replace(/[\(\)]/g, escape);
this.whitelist[encodedCookieName] = true;
if (this.getDomain(cookieName)) {
prCookieService.remove(cookieName, {domain: this.getDomain(cookieName)});
} else {
prCookieService.remove(cookieName);
if (this.config.cookie.parentDomain) {
prCookieService.remove(cookieName, {domain: this.config.cookie.parentDomain});
}
}
this.logger.warn('CookieConsent: remove cookie "' + cookieName + '"');
if (typeof prCookieService.get(cookieName) !== 'undefined') {
this.logger.error('CookieConsent: fail to remove cookie "' + cookieName + '"');
}
this.whitelist[encodedCookieName] = false;
}.bind(this));
}
};
prCookieConsentApi.userScript = {
/**
* List of callbacks and categories they depend on.
*/
pendingScripts: [],
/**
* Run script after model is configured or after user provided consent.
*/
init: function () {
prCookieConsentApi.addConfiguredCallback(this.executePendingScripts.bind(this));
prCookieConsentApi.consent.addCallback(this.executePendingScripts.bind(this));
},
/**
* Run or delay script.
*
* @param {function} callback
* @param {string} categoryKey
*/
execute: function (callback, categoryKey) {
if (prCookieConsentApi.isConfigured && prCookieConsentApi.isAllowedCategory(categoryKey)) {
callback();
return;
}
this.pendingScripts.push({callback: callback, categoryKey: categoryKey, executed: false});
},
/**
* Run pending scripts.
*/
executePendingScripts: function () {
this.pendingScripts.forEach(function (script) {
if (false === script.executed && prCookieConsentApi.isAllowedCategory(script.categoryKey)) {
script.callback();
script.executed = true;
}
}.bind(this));
},
};
prCookieConsentApi.websiteRestriction = {
getAllowed: function () {
var allowedWebsites = prCookieConsentApi.getCookieValue(prCookieConsentApi.config.mage.cookieName);
return allowedWebsites ? JSON.parse(allowedWebsites) : {};
},
allowCurrent: function () {
return this.set(prCookieConsentApi.config.mage.website, true);
},
disallowCurrent: function () {
return this.set(prCookieConsentApi.config.mage.website, false);
},
/**
* @param {number} website
* @param {boolean} flag
* @return {CookieRestriction.websiteRestriction}
*/
set: function (website, flag) {
var allowedWebsites = this.getAllowed();
if (flag) {
allowedWebsites[website] = 1;
} else {
delete allowedWebsites[website];
}
prCookieService.set(prCookieConsentApi.config.mage.cookieName, allowedWebsites, {
path: prCookieConsentApi.config.cookie.path,
expires: prCookieConsentApi.config.mage.lifetime ? Math.ceil(prCookieConsentApi.config.mage.lifetime / 86400) : 0
});
return this;
}
};
prCookieConsentApi.cache = {
cacheData: {allowAllCategories: null},
get: function (key) {
return this.cacheData[key];
},
set: function (key, value) {
this.cacheData[key] = value;
},
reset: function () {
this.cacheData = {allowAllCategories: null};
}
};
prCookieConsentApi.logger = {
level: 0, /* disabled */
init: function () {
if (window.location.hash === '#pr-enable-cookie-log') {
this.level = 1; /* only warnings and errors */
}
if (window.location.hash === '#pr-enable-cookie-log-all') {
this.level = 2; /* all logs */
}
},
log: function () {
this.level > 1 && console.log.apply(console, arguments);
},
warn: function () {
this.level > 0 && console.warn.apply(console, arguments);
},
error: function () {
this.level > 0 && console.error.apply(console, arguments);
}
};
prCookieConsentApi.consent = {
/**
* Contains callbacks that run after user consent.
*
* @type {function[]}
*/
callbacks: [],
allowAllCategories: function () {
prCookieConsentApi.cache.reset();
prCookieConsentApi.consent.set(['all']);
return this;
},
declineAll: function () {
prCookieConsentApi.cache.reset();
prCookieConsentApi.consent.set([]);
return this;
},
set: function (allowedCategories) {
prCookieService.set(prCookieConsentApi.CUSTOMER_CONSENT, JSON.stringify(allowedCategories), {
expires: prCookieConsentApi.config.consent.expiry,
path: prCookieConsentApi.config.cookie.path,
domain: prCookieConsentApi.config.cookie.domain
});
if (allowedCategories.includes('all')) {
prCookieConsentApi.websiteRestriction.allowCurrent();
} else {
prCookieConsentApi.websiteRestriction.disallowCurrent();
}
prCookieConsentApi.cache.reset();
var isAccepting = allowedCategories.length;
this.callbacks.forEach(function (callback) {
callback(allowedCategories)
});
fetch(prCookieConsentApi.config.consent.logUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Requested-With': 'XMLHttpRequest'
},
body: JSON.stringify({acceptedKeys: allowedCategories})
})
.then(this.pageReloadAfterAction.bind(this, isAccepting));
},
/**
* Reload page by configuration and action
*
* @param isAccepting
*/
pageReloadAfterAction: function (isAccepting) {
if (isAccepting && prCookieConsentApi.config.consent.reloadAfterAccept) {
window.location.reload();
}
if (! isAccepting && prCookieConsentApi.config.consent.reloadAfterDecline) {
window.location.reload();
}
},
get: function () {
var consent = prCookieConsentApi.getCookieValue(prCookieConsentApi.CUSTOMER_CONSENT);
return consent ? JSON.parse(consent) : false;
},
addCallback: function (callback) {
this.callbacks.push(callback);
return this;
},
};
prCookieConsentApi.configure('<?= $block->escapeJs($block->getSerializedRestrictionConfig()) ?>');
prCookieConsentApi.initCookieBlocking();
if (typeof define === 'function') {
define('prCookieService', function () {return prCookieService});
define('prCookieConsentApi', function () {return prCookieConsentApi;});
}
</script>
@@ -0,0 +1,31 @@
<?php
/**
* Plumrocket Inc.
*
* NOTICE OF LICENSE
*
* This source file is subject to the End-user License Agreement
* that is available through the world-wide-web at this URL:
* http://wiki.plumrocket.net/wiki/EULA
* If you are unable to obtain it through the world-wide-web, please
* send an email to support@plumrocket.com so we can send you a copy immediately.
*
* @package Plumrocket_CookieConsent
* @copyright Copyright (c) 2020 Plumrocket Inc. (http://www.plumrocket.com)
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
*/
/** @var \Plumrocket\CookieConsent\Block\Settings $block */
?>
<div data-bind="scope: 'pr-cookie-settings-bar'" class="pr-cookie-settings-bar-wrapper">
<!-- ko template: getTemplate() --><!-- /ko -->
</div>
<script type="text/x-magento-init">
{
"*": {
"Magento_Ui/js/core/app": <?= $block->getJsLayout() ?>
}
}
</script>
@@ -0,0 +1,23 @@
<?php
/**
* Plumrocket Inc.
*
* NOTICE OF LICENSE
*
* This source file is subject to the End-user License Agreement
* that is available through the world-wide-web at this URL:
* http://wiki.plumrocket.net/wiki/EULA
* If you are unable to obtain it through the world-wide-web, please
* send an email to support@plumrocket.com so we can send you a copy immediately.
*
* @package Plumrocket_CookieConsent
* @copyright Copyright (c) 2021 Plumrocket Inc. (http://www.plumrocket.com)
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
*/
/** @var \Plumrocket\CookieConsent\Block\Widget\CookieSettingsButton $block */
?>
<button class="action primary pr-open-cookie-settings" title="<?= $block->escapeHtml(__($block->getTitle())) ?>">
<?= $block->escapeHtml(__($block->getTitle())) ?>
</button>
@@ -0,0 +1,23 @@
<?php
/**
* Plumrocket Inc.
*
* NOTICE OF LICENSE
*
* This source file is subject to the End-user License Agreement
* that is available through the world-wide-web at this URL:
* http://wiki.plumrocket.net/wiki/EULA
* If you are unable to obtain it through the world-wide-web, please
* send an email to support@plumrocket.com so we can send you a copy immediately.
*
* @package Plumrocket_CookieConsent
* @copyright Copyright (c) 2021 Plumrocket Inc. (http://www.plumrocket.com)
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
*/
/** @var \Plumrocket\CookieConsent\Block\Widget\CookieSettingsButton $block */
?>
<a href="#" class="pr-open-cookie-settings" title="<?= $block->escapeHtmlAttr(__($block->getTitle())) ?>">
<?= $block->escapeHtml(__($block->getTitle())) ?>
</a>
@@ -0,0 +1,26 @@
<?php
/**
* @package Plumrocket_CookieConsent
* @copyright Copyright (c) 2022 Plumrocket Inc. (https://plumrocket.com)
* @license https://plumrocket.com/license End-user License Agreement
*/
?>
<?php
/** @var \Magento\Framework\View\Element\Template $block */
/** @var \Plumrocket\CookieConsent\ViewModel\Integration\NoCookieYoutube $viewModel */
$viewModel = $block->getData('viewModel');
/** @var \Plumrocket\Base\ViewModel\CspNonce $cspNonceViewModel */
$cspNonceViewModel = $block->getData('cspNonceViewModel');
?>
<?php if ($viewModel->isEnabled()): ?>
<script type="text/x-magento-init" <?= /* @noEscape */ $cspNonceViewModel->getNonce() ?>>
{
"*": {
"Plumrocket_CookieConsent/js/youtube": {
"categoryKey": "<?= $block->escapeJs($viewModel->getAssociatedCategoryKey()) ?>"
}
}
}
</script>
<?php endif; ?>