table = 'simulator_theme'; $this->className = 'SimulatorTheme'; $this->identifier = 'id_simulator_theme'; $this->lang = false; // Set fields list $this->fields_list = array( 'name' => array( 'title' => $this->l('Nom'), ), ); // Enable bootstrap $this->bootstrap = true; // Call of the parent constructor method parent::__construct(); } public function init() { parent::init(); $this->id_simulator = Tools::getValue('id_simulator'); } public function postProcess() { $path = _PS_ROOT_DIR_.'/themes/simulation'; if (Tools::isSubmit('submitAddsimulatortheme')) { $simulator = new Simulator($this->id_simulator); $name = Tools::getValue('name'); $isCreated = mkdir($path.'/'.$simulator->name.'/'.$name); if (!$isCreated) { $this->errors[] = Tools::displayError("Can't create directory"); } $id_simulator = Tools::getValue('id_simulator'); $this->redirect_after = $this->context->link->getAdminLink('AdminAntadisSimulatorTheme'). '&id_simulator='.(int)$id_simulator; } parent::postProcess(); } public function initToolbar() { $this->toolbar_btn['new'] = array( 'href' => self::$currentIndex.'&addsimulator_theme&id_simulator='.(int)$this->id_simulator.'&token='.Tools::getAdminTokenLite('AdminAntadisSimulatorTheme'), 'desc' => $this->l('Add New Theme', null, null, false) ); } public function displayConfigLink($token = null, $id, $name = null) { $tpl = $this->createTemplate('helpers/list/list_action_details.tpl'); if (!array_key_exists('Config', self::$cache_lang)) { self::$cache_lang['Config'] = $this->l('Configuration', 'Helper'); } $id_simulator = Tools::getValue('id_simulator'); $link = $this->context->link->getAdminLink('AdminAntadisSimulatorDetail', true); $tpl->assign(array( 'href' => $link.'&id_simulator='.$id_simulator.'&id_simulator_theme='.$id, 'action' => self::$cache_lang['Config'], 'id' => $id )); return $tpl->fetch(); } public function renderList() { $this->addRowAction('config'); $this->_where = " AND `id_simulator` = ".(int)$this->id_simulator; $this->_orderBy = "name"; return parent::renderList(); } public function renderForm() { $this->table = 'simulator_theme'; $this->identifier = 'id_simulator_theme'; $this->show_form_cancel_button = true; $this->fields_form = array( 'legend' => array('title' => $this->l('Add / Edit')), 'input' => array( array( 'type' => 'hidden', 'name' => 'id_simulator', 'required' => true, ), array( 'type' => 'text', 'label' => $this->l('Name'), 'desc' => $this->l("Nom du theme."), 'name' => 'name', 'empty_message' => $this->l('Le champs nom ne peut pas ĂȘtre vide.'), 'required' => true, ), ), 'submit' => array('title' => $this->l('Save')) ); $this->fields_value['id_simulator'] = $this->id_simulator; return parent::renderForm(); } }