name = 'cyb_diy'; $this->tab = 'cyb_diy'; $this->version = '1'; $this->author = 'Cyberscope Bastien'; $this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_); $this->bootstrap = true; $this->display = 'view'; parent::__construct(); $this->displayName = $this->l('Cyberscope DIY'); $this->description = $this->l(''); $this->confirmUninstall = $this->l('Êtes-vous sûr de vouloir désinstaller ce module ?'); $this->templateFile = 'module:cyb_texteh1/cyb_diy.tpl'; } public function install(){ if(!parent::install() || !Configuration::updateValue('diy', '') || !$this->registerHook('displayHome') || !$this->registerHook('header')){ return false; } else{ return true; } } public function uninstall(){ if(!parent::uninstall() || !Configuration::deleteByName('diy')){ return false; } else{ return true; } } public function getContent(){ return $this->postProcess().$this->renderForm(); } private function postProcess(){ if(Tools::isSubmit('submitConfDiy')) { if(Configuration::updateValue('diy', htmlentities($_POST['diy']))){ return $this->displayConfirmation('Le champ a été enregistré'); } else{ return $this->displayError('Une erreur a été rencontré'); } } } private function renderForm(){ var_dump(Configuration::get('diy')); $helper = new HelperForm(); $helper->submit_action = 'submitConfDiy'; $fields_form = array( // 'tinymce' => true, 'form' => array( 'legend' => array( 'title' => $this->trans('Settings', array(), 'Admin.Global'), 'icon' => 'icon-cogs' ), 'input' => array( array( 'type' => 'textarea', 'label' => 'Votre texte :', 'name' => 'diy', 'class' => '', 'required' => true, 'autoload_rte' => true, ) ), 'submit' => array( 'title' => 'Sauvegarder' ) ), ); $helper->tpl_vars = array( 'fields_value' => array( 'diy' => html_entity_decode(Configuration::get('diy')) ) ); return $helper->generateForm(array($fields_form)); } public function hookHeader(){ $this->context->controller->registerStylesheet('css-cyb-diy', 'modules/' . $this->name. '/css/style.css', [ 'media' => 'all', 'priority' => 0, ] ); } public function hookDisplayHome(){ global $smarty; $smarty->assign('message', array('title' => html_entity_decode(Configuration::get('diy')))); return $this->display(__FILE__,'cyb_diy.tpl'); } }