name = 'belvg_blockconstructor'; $this->tab = 'front_office_features'; $this->version = '1.6.1'; $this->author = 'BelVG'; $this->need_instance = 0; $this->module_key = 'ab9287f3944d7128cc80e8e194fef8dd'; parent::__construct(); $this->displayName = $this->l('Blocks Constructor (PS 1.6)'); $this->description = $this->l('Blocks Constructor (PS 1.6)'); } public function install() { $sql = array(); $sql[] = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'belvg_blockconstructor` ( `id_belvg_blockconstructor` int(10) unsigned NOT NULL auto_increment, `status` int(10) NOT NULL default "1", `id_hook` int(10) NOT NULL, `id_category` int(10) NOT NULL, `nb_column` int(10) NOT NULL, `position` int(10) NOT NULL, `date_from` date NOT NULL, `date_to` date NOT NULL, `date_add` datetime NOT NULL, `date_upd` datetime NOT NULL, PRIMARY KEY (`id_belvg_blockconstructor`) ) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8'; $sql[] = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'belvg_blockconstructor_shop` ( `id_belvg_blockconstructor` int(10) unsigned NOT NULL auto_increment, `id_shop` int(10) unsigned NOT NULL, PRIMARY KEY (`id_belvg_blockconstructor`, `id_shop`) ) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8'; $sql[] = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'belvg_blockconstructor_lang` ( `id_belvg_blockconstructor` int(10) unsigned NOT NULL, `id_lang` int(10) unsigned NOT NULL, `title` varchar(255) NOT NULL, `subtitle` varchar(255), `classbloc` varchar(255), `link` varchar(255), `content` text, PRIMARY KEY (`id_belvg_blockconstructor`,`id_lang`) ) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8'; foreach ($sql as $_sql) { Db::getInstance()->Execute($_sql); } $new_tab = new Tab(); $new_tab->class_name = 'AdminBlockConstructor'; $new_tab->id_parent = Tab::getCurrentParentId(); $new_tab->module = $this->name; $languages = Language::getLanguages(); foreach ($languages as $language) { $new_tab->name[$language['id_lang']] = 'Belvg Blocks Constructor'; } $new_tab->add(); $install = parent::install(); $_hooks = Hook::getHooks(1); $this->registerHook('displayHome'); $this->registerHook('displayProductAfter'); return $install; } public function uninstall() { $sql = array(); $sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'belvg_blockconstructor`'; $sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'belvg_blockconstructor_shop`'; $sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'belvg_blockconstructor_lang`'; foreach ($sql as $_sql) { Db::getInstance()->Execute($_sql); } $idTab = Tab::getIdFromClassName('AdminBlockConstructor'); if ($idTab) { $tab = new Tab($idTab); $tab->delete(); } $uninstall = parent::uninstall(); $_hooks = Hook::getHooks(1); foreach ($_hooks as $hook) { $this->unregisterHook($hook['name']); } return $uninstall; } public function __call($name, $args = array()) { $hookName = str_replace('hook', '', $name); $id_hook = (int)Hook::getIdByName($hookName); if ($id_hook) { $this->smarty->assign( array( 'blocks' => BelvgBlockConstructor::getBlocksContent($id_hook), 'linkimg' =>'modules/belvg_blockconstructor/img/', 'position' => $args[0]['position'], ) ); return $this->display(__FILE__, $hookName.'.tpl'); } return NULL; } }