name = 'antadisconfigurator'; $this->tab = 'front_office_features'; $this->version = '0.1'; $this->author = 'antadis'; $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('Product Options'); $this->description = $this->l('Add options on product'); $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); $this->confirmUninstall = $this->l('Are you sure you want to uninstall this module?'); } public function install() { // Call install parent method if (!parent::install()) { return false; } // Menu if (!$this->installTab('AdminCatalog', 'AdminAntadisConfigurator', 'Configurator Options')) { return false; } // Install AdminAntadisConfiguratorProduct if (!$this->installTab('AdminCatalog', 'AdminAntadisConfiguratorProduct', 'Configurator Product', 0)) { return false; } // Hook if (!$this->registerHook('displayAdminProductsExtra') || !$this->registerHook('displayAdminOrderProductConfigurator') || !$this->registerHook('displayProductTabContent') || !$this->registerHook('displayProductForm')) { return false; } // All went well! return true; } public function uninstall() { // Call uninstall parent method if (!parent::uninstall()) { return false; } // Menu if (!$this->uninstallTab('AdminAntadisConfigurator') || !$this->uninstallTab('AdminAntadisConfiguratorProduct')) { return false; } // Hook if (!$this->unregisterHook('displayAdminProductsExtra') || !$this->unregisterHook('displayAdminOrderProductConfigurator') || !$this->unregisterHook('displayProductTabContent') || !$this->unregisterHook('displayProductForm')) { return false; } // All went well! return true; } public function getContent() { $ajax_hook = Tools::getValue('ajax_hook'); if ($ajax_hook != '') { $ajax_method = 'hook'.ucfirst($ajax_hook); if (method_exists($this, $ajax_method)) { die($this->{$ajax_method}(array())); } } $controller = $this->getHookController('getContent'); return $controller->run(); } public function installTab($parent, $class_name, $name, $active = 1) { // Create new admin tab $tab = new Tab(); $tab->id_parent = (int)Tab::getIdFromClassName($parent); $tab->name = array(); foreach (Language::getLanguages(true) as $lang) { $tab->name[$lang['id_lang']] = $name; $tab->class_name = $class_name; $tab->module = $this->name; $tab->active = $active; return $tab->add(); } } public function uninstallTab($class_name) { // Retrieve Tab ID $id_tab = (int)Tab::getIdFromClassName($class_name); // Load tab $tab = new Tab((int)$id_tab); // Delete it return $tab->delete(); } public function getHookController($hook_name) { // Include the controller file require_once(dirname(__FILE__).'/controllers/hook/'. $hook_name.'.php'); // Build dynamically the controller name $controller_name = $this->name.$hook_name.'Controller'; // Instantiate controller $controller = new $controller_name($this, __FILE__, $this->_path); // Return the controller return $controller; } public function hookDisplayAdminProductsExtra($params) { $controller = $this->getHookController('displayAdminProductsExtra'); return $controller->run(); } public function hookDisplayProductTabContent($params) { $controller = $this->getHookController('displayProductTabContent'); return $controller->run(); } public function hookDisplayProductForm($params) { $controller = $this->getHookController('displayProductForm'); return $controller->run(); } public function hookDisplayAdminOrderProductConfigurator($params) { $controller = $this->getHookController('displayAdminOrderProductConfigurator'); return $controller->run($params); } }