Files
2019-11-17 19:14:07 +01:00

144 lines
3.4 KiB
PHP

<?php
if (!defined('_PS_VERSION_')){
exit;
}
class Cyb_Contact extends Module {
public function __construct(){
$this->name = 'cyb_contact';
$this->tab = 'cyb_contact';
$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 Contact');
$this->description = $this->l('');
$this->confirmUninstall = $this->l('Êtes-vous sûr de vouloir désinstaller ce module ?');
$this->templateFile = 'module:cyb_contact/cyb_contact.tpl';
}
public function install(){
if(!parent::install() || !Configuration::updateValue('contact', '') || !$this->registerHook('displayFooterGauche')){
return false;
}
else{
return true;
}
}
public function uninstall(){
if(!parent::uninstall() || !Configuration::deleteByName('contact')){
return false;
}
else{
return true;
}
}
public function getContent(){
return $this->postProcess().$this->renderForm();
}
private function postProcess(){
if(Tools::isSubmit('submitContact')) {
if(Configuration::updateValue('contact', htmlentities($_POST['contact']))){
return $this->displayConfirmation('Le champ a été enregistré');
}
else{
return $this->displayError('Une erreur a été rencontré');
}
}
}
private function renderForm(){
var_dump(Configuration::get('contact'));
$helper = new HelperForm();
$helper->submit_action = 'submitContact';
$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' => 'Texte :',
'name' => 'contact',
'class' => '',
'required' => true,
'autoload_rte' => true,
)
),
'submit' => array(
'title' => 'Sauvegarder'
)
),
);
$helper->tpl_vars = array(
'fields_value' => array(
'contact' => html_entity_decode(Configuration::get('contact'))
)
);
return $helper->generateForm(array($fields_form));
}
// public function hookHeader(){
// $this->context->controller->registerStylesheet('css-cyb-contact', 'modules/' . $this->name. '/css/style.css',
// [
// 'media' => 'all',
// 'priority' => 0,
// ]
// );
// }
public function hookDisplayFooterGauche(){
global $smarty;
$smarty->assign('message', array('texte' => html_entity_decode(Configuration::get('contact'))));
return $this->display(__FILE__,'cyb_contact.tpl');
}
}