138 lines
4.1 KiB
PHP
138 lines
4.1 KiB
PHP
|
<?php
|
||
|
|
||
|
if (!defined('_CAN_LOAD_FILES_'))
|
||
|
exit;
|
||
|
|
||
|
include_once(dirname(__FILE__) . '/classes/AdvRea2.php');
|
||
|
|
||
|
class AdvReassurance2 extends Module
|
||
|
{
|
||
|
public function __construct()
|
||
|
{
|
||
|
$this->name = 'advreassurance2';
|
||
|
$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('Reassurance avancé 2');
|
||
|
$this->description = $this->l('Gestion des blocks reassurance2');
|
||
|
}
|
||
|
|
||
|
public function install()
|
||
|
{
|
||
|
$sql = array();
|
||
|
|
||
|
$sql[] =
|
||
|
'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'advreassurance2` (
|
||
|
`id_reassurance2` int(10) unsigned NOT NULL auto_increment,
|
||
|
`position` INT(11) UNSIGNED NOT NULL default 0,
|
||
|
`active` INT(11) UNSIGNED NOT NULL default 1,
|
||
|
PRIMARY KEY (`id_reassurance2`)
|
||
|
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8';
|
||
|
|
||
|
$sql[] =
|
||
|
'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'advreassurance2_lang` (
|
||
|
`id_reassurance2` int(10) unsigned NOT NULL,
|
||
|
`id_lang` int(10) unsigned NOT NULL,
|
||
|
`title` varchar(255) NOT NULL,
|
||
|
`subtitle` varchar(255) NOT NULL,
|
||
|
`url` varchar(255),
|
||
|
PRIMARY KEY (`id_reassurance2`,`id_lang`)
|
||
|
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8';
|
||
|
|
||
|
$sql[] =
|
||
|
'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'advreassurance2_shop` (
|
||
|
`id_reassurance2` int(10) unsigned NOT NULL auto_increment,
|
||
|
`id_shop` int(10) unsigned NOT NULL,
|
||
|
PRIMARY KEY (`id_reassurance2`, `id_shop`)
|
||
|
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8';
|
||
|
|
||
|
|
||
|
foreach ($sql as $_sql) {
|
||
|
Db::getInstance()->Execute($_sql);
|
||
|
}
|
||
|
|
||
|
$tab = new Tab();
|
||
|
$tab->class_name = 'AdminAdvReassurance2';
|
||
|
$tab->id_parent = Tab::getCurrentParentId();
|
||
|
$tab->module = $this->name;
|
||
|
$languages = Language::getLanguages();
|
||
|
foreach ($languages as $language) {
|
||
|
$tab->name[$language['id_lang']] = 'Reassurance2';
|
||
|
}
|
||
|
|
||
|
$img_dir = _PS_IMG_DIR_ . 'reassurance2';
|
||
|
$folder = is_dir($img_dir);
|
||
|
if (!$folder)
|
||
|
{
|
||
|
$folder = mkdir($img_dir, 0755, true);
|
||
|
}
|
||
|
|
||
|
return parent::install() && $tab->add() && $this->registerHook('displayReassurance2') && $this->registerHook('actionRefreshReassurance2') && $folder;
|
||
|
|
||
|
}
|
||
|
|
||
|
public function uninstall()
|
||
|
{
|
||
|
$sql = 'DROP TABLE IF EXISTS
|
||
|
`' . _DB_PREFIX_ . 'advreassurance2_lang`,
|
||
|
`' . _DB_PREFIX_ . 'advreassurance2_shop`,
|
||
|
`' . _DB_PREFIX_ . 'advreassurance2`
|
||
|
';
|
||
|
|
||
|
Db::getInstance()->Execute($sql);
|
||
|
|
||
|
$idTab = Tab::getIdFromClassName('AdminAdvReassurance2');
|
||
|
if ($idTab) {
|
||
|
$tab = new Tab($idTab);
|
||
|
$tab->delete();
|
||
|
}
|
||
|
|
||
|
return parent::uninstall();
|
||
|
}
|
||
|
|
||
|
public function assignBlocks()
|
||
|
{
|
||
|
$blocks = AdvRea2::getBlocks();
|
||
|
if (!$blocks)
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
$this->smarty->assign('blocks', $blocks);
|
||
|
}
|
||
|
|
||
|
public function hookDisplayReassurance2($params)
|
||
|
{
|
||
|
if (!$this->isCached('advreassurance2.tpl', $this->getCacheId()))
|
||
|
{
|
||
|
$this->assignBlocks();
|
||
|
}
|
||
|
|
||
|
return $this->display(__FILE__, 'advreassurance2.tpl', $this->getCacheId());
|
||
|
}
|
||
|
public function hookHome($params)
|
||
|
{
|
||
|
return $this->hookDisplayReassurance2($params);
|
||
|
}
|
||
|
|
||
|
public function hookDisplayReassurance2Bottom($params)
|
||
|
{
|
||
|
if (!$this->isCached('advreassurance2-bottom.tpl', $this->getCacheId()))
|
||
|
{
|
||
|
$this->assignBlocks();
|
||
|
}
|
||
|
|
||
|
return $this->display(__FILE__, 'advreassurance2-bottom.tpl', $this->getCacheId());
|
||
|
}
|
||
|
|
||
|
public function hookActionRefreshReassurance2()
|
||
|
{
|
||
|
$this->_clearCache('advreassurance2');
|
||
|
}
|
||
|
|
||
|
}
|