@@ -42,12 +42,117 @@ public function __construct()
42
42
$ this ->ps_versions_compliancy = array ('min ' => '1.6 ' , 'max ' => _PS_VERSION_ );
43
43
}
44
44
45
+ public function getContent ()
46
+ {
47
+ $ this ->html = '' ;
48
+ if (Tools::isSubmit ('btnConfigSubmit ' )) {
49
+ $ this ->postProcess ();
50
+ } else {
51
+ $ this ->html .= '<br /> ' ;
52
+ }
53
+
54
+ $ this ->html .= $ this ->renderForm ();
55
+
56
+ return $ this ->html ;
57
+ }
58
+
59
+ public function renderForm ()
60
+ {
61
+ $ fields_form = array ();
62
+ $ fields_form ['form ' ] = array (
63
+ 'legend ' => array (
64
+ 'icon ' => 'icon-cog ' ,
65
+ 'title ' => $ this ->l ('Search Results Page Filters ' ),
66
+ ),
67
+ 'input ' => array (
68
+ array (
69
+ 'type ' => 'switch ' ,
70
+ 'label ' => $ this ->l ('Show Amenities filter ' ),
71
+ 'name ' => 'SHOW_AMENITIES_FILTER ' ,
72
+ 'is_bool ' => true ,
73
+ 'values ' => array (
74
+ array (
75
+ 'id ' => 'active_on ' ,
76
+ 'value ' => 1 ,
77
+ ),
78
+ array (
79
+ 'id ' => 'active_off ' ,
80
+ 'value ' => 0 ,
81
+ ),
82
+ ),
83
+ 'hint ' => $ this ->l ('Enable to display Amenities filter. ' ),
84
+ ),
85
+ array (
86
+ 'type ' => 'switch ' ,
87
+ 'label ' => $ this ->l ('Show Price filter ' ),
88
+ 'name ' => 'SHOW_PRICE_FILTER ' ,
89
+ 'is_bool ' => true ,
90
+ 'values ' => array (
91
+ array (
92
+ 'id ' => 'active_on ' ,
93
+ 'value ' => 1 ,
94
+ ),
95
+ array (
96
+ 'id ' => 'active_off ' ,
97
+ 'value ' => 0 ,
98
+ ),
99
+ ),
100
+ 'hint ' => $ this ->l ('Enable to display Price filter. ' ),
101
+ ),
102
+ ),
103
+ 'submit ' => array (
104
+ 'title ' => $ this ->l ('Save ' ),
105
+ 'name ' => 'submit_conf_filter ' ,
106
+ ),
107
+ );
108
+
109
+ $ helper = new HelperForm ();
110
+ $ helper ->show_toolbar = false ;
111
+ $ helper ->table = $ this ->table ;
112
+ $ lang = new Language ((int ) Configuration::get ('PS_LANG_DEFAULT ' ));
113
+ $ helper ->default_form_language = $ lang ->id ;
114
+ $ this ->fields_form = array ();
115
+ $ helper ->identifier = $ this ->identifier ;
116
+ $ helper ->submit_action = 'btnConfigSubmit ' ;
117
+ $ helper ->currentIndex = $ this ->context ->link ->getAdminLink ('AdminModules ' , false ).
118
+ '&configure= ' .$ this ->name .'&module_name= ' .$ this ->name ;
119
+ $ helper ->token = Tools::getAdminTokenLite ('AdminModules ' );
120
+
121
+ $ helper ->tpl_vars = array (
122
+ 'fields_value ' => $ this ->getConfigFieldsValues (),
123
+ 'languages ' => $ this ->context ->controller ->getLanguages (),
124
+ 'id_language ' => $ this ->context ->language ->id ,
125
+ );
126
+
127
+ return $ helper ->generateForm (array ($ fields_form ));
128
+ }
129
+
130
+ public function postProcess ()
131
+ {
132
+ if (Tools::isSubmit ('btnConfigSubmit ' )) {
133
+ Configuration::updateValue (
134
+ 'SHOW_AMENITIES_FILTER ' ,
135
+ Tools::getValue ('SHOW_AMENITIES_FILTER ' )
136
+ );
137
+ Configuration::updateValue ('SHOW_PRICE_FILTER ' , Tools::getValue ('SHOW_PRICE_FILTER ' ));
138
+
139
+ // redirect after saving the configuration
140
+ Tools::redirectAdmin (
141
+ $ this ->context ->link ->getAdminLink ('AdminModules ' ).'&configure= ' .$ this ->name .'&tab_module= ' .$ this ->tab .
142
+ '&module_name= ' .$ this ->name .'&conf=4 '
143
+ );
144
+ }
145
+ }
146
+
45
147
public function install ()
46
148
{
47
149
if (!parent ::install ()
48
150
|| !$ this ->registerHook ('header ' )
49
151
|| !$ this ->registerHook ('addOtherModuleSetting ' )
50
- || !$ this ->registerHook ('displayLeftColumn ' )) {
152
+ || !$ this ->registerHook ('displayLeftColumn ' )
153
+ || !Configuration::updateValue ('SHOW_AMENITIES_FILTER ' , 1 )
154
+ || !Configuration::updateValue ('SHOW_PRICE_FILTER ' , 1 )
155
+ ) {
51
156
return false ;
52
157
}
53
158
@@ -155,4 +260,16 @@ public function getConfigFieldsValues()
155
260
'SHOW_PRICE_FILTER ' => Configuration::get ('SHOW_PRICE_FILTER ' ),
156
261
);
157
262
}
263
+
264
+ public function uninstall ()
265
+ {
266
+ if (!parent ::uninstall ()
267
+ || !Configuration::deleteByName ('SHOW_AMENITIES_FILTER ' )
268
+ || !Configuration::deleteByName ('SHOW_PRICE_FILTER ' )
269
+ ) {
270
+ return false ;
271
+ }
272
+
273
+ return true ;
274
+ }
158
275
}
0 commit comments