-
Notifications
You must be signed in to change notification settings - Fork 0
/
pitticahomeyoutube.php
143 lines (123 loc) · 4.89 KB
/
pitticahomeyoutube.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php
/**
* 2021 Pittica S.r.l.s.
*
* @author Lucio Benini <info@pittica.com>
* @copyright 2021 Pittica S.r.l.s.
* @license http://opensource.org/licenses/LGPL-3.0 The GNU Lesser General Public License, version 3.0 ( LGPL-3.0 )
*/
if (!defined('_PS_VERSION_')) {
exit;
}
class PitticaHomeYoutube extends Module
{
public function __construct()
{
$this->name = 'pitticahomeyoutube';
$this->tab = 'front_office_features';
$this->version = '1.0.0';
$this->author = 'Pittica';
$this->need_instance = 1;
$this->bootstrap = 1;
parent::__construct();
$this->displayName = $this->l('YouTube for Home');
$this->description = $this->l('YouTube for homepage.');
$this->ps_versions_compliancy = array(
'min' => '1.7',
'max' => _PS_VERSION_
);
}
public function install()
{
return parent::install() && $this->registerHook('displayHome');
}
public function uninstall()
{
Configuration::deleteByName('PITTICA_YOUTUBE_HOME_CODE');
Configuration::deleteByName('PITTICA_YOUTUBE_HOME_ALIGNMENT');
return parent::uninstall();
}
public function hookDisplayHome($params)
{
$code = Configuration::get('PITTICA_YOUTUBE_HOME_CODE');
if ($code) {
$this->context->smarty->assign(array(
'youtubecode' => $code,
'youtubealign' => Configuration::get('PITTICA_YOUTUBE_HOME_ALIGNMENT', null, null, null, 'center')
));
return $this->fetch('module:' . $this->name . '/views/templates/hook/displayHome.tpl');
} else {
return null;
}
}
public function getContent()
{
$output = '';
if (Tools::isSubmit('savepitticahomeyoutube')) {
Configuration::updateValue('PITTICA_YOUTUBE_HOME_CODE', Tools::getValue('code'));
Configuration::updateValue('PITTICA_YOUTUBE_HOME_ALIGNMENT', Tools::getValue('alignment'));
$output .= $this->displayConfirmation($this->l('Settings updated.'));
}
return $output . $this->renderForm();
}
protected function renderForm()
{
$lang = (int) Configuration::get('PS_LANG_DEFAULT');
$helper = new HelperForm();
$helper->module = $this;
$helper->name_controller = 'pitticahomeyoutube';
$helper->identifier = $this->identifier;
$helper->token = Tools::getAdminTokenLite('AdminModules');
$helper->currentIndex = AdminController::$currentIndex . '&configure=' . $this->name;
$helper->default_form_language = $lang;
$helper->allow_employee_form_lang = $lang;
$helper->title = $this->displayName;
$helper->submit_action = 'savepitticahomeyoutube';
$helper->fields_value = array(
'code' => Configuration::get('PITTICA_YOUTUBE_HOME_CODE'),
'alignment' => Configuration::get('PITTICA_YOUTUBE_HOME_ALIGNMENT', null, null, null, 'center')
);
return $helper->generateForm(array(
array(
'form' => array(
'legend' => array(
'title' => $this->l('Settings')
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('YouTube Code'),
'name' => 'code'
),
array(
'type' => 'select',
'label' => $this->l('Alignment'),
'name' => 'alignment',
'options' => array(
'query' => array(
array(
'value' => 'center',
'name' => $this->l('Center')
),
array(
'value' => 'left',
'name' => $this->l('Left')
),
array(
'value' => 'right',
'name' => $this->l('Right')
)
),
'id' => 'value',
'name' => 'name'
)
)
),
'submit' => array(
'title' => $this->l('Save')
)
)
)
));
}
}