157 lines
3.9 KiB
PHP
157 lines
3.9 KiB
PHP
<?php
|
|
|
|
if (!defined('_PS_VERSION_')){
|
|
exit;
|
|
}
|
|
|
|
class Cyb_Video extends Module {
|
|
|
|
|
|
public function __construct(){
|
|
$this->name = 'cyb_video';
|
|
$this->tab = 'cyb_video';
|
|
$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 Video');
|
|
$this->description = $this->l('');
|
|
$this->confirmUninstall = $this->l('Êtes-vous sûr de vouloir désinstaller ce module ?');
|
|
|
|
$this->templateFile = 'module:cyb_video/cyb_video.tpl';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function install(){
|
|
if(!parent::install()
|
|
|| !Configuration::updateValue('video_titre', '')
|
|
|| !Configuration::updateValue('video_lien', '')
|
|
|| !$this->registerHook('displayConcept')
|
|
|| !$this->registerHook('header')){
|
|
return false;
|
|
}
|
|
else{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function uninstall(){
|
|
if(!parent::uninstall()
|
|
|| !Configuration::deleteByName('video_titre')
|
|
|| !Configuration::deleteByName('video_lien')){
|
|
return false;
|
|
}
|
|
else{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getContent(){
|
|
return $this->postProcess().$this->renderForm();
|
|
}
|
|
|
|
|
|
|
|
|
|
private function postProcess(){
|
|
if(Tools::isSubmit('submitConfVideo')) {
|
|
if(Configuration::updateValue('video_titre', $_POST['video_titre']) && Configuration::updateValue('video_lien', $_POST['video_lien'])){
|
|
return $this->displayConfirmation('Le champ a été enregistré');
|
|
}
|
|
else{
|
|
return $this->displayError('Une erreur a été rencontré');
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private function renderForm(){
|
|
$helper = new HelperForm();
|
|
$helper->submit_action = 'submitConfVideo';
|
|
$fields_form = array(
|
|
// 'tinymce' => true,
|
|
'form' => array(
|
|
'legend' => array(
|
|
'title' => $this->trans('Settings', array(), 'Admin.Global'),
|
|
'icon' => 'icon-cogs'
|
|
),
|
|
'input' => array(
|
|
array(
|
|
'type' => 'text',
|
|
'label' => 'Titre :',
|
|
'name' => 'video_titre',
|
|
'class' => '',
|
|
'required' => true,
|
|
),
|
|
array(
|
|
'type' => 'text',
|
|
'label' => 'Lien :',
|
|
'name' => 'video_lien',
|
|
'class' => '',
|
|
'required' => true,
|
|
'desc' => $this->l('Copier-coller le lien de la video tel que https://youtu.be/WHYMbu-Y3Xk'),
|
|
)
|
|
),
|
|
'submit' => array(
|
|
'title' => 'Sauvegarder'
|
|
)
|
|
),
|
|
);
|
|
$helper->tpl_vars = array(
|
|
'fields_value' => array(
|
|
'video_titre' => Configuration::get('video_titre'),
|
|
'video_lien' => Configuration::get('video_lien')
|
|
)
|
|
);
|
|
return $helper->generateForm(array($fields_form));
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function hookHeader(){
|
|
$this->context->controller->registerStylesheet('css-cyb-video', 'modules/' . $this->name. '/css/style.css',
|
|
[
|
|
'media' => 'all',
|
|
'priority' => 0,
|
|
]
|
|
);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function hookdisplayConcept(){
|
|
global $smarty;
|
|
|
|
$smarty->assign('video', array('titre' => Configuration::get('video_titre'), 'lien' => Configuration::get('video_lien')));
|
|
return $this->display(__FILE__,'cyb_video.tpl');
|
|
}
|
|
|
|
|
|
|
|
|
|
} |