Your IP : 216.73.216.219


Current Path : /home/pteabiscqq/www/plugins/system/lab5_cookie_commander/cookie_commander/
Upload File :
Current File : /home/pteabiscqq/www/plugins/system/lab5_cookie_commander/cookie_commander/cookie_commander.JS.php

<?php defined('_JEXEC') or die();
/////////////////////////////////////////////////////////////////////////////////////////////
/** 
* Cookie Commander
* 
* @author : Lab5 - Dennis Riegelsberger
* @authorUrl : https://lab5.ch
* @copyright : Copyright (C) 2018+  Lab5 - Dennis Riegelsberger. All rights reserved.
* @license : GNU/GPL General Public License version 2 or later
* @project : https://lab5.ch/cookie-commander
* @on JED : https://extensions.joomla.org/extensions/extension/site-management/cookie-control/lab5-cookie-commander/
* 
* Built with <3 
* Lab5
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 
/**
 * @CHANGELOG :
 * * 2020.08.10 : Great overhaul
 * * 
 */
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
	
	/////////////////////////////////////////////////////////
	// HTML : Popup-Overlay / MODAL 
	/////////////////////////////////////////////////////////
	
						if(self::$xstor->cooco->controlsButton):  // Only needed, if Controlls-Button exists
						//////////////////////////////////////////////
										
										require('load_popup.php'); 
										
							
										////////////////////////////////////////////
										// POPUP-OVERLAY - VARIANT
										////////////////////////////////////////////
										if( self::$xstor->cooco->popupVariant == "2" ){
															
															$doc->addScript( $lebase.'/assets/jquery.popupoverlay.js');
															
															$popupHTML = 
															// '<div id="'.self::$xstor->cooco->idPopup.'" class="modal">'. 
																	'<div class="modal-header">' .
																			'<h3  >'.  $popup_header . '</h3>' .
																	'</div>' .
																	'<div class="modal-body">' .
																			$popup_body . 
																	'</div>' .
																	'<div class="modal-footer">' .
																			$popup_footer . 
																	'</div>' .
															// '</div>' .
															'';
															
															$popupHTML = str_replace( "{popup_html}", $popupHTML, $popup_form );
															
															$popupHTML = 
															'<div id="'.self::$xstor->cooco->idPopup.'" class="">'. 
																	// '<div class="">' .
																			$popupHTML . 
																	// '</div>' .
															'</div>' ;
															
										}			
										////////////////////////////////////////////
										// MODAL - VARIANT
										////////////////////////////////////////////
										if( self::$xstor->cooco->popupVariant == "1" ){ 
															
															// MODAL 
															//////////////////////
															$popupHTML = JHtml::_(
																			
																				'bootstrap.renderModal',
																				self::$xstor->cooco->idPopup,
																				array(
																					'title'  => $popup_header ,
																					'footer' => $popup_footer,
																					'backdrop'    => true ,
																					'modalWidth'  => '33', 
																				),
																				'<div  >'. $popup_body . '</div>' // MODAL BODY
															); 
															
															$popupHTML = str_replace( "{popup_html}", $popupHTML, $popup_form );
															
															$popupHTML = 
															'<div id="'.self::$xstor->cooco->idPopup.'_cooco_modalwrap" class="cooco_popup_wrapper" >'.  
																	$popupHTML . 
															'</div>' ;
										}			
										////////////////////////////////////////////
										 
										self::$xstor->cooco->popupContentHTML = $popupHTML;
										
						endif; ///////////////////////////////////
						
	 
	////////////////////////////////////////////////
	// Analytics - Google 
	////////////////////////////////////////////////
	
						$JS_analytics_google = "";
						////////////////////
						if( 	
						self::$xstor->cooco->modusOperandi == 'optin' &&
						self::$xstor->cooco->activate_google && 
						!self::$xstor->cooco->include_google ):
						//////////////////////////////////////////////
						
													require ( realpath( __DIR__ . '/../').'/analytics/code.google.php'); 
													$JS_analytics_google = $anal_code;
													
						endif; ///////////////////////////////////
						
	////////////////////////////////////////////////
	// Analytics - Matomo / Piwik - via JS
	////////////////////////////////////////////////

						$JS_analytics_matomo = "";
						////////////////////
						if( 	
						self::$xstor->cooco->modusOperandi == 'optin' &&
						self::$xstor->cooco->activate_piwik &&
						!self::$xstor->cooco->include_piwik && 
						self::$xstor->cooco->piwikEmbedMode == 1 ):
						//////////////////////////////////////////////

													require ( realpath( __DIR__ . '/../').'/analytics/code.piwik.php'); 
													// To call code from function -> varis MUST explicitly be set up w global scope ! 
													// => we do that useing window.yourGlobalVariable = ...;
													// https://stackoverflow.com/questions/5786851/define-global-variable-in-a-javascript-function
													$JS_analytics_matomo = ''."\n".
														'	window._paq = window._paq || []; '."\n".
													$anal_code;
													// die($JS_analytics_matomo );
													
						endif; ///////////////////////////////////

	/////////////////////////////////////////////////////////
	// Cookie Bar 
	/////////////////////////////////////////////////////////
	$JS = "
			$(document).ready(function() { 
				
						jQuery.cookieBar( { 	
									
									storageMode: '".self::$xstor->cccookies->STORM."' , 
									consentCookieName: '".self::$xstor->cooco->consentCookieName."' ,
									cookienames:  ['".implode( "','", array_keys(self::$xstor->cccookies->cookie_switches) )."'] ,
									expireDays: '".self::$xstor->cooco->expireDays."' ,
									popupVariant: ".self::$xstor->cooco->popupVariant.",
		
									autoEnable: ".self::$xstor->cooco->autoEnable." ,
									acceptOnContinue: ".self::$xstor->cooco->acceptOnContinue." ,
									acceptOnScroll: ".self::$xstor->cooco->acceptOnScroll." ,
									acceptAnyClick: ".self::$xstor->cooco->acceptAnyClick." ,
									renewOnVisit: ".self::$xstor->cooco->renewOnVisit." ,

									idCookieBar: '".self::$xstor->cooco->idCookieBar."' ,
									idPopup: '".self::$xstor->cooco->idPopup."' ,
									
									controlsButton: ".self::$xstor->cooco->controlsButton." , 
									controlsText: '". self::$xstor->cooco->controlsText."' ,
									btnClassControls: '". self::$xstor->cooco->btnClassControls."' ,
									classBTNControls: '".self::$xstor->cooco->classBTNControls."' ,
									
									acceptButton: ".self::$xstor->cooco->acceptButton." , 
									acceptText: '". self::$xstor->cooco->acceptText."' ,
									btnClassAccept: '". self::$xstor->cooco->btnClassAccept."' ,
									classBTNAccept: '".self::$xstor->cooco->classBTNAccept."' ,
			
									declineButton: ".self::$xstor->cooco->declineButton." ,
									declineText: '". self::$xstor->cooco->declineText."' ,
									btnClassDecline: '". self::$xstor->cooco->btnClassDecline."' ,
									classBTNDecline: '".self::$xstor->cooco->classBTNDecline."' ,
									
									policyButton: ".self::$xstor->cooco->policyButton." ,
									policyText: '". self::$xstor->cooco->policyText."' ,
									btnClassPolicy: '". self::$xstor->cooco->btnClassPolicy."' ,
									classBTNPolicy: '".self::$xstor->cooco->classBTNPolicy."' ,
									policyURL: '".self::$xstor->cooco->policyURL."' ,
									
									showMode: '".self::$xstor->cooco->showMode."' , 
									zindex: ".self::$xstor->cooco->zindex." , 
									append: ".self::$xstor->cooco->append." , 
									
									";	
									// Old Stuff from when the HTML was still build within the JS ( now it's created directly )
									/**
									$JS = " 
									message: '". addslashes(self::$xstor->cooco->message)."' ,
									popupContentHTML: '".self::$xstor->cooco->popupContentHTML."' , // Old method with Overlay 
									fixed: ".self::$xstor->cooco->fixed." ,
									bottom: ".self::$xstor->cooco->bottom." ,
									";
									* * * */
									$JS .= " 
									acceptFunction: function(cookieValue){
												 
														/* dynamically set Analytics tracking if accepted  */				
														".$JS_analytics_google."
														".$JS_analytics_matomo."
														
												 
												if(cookieValue!='undecided' && cookieValue!='accepted') { 
														
														".
														// " window.location = window.location.href; ".
														"
												}
									} , 
									declineFunction: function(cookieValue){	
									";	
												if( self::$xstor->cooco->activate_google && self::$xstor->cooco->modusOperandi == 'optout' ){ 
												$JS .= "
												
												/* kills google analytics cookies */
												if( typeof(gaOptout) == 'function' ) { gaOptout(); }
												
												"; 
												}
												if( !empty(trim(self::$xstor->cooco->declineURL))){
												$JS .= "	
													if(cookieValue=='undecided' || cookieValue=='accepted') { 
															/* window.location = window.location.href;  */
															window.location = '".self::$xstor->cooco->declineURL."' ;
													}
												"; 
												}
												$JS .= "	
									}

						}); 

			});
	";
	$doc->addScriptDeclaration( $JS );  
	unset($JS);
	
/////////////////////////////////////////////////////////////////////////////////////////////