* @copyright 2013-2014 Antadis * @version 1.0 */ if (!defined('_PS_VERSION_')) exit; class CookiesInfos extends Module { public function __construct() { $this->name = 'cookiesinfos'; $this->tab = 'font_office_featues'; $this->version = '1.0'; $this->author = 'Antadis'; parent::__construct(); $this->displayName = $this->l('Cookies Informatiosn'); $this->description = $this->l('Display a cookies informations top bar with link to redirect where you want'); if (!Configuration::get('COOKIESINFO_LINK') || !Configuration::get('COOKIESINFO_INTRO')) $this->warning = $this->l('Wrong settings'); } public function install() { if(!parent::install() || !$this->registerHook('header') || !$this->registerHook('footer') || !Configuration::updateValue('COOKIESINFO_LINK', '') || !Configuration::updateValue('COOKIESINFO_INTRO', '')) return false; return true; } public function uninstall() { if (!parent::uninstall() || !Configuration::updateValue('COOKIESINFO_LINK', '') || !Configuration::updateValue('COOKIESINFO_INTRO', '')) return false; return true; } public function getContent() { global $cookie; /* Language */ $defaultLanguage = intval(Configuration::get('PS_LANG_DEFAULT')); $languages = Language::getLanguages(FALSE); $divLangName = 'link¤intro'; if (Tools::isSubmit('submitConfig')) { foreach ($languages as $language) { Configuration::updateValue('COOKIESINFO_LINK'.'_'.$language['id_lang'], Tools::getValue('link'.'_'.$language['id_lang'])); Configuration::updateValue('COOKIESINFO_INTRO'.'_'.$language['id_lang'], Tools::getValue('intro'.'_'.$language['id_lang'])); } echo '
Mise à jour avec succès
'; } echo '
Configuration
'; foreach ($languages as $language) { echo ''; } echo $this->displayFlags($languages, $defaultLanguage, $divLangName, 'link', true); echo '
'; foreach ($languages as $language) { echo '
'; echo ''; echo '
'; } echo $this->displayFlags($languages, $defaultLanguage, $divLangName, 'intro', true); echo '
'; } public function hookHeader($params) { if (Tools::getValue('cookie') ) { setcookie('cookie_info', 1, time() + (365 * 24 * 60 * 60) , '/'); Tools::redirect($_SERVER['HTTP_REFERER']); } if(!isset($_COOKIE['cookie_info']) || $_COOKIE['cookie_info'] != 1) { Tools::addCSS(($this->_path).'css/cookiesinfo.css', 'all'); Tools::addJS(($this->_path).'js/cookiesinfo.js'); } } public function hookFooter($params) { global $smarty, $cookie; if(isset($_COOKIE['cookie_info']) && $_COOKIE['cookie_info'] == 1 || isset($_GET['lp']) || isset($_GET['sponsor']) ) { return FALSE; } else { $smarty->assign(array( 'cookies_intro' => Configuration::get('COOKIESINFO_INTRO_'.$cookie->id_lang), 'cookies_link' => Configuration::get('COOKIESINFO_LINK_'.$cookie->id_lang) )); return $this->display($this->_path, 'views/templates/hook/displayTop.tpl'); } } }