· 5 years ago · Nov 18, 2020, 01:14 PM
1<?php
2class ControllerExtensionModulePtcontrolpanel extends Controller
3{
4 private $error = array();
5
6 public function index() {
7 $this->load->language('plaza/adminmenu');
8 $this->load->language('extension/module/ptcontrolpanel');
9
10 $this->document->setTitle($this->language->get('page_title'));
11
12 $this->load->model('setting/setting');
13 $this->load->model('plaza/sass');
14
15 if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
16 $this->model_setting_setting->editSetting('module_ptcontrolpanel', $this->request->post);
17 $this->model_plaza_sass->compileData($this->request->post);
18
19 $this->session->data['success'] = $this->language->get('text_success');
20
21 $this->response->redirect($this->url->link('extension/module/ptcontrolpanel', 'user_token=' . $this->session->data['user_token'], true));
22 }
23
24 $this->load->model('setting/store');
25
26 $data['stores'] = array();
27
28 $data['stores'][] = array(
29 'store_id' => 0,
30 'name' => $this->config->get('config_name') . $this->language->get('text_default')
31 );
32
33 $stores = $this->model_setting_store->getStores();
34
35 foreach ($stores as $store) {
36 $data['stores'][] = array(
37 'store_id' => $store['store_id'],
38 'name' => $store['name']
39 );
40 }
41
42 $this->load->model('catalog/option');
43
44 $data['options'] = array();
45
46 $results = $this->model_catalog_option->getOptions();
47
48 foreach ($results as $result) {
49 $data['options'][] = array(
50 'option_id' => $result['option_id'],
51 'type' => $result['type'],
52 'name' => $result['name']
53 );
54 }
55
56 if(isset($this->session->data['success'])) {
57 $data['success'] = $this->session->data['success'];
58
59 unset($this->session->data['success']);
60 } else {
61 $data['success'] = false;
62 }
63
64 if(isset($this->session->data['error_load_file'])) {
65 $data['error_load_file'] = $this->session->data['error_load_file'];
66
67 unset($this->session->data['error_load_file']);
68 } else {
69 $data['error_load_file'] = false;
70 }
71
72 if (isset($this->error['warning'])) {
73 $data['error_warning'] = $this->error['warning'];
74 } else {
75 $data['error_warning'] = '';
76 }
77
78 $data['breadcrumbs'] = array();
79
80 $data['breadcrumbs'][] = array(
81 'text' => $this->language->get('text_home'),
82 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
83 );
84
85 $data['breadcrumbs'][] = array(
86 'text' => $this->language->get('text_extension'),
87 'href' => $this->url->link('plaza/module', 'user_token=' . $this->session->data['user_token'], true)
88 );
89
90 $data['breadcrumbs'][] = array(
91 'text' => $this->language->get('heading_title'),
92 'href' => $this->url->link('extension/module/ptcontrolpanel', 'user_token=' . $this->session->data['user_token'], true)
93 );
94
95 $data['database'] = array(
96 DIR_APPLICATION . '../plazadata/plaza_db1.sql' => 'Layout 1',
97 DIR_APPLICATION . '../plazadata/plaza_db2.sql' => 'Layout 2',
98 DIR_APPLICATION . '../plazadata/plaza_db3.sql' => 'Layout 3',
99 DIR_APPLICATION . '../plazadata/plaza_db4.sql' => 'Layout 4',
100 DIR_APPLICATION . '../plazadata/plaza_db5.sql' => 'Layout 5',
101 );
102
103 $arrContextOptions = array(
104 "ssl" => array(
105 "verify_peer" => false,
106 "verify_peer_name" => false,
107 ),
108 );
109
110 $url = 'https://www.googleapis.com/webfonts/v1/webfonts?key=AIzaSyAov68H0SNcVzNpBfx40cOrObR8ZvV_cps';
111
112 $fonts_file = file_get_contents($url, false, stream_context_create($arrContextOptions));
113
114 $google_fonts = json_decode($fonts_file, true);
115
116 $fonts = $google_fonts['items'];
117
118 foreach ($fonts as $key => $font) {
119 $font_family_val = str_replace(' ', '+', $font['family']);
120 $variants = implode(',', $font['variants']);
121 $subsets = implode(',', $font['subsets']);
122 $data['fonts'][] = array(
123 'id' => $key,
124 'family' => $font['family'],
125 'family_val' => $font_family_val,
126 'variants' => $variants,
127 'subsets' => $subsets,
128 'category' => $font['category']
129 );
130 }
131
132 $data['user_token'] = $this->session->data['user_token'];
133
134 $data['action'] = $this->url->link('extension/module/ptcontrolpanel', 'user_token=' . $this->session->data['user_token'], true);
135 $data['action_import'] = $this->url->link('extension/module/ptcontrolpanel/import', 'user_token=' . $this->session->data['user_token'], true);
136
137 $data['cancel'] = $this->url->link('plaza/module', 'user_token=' . $this->session->data['user_token'], true);
138
139 /* General */
140 if (isset($this->request->post['module_ptcontrolpanel_sticky_header'])) {
141 $data['module_ptcontrolpanel_sticky_header'] = $this->request->post['module_ptcontrolpanel_sticky_header'];
142 } else {
143 $data['module_ptcontrolpanel_sticky_header'] = $this->config->get('module_ptcontrolpanel_sticky_header');
144 }
145
146 if (isset($this->request->post['module_ptcontrolpanel_scroll_top'])) {
147 $data['module_ptcontrolpanel_scroll_top'] = $this->request->post['module_ptcontrolpanel_scroll_top'];
148 } else {
149 $data['module_ptcontrolpanel_scroll_top'] = $this->config->get('module_ptcontrolpanel_scroll_top');
150 }
151
152 if (isset($this->request->post['module_ptcontrolpanel_lazy_load'])) {
153 $data['module_ptcontrolpanel_lazy_load'] = $this->request->post['module_ptcontrolpanel_lazy_load'];
154 } else {
155 $data['module_ptcontrolpanel_lazy_load'] = $this->config->get('module_ptcontrolpanel_lazy_load');
156 }
157
158 if (isset($this->request->post['module_ptcontrolpanel_header_layout'])) {
159 $data['module_ptcontrolpanel_header_layout'] = $this->request->post['module_ptcontrolpanel_header_layout'];
160 } else {
161 $data['module_ptcontrolpanel_header_layout'] = $this->config->get('module_ptcontrolpanel_header_layout');
162 }
163
164 if (isset($this->request->post['module_ptcontrolpanel_responsive_type'])) {
165 $data['module_ptcontrolpanel_responsive_type'] = $this->request->post['module_ptcontrolpanel_responsive_type'];
166 } else {
167 $data['module_ptcontrolpanel_responsive_type'] = $this->config->get('module_ptcontrolpanel_responsive_type');
168 }
169
170 $this->load->model('tool/image');
171
172 foreach ($data['stores'] as $store) {
173 if (isset($this->request->post['module_ptcontrolpanel_loader_img'][$store['store_id']]) && is_file(DIR_IMAGE . $this->request->post['module_ptcontrolpanel_loader_img'][$store['store_id']])) {
174 $data['thumb'][$store['store_id']] = $this->model_tool_image->resize($this->request->post['module_ptcontrolpanel_loader_img'][$store['store_id']], 50, 50);
175 $data['module_ptcontrolpanel_loader_img'] = $this->request->post['module_ptcontrolpanel_loader_img'];
176 } elseif (is_file(DIR_IMAGE . $this->config->get('module_ptcontrolpanel_loader_img')[$store['store_id']])) {
177 $data['thumb'][$store['store_id']] = $this->model_tool_image->resize($this->config->get('module_ptcontrolpanel_loader_img')[$store['store_id']], 50, 50);
178 $data['module_ptcontrolpanel_loader_img'] = $this->config->get('module_ptcontrolpanel_loader_img');
179 } else {
180 $data['thumb'][$store['store_id']] = $this->model_tool_image->resize('no_image.png', 50, 50);
181 }
182 }
183
184 $data['placeholder'] = $this->model_tool_image->resize('no_image.png', 50, 50);
185
186 /* Font & CSS */
187 /* Body */
188 if (isset($this->request->post['module_ptcontrolpanel_body_font_family_id'])) {
189 $data['module_ptcontrolpanel_body_font_family_id'] = $this->request->post['module_ptcontrolpanel_body_font_family_id'];
190 } else {
191 $data['module_ptcontrolpanel_body_font_family_id'] = $this->config->get('module_ptcontrolpanel_body_font_family_id');
192 }
193
194 if (isset($this->request->post['module_ptcontrolpanel_body_font_family_name'])) {
195 $data['module_ptcontrolpanel_body_font_family_name'] = $this->request->post['module_ptcontrolpanel_body_font_family_name'];
196 } else {
197 $data['module_ptcontrolpanel_body_font_family_name'] = $this->config->get('module_ptcontrolpanel_body_font_family_name');
198 }
199
200 if (isset($this->request->post['module_ptcontrolpanel_body_font_family_cate'])) {
201 $data['module_ptcontrolpanel_body_font_family_cate'] = $this->request->post['module_ptcontrolpanel_body_font_family_cate'];
202 } else {
203 $data['module_ptcontrolpanel_body_font_family_cate'] = $this->config->get('module_ptcontrolpanel_body_font_family_cate');
204 }
205
206 if (isset($this->request->post['module_ptcontrolpanel_body_font_family_link'])) {
207 $data['module_ptcontrolpanel_body_font_family_link'] = $this->request->post['module_ptcontrolpanel_body_font_family_link'];
208 } else {
209 $data['module_ptcontrolpanel_body_font_family_link'] = $this->config->get('module_ptcontrolpanel_body_font_family_link');
210 }
211
212 if (isset($this->request->post['module_ptcontrolpanel_body_font_size'])) {
213 $data['module_ptcontrolpanel_body_font_size'] = $this->request->post['module_ptcontrolpanel_body_font_size'];
214 } else {
215 $data['module_ptcontrolpanel_body_font_size'] = $this->config->get('module_ptcontrolpanel_body_font_size');
216 }
217
218 if (isset($this->request->post['module_ptcontrolpanel_body_font_weight'])) {
219 $data['module_ptcontrolpanel_body_font_weight'] = $this->request->post['module_ptcontrolpanel_body_font_weight'];
220 } else {
221 $data['module_ptcontrolpanel_body_font_weight'] = $this->config->get('module_ptcontrolpanel_body_font_weight');
222 }
223
224 if (isset($this->request->post['module_ptcontrolpanel_body_color'])) {
225 $data['module_ptcontrolpanel_body_color'] = $this->request->post['module_ptcontrolpanel_body_color'];
226 } else {
227 $data['module_ptcontrolpanel_body_color'] = $this->config->get('module_ptcontrolpanel_body_color');
228 }
229
230 /* Heading */
231 if (isset($this->request->post['module_ptcontrolpanel_heading_font_family_id'])) {
232 $data['module_ptcontrolpanel_heading_font_family_id'] = $this->request->post['module_ptcontrolpanel_heading_font_family_id'];
233 } else {
234 $data['module_ptcontrolpanel_heading_font_family_id'] = $this->config->get('module_ptcontrolpanel_heading_font_family_id');
235 }
236
237 if (isset($this->request->post['module_ptcontrolpanel_heading_font_family_name'])) {
238 $data['module_ptcontrolpanel_heading_font_family_name'] = $this->request->post['module_ptcontrolpanel_heading_font_family_name'];
239 } else {
240 $data['module_ptcontrolpanel_heading_font_family_name'] = $this->config->get('module_ptcontrolpanel_heading_font_family_name');
241 }
242
243 if (isset($this->request->post['module_ptcontrolpanel_heading_font_family_cate'])) {
244 $data['module_ptcontrolpanel_heading_font_family_cate'] = $this->request->post['module_ptcontrolpanel_heading_font_family_cate'];
245 } else {
246 $data['module_ptcontrolpanel_heading_font_family_cate'] = $this->config->get('module_ptcontrolpanel_heading_font_family_cate');
247 }
248
249 if (isset($this->request->post['module_ptcontrolpanel_heading_font_family_link'])) {
250 $data['module_ptcontrolpanel_heading_font_family_link'] = $this->request->post['module_ptcontrolpanel_heading_font_family_link'];
251 } else {
252 $data['module_ptcontrolpanel_heading_font_family_link'] = $this->config->get('module_ptcontrolpanel_heading_font_family_link');
253 }
254
255 if (isset($this->request->post['module_ptcontrolpanel_heading_font_weight'])) {
256 $data['module_ptcontrolpanel_heading_font_weight'] = $this->request->post['module_ptcontrolpanel_heading_font_weight'];
257 } else {
258 $data['module_ptcontrolpanel_heading_font_weight'] = $this->config->get('module_ptcontrolpanel_heading_font_weight');
259 }
260
261 if (isset($this->request->post['module_ptcontrolpanel_heading_color'])) {
262 $data['module_ptcontrolpanel_heading_color'] = $this->request->post['module_ptcontrolpanel_heading_color'];
263 } else {
264 $data['module_ptcontrolpanel_heading_color'] = $this->config->get('module_ptcontrolpanel_heading_color');
265 }
266
267 /* Link */
268 if (isset($this->request->post['module_ptcontrolpanel_link_color'])) {
269 $data['module_ptcontrolpanel_link_color'] = $this->request->post['module_ptcontrolpanel_link_color'];
270 } else {
271 $data['module_ptcontrolpanel_link_color'] = $this->config->get('module_ptcontrolpanel_link_color');
272 }
273
274 if (isset($this->request->post['module_ptcontrolpanel_link_hover_color'])) {
275 $data['module_ptcontrolpanel_link_hover_color'] = $this->request->post['module_ptcontrolpanel_link_hover_color'];
276 } else {
277 $data['module_ptcontrolpanel_link_hover_color'] = $this->config->get('module_ptcontrolpanel_link_hover_color');
278 }
279
280 /* Button */
281 if (isset($this->request->post['module_ptcontrolpanel_button_color'])) {
282 $data['module_ptcontrolpanel_button_color'] = $this->request->post['module_ptcontrolpanel_button_color'];
283 } else {
284 $data['module_ptcontrolpanel_button_color'] = $this->config->get('module_ptcontrolpanel_button_color');
285 }
286
287 if (isset($this->request->post['module_ptcontrolpanel_button_hover_color'])) {
288 $data['module_ptcontrolpanel_button_hover_color'] = $this->request->post['module_ptcontrolpanel_button_hover_color'];
289 } else {
290 $data['module_ptcontrolpanel_button_hover_color'] = $this->config->get('module_ptcontrolpanel_button_hover_color');
291 }
292
293 if (isset($this->request->post['module_ptcontrolpanel_button_bg_color'])) {
294 $data['module_ptcontrolpanel_button_bg_color'] = $this->request->post['module_ptcontrolpanel_button_bg_color'];
295 } else {
296 $data['module_ptcontrolpanel_button_bg_color'] = $this->config->get('module_ptcontrolpanel_button_bg_color');
297 }
298
299 if (isset($this->request->post['module_ptcontrolpanel_button_bg_hover_color'])) {
300 $data['module_ptcontrolpanel_button_bg_hover_color'] = $this->request->post['module_ptcontrolpanel_button_bg_hover_color'];
301 } else {
302 $data['module_ptcontrolpanel_button_bg_hover_color'] = $this->config->get('module_ptcontrolpanel_button_bg_hover_color');
303 }
304
305 /* Catalog */
306 /* Header */
307 if (isset($this->request->post['module_ptcontrolpanel_header_cart'])) {
308 $data['module_ptcontrolpanel_header_cart'] = $this->request->post['module_ptcontrolpanel_header_cart'];
309 } else {
310 $data['module_ptcontrolpanel_header_cart'] = $this->config->get('module_ptcontrolpanel_header_cart');
311 }
312
313 if (isset($this->request->post['module_ptcontrolpanel_header_currency'])) {
314 $data['module_ptcontrolpanel_header_currency'] = $this->request->post['module_ptcontrolpanel_header_currency'];
315 } else {
316 $data['module_ptcontrolpanel_header_currency'] = $this->config->get('module_ptcontrolpanel_header_currency');
317 }
318
319 /* Product catalog */
320 if (isset($this->request->post['module_ptcontrolpanel_product_price'])) {
321 $data['module_ptcontrolpanel_product_price'] = $this->request->post['module_ptcontrolpanel_product_price'];
322 } else {
323 $data['module_ptcontrolpanel_product_price'] = $this->config->get('module_ptcontrolpanel_product_price');
324 }
325
326 if (isset($this->request->post['module_ptcontrolpanel_product_cart'])) {
327 $data['module_ptcontrolpanel_product_cart'] = $this->request->post['module_ptcontrolpanel_product_cart'];
328 } else {
329 $data['module_ptcontrolpanel_product_cart'] = $this->config->get('module_ptcontrolpanel_product_cart');
330 }
331
332 if (isset($this->request->post['module_ptcontrolpanel_product_wishlist'])) {
333 $data['module_ptcontrolpanel_product_wishlist'] = $this->request->post['module_ptcontrolpanel_product_wishlist'];
334 } else {
335 $data['module_ptcontrolpanel_product_wishlist'] = $this->config->get('module_ptcontrolpanel_product_wishlist');
336 }
337
338 if (isset($this->request->post['module_ptcontrolpanel_product_compare'])) {
339 $data['module_ptcontrolpanel_product_compare'] = $this->request->post['module_ptcontrolpanel_product_compare'];
340 } else {
341 $data['module_ptcontrolpanel_product_compare'] = $this->config->get('module_ptcontrolpanel_product_compare');
342 }
343
344 if (isset($this->request->post['module_ptcontrolpanel_product_options'])) {
345 $data['module_ptcontrolpanel_product_options'] = $this->request->post['module_ptcontrolpanel_product_options'];
346 } else {
347 $data['module_ptcontrolpanel_product_options'] = $this->config->get('module_ptcontrolpanel_product_options');
348 }
349
350 /* Category Catalog */
351 if (isset($this->request->post['module_ptcontrolpanel_category_price'])) {
352 $data['module_ptcontrolpanel_category_price'] = $this->request->post['module_ptcontrolpanel_category_price'];
353 } else {
354 $data['module_ptcontrolpanel_category_price'] = $this->config->get('module_ptcontrolpanel_category_price');
355 }
356
357 if (isset($this->request->post['module_ptcontrolpanel_category_cart'])) {
358 $data['module_ptcontrolpanel_category_cart'] = $this->request->post['module_ptcontrolpanel_category_cart'];
359 } else {
360 $data['module_ptcontrolpanel_category_cart'] = $this->config->get('module_ptcontrolpanel_category_cart');
361 }
362
363 if (isset($this->request->post['module_ptcontrolpanel_category_wishlist'])) {
364 $data['module_ptcontrolpanel_category_wishlist'] = $this->request->post['module_ptcontrolpanel_category_wishlist'];
365 } else {
366 $data['module_ptcontrolpanel_category_wishlist'] = $this->config->get('module_ptcontrolpanel_category_wishlist');
367 }
368
369 if (isset($this->request->post['module_ptcontrolpanel_category_compare'])) {
370 $data['module_ptcontrolpanel_category_compare'] = $this->request->post['module_ptcontrolpanel_category_compare'];
371 } else {
372 $data['module_ptcontrolpanel_category_compare'] = $this->config->get('module_ptcontrolpanel_category_compare');
373 }
374
375 if (isset($this->request->post['module_ptcontrolpanel_category_prodes'])) {
376 $data['module_ptcontrolpanel_category_prodes'] = $this->request->post['module_ptcontrolpanel_category_prodes'];
377 } else {
378 $data['module_ptcontrolpanel_category_prodes'] = $this->config->get('module_ptcontrolpanel_category_prodes');
379 }
380
381 if (isset($this->request->post['module_ptcontrolpanel_category_label'])) {
382 $data['module_ptcontrolpanel_category_label'] = $this->request->post['module_ptcontrolpanel_category_label'];
383 } else {
384 $data['module_ptcontrolpanel_category_label'] = $this->config->get('module_ptcontrolpanel_category_label');
385 }
386
387 /* Product */
388 if (isset($this->request->post['module_ptcontrolpanel_related'])) {
389 $data['module_ptcontrolpanel_related'] = $this->request->post['module_ptcontrolpanel_related'];
390 } else {
391 $data['module_ptcontrolpanel_related'] = $this->config->get('module_ptcontrolpanel_related');
392 }
393
394 if (isset($this->request->post['module_ptcontrolpanel_social'])) {
395 $data['module_ptcontrolpanel_social'] = $this->request->post['module_ptcontrolpanel_social'];
396 } else {
397 $data['module_ptcontrolpanel_social'] = $this->config->get('module_ptcontrolpanel_social');
398 }
399
400 if (isset($this->request->post['module_ptcontrolpanel_tax'])) {
401 $data['module_ptcontrolpanel_tax'] = $this->request->post['module_ptcontrolpanel_tax'];
402 } else {
403 $data['module_ptcontrolpanel_tax'] = $this->config->get('module_ptcontrolpanel_tax');
404 }
405
406 if (isset($this->request->post['module_ptcontrolpanel_tags'])) {
407 $data['module_ptcontrolpanel_tags'] = $this->request->post['module_ptcontrolpanel_tags'];
408 } else {
409 $data['module_ptcontrolpanel_tags'] = $this->config->get('module_ptcontrolpanel_tags');
410 }
411
412 if (isset($this->request->post['module_ptcontrolpanel_use_zoom'])) {
413 $data['module_ptcontrolpanel_use_zoom'] = $this->request->post['module_ptcontrolpanel_use_zoom'];
414 } else {
415 $data['module_ptcontrolpanel_use_zoom'] = $this->config->get('module_ptcontrolpanel_use_zoom');
416 }
417
418 if (isset($this->request->post['module_ptcontrolpanel_zoom_type'])) {
419 $data['module_ptcontrolpanel_zoom_type'] = $this->request->post['module_ptcontrolpanel_zoom_type'];
420 } else {
421 $data['module_ptcontrolpanel_zoom_type'] = $this->config->get('module_ptcontrolpanel_zoom_type');
422 }
423
424 if (isset($this->request->post['module_ptcontrolpanel_zoom_space'])) {
425 $data['module_ptcontrolpanel_zoom_space'] = $this->request->post['module_ptcontrolpanel_zoom_space'];
426 } else {
427 $data['module_ptcontrolpanel_zoom_space'] = $this->config->get('module_ptcontrolpanel_zoom_space');
428 }
429
430 if (isset($this->request->post['module_ptcontrolpanel_zoom_title'])) {
431 $data['module_ptcontrolpanel_zoom_title'] = $this->request->post['module_ptcontrolpanel_zoom_title'];
432 } else {
433 $data['module_ptcontrolpanel_zoom_title'] = $this->config->get('module_ptcontrolpanel_zoom_title');
434 }
435
436 if (isset($this->request->post['module_ptcontrolpanel_use_swatches'])) {
437 $data['module_ptcontrolpanel_use_swatches'] = $this->request->post['module_ptcontrolpanel_use_swatches'];
438 } else {
439 $data['module_ptcontrolpanel_use_swatches'] = $this->config->get('module_ptcontrolpanel_use_swatches');
440 }
441
442 if (isset($this->request->post['module_ptcontrolpanel_swatches_width'])) {
443 $data['module_ptcontrolpanel_swatches_width'] = $this->request->post['module_ptcontrolpanel_swatches_width'];
444 } else {
445 $data['module_ptcontrolpanel_swatches_width'] = $this->config->get('module_ptcontrolpanel_swatches_width');
446 }
447
448 if (isset($this->request->post['module_ptcontrolpanel_swatches_height'])) {
449 $data['module_ptcontrolpanel_swatches_height'] = $this->request->post['module_ptcontrolpanel_swatches_height'];
450 } else {
451 $data['module_ptcontrolpanel_swatches_height'] = $this->config->get('module_ptcontrolpanel_swatches_height');
452 }
453
454 if (isset($this->request->post['module_ptcontrolpanel_swatches_option'])) {
455 $data['module_ptcontrolpanel_swatches_option'] = $this->request->post['module_ptcontrolpanel_swatches_option'];
456 } else {
457 $data['module_ptcontrolpanel_swatches_option'] = $this->config->get('module_ptcontrolpanel_swatches_option');
458 }
459
460 /* Category */
461 if (isset($this->request->post['module_ptcontrolpanel_category_image'])) {
462 $data['module_ptcontrolpanel_category_image'] = $this->request->post['module_ptcontrolpanel_category_image'];
463 } else {
464 $data['module_ptcontrolpanel_category_image'] = $this->config->get('module_ptcontrolpanel_category_image');
465 }
466
467 if (isset($this->request->post['module_ptcontrolpanel_category_description'])) {
468 $data['module_ptcontrolpanel_category_description'] = $this->request->post['module_ptcontrolpanel_category_description'];
469 } else {
470 $data['module_ptcontrolpanel_category_description'] = $this->config->get('module_ptcontrolpanel_category_description');
471 }
472
473 if (isset($this->request->post['module_ptcontrolpanel_sub_category'])) {
474 $data['module_ptcontrolpanel_sub_category'] = $this->request->post['module_ptcontrolpanel_sub_category'];
475 } else {
476 $data['module_ptcontrolpanel_sub_category'] = $this->config->get('module_ptcontrolpanel_sub_category');
477 }
478
479 if (isset($this->request->post['module_ptcontrolpanel_use_filter'])) {
480 $data['module_ptcontrolpanel_use_filter'] = $this->request->post['module_ptcontrolpanel_use_filter'];
481 } else {
482 $data['module_ptcontrolpanel_use_filter'] = $this->config->get('module_ptcontrolpanel_use_filter');
483 }
484
485 if (isset($this->request->post['module_ptcontrolpanel_filter_position'])) {
486 $data['module_ptcontrolpanel_filter_position'] = $this->request->post['module_ptcontrolpanel_filter_position'];
487 } else {
488 $data['module_ptcontrolpanel_filter_position'] = $this->config->get('module_ptcontrolpanel_filter_position');
489 }
490
491 if (isset($this->request->post['module_ptcontrolpanel_cate_quickview'])) {
492 $data['module_ptcontrolpanel_cate_quickview'] = $this->request->post['module_ptcontrolpanel_cate_quickview'];
493 } else {
494 $data['module_ptcontrolpanel_cate_quickview'] = $this->config->get('module_ptcontrolpanel_cate_quickview');
495 }
496
497 if (isset($this->request->post['module_ptcontrolpanel_img_effect'])) {
498 $data['module_ptcontrolpanel_img_effect'] = $this->request->post['module_ptcontrolpanel_img_effect'];
499 } else {
500 $data['module_ptcontrolpanel_img_effect'] = $this->config->get('module_ptcontrolpanel_img_effect');
501 }
502
503 if (isset($this->request->post['module_ptcontrolpanel_cate_swatches_width'])) {
504 $data['module_ptcontrolpanel_cate_swatches_width'] = $this->request->post['module_ptcontrolpanel_cate_swatches_width'];
505 } else {
506 $data['module_ptcontrolpanel_cate_swatches_width'] = $this->config->get('module_ptcontrolpanel_cate_swatches_width');
507 }
508
509 if (isset($this->request->post['module_ptcontrolpanel_cate_swatches_height'])) {
510 $data['module_ptcontrolpanel_cate_swatches_height'] = $this->request->post['module_ptcontrolpanel_cate_swatches_height'];
511 } else {
512 $data['module_ptcontrolpanel_cate_swatches_height'] = $this->config->get('module_ptcontrolpanel_cate_swatches_height');
513 }
514
515 if (isset($this->request->post['module_ptcontrolpanel_advance_view'])) {
516 $data['module_ptcontrolpanel_advance_view'] = $this->request->post['module_ptcontrolpanel_advance_view'];
517 } else {
518 $data['module_ptcontrolpanel_advance_view'] = $this->config->get('module_ptcontrolpanel_advance_view');
519 }
520
521 if (isset($this->request->post['module_ptcontrolpanel_default_view'])) {
522 $data['module_ptcontrolpanel_default_view'] = $this->request->post['module_ptcontrolpanel_default_view'];
523 } else {
524 $data['module_ptcontrolpanel_default_view'] = $this->config->get('module_ptcontrolpanel_default_view');
525 }
526
527 if (isset($this->request->post['module_ptcontrolpanel_product_row'])) {
528 $data['module_ptcontrolpanel_product_row'] = $this->request->post['module_ptcontrolpanel_product_row'];
529 } else {
530 $data['module_ptcontrolpanel_product_row'] = $this->config->get('module_ptcontrolpanel_product_row');
531 }
532
533 if (isset($this->request->post['module_ptcontrolpanel_custom_css'])) {
534 $data['module_ptcontrolpanel_custom_css'] = $this->request->post['module_ptcontrolpanel_custom_css'];
535 } else {
536 $data['module_ptcontrolpanel_custom_css'] = $this->config->get('module_ptcontrolpanel_custom_css');
537 }
538
539 if (isset($this->request->post['module_ptcontrolpanel_custom_js'])) {
540 $data['module_ptcontrolpanel_custom_js'] = $this->request->post['module_ptcontrolpanel_custom_js'];
541 } else {
542 $data['module_ptcontrolpanel_custom_js'] = $this->config->get('module_ptcontrolpanel_custom_js');
543 }
544
545 $data['plaza_menus'] = array();
546
547 if($this->user->hasPermission('access', 'extension/module/ptcontrolpanel')) {
548 $data['plaza_menus'][] = array(
549 'title' => '<i class="a fa fa-magic"></i> ' . $this->language->get('text_control_panel'),
550 'url' => $this->url->link('extension/module/ptcontrolpanel', 'user_token=' . $this->session->data['user_token'], true),
551 'active' => 1
552 );
553 }
554
555 if($this->user->hasPermission('access', 'plaza/module')) {
556 $data['plaza_menus'][] = array(
557 'title' => '<i class="a fa fa-puzzle-piece"></i> ' . $this->language->get('text_theme_module'),
558 'url' => $this->url->link('plaza/module', 'user_token=' . $this->session->data['user_token'], true),
559 'active' => 0
560 );
561 }
562
563 if($this->user->hasPermission('access', 'plaza/featuredcate')) {
564 $data['plaza_menus'][] = array(
565 'title' => '<i class="a fa fa-tag"></i> ' . $this->language->get('text_special_category'),
566 'url' => $this->url->link('plaza/featuredcate', 'user_token=' . $this->session->data['user_token'], true),
567 'active' => 0
568 );
569 }
570
571 if($this->user->hasPermission('access', 'plaza/ultimatemenu')) {
572 $data['plaza_menus'][] = array(
573 'title' => '<i class="a fa fa-bars"></i> ' . $this->language->get('text_ultimate_menu'),
574 'url' => $this->url->link('plaza/ultimatemenu/menuList', 'user_token=' . $this->session->data['user_token'], true),
575 'active' => 0
576 );
577 }
578
579 if ($this->user->hasPermission('access', 'plaza/blog')) {
580 $blog_menu = array();
581
582 if ($this->user->hasPermission('access', 'plaza/blog/post')) {
583 $blog_menu[] = array(
584 'title' => $this->language->get('text_posts'),
585 'url' => $this->url->link('plaza/blog/post', 'user_token=' . $this->session->data['user_token'], true),
586 'active' => 0
587 );
588 }
589
590 if ($this->user->hasPermission('access', 'plaza/blog/list')) {
591 $blog_menu[] = array(
592 'title' => $this->language->get('text_posts_list'),
593 'url' => $this->url->link('plaza/blog/list', 'user_token=' . $this->session->data['user_token'], true),
594 'active' => 0
595 );
596 }
597
598 if ($this->user->hasPermission('access', 'plaza/blog/setting')) {
599 $blog_menu[] = array(
600 'title' => $this->language->get('text_blog_setting'),
601 'url' => $this->url->link('plaza/blog/setting', 'user_token=' . $this->session->data['user_token'], true),
602 'active' => 0
603 );
604 }
605
606 if($blog_menu) {
607 $data['plaza_menus'][] = array(
608 'title' => '<i class="a fa fa-ticket"></i> ' . $this->language->get('text_blog'),
609 'child' => $blog_menu,
610 'active' => 0
611 );
612 }
613 }
614
615 if($this->user->hasPermission('access', 'plaza/slider')) {
616 $data['plaza_menus'][] = array(
617 'title' => '<i class="a fa fa-film"></i> ' . $this->language->get('text_slider'),
618 'url' => $this->url->link('plaza/slider', 'user_token=' . $this->session->data['user_token'], true),
619 'active' => 0
620 );
621 }
622
623 if($this->user->hasPermission('access', 'plaza/testimonial')) {
624 $data['plaza_menus'][] = array(
625 'title' => '<i class="a fa fa-comment"></i> ' . $this->language->get('text_testimonial'),
626 'url' => $this->url->link('plaza/testimonial', 'user_token=' . $this->session->data['user_token'], true),
627 'active' => 0
628 );
629 }
630
631 if($this->user->hasPermission('access', 'plaza/newsletter')) {
632 $data['plaza_menus'][] = array(
633 'title' => '<i class="a fa fa-envelope"></i> ' . $this->language->get('text_newsletter'),
634 'url' => $this->url->link('plaza/newsletter', 'user_token=' . $this->session->data['user_token'], true),
635 'active' => 0
636 );
637 }
638
639 $this->document->addStyle('view/stylesheet/plaza/themeadmin.css');
640 $this->document->addScript('view/javascript/plaza/jscolor.min.js');
641 $this->document->addScript('view/javascript/plaza/switch-toggle/js/bootstrap-toggle.min.js');
642 $this->document->addStyle('view/javascript/plaza/switch-toggle/css/bootstrap-toggle.min.css');
643 $this->document->addScript('view/javascript/plaza/selection/js/bootstrap-select.min.js');
644 $this->document->addStyle('view/javascript/plaza/selection/css/bootstrap-select.min.css');
645
646 $data['header'] = $this->load->controller('common/header');
647 $data['column_left'] = $this->load->controller('common/column_left');
648 $data['footer'] = $this->load->controller('common/footer');
649
650 $this->response->setOutput($this->load->view('plaza/module/ptcontrolpanel', $data));
651 }
652
653 public function import() {
654 $this->load->language('extension/module/ptcontrolpanel');
655
656 if (($this->request->server['REQUEST_METHOD'] == 'POST') && isset($this->request->post['file'])) {
657 $file = $this->request->post['file'];
658 } else {
659 $file = '';
660 }
661
662 if (!file_exists($file)) {
663 unset($this->session->data['success']);
664
665 $this->session->data['error_load_file'] = sprintf($this->language->get('error_load_file'), $file);
666
667 $this->response->redirect($this->url->link('extension/module/ptcontrolpanel', 'user_token=' . $this->session->data['user_token'], true));
668 } else {
669 unset($this->session->data['error_load_file']);
670
671 $lines = file($file);
672
673 if($lines) {
674 $sql = '';
675
676 foreach($lines as $line) {
677 if ($line && (substr($line, 0, 2) != '--') && (substr($line, 0, 1) != '#')) {
678 $sql .= $line;
679
680 if (preg_match('/;\s*$/', $line)) {
681 $sql = str_replace("DROP TABLE IF EXISTS `oc_", "DROP TABLE IF EXISTS `" . DB_PREFIX, $sql);
682 $sql = str_replace("CREATE TABLE `oc_", "CREATE TABLE `" . DB_PREFIX, $sql);
683 $sql = str_replace("CREATE TABLE IF NOT EXISTS `oc_", "CREATE TABLE `" . DB_PREFIX, $sql);
684 $sql = str_replace("INSERT INTO `oc_", "INSERT INTO `" . DB_PREFIX, $sql);
685 $sql = str_replace("UPDATE `oc_", "UPDATE `" . DB_PREFIX, $sql);
686 $sql = str_replace("WHERE `oc_", "WHERE `" . DB_PREFIX, $sql);
687 $sql = str_replace("TRUNCATE TABLE `oc_", "TRUNCATE TABLE `" . DB_PREFIX, $sql);
688 $sql = str_replace("ALTER TABLE `oc_", "ALTER TABLE `" . DB_PREFIX, $sql);
689
690 $this->db->query($sql);
691
692 $sql = '';
693 }
694 }
695 }
696 }
697
698 $this->session->data['success'] = $this->language->get('text_import_success');
699
700 $this->response->redirect($this->url->link('extension/module/ptcontrolpanel', 'user_token=' . $this->session->data['user_token'], true));
701 }
702 }
703
704 public function install() {
705 $this->load->model('plaza/controlpanel');
706 $this->model_plaza_controlpanel->setupData();
707
708 $this->load->model('setting/setting');
709
710 $data = array(
711 'module_ptcontrolpanel_status' => 1
712 );
713
714 $this->model_setting_setting->editSetting('module_ptcontrolpanel', $data, 0);
715
716 $this->load->model('user/user_group');
717 $this->model_user_user_group->addPermission($this->user->getGroupId(), 'access', 'plaza/module');
718 $this->model_user_user_group->addPermission($this->user->getGroupId(), 'modify', 'plaza/module');
719 }
720
721 public function uninstall() {
722 $this->load->model('user/user_group');
723
724 $this->model_user_user_group->removePermission($this->user->getGroupId(), 'access', 'extension/module/ptcontrolpanel');
725 $this->model_user_user_group->removePermission($this->user->getGroupId(), 'modify', 'extension/module/ptcontrolpanel');
726
727 $this->model_user_user_group->removePermission($this->user->getGroupId(), 'access', 'plaza/blog');
728 $this->model_user_user_group->removePermission($this->user->getGroupId(), 'modify', 'plaza/blog');
729
730 $this->model_user_user_group->removePermission($this->user->getGroupId(), 'access', 'plaza/blog/post');
731 $this->model_user_user_group->removePermission($this->user->getGroupId(), 'modify', 'plaza/blog/post');
732
733 $this->model_user_user_group->removePermission($this->user->getGroupId(), 'access', 'plaza/blog/list');
734 $this->model_user_user_group->removePermission($this->user->getGroupId(), 'modify', 'plaza/blog/list');
735
736 $this->model_user_user_group->removePermission($this->user->getGroupId(), 'access', 'plaza/blog/setting');
737 $this->model_user_user_group->removePermission($this->user->getGroupId(), 'modify', 'plaza/blog/setting');
738
739 $this->model_user_user_group->removePermission($this->user->getGroupId(), 'access', 'plaza/slider');
740 $this->model_user_user_group->removePermission($this->user->getGroupId(), 'modify', 'plaza/slider');
741
742 $this->model_user_user_group->removePermission($this->user->getGroupId(), 'access', 'plaza/testimonial');
743 $this->model_user_user_group->removePermission($this->user->getGroupId(), 'modify', 'plaza/testimonial');
744
745 $this->model_user_user_group->removePermission($this->user->getGroupId(), 'access', 'plaza/ultimatemenu');
746 $this->model_user_user_group->removePermission($this->user->getGroupId(), 'modify', 'plaza/ultimatemenu');
747
748 $this->model_user_user_group->removePermission($this->user->getGroupId(), 'access', 'plaza/featuredcate');
749 $this->model_user_user_group->removePermission($this->user->getGroupId(), 'modify', 'plaza/featuredcate');
750
751 $this->model_user_user_group->removePermission($this->user->getGroupId(), 'access', 'plaza/newsletter');
752 $this->model_user_user_group->removePermission($this->user->getGroupId(), 'modify', 'plaza/newsletter');
753 }
754
755 protected function validate() {
756 if (!$this->user->hasPermission('modify', 'extension/module/ptcontrolpanel')) {
757 $this->error['warning'] = $this->language->get('error_permission');
758 }
759
760 return !$this->error;
761 }
762}