-
Notifications
You must be signed in to change notification settings - Fork 0
/
helper.php
54 lines (51 loc) · 18.1 KB
/
helper.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* @version 1.0.0 stable
* @package RKR Cookie Control
* @copyright Copyright (C) 2012 ReneKreijveld.nl, All rights reserved.
* @license http://www.gnu.org/licenses GNU/GPL
* @author url: http://www.renekreijveld.nl
* @author email [email protected]
* @developer René Kreijveld
*
* RKR Cookie Control is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. See <http://www.gnu.org/licenses/>.
*
* RKR Cookie Control is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
// no direct access
defined('_JEXEC') or die;
class modRKRCookieControlHelper
{
/**
* Get a list of the menu items.
*
* @param JRegistry $params The module options.
*
* @return array
* @since 1.5
*/
static function getScript(&$params)
{
$koptekst = $params->get('ccKoptekst');
$statoe = $params->get('ccStatoe');
$sluiten = $params->get('ccSluiten');
$leesmeer = $params->get('ccLeesmeer');
$leesminder = $params->get('ccLeesminder');
$toelnietmeer = $params->get('ccToelnietmeer');
$script = 'function cookieControl(a){if(typeof(a)=="undefined"){a={pollPeriod:25,pollIncrement:1.25}}a.pollPeriod=a.pollPeriod||25;a.pollIncrement=a.pollIncrement||1.25;_cookieControlPoll(a)}function _cookieControlPoll(a){if(typeof(jQuery)=="undefined"){setTimeout(function(){_cookieControlPoll(a)},a.pollPeriod);a.pollPeriod*=a.pollIncrement}else{jQuery(function(){CookieControl.init(a)})}}var CookieControl={options:{countries:"United Kingdom",shape:"triangle",position:"left",theme:"light",introText:"~introduction_text",fullText:"~full_text",cookieOnText:"Cookies akkoord",cookieOffText:"Geen Cookies",cookieName:"rkrAllowCookies",protectedCookies:[],iconStatusCookieName:"rkrShowCookieIcon",cookiePath:"/",clickFadeSpeed:1000,acceptDelay:400,startOpen:false,autoHide:60000,autoDelete:60000,domain:"",subdomains:true,css:".ccc-content label{paddin:0 !important;width:auto !important;}div#cccwr div{font:11px/16px sans-serif;margin:0;text-align:left}div#cccwr #ccc-icon{cursor:pointer;display:none;z-index:9999;bottom:0;left:0;position:fixed}div#ccc-icon button{background:transparent url(/modules/mod_rkr_cookiecontrol/assets/ccc-icons2.png) no-repeat 0 0;*background-image:url(/modules/mod_rkr_cookiecontrol/assets/ccc-icons.gif);border:0;height:62px;width:62px}div#ccc-icon button span{visibility:hidden}.ccc-left #ccc-icon.ccc-triangle button{background-position:-62px 0!important}.ccc-left .ccc-go #ccc-icon.ccc-triangle button{background-position:-62px -62px!important}.ccc-right #ccc-icon.ccc-triangle button{background-position:-124px 0!important}.ccc-right .ccc-go #ccc-icon.ccc-triangle button{background-position:-124px -62px!important}div#cccwr #ccc-icon.ccc-diamond button{background-position:10px 0!important}div#cccwr .ccc-go #ccc-icon.ccc-diamond button{background-position:10px -62px!important}div#cccwr.ccc-right{left:auto;right:0}div#cccwr.ccc-right .ccc-go #ccc-icon.ccc-diamond button{background-position:0 -62px!important}div#cccwr.ccc-right #ccc-icon.ccc-diamond button{background-position:10px 0!important}div#cccwr.ccc-right #ccc-icon{left:auto;right:0}.ccc-widget{position:fixed;bottom:35px;left:70px;z-index:9999;display:none}div#cccwr.ccc-right .ccc-widget{left:auto;right:70px}.ccc-outer{background:#fff;border:1px solid #f0942b;border-radius:5px;box-shadow:0 0 5px rgba(0,0,0,0.3);color:#888;left:70px;width:200px;bottom:30px}.ccc-expand,.ccc-close,.ccc-inner h2{background:transparent url(/modules/mod_rkr_cookiecontrol/assets/ccc-star.png) no-repeat 0 0;*background-image:url(/modules/mod_rkr_cookiecontrol/assets/widget-x.gif);border:0}.ccc-inner{background:#fff;border-radius:5px 5px 5px 0;position:relative;z-index:2}.ccc-content{padding:5px 10px 10px 10px}.ccc-icon{background-position:0 -18px;height:34px;left:0;position:absolute;text-indent:-999em;top:0;width:40px}.ccc-close{background-position:0 -40px;border:0;height:13px;position:absolute;right:11px;text-indent:-999em;top:11px;width:13px}.ccc-inner h2{background-color:#f0942b;background-position:9px 6px;border-radius:3px 3px 0 0;color:#fff;font-size:1.3em;font-weight:bold;margin:0;padding:10px 9px 8px 44px}.ccc-inner p{margin:5px 0 8px;padding:0}.ccc-inner ul{margin:8px 0;padding:0 0 0 12px}.ccc-inner a{color:#f0942b}.ccc-inner a,.ccc-inner a:hover{text-decoration:none}#cccwr button{cursor:pointer}.ccc-inner .ccc-button{background-color:#666;border:1px solid #666;border-radius:3px;box-shadow:inset 0 0 2px #fff;color:#fff;display:block;font-size:1em;font-weight:bold;padding:3px;text-align:center;text-decoration:none;text-shadow:none}.ccc-inner .ccc-browser{background-color:#f0942b;border-color:#f0942b;width:100%}.ccc-expanded{display:none}.ccc-expand{background:#f0942b;border:0;border-radius:0 0 5px 5px;box-shadow:0 0 5px rgba(0,0,0,0.3);color:#fff;bottom:-25px;cursor:pointer;font-size:1em;left:50%;line-height:25px;margin-left:-40px;position:absolute;text-align:center;text-indent:0;width:80px;z-index:1}.ccc-inner .ccc-about{margin:0;position:relative;text-align:right;top:5px}.ccc-about small{font-size:10px}#cccwr.ccc-left .ccc-outer,#cccwr.ccc-left .ccc-inner{border-radius:5px 5px 5px 0}#cccwr.ccc-left .ccc-expand{left:0;margin-left:0;right:auto}#cccwr.ccc-right .ccc-outer,#cccwr.ccc-right .ccc-inner{border-radius:5px 5px 0 5px}#cccwr.ccc-right .ccc-expand{left:auto;right:0}#cccwr.ccc-dark .ccc-outer{background:#333;background-color:rgba(20,20,20,0.9);*background-color:#141414;border-radius:5px 5px 5px 0;border-color:#000;color:#fff}#cccwr.ccc-dark.ccc-right .ccc-outer{border-radius:5px 5px 0 5px}#cccwr.ccc-dark .ccc-inner{background:transparent}#cccwr.ccc-dark .ccc-inner p{color:#fff}#cccwr.ccc-dark .ccc-inner h2{background-color:transparent;background-position:9px -54px;background-repeat:no-repeat}#cccwr.ccc-dark .ccc-content{padding-top:0}#cccwr.ccc-dark .ccc-expand{height:27px;border:1px solid #000;border-top:0;padding-top:0;background:#333;background-color:rgba(20,20,20,0.9);*background-color:#141414}#cccwr.ccc-dark .ccc-close{background-position:0 -100px}#cccwr #ccc-cookies-switch{width:180px;height:30px;overflow:hidden;display:none}#cccwr #cctoggle{display:inline-block;width:180px;height:30px;background:url(/modules/mod_rkr_cookiecontrol/assets/ccc-switch.png) no-repeat;*background-image:url(/modules/mod_rkr_cookiecontrol/assets/ccc-switch.png);*background-repeat:no-repeat;line-height:28px;font-size:13px;color:white}.cctoggle-on{background-position:100% 0!important}#cccwr #ccc-implicit-warning{display:none}#cccwr #ccc-explicit-checkbox{display:none}#cccwr .cctoggle-text-off{padding-left:20px}#cccwr .cctoggle-text-on{padding-left:70px}",html:\'<div id="cccwr"><div id="ccc-state" class="ccc-pause"><div id="ccc-icon"><button><span>Cookie Controle</span></button></div><div class="ccc-widget"><div class="ccc-outer"><div class="ccc-inner"><h2>Cookie Controle</h2><div class="ccc-content"><p class="ccc-intro"></p><div class="ccc-expanded"></div><div id="ccc-cookies-switch" style="background-position-x: 0;"><a id="cctoggle" href="#" style="background-position-x: 0;"><span id="cctoggle-text">Cookies test</span></a></div><div id="ccc-implicit-warning"><p>Eén cookie werd geplaatst om uw voorkeur op te slaan</p></div><div id="ccc-explicit-checkbox"><p><input id="cchide-popup" type="checkbox" name="ccc-hide-popup" value="Y" /> #toelnietmeer#</p></div><a class="ccc-icon" href="http://www.civicuk.com/cookie-law" target="_blank" title="Over Cookie Controle">Over Cookie Controle</a><button class="ccc-close">Close</button></div></div></div><button class="ccc-expand">#leesmeer#</button></div></div></div>\',onReady:null,onCookiesAllowed:null,onCookiesNotAllowed:null,onAccept:null,consentModel:"information_only"},init:function(a){this._jc=false;this.options=jQuery.extend(this.options,a);this.initWidget();this.readyEvent();if(this.maySendCookies()){this.cookiesAllowedEvent()}else{this.cookiesNotAllowedEvent()}},cookieLawApplies:function(){if(this.countryHasCookieLaw()){return true}return false},maySendCookies:function(){if(!this.cookieLawApplies()){return true}if(this.consented()){return true}return false},consented:function(){return this._jc||(this.getCookie(this.options.cookieName)==="yes")},reset:function(){this.setCookie(this.options.cookieName,"",true);this.setCookie(this.options.iconStatusCookieName,"",true);this.setCookie("rkrNoPopup","",true)},initWidget:function(){if(!this.cookieLawApplies()){return}if(this.getCookie(this.options.iconStatusCookieName)==="no"){return}this.initShowCookieWidget()},initShowCookieWidget:function(){var e=this.consented();if(jQuery("#cccwr .ccc-outer").length){return}jQuery("head").append(\'<style type="text/css">\'+this.options.css+"</style>");jQuery("body").prepend(this.options.html);var a=jQuery("#ccc-icon");var c=jQuery("#ccc-state");jQuery("#cccwr").addClass("ccc-"+this.options.position);a.addClass("ccc-"+this.options.shape);jQuery("#cccwr .ccc-intro").append(this.options.introText);jQuery("#cccwr .ccc-expanded").prepend(this.options.fullText);jQuery("#cccwr").addClass("ccc-"+this.options.theme);a.show();c.addClass(e?"ccc-go":"ccc-pause");var d=this.getCookie(this.options.cookieName);switch(this.options.consentModel){case"information_only":c.removeClass("ccc-pause").addClass("ccc-go");jQuery("#cctoggle-text").addClass("cctoggle-text-on");jQuery("#cctoggle-text").html(CookieControl.options.cookieOnText);break;case"implicit":jQuery("#cccwr #ccc-cookies-switch").show();if(!d){c.removeClass("ccc-pause").addClass("ccc-go");jQuery("#cctoggle-text").addClass("cctoggle-text-on");jQuery("#cctoggle-text").html(CookieControl.options.cookieOnText);CookieControl._jc=true;CookieControl.acceptEvent();CookieControl.setCookie(CookieControl.options.cookieName,"yes");CookieControl.cookiesAllowedEvent()}CookieControl.options.protectedCookies.push(CookieControl.options.cookieName);break;case"explicit":var b=this.getCookie("rkrNoPopup");if(b=="no"){jQuery("#cccwr #cchide-popup").attr("checked",true)}else{jQuery("#cccwr #cchide-popup").removeAttr("checked")}jQuery("#cccwr #ccc-cookies-switch").show();jQuery("#cctoggle-text").addClass("cctoggle-text-off");jQuery("#cctoggle-text").val(CookieControl.options.cookieOffText);break}if(this.options.consentModel!="information_only"){if(d=="yes"){jQuery("#cccwr #ccc-cookies-switch #ccc-cookies-checkbox").attr("checked",true);jQuery("#cctoggle").addClass("cctoggle-on");jQuery("#cctoggle-text").removeClass("cctoggle-text-off").addClass("cctoggle-text-on");jQuery("#cctoggle-text").html(CookieControl.options.cookieOnText)}else{if(!d&&this.options.consentModel=="implicit"){jQuery("#cccwr #ccc-cookies-switch #ccc-cookies-checkbox").attr("checked",true);jQuery("#cctoggle").addClass("cctoggle-on");jQuery("#cctoggle-text").removeClass("cctoggle-text-off").addClass("cctoggle-text-on");jQuery("#cctoggle-text").html(CookieControl.options.cookieOnText)}else{jQuery("#cccwr #ccc-cookies-switch #ccc-cookies-checkbox").removeAttr("checked");jQuery("#cctoggle").removeClass("cctoggle-on");jQuery("#cctoggle-text").removeClass("cctoggle-text-on").addClass("cctoggle-text-off");jQuery("#cctoggle-text").html(CookieControl.options.cookieOffText);if(CookieControl.options.consentModel=="implicit"){jQuery("#cccwr #ccc-implicit-warning").show()}else{if(CookieControl.options.consentModel=="explicit"){jQuery("#cccwr #ccc-explicit-checkbox").show()}}}}}else{if(d==false){c.removeClass("ccc-pause").addClass("ccc-go");jQuery("#cctoggle-text").removeClass("cctoggle-text-off").addClass("cctoggle-text-on");jQuery("#cctoggle-text").html(CookieControl.options.cookieOnText);CookieControl._jc=true;CookieControl.acceptEvent();CookieControl.setCookie(CookieControl.options.cookieName,"yes");CookieControl.cookiesAllowedEvent()}}a.click(function(f){f.preventDefault();jQuery("#cccwr .ccc-widget").clearQueue().fadeToggle(CookieControl.options.clickFadeSpeed)});jQuery("#cccwr #cchide-popup").click(function(g){var f=jQuery(this).attr("checked");var h=CookieControl;if(f==true){h.setCookie("rkrNoPopup","no");jQuery("#cccwr .ccc-widget").fadeOut(CookieControl.options.clickFadeSpeed)}else{h.setCookie("rkrNoPopup","",true)}});jQuery("#cccwr .ccc-close").click(function(f){f.preventDefault();jQuery("#cccwr .ccc-widget").clearQueue().fadeOut(CookieControl.options.clickFadeSpeed)});jQuery("#cccwr .ccc-expand").click(function(){var f=jQuery(this);if(jQuery(".ccc-expanded").css("display")==="none"){jQuery(".ccc-expanded").slideDown(200,function(){f.text("#leesminder#")});jQuery(this).css({backgroundPosition:"center 0"})}else{jQuery(".ccc-expanded").slideUp(200,function(){f.text("#leesmeer#")});jQuery(this).css({backgroundPosition:"center -9px"})}});jQuery("#cctoggle").click(function(){if(jQuery(this).hasClass("cctoggle-on")){jQuery("#cctoggle-text").html("");jQuery("#cctoggle-text").removeClass("cctoggle-text-on");jQuery(this).animate({"background-position-x":"0"},250,function(){jQuery(this).removeClass("cctoggle-on");c.removeClass("ccc-go").addClass("ccc-pause");CookieControl._jc=false;if(CookieControl.options.consentModel!="explicit"){CookieControl.setCookie(CookieControl.options.cookieName,"no")}else{CookieControl.setCookie(CookieControl.options.cookieName,"",true)}CookieControl.cookiesNotAllowedEvent();if(CookieControl.options.consentModel=="implicit"){jQuery("#cccwr #ccc-implicit-warning").slideDown();jQuery("#cccwr .ccc-widget").fadeOut(5000)}else{if(CookieControl.options.consentModel=="explicit"){if(jQuery.browser.msie&&parseInt(jQuery.browser.version,10)===7){jQuery("#cccwr #ccc-explicit-checkbox").show()}else{jQuery("#cccwr #ccc-explicit-checkbox").slideDown()}}}jQuery("#cctoggle-text").addClass("cctoggle-text-off");jQuery("#cctoggle-text").html(CookieControl.options.cookieOffText);CookieControl.delAllCookies(CookieControl.options.protectedCookies)})}else{jQuery("#cctoggle-text").html("");jQuery("#cctoggle-text").removeClass("cctoggle-text-off");jQuery(this).animate({"background-position-x":"100%"},250,function(){jQuery(this).addClass("cctoggle-on");c.removeClass("ccc-pause").addClass("ccc-go");CookieControl._jc=true;CookieControl.acceptEvent();CookieControl.setCookie(CookieControl.options.cookieName,"yes");CookieControl.cookiesAllowedEvent();if(CookieControl.options.consentModel=="implicit"){jQuery("#cccwr #ccc-implicit-warning").slideUp()}else{if(CookieControl.options.consentModel=="explicit"){jQuery("#cccwr #ccc-explicit-checkbox").slideUp()}}jQuery("#cctoggle-text").addClass("cctoggle-text-on");jQuery("#cctoggle-text").html(CookieControl.options.cookieOnText);jQuery("#cccwr .ccc-widget").fadeOut(2000)})}});var b=this.getCookie("rkrNoPopup");if(this.options.startOpen&&d!="yes"&&d!="no"&&b!="no"){jQuery("#cccwr .ccc-widget").fadeIn(this.options.clickFadeSpeed).delay(this.options.autoHide).fadeOut(this.options.clickFadeSpeed,function(){if(!CookieControl.getCookie(CookieControl.options.cookieName)&&CookieControl.options.consentModel!="explicit"){CookieControl._jc=false;CookieControl.setCookie(CookieControl.options.cookieName,"no");CookieControl.cookiesNotAllowedEvent()}});jQuery("#cccwr .ccc-widget").mouseover(function(){jQuery("#cccwr .ccc-widget").clearQueue();if(!CookieControl.getCookie(CookieControl.options.cookieName)&&CookieControl.options.consentModel!="explicit"){CookieControl._jc=false;CookieControl.setCookie(CookieControl.options.cookieName,"no");CookieControl.cookiesNotAllowedEvent()}})}},countryHasCookieLaw:function(){if(this.options.countries&&typeof(geoplugin_countryName)==="function"){var a=geoplugin_countryName().replace(/^\s+|\s+$/g,"");if(typeof(this.options.countries)==="string"){this.options.countries=this.options.countries.split(/\s*,\s*/)}return jQuery.inArray(geoplugin_countryName().replace(/^\s+|\s+$/g,""),this.options.countries)>=0}return true},checkShowIconState:function(){var a=CookieControl;if(jQuery(".ccc-widget input[name=showicon]:checked").val()==="N"){this.setCookie(a.options.iconStatusCookieName,"no");return true}else{this.setCookie(a.options.iconStatusCookieName,"yes");return false}},setCookie:function(a,k,b,l){var e="Thursday, 01-Jan-1970 00:00:01 GMT";if(!b){var g=new Date();var d=1000*60*60*24*90;var c=new Date(g.getTime()+d);var e=c.toGMTString()}var f=this.options.domain;if(f.length===0){var i=window.location.hostname;var h=2;if(i.match(/\.(gov|police|org|co|uk|ltd|me|plc|ac|net)\.\w{2}/)){h=3}var j=i.split(".").reverse();j.length=h;f=j.reverse().toString().replace(/,/g,".")}if(this.options.subdomains===true){domainString=";domain="+f}else{domainString=";domain="+i}document.cookie=a+"="+k+";expires="+e+";path="+this.options.cookiePath+domainString},getCookie:function(a){var b=false;jQuery.each(document.cookie.split(";"),function(e,f){var d=f.split("=");if(d[0].replace(/^\s+|\s+$/g,"")===a){b=unescape(d[1]);return false}});if("undefined"===typeof b){b=false}return b},delCookie:function(a,c,d){var c=c||document.domain;var d=d||"/";var b=a+"=;expires=Thursday, 01-Jan-1970 00:00:01 GMT;; domain="+c+"; path="+d;document.cookie=b},delAllCookies:function(d){if(!this.options.autoDelete){return}var e=document.cookie.split(/;\s*/);var c;for(c=0;c<e.length;c++){var b=e[c];var f=b.indexOf("=");var a=f>-1?b.substr(0,f):b;if(jQuery.inArray(a,d)<0){this.setCookie(a,"",true);this.delCookie(a)}}},acceptEvent:function(a){if(this.firedAcceptEvent||this.getCookie(this.options.cookieName)==="yes"){return}this.firedAcceptEvent=true;if(typeof(this.options.onAccept)=="function"){this.options.onAccept(this)}return a},readyEvent:function(a){if(typeof(this.options.onReady)=="function"){this.options.onReady(this)}return a},cookiesNotAllowedEvent:function(a){if(typeof(this.options.onCookiesNotAllowed)=="function"){this.options.onCookiesNotAllowed(this)}return a},cookiesAllowedEvent:function(a){if(typeof(this.options.onCookiesAllowed)=="function"){this.options.onCookiesAllowed(this)}return a}};';
$script = str_replace('#koptekst#',$koptekst,$script);
$script = str_replace('#statoe#',$statoe,$script);
$script = str_replace('#sluiten#',$sluiten,$script);
$script = str_replace('#leesmeer#',$leesmeer,$script);
$script = str_replace('#leesminder#',$leesminder,$script);
$script = str_replace('#toelnietmeer#',$toelnietmeer,$script);
return $script;
}
}