116 lines
3.6 KiB
PHP
116 lines
3.6 KiB
PHP
<?php
|
|
|
|
if (!defined('_CAN_LOAD_FILES_'))
|
|
exit;
|
|
|
|
include_once(dirname(__FILE__) . '/classes/AdvLink.php');
|
|
|
|
class AdvBlockLink extends Module
|
|
{
|
|
public function __construct()
|
|
{
|
|
$this->name = 'advblocklink';
|
|
$this->tab = 'front_office_features';
|
|
$this->version = '1.0';
|
|
$this->author = 'Antadis';
|
|
$this->need_instance = 0;
|
|
|
|
$this->bootstrap = true;
|
|
parent::__construct();
|
|
|
|
$this->displayName = $this->l('Bloc liens avancé');
|
|
$this->description = $this->l('Gestion des blocs de liens du footer');
|
|
}
|
|
|
|
public function install()
|
|
{
|
|
$sql = array();
|
|
|
|
$sql[] =
|
|
'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'advblocklink` (
|
|
`id_link` int(10) unsigned NOT NULL auto_increment,
|
|
`id_parent` varchar(255) NOT NULL,
|
|
`position` INT(11) UNSIGNED NOT NULL default 0,
|
|
`external` INT(3) NOT NULL,
|
|
`active` INT(3) NOT NULL,
|
|
PRIMARY KEY (`id_link`)
|
|
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8';
|
|
|
|
$sql[] =
|
|
'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'advblocklink_shop` (
|
|
`id_link` int(10) unsigned NOT NULL auto_increment,
|
|
`id_shop` int(10) unsigned NOT NULL,
|
|
PRIMARY KEY (`id_link`, `id_shop`)
|
|
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8';
|
|
|
|
$sql[] =
|
|
'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'advblocklink_lang` (
|
|
`id_link` int(10) unsigned NOT NULL,
|
|
`id_lang` int(10) unsigned NOT NULL,
|
|
`title` varchar(255) NOT NULL,
|
|
`url` varchar(255),
|
|
PRIMARY KEY (`id_link`,`id_lang`)
|
|
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8';
|
|
|
|
foreach ($sql as $_sql) {
|
|
Db::getInstance()->Execute($_sql);
|
|
}
|
|
|
|
AdvLink::refreshPositionsAll();
|
|
|
|
$new_tab = new Tab();
|
|
$new_tab->class_name = 'AdminAdvBlockLink';
|
|
$new_tab->id_parent = Tab::getCurrentParentId();
|
|
$new_tab->module = $this->name;
|
|
$languages = Language::getLanguages();
|
|
foreach ($languages as $language) {
|
|
$new_tab->name[$language['id_lang']] = 'Liens du footer';
|
|
}
|
|
|
|
$new_tab->add();
|
|
|
|
return parent::install() && $this->registerHook('displayFooter') && $this->registerHook('actionRefreshBLocklink');
|
|
}
|
|
|
|
public function uninstall()
|
|
{
|
|
$sql = 'DROP TABLE IF EXISTS
|
|
`' . _DB_PREFIX_ . 'advblocklink_lang`,
|
|
`' . _DB_PREFIX_ . 'advblocklink_shop`,
|
|
`' . _DB_PREFIX_ . 'advblocklink`
|
|
';
|
|
|
|
Db::getInstance()->Execute($sql);
|
|
|
|
$idTab = Tab::getIdFromClassName('AdminAdvBlockLink');
|
|
if ($idTab) {
|
|
$tab = new Tab($idTab);
|
|
$tab->delete();
|
|
}
|
|
|
|
return parent::uninstall();
|
|
}
|
|
|
|
public function hookDisplayFooter($params)
|
|
{
|
|
if (!$this->isCached('advblocklink.tpl', $this->getCacheId())) {
|
|
$blockLinks = AdvLink::getBlockLinks();
|
|
if (!$blockLinks) {
|
|
return false;
|
|
}
|
|
$this->smarty->assign('blockLinks', $blockLinks);
|
|
}
|
|
return $this->display(__FILE__, 'advblocklink.tpl', $this->getCacheId());
|
|
}
|
|
|
|
public function hookDisplayLinks($params)
|
|
{
|
|
return $this->hookDisplayFooter($params);
|
|
}
|
|
|
|
public function hookActionRefreshBLocklink()
|
|
{
|
|
$this->_clearCache('advblocklink.tpl');
|
|
}
|
|
|
|
} |