name = 'lgcookieslaw';
$this->tab = 'front_office_features';
$this->version = '1.4.19';
$this->author = 'Línea Gráfica';
$this->need_instance = 0;
$this->module_key = '56c109696b8e3185bc40d38d855f7332';
$this->author_address = '0x30052019eD7528f284fd035BdA14B6eC3A4a1ffB';
if (substr_count(_PS_VERSION_, '1.6') > 0) {
$this->bootstrap = true;
} else {
$this->bootstrap = false;
}
parent::__construct();
$this->displayName = $this->l('EU Cookie Law (Notification Banner + Cookie Blocker)');
$this->description = $this->l('Display a cookie banner and block cookies before getting the user consent.');
/* Backward compatibility */
if (_PS_VERSION_ < '1.5') {
require(_PS_MODULE_DIR_.$this->name.'/backward_compatibility/backward.php');
}
}
public function install()
{
$messages = array(
'en' => array(
'accept' => 'I accept',
'moreinfo' => 'More information',
'message' =>
'Our webstore '.
'uses cookies to offer a better user experience and we recommend you to accept their '.
'use to fully enjoy your navigation.',
),
'es' => array(
'accept' => 'Acepto',
'moreinfo' => 'Más información',
'message' =>
'Nuestra '.
'tienda usa cookies para mejorar la experiencia de usuario y le recomendamos '.
'aceptar su uso para aprovechar plenamente la navegación.',
),
'fr' => array(
'accept' => 'J\'accepte',
'moreinfo' => 'Plus d\'informations',
'message' =>
'Notre boutique '.
'utilise des cookies pour améliorer l\'expérience utilisateur et nous vous recommandons '.
'd\'accepter leur utilisation pour profiter pleinement de votre navigation.',
),
'it' => array(
'accept' => 'Accetto',
'moreinfo' => 'Piú info',
'message' =>
'Our webstore '.
'uses cookies to offer a better user experience and we recommend you to accept their '.
'use to fully enjoy your navigation.',
),
);
if (!parent::install()
|| !$this->registerHook('top')
|| !$this->registerHook('displayMobileTop')
|| !$this->registerHook('header')
|| !$this->registerHook('backofficeHeader')
|| !$this->registerHook('displayCustomerAccount')
) {
return false;
}
Configuration::updateValue('PS_LGCOOKIES_TIMELIFE', '31536000');
Configuration::updateValue('PS_LGCOOKIES_NAME', '__lglaw');
Configuration::updateValue('PS_LGCOOKIES_DIVCOLOR', '#000000');
Configuration::updateValue('PS_LGCOOKIES_POSITION', '2');
Configuration::updateValue('PS_LGCOOKIES_OPACITY', '0.8');
Configuration::updateValue('PS_LGCOOKIES_TESTMODE', '1');
Configuration::updateValue('PS_LGCOOKIES_RELOAD', '0');
Configuration::updateValue('PS_LGCOOKIES_HIDDEN', '0');
Configuration::updateValue('PS_LGCOOKIES_SHADOWCOLOR', '#000000');
Configuration::updateValue('PS_LGCOOKIES_FONTCOLOR', '#FFFFFF');
Configuration::updateValue('PS_LGCOOKIES_CMS', '1');
Configuration::updateValue('PS_LGCOOKIES_NAVIGATION_BTN', '5');
Configuration::updateValue('PS_LGCOOKIES_CMS_TARGET', '1');
Configuration::updateValue('PS_LGCOOKIES_POSITION', '1');
Configuration::updateValue('PS_LGCOOKIES_SHOW_CLOSE', '1');
Configuration::updateValue('PS_LGCOOKIES_BTN1_FONT_COLOR', '#FFFFFF');
Configuration::updateValue('PS_LGCOOKIES_BTN1_BG_COLOR', '#8BC954');
Configuration::updateValue('PS_LGCOOKIES_BTN2_FONT_COLOR', '#FFFFFF');
Configuration::updateValue('PS_LGCOOKIES_BTN2_BG_COLOR', '#5BC0DE');
Configuration::updateValue('PS_LGCOOKIES_NAVIGATION', '0');
Configuration::updateValue('PS_LGCOOKIES_IPTESTMODE', ''.$_SERVER['REMOTE_ADDR'].'');
Configuration::updateValue(
'PS_LGCOOKIES_BOTS',
'Teoma,alexa,froogle,Gigabot,inktomi,looksmart,URL_Spider_SQL,Firefly,NationalDirectory,'.
'AskJeeves,TECNOSEEK,InfoSeek,WebFindBot,girafabot,crawler,www.galaxy.com,Googlebot,Scooter,'.
'TechnoratiSnoop,Rankivabot,Mediapartners-Google, Sogouwebspider,WebAltaCrawler,TweetmemeBot,'.
'Butterfly,Twitturls,Me.dium,Twiceler'
);
// db tables
$query = 'CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'lgcookieslaw` (
`id_module` int(11) NOT NULL,
UNIQUE KEY `id_module` (`id_module`)
) ENGINE='.(defined('ENGINE_TYPE') ? ENGINE_TYPE : 'Innodb');
if (!Db::getInstance()->Execute($query)) {
return false;
}
$query = 'CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'lgcookieslaw_lang` (
`id_lang` int(11) NOT NULL,
`button1` text NOT NULL,
`button2` text NOT NULL,
`content` text NOT NULL,
UNIQUE KEY `id_lang` (`id_lang`)
) ENGINE='.(defined('ENGINE_TYPE') ? ENGINE_TYPE : 'Innodb').' CHARSET=utf8';
if (!Db::getInstance()->Execute($query)) {
return false;
}
// main langs, english by default
$languages = Language::getLanguages();
foreach ($languages as $language) {
if (isset($messages[$language['iso_code']])) {
$message = $messages[$language['iso_code']];
} else {
$message = $messages['en'];
}
Db::getInstance()->Execute(
'INSERT INTO `'._DB_PREFIX_.'lgcookieslaw_lang` VALUES ('.
(int)$language['id_lang'].', '.
'\''.pSQL($message['accept']).'\', '.
'\''.pSQL($message['moreinfo']).'\', '.
'\''.pSQL($message['message'], 'html').'\' '.
')'
);
}
return true;
}
public function uninstall()
{
Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'lgcookieslaw`');
Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'lgcookieslaw_lang`');
return parent::uninstall();
}
private function cleanBots($bots)
{
$bots = str_replace(' ', '', $bots);
return $bots;
}
private function getCMSList()
{
$cms = Db::getInstance()->ExecuteS(
'SELECT * '.
'FROM '._DB_PREFIX_.'cms_lang '.
'WHERE id_lang = '.(int)(Configuration::get('PS_LANG_DEFAULT'))
);
return $cms;
}
private function isBot($agente)
{
$bots = Configuration::get('PS_LGCOOKIES_BOTS');
$botlist = explode(',', $bots);
foreach ($botlist as $bot) {
if (strpos($agente, $bot) !== false) {
return true;
}
}
return false;
}
private function getModuleList()
{
$modules = Db::getInstance()->ExecuteS('SELECT * FROM '._DB_PREFIX_.'module');
foreach ($modules as &$module) {
$module['checked'] = (int)$this->checkModule($module['id_module']);
}
return $modules;
}
private function checkModule($id_module)
{
$checkmodule = Db::getInstance()->getValue(
'SELECT id_module '.
'FROM '._DB_PREFIX_.'lgcookieslaw '.
'WHERE id_module = '.(int)$id_module
);
if ($checkmodule) {
return true;
} else {
return false;
}
}
private function getContentLang($id_lang, $field)
{
$content = Db::getInstance()->getValue(
'SELECT '.$field.' '.
'FROM '._DB_PREFIX_.'lgcookieslaw_lang '.
'WHERE id_lang = '.(int)$id_lang
);
return $content;
}
private function formatBootstrap($text)
{
$text = str_replace('