2017-06-08 12:23:50 +02:00
|
|
|
<?php
|
|
|
|
if (!defined('_PS_VERSION_')) {
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
require_once dirname(__FILE__).'/classes/ConfiguratorOptGroup.php';
|
|
|
|
require_once dirname(__FILE__).'/classes/ConfiguratorOpt.php';
|
|
|
|
require_once dirname(__FILE__).'/classes/ProductConfiguratorOptGroup.php';
|
|
|
|
require_once dirname(__FILE__).'/classes/ProductConfiguratorOptImpact.php';
|
2017-06-09 11:10:25 +02:00
|
|
|
require_once dirname(__FILE__).'/classes/ConfiguratorStorage.php';
|
2017-06-08 12:23:50 +02:00
|
|
|
|
|
|
|
class AntadisConfigurator extends Module
|
|
|
|
{
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->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;
|
|
|
|
}
|
|
|
|
|
2017-06-14 15:14:07 +02:00
|
|
|
// Install AdminAntadisConfiguratorProductGroup AdminAntadisConfiguratorProductImpact
|
|
|
|
if (!$this->installTab('AdminCatalog', 'AdminAntadisConfiguratorProductGroup', 'Configurator Product Group', 0) ||
|
|
|
|
!$this->installTab('AdminCatalog', 'AdminAntadisConfiguratorProductImpact', 'Configurator Product Impact', 0)) {
|
2017-06-08 12:23:50 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Hook
|
|
|
|
if (!$this->registerHook('displayAdminProductsExtra') ||
|
2017-06-09 14:35:12 +02:00
|
|
|
!$this->registerHook('displayAdminOrderProductConfigurator') ||
|
2017-06-08 12:23:50 +02:00
|
|
|
!$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') ||
|
2017-06-09 14:35:12 +02:00
|
|
|
!$this->unregisterHook('displayAdminOrderProductConfigurator') ||
|
2017-06-08 12:23:50 +02:00
|
|
|
!$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();
|
|
|
|
}
|
2017-06-09 14:35:12 +02:00
|
|
|
|
|
|
|
public function hookDisplayAdminOrderProductConfigurator($params)
|
|
|
|
{
|
|
|
|
$controller = $this->getHookController('displayAdminOrderProductConfigurator');
|
|
|
|
return $controller->run($params);
|
|
|
|
}
|
2017-06-08 12:23:50 +02:00
|
|
|
}
|