309 lines
11 KiB
PHP
309 lines
11 KiB
PHP
{{-- blade-formatter-disable --}}
|
||
@php
|
||
|
||
$site_name = Str::ucfirst(config('app.name'));
|
||
$logo_picture_url = Vite::asset('resources/assets/images/layout/logo.svg', 'build');
|
||
$logo_title_text = __('Logo du site :name', ['name' => $site_name]);
|
||
$logo_alt_text = __('Logo :name', ['name' => $site_name]);
|
||
|
||
$strings = (object)[
|
||
'modal_title' => __('cookie-notice.modal_title'),
|
||
'button_customize_cookies' => __('cookie-notice.button_customize_cookies'),
|
||
'button_close_cookies' => __('cookie-notice.button_close_cookies'),
|
||
'button_title_open_new_tab' => __('cookie-notice.button_title_open_new_tab'),
|
||
'button_toggle_cookie' => __('cookie-notice.button_toggle_cookie'),
|
||
'button_forbid_all' => Str::upper(__('cookie-notice.button_forbid_all')),
|
||
'button_allow_all' => Str::upper(__('cookie-notice.button_allow_all')),
|
||
'button_customize' => Str::upper(__('cookie-notice.button_customize')),
|
||
'button_forbid_all_title' => __('cookie-notice.button_forbid_all_title'),
|
||
'button_allow_all_title' => __('cookie-notice.button_allow_all_title'),
|
||
'button_validate_and_close' => Str::upper(__('cookie-notice.button_validate_and_close')),
|
||
'banner_title' => __('cookie-notice.banner_title', ['site_name' => $site_name]),
|
||
'banner_text' => sprintf(
|
||
"%s<br><br>%s",
|
||
"Nous utilisons des cookies pour nous assurer du bon fonctionnement de notre site et à des fins analytiques. Vous pouvez changer d'avis à tout moment en cliquant sur l'icône présente sur chaque page de notre site. En autorisant ces services tiers, vous acceptez le dépôt et la lecture de cookies et l'utilisation de technologies de suivi nécessaires à leur bon fonctionnement.",
|
||
"<a href='/charte-de-confidentialite'>Charte de confidentialité</a>"
|
||
),
|
||
'panel_content' => __('cookie-notice.panel_content'),
|
||
'picture_cookie_title' => __('cookie-notice.picture_cookie_title'),
|
||
'navigation_title' => __('cookie-notice.navigation_title'),
|
||
];
|
||
|
||
$cookieInline = function ($cookieName, $text, $subtext = '') {
|
||
return <<<SCRIPT
|
||
(() => {
|
||
const cookieActivateContainer = document.createElement("div");
|
||
cookieActivateContainer.classList.add(
|
||
'd-flex',
|
||
'justify-content-center',
|
||
'align-items-center'
|
||
);
|
||
|
||
const cookieActivate = document.createElement("span");
|
||
cookieActivate.classList.add(
|
||
'cn-cookie-activate',
|
||
'border',
|
||
'border-3',
|
||
'border-dark',
|
||
'p-3',
|
||
'rounded-3',
|
||
'text-center'
|
||
);
|
||
cookieActivate.dataset.cookieName = '{$cookieName}';
|
||
|
||
const childSpan = document.createElement("span");
|
||
const childSpanSpan = document.createElement("span");
|
||
childSpanSpan.classList.add(
|
||
'text-dark',
|
||
'fs-6',
|
||
'fw-bold',
|
||
'lh-sm'
|
||
);
|
||
const childSpanSmall = document.createElement("span");
|
||
childSpanSmall.classList.add(
|
||
'small-text',
|
||
'fs-6',
|
||
'lh-sm'
|
||
);
|
||
childSpanSpan.textContent = '{$text}';
|
||
childSpanSmall.textContent = '{$subtext}';
|
||
childSpan.appendChild(childSpanSpan);
|
||
childSpan.appendChild(childSpanSmall);
|
||
|
||
const childBtn = document.createElement("button");
|
||
childBtn.classList.add(
|
||
'btn',
|
||
'btn-secondary',
|
||
'rounded-2',
|
||
'border-0',
|
||
'fs-6',
|
||
'fw-bold',
|
||
'ms-3',
|
||
'px-4',
|
||
'py-3'
|
||
);
|
||
childBtn.textContent = 'Autoriser';
|
||
|
||
cookieActivate.appendChild(childSpan);
|
||
cookieActivate.appendChild(childBtn);
|
||
cookieActivateContainer.appendChild(cookieActivate);
|
||
return cookieActivateContainer;
|
||
})
|
||
SCRIPT;
|
||
};
|
||
|
||
$cookies = [];
|
||
|
||
// YOUTUBE
|
||
$cookies['youtube'] = [
|
||
'name' => __('cookie-notice.custom.youtube.name'),
|
||
'description' => __('cookie-notice.custom.youtube.description'),
|
||
'labelLink' => __('cookie-notice.custom.youtube.labelLink'),
|
||
'link' => 'https://policies.google.com/technologies/cookies?hl=fr&utm_source=ucb',
|
||
'cookies' => [
|
||
"NID", "ENID", "_Secure-ENID", "VISITOR_INFO1_LIVE", "YEC", "__Secure-YEC", "YSC",
|
||
"GEUP", "PREF", "pm_sess", "CGIC", "SOCS", "GPS", "yt-player-bandwidth", "yt-player-headers-readable"
|
||
]
|
||
];
|
||
$inlineYt = $cookieInline(
|
||
'youtube',
|
||
'Youtube est désactivé'
|
||
);
|
||
|
||
$cookies['youtube']['script'] = <<<SCRIPT
|
||
function () {
|
||
let youtubeVids = document.getElementsByClassName('cn-youtube');
|
||
for (let item of youtubeVids) {
|
||
let id = item.dataset.id;
|
||
let e = document.createElement('iframe');
|
||
e.src = "https://www.youtube.com/embed/" + id + "?autoplay=1&loop=1&playlist=" + id;
|
||
e.width = "1920px";
|
||
e.height = "1080px";
|
||
e.classList.add("w-100");
|
||
e.classList.add("h-100");
|
||
e.frameBorder = "0";
|
||
e.allow = "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture";
|
||
e.allowFullscreen = true;
|
||
item.innerHTML = "";
|
||
item.appendChild(e);
|
||
}
|
||
}
|
||
SCRIPT;
|
||
$cookies['youtube']['fallback'] = <<<FALLBACK
|
||
function () {
|
||
let youtubeVids = document.getElementsByClassName('cn-youtube');
|
||
for (let item of youtubeVids) {
|
||
item.innerHTML = "";
|
||
item.appendChild({$inlineYt}());
|
||
setTimeout(() => listenInlineCnButtons(), 500);
|
||
}
|
||
}
|
||
FALLBACK;
|
||
|
||
// VIMEO
|
||
$cookies['vimeo'] = [
|
||
'name' => 'VIDEOS - Vimeo',
|
||
'description' => __('Les cookies déposés via les services de partage de vidéo ont pour finalité de permettre à l’utilisateur de visionner directement sur le site le contenu multimédia.'),
|
||
'link' => 'https://vimeo.com/cookie_policy',
|
||
'labelLink' => __('En savoir +'),
|
||
'cookies' => [
|
||
"vuid", "__utmt_player"
|
||
]
|
||
];
|
||
$inlineVo = $cookieInline(
|
||
'vimeo',
|
||
'Vimeo est désactivé'
|
||
);
|
||
|
||
$cookies['vimeo']['script'] = <<<SCRIPT
|
||
function () {
|
||
let vimeoVids = document.getElementsByClassName('cn-vimeo');
|
||
for (let item of vimeoVids) {
|
||
let id = item.dataset.id;
|
||
let e = document.createElement('iframe');
|
||
e.src = "https://player.vimeo.com/video/" + id + "?autoplay=1&loop=1&badge=0";
|
||
e.width = "1920px";
|
||
e.height = "1080px";
|
||
e.classList.add("w-100");
|
||
e.classList.add("h-100");
|
||
e.frameBorder = "0";
|
||
e.allow = "autoplay; fullscreen; picture-in-picture";
|
||
e.allowFullscreen = true;
|
||
item.innerHTML = "";
|
||
item.appendChild(e);
|
||
}
|
||
}
|
||
SCRIPT;
|
||
$cookies['vimeo']['fallback'] = <<<FALLBACK
|
||
function () {
|
||
let vimeoVids = document.getElementsByClassName('cn-vimeo');
|
||
for (let item of vimeoVids) {
|
||
item.innerHTML = "";
|
||
item.appendChild({$inlineVo}());
|
||
setTimeout(() => listenInlineCnButtons(), 500);
|
||
}
|
||
}
|
||
FALLBACK;
|
||
|
||
// RECAPTCHA
|
||
$cookies['recaptcha'] = [
|
||
'name' => __('cookie-notice.custom.recaptcha.title'),
|
||
'description' => __('cookie-notice.custom.recaptcha.description'),
|
||
'link' => 'https://policies.google.com/privacy',
|
||
'labelLink' => __('cookie-notice.custom.recaptcha.labelLink'),
|
||
'cookies' => [
|
||
"NID", "_grecaptcha", "__Secure-3PAPISID", "__Secure-3PSID", "__Secure-3PSIDCC",
|
||
"_GRECAPTCHA", "rc::c", "rc::b", "rc::a", "itsec-recaptcha-opt-in-*"
|
||
]
|
||
];
|
||
|
||
$cookies['recaptcha']['script'] = <<<SCRIPT
|
||
function () {
|
||
if (window.__CN_Recaptcha) {
|
||
window.__CN_Recaptcha();
|
||
}
|
||
[...document.getElementsByClassName('cn-cookie-activate')].forEach(function(el) {
|
||
if (el.dataset.cookieName === 'recaptcha') {
|
||
el.classList.add('d-none');
|
||
document.getElementById('contact-form').inert = false;
|
||
}
|
||
});
|
||
}
|
||
SCRIPT;
|
||
$cookies['recaptcha']['fallback'] = <<<FALLBACK
|
||
function () {
|
||
if (window.__CN_Recaptcha_Reset) {
|
||
window.__CN_Recaptcha_Reset();
|
||
}
|
||
[...document.getElementsByClassName('cn-cookie-activate')].forEach(function(el) {
|
||
if (el.dataset.cookieName === 'recaptcha') {
|
||
el.classList.remove('d-none');
|
||
document.getElementById('contact-form').inert = true;
|
||
}
|
||
});
|
||
}
|
||
FALLBACK;
|
||
|
||
// MATOMO
|
||
$cookies['matomo'] = [
|
||
'name' => __('cookie-notice.custom.matomo.title'),
|
||
'description' => __('cookie-notice.custom.matomo.description'),
|
||
'link' => 'https://fr.matomo.org/gdpr-analytics/',
|
||
'labelLink' => __('cookie-notice.custom.matomo.labelLink'),
|
||
'cookies' => [
|
||
"_pk*",
|
||
"_pk_ref", "_pk_cvar", "_pk_id", "_pk_ses", "_pk_hsr", "piwik_ignore", "_pk_uid",
|
||
"_pk_ref", "_pk_cvar", "_pk_id", "_pk_ses", "_pk_hsr", "mtm_consent", "matomo_ignore", "matomo_sessid"
|
||
]
|
||
];
|
||
|
||
$cookies['matomo']['script'] = <<<SCRIPT
|
||
function () {
|
||
var _paq = window._paq = window._paq || [];
|
||
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
|
||
_paq.push(['trackPageView']);
|
||
_paq.push(['enableLinkTracking']);
|
||
(function() {
|
||
var u="//yl.s-web.fr/";
|
||
_paq.push(['setTrackerUrl', u+'rainbow']);
|
||
_paq.push(['setSiteId', '
|
||
SCRIPT;
|
||
$cookies['matomo']['script'] .= config("services.matomo.site_id");
|
||
$cookies['matomo']['script'] .= <<<SCRIPT
|
||
']);
|
||
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
|
||
g.async=true; g.src=u+'unicorn'; s.parentNode.insertBefore(g,s);
|
||
})();
|
||
}
|
||
SCRIPT;
|
||
|
||
@endphp
|
||
|
||
{{-- INCLUDE TEMPLATE --}}
|
||
@include('vendor.cookie-notice-templates.standard', compact(
|
||
'site_name', 'logo_picture_url', 'logo_alt_text',
|
||
'logo_title_text', 'strings'
|
||
))
|
||
|
||
@push('scripts')
|
||
<script nonce="{{ $nonce ?? '' }}">
|
||
document.addEventListener('DOMContentLoaded', function () {
|
||
window.WebCookieNotice = {};
|
||
@foreach($cookies as $index_name => $cookie)
|
||
window.WebCookieNotice['{{ $index_name }}'] = {};
|
||
window.WebCookieNotice['{{ $index_name }}'].tmp = {};
|
||
// SCRIPT
|
||
window.WebCookieNotice['{{ $index_name }}'].tmp.script = {!! strip_tags($cookie['script']) !!};
|
||
@php unset($cookie['script']); @endphp
|
||
// FALLBACK
|
||
@if(isset($cookie['fallback']))
|
||
window.WebCookieNotice['{{ $index_name }}'].tmp.fallback = {!! strip_tags($cookie['fallback']) !!};
|
||
@php unset($cookie['fallback']); @endphp
|
||
@endif
|
||
window.WebCookieNotice['{{ $index_name }}'].conf = @json($cookie);
|
||
window.WebCookieNotice['{{ $index_name }}'].conf.script = window.WebCookieNotice['{{ $index_name }}'].tmp.script;
|
||
window.WebCookieNotice['{{ $index_name }}'].conf.fallback = window.WebCookieNotice['{{ $index_name }}'].tmp.fallback;
|
||
window.WebCookieNotice['{{ $index_name }}'] = window.WebCookieNotice['{{ $index_name }}'].conf;
|
||
@endforeach
|
||
window.WebCookieNotice = new window.CookieNotice(window.WebCookieNotice);
|
||
|
||
function listenInlineCnButtons() {
|
||
const cookieInlineActivation =
|
||
document.getElementsByClassName("cn-cookie-activate");
|
||
[...cookieInlineActivation].forEach((cookieEl) => {
|
||
const cookieBtnActivation = cookieEl.querySelector("button");
|
||
if (!cookieBtnActivation) {
|
||
throw new Error("Invalid template cookie button");
|
||
}
|
||
cookieBtnActivation.addEventListener("click", (e) => {
|
||
e.preventDefault();
|
||
if (cookieEl.dataset.cookieName) {
|
||
window.WebCookieNotice.acceptCookie(cookieEl.dataset.cookieName);
|
||
cookieEl.classList.add("d-none");
|
||
}
|
||
});
|
||
});
|
||
};
|
||
});
|
||
</script>
|
||
@endpush
|