-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathskeleton.php
executable file
·148 lines (118 loc) · 3.69 KB
/
skeleton.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
144
145
146
147
148
<?php
/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <jevin9@gmail.com> wrote this module. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return. Jevin O. Sewaruth.
* ----------------------------------------------------------------------------
*/
if (!defined('_PS_VERSION_'))
exit;
class Skeleton extends Module
{
public function __construct()
{
$this->name = 'skeleton';
$this->tab = 'front_office_features';
$this->version = '1.0';
$this->author = 'Jevin O. Sewaruth';
parent::__construct();
$this->displayName = $this->l('Skeleton Module');
$this->description = $this->l('This is just an empty module. You should modify it to make your own.');
$this->confirmUninstall = $this->l('Are you sure you want to uninstall this module?');
$this->_checkContent();
$this->context->smarty->assign('module_name', $this->name);
}
public function install()
{
if (!parent::install() ||
!$this->registerHook('displayHeader') ||
!$this->registerHook('displayLeftColumn') ||
!$this->registerHook('displayRightColumn') ||
!$this->registerHook('displayFooter') ||
!$this->_createContent())
return false;
return true;
}
public function uninstall()
{
if (!parent::uninstall() ||
!$this->_deleteContent())
return false;
return true;
}
public function hookDisplayHeader()
{
$this->context->controller->addCSS($this->_path.'css/style.css', 'all');
$this->context->controller->addJS($this->_path.'js/script.js', 'all');
}
public function hookDisplayLeftColumn()
{
$this->context->smarty->assign(array(
'placement' => 'left',
));
return $this->display(__FILE__, 'left.tpl');
}
public function hookDisplayRightColumn()
{
$this->context->smarty->assign(array(
'placement' => 'right',
));
return $this->display(__FILE__, 'right.tpl');
}
public function hookDisplayFooter()
{
$this->context->smarty->assign(array(
'module_link' => $this->context->link->getModuleLink('skeleton', 'details'),
));
return $this->display(__FILE__, 'footer.tpl');
}
public function getContent()
{
$message = '';
if (Tools::isSubmit('submit_'.$this->name))
$message = $this->_saveContent();
$this->_displayContent($message);
return $this->display(__FILE__, 'settings.tpl');
}
private function _saveContent()
{
$message = '';
if (Configuration::updateValue('MOD_SKELETON_NAME', Tools::getValue('MOD_SKELETON_NAME')) &&
Configuration::updateValue('MOD_SKELETON_COLOR', Tools::getValue('MOD_SKELETON_COLOR')))
$message = $this->displayConfirmation($this->l('Your settings have been saved'));
else
$message = $this->displayError($this->l('There was an error while saving your settings'));
return $message;
}
private function _displayContent($message)
{
$this->context->smarty->assign(array(
'message' => $message,
'MOD_SKELETON_NAME' => Configuration::get('MOD_SKELETON_NAME'),
'MOD_SKELETON_COLOR' => Configuration::get('MOD_SKELETON_COLOR'),
));
}
private function _checkContent()
{
if (!Configuration::get('MOD_SKELETON_NAME') &&
!Configuration::get('MOD_SKELETON_COLOR'))
$this->warning = $this->l('You need to configure this module.');
}
private function _createContent()
{
if (!Configuration::updateValue('MOD_SKELETON_NAME', '') ||
!Configuration::updateValue('MOD_SKELETON_COLOR', ''))
return false;
return true;
}
private function _deleteContent()
{
if (!Configuration::deleteByName('MOD_SKELETON_NAME') ||
!Configuration::deleteByName('MOD_SKELETON_COLOR'))
return false;
return true;
}
}
?>