1 | <?php |
||
2 | |||
3 | /* Divine CMS - Open source CMS for widespread use. |
||
4 | Copyright (c) 2019 Mykola Burakov ([email protected]) |
||
5 | |||
6 | See SOURCE.txt for other and additional information. |
||
7 | |||
8 | This file is part of Divine CMS. |
||
9 | |||
10 | This program is free software: you can redistribute it and/or modify |
||
11 | it under the terms of the GNU General Public License as published by |
||
12 | the Free Software Foundation, either version 3 of the License, or |
||
13 | (at your option) any later version. |
||
14 | |||
15 | This program is distributed in the hope that it will be useful, |
||
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
18 | GNU General Public License for more details. |
||
19 | |||
20 | You should have received a copy of the GNU General Public License |
||
21 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
||
22 | |||
23 | class ControllerCommonHeader extends \Divine\Engine\Core\Controller |
||
0 ignored issues
–
show
|
|||
24 | { |
||
25 | public function index() |
||
0 ignored issues
–
show
|
|||
26 | { |
||
27 | // styles (addStylePreload if "preload" or addStyle if not) |
||
28 | $this->document->addStyle('https://cdnjs.cloudflare.com/ajax/libs/uikit/3.1.6/css/uikit.min.css'); |
||
29 | $this->document->addStyle('/public_html/assets/css/application/general/styles.css'); |
||
30 | if (defined('SR_TRACY_DEBUG') && SR_TRACY_DEBUG == true) { |
||
0 ignored issues
–
show
|
|||
31 | $this->document->addStyle('/public_html/assets/css/application/general/tracy-debugger.css'); |
||
32 | } |
||
33 | // scripts (addScriptDefer if "defer" or addScriptAsync if "async" or addScript if neither one nor the other) |
||
34 | $this->document->addScriptAsync('https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js'); |
||
35 | $this->document->addScriptAsync('https://cdnjs.cloudflare.com/ajax/libs/uikit/3.1.6/js/uikit.min.js'); |
||
36 | $this->document->addScriptDefer('https://cdnjs.cloudflare.com/ajax/libs/uikit/3.1.6/js/uikit-icons.min.js'); |
||
37 | $this->document->addScriptAsync('/public_html/assets/js/application/general/common/cart.js'); |
||
38 | // links | $this->document->addLink('/public_html/assets/images/' . $this->config->get('...'), 'icon'); |
||
39 | |||
40 | $data['title'] = $this->document->getTitle(); |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
41 | |||
42 | $data['description'] = $this->document->getDescription(); |
||
43 | $data['links'] = $this->document->getLinks(); |
||
44 | $data['robots'] = $this->document->getRobots(); |
||
45 | |||
46 | $data['stylespreload'] = $this->document->getStylespreload(); |
||
47 | $data['styles'] = $this->document->getStyles(); |
||
48 | |||
49 | $data['scriptsasync'] = $this->document->getScriptsAsync(); |
||
50 | $data['scriptsdefer'] = $this->document->getScriptsDefer(); |
||
51 | $data['scripts'] = $this->document->getScripts(); |
||
52 | |||
53 | $data['lang'] = $this->language->get('code'); |
||
54 | $data['direction'] = $this->language->get('direction'); |
||
55 | |||
56 | $data['name'] = $this->config->get('config_name'); |
||
57 | |||
58 | if (is_file($_SERVER['DOCUMENT_ROOT'] . '/public_html/assets/images/' . $this->config->get('config_logo'))) { |
||
59 | $data['logo'] = '/public_html/assets/images/' . $this->config->get('config_logo'); |
||
60 | } else { |
||
61 | $data['logo'] = ''; |
||
62 | } |
||
63 | |||
64 | // language |
||
65 | $this->load->language('common/header'); |
||
66 | |||
67 | $data['test'] = $this->language->test(); |
||
68 | |||
69 | $data['text_home'] = $this->language->get('text_home'); |
||
70 | $data['text_shopping_cart'] = $this->language->get('text_shopping_cart'); |
||
71 | $data['text_logged'] = sprintf( |
||
72 | $this->language->get('text_logged'), |
||
73 | $this->url->link('account/account', '', true), |
||
74 | $this->customer->getFirstName(), |
||
75 | $this->url->link('account/logout', '', true) |
||
76 | ); |
||
77 | $data['text_account'] = $this->language->get('text_account'); |
||
78 | $data['text_register'] = $this->language->get('text_register'); |
||
79 | $data['text_login'] = $this->language->get('text_login'); |
||
80 | $data['text_order'] = $this->language->get('text_order'); |
||
81 | $data['text_transaction'] = $this->language->get('text_transaction'); |
||
82 | $data['text_download'] = $this->language->get('text_download'); |
||
83 | $data['text_logout'] = $this->language->get('text_logout'); |
||
84 | $data['text_checkout'] = $this->language->get('text_checkout'); |
||
85 | $data['text_main_menu'] = $this->language->get('text_main_menu'); |
||
86 | $data['text_go_to'] = $this->language->get('text_go_to'); |
||
87 | $data['text_look_at_map'] = $this->language->get('text_look_at_map'); |
||
88 | // |
||
89 | |||
90 | // links |
||
91 | $data['home'] = $this->url->link('common/home'); |
||
92 | $data['logged'] = $this->customer->isLogged(); |
||
93 | $data['account'] = $this->url->link('account/account', '', true); |
||
94 | $data['register'] = $this->url->link('account/register', '', true); |
||
95 | $data['login'] = $this->url->link('account/login', '', true); |
||
96 | $data['order'] = $this->url->link('account/order', '', true); |
||
97 | $data['transaction'] = $this->url->link('account/transaction', '', true); |
||
98 | $data['download'] = $this->url->link('account/download', '', true); |
||
99 | $data['logout'] = $this->url->link('account/logout', '', true); |
||
100 | $data['shopping_cart'] = $this->url->link('checkout/cart'); |
||
101 | // $data['checkout'] = $this->url->link('checkout/checkout', '', true); |
||
102 | $data['checkout'] = $this->url->link('checkout/onepagecheckout', '', true); |
||
103 | // |
||
104 | $data['contact'] = $this->url->link('information/contact'); |
||
105 | $data['telephone'] = $this->config->get('config_telephone'); |
||
106 | // |
||
107 | |||
108 | // Menu |
||
109 | $this->load->model('design/custommenu'); |
||
110 | $this->load->model('catalog/category'); |
||
111 | |||
112 | $this->load->model('catalog/product'); |
||
113 | |||
114 | $data['categories'] = array(); |
||
115 | |||
116 | if ($this->config->get('configcustommenu_custommenu')) { |
||
117 | $custommenus = $this->model_design_custommenu->getcustommenus(); |
||
118 | $custommenu_child = $this->model_design_custommenu->getChildcustommenus(); |
||
119 | |||
120 | foreach ($custommenus as $id => $custommenu) { |
||
121 | $children_data = array(); |
||
122 | |||
123 | foreach ($custommenu_child as $child_id => $child_custommenu) { |
||
124 | if (($custommenu['custommenu_id'] != $child_custommenu['custommenu_id']) or !is_numeric($child_id)) { |
||
125 | continue; |
||
126 | } |
||
127 | |||
128 | $child_name = ''; |
||
129 | |||
130 | if (($custommenu['custommenu_type'] == 'category') and ($child_custommenu['custommenu_type'] == 'category')) { |
||
131 | $filter_data = array( |
||
132 | 'filter_category_id' => $child_custommenu['link'], |
||
133 | 'filter_sub_category' => true |
||
134 | ); |
||
135 | |||
136 | $child_name = ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''); |
||
137 | } |
||
138 | |||
139 | $children_data[] = array( |
||
140 | 'name' => $child_custommenu['name'] . $child_name, |
||
141 | 'href' => $this->getcustommenuLink($custommenu, $child_custommenu) |
||
142 | ); |
||
143 | } |
||
144 | |||
145 | $data['categories'][] = array( |
||
146 | 'name' => $custommenu['name'], |
||
147 | 'children' => $children_data, |
||
148 | 'column' => $custommenu['columns'] ? $custommenu['columns'] : 1, |
||
149 | 'href' => $this->getcustommenuLink($custommenu) |
||
150 | ); |
||
151 | } |
||
152 | } else { |
||
153 | $categories = $this->model_catalog_category->getCategories(0); |
||
154 | |||
155 | foreach ($categories as $category) { |
||
156 | if ($category['top']) { |
||
0 ignored issues
–
show
|
|||
157 | |||
158 | // Level 2 |
||
159 | $children_data = array(); |
||
160 | |||
161 | $children = $this->model_catalog_category->getCategories($category['category_id']); |
||
162 | |||
163 | foreach ($children as $child) { |
||
164 | $filter_data = array( |
||
165 | 'filter_category_id' => $child['category_id'], |
||
166 | 'filter_sub_category' => true |
||
167 | ); |
||
168 | |||
169 | $children_data[] = array( |
||
170 | 'name' => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''), |
||
171 | 'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']) |
||
172 | ); |
||
173 | } |
||
174 | |||
175 | // Level 1 |
||
176 | $data['categories'][] = array( |
||
177 | 'name' => $category['name'], |
||
178 | 'children' => $children_data, |
||
179 | 'column' => $category['column'] ? $category['column'] : 1, |
||
180 | 'href' => $this->url->link('product/category', 'path=' . $category['category_id']) |
||
181 | ); |
||
182 | } |
||
183 | } |
||
184 | } |
||
185 | |||
186 | if ($this->config->get('configblog_blog_menu')) { |
||
187 | $data['menu'] = $this->load->controller('blog/menu'); |
||
188 | } else { |
||
189 | $data['menu'] = ''; |
||
190 | } |
||
191 | // |
||
192 | |||
193 | // adminbar |
||
194 | if (isset($this->session->data['token'])) { |
||
0 ignored issues
–
show
|
|||
195 | |||
196 | // token |
||
197 | $data['token_admin'] = $this->session->data['token']; |
||
198 | // |
||
199 | |||
200 | // route |
||
201 | if (isset($this->request->get['route'])) { |
||
202 | if ($this->request->get['route'] == 'product/product') { |
||
203 | $data['quick_edit_admin'] = '/administration/index.php?route=catalog/product/edit&product_id=' . $this->request->get['product_id'] . '&token=' . $data['token_admin']; |
||
204 | } elseif ($this->request->get['route'] == 'product/category') { |
||
205 | $path_parts = explode('_', $this->request->get['path']); |
||
206 | $data['quick_edit_admin'] = '/administration/index.php?route=catalog/category/edit&category_id=' . array_pop($path_parts) . '&token=' . $data['token_admin']; |
||
207 | } elseif ($this->request->get['route'] == 'information/information') { |
||
208 | $data['quick_edit_admin'] = '/administration/index.php?route=catalog/information/edit&information_id=' . $this->request->get['information_id'] . '&token=' . $data['token_admin']; |
||
209 | } elseif ($this->request->get['route'] == 'product/manufacturer/info') { |
||
210 | $data['quick_edit_admin'] = '/administration/index.php?route=catalog/manufacturer/edit&manufacturer_id=' . $this->request->get['manufacturer_id'] . '&token=' . $data['token_admin']; |
||
211 | } else { |
||
212 | $data['quick_edit_admin'] = ''; |
||
213 | } |
||
214 | } else { |
||
215 | $data['quick_edit_admin'] = ''; |
||
216 | } |
||
217 | // |
||
218 | |||
219 | // links |
||
220 | $data['dashboard_admin'] = '/administration/index.php?route=common/dashboard&token=' . $data['token_admin']; |
||
221 | $data['category_add_admin'] = '/administration/index.php?route=catalog/category/add&token=' . $data['token_admin']; |
||
222 | $data['product_add_admin'] = '/administration/index.php?route=catalog/product/add&token=' . $data['token_admin']; |
||
223 | $data['filter_add_admin'] = '/administration/index.php?route=catalog/filter/add&token=' . $data['token_admin']; |
||
224 | $data['attribute_add_admin'] = '/administration/index.php?route=catalog/attribute/add&token=' . $data['token_admin']; |
||
225 | $data['option_add_admin'] = '/administration/index.php?route=catalog/option/add&token=' . $data['token_admin']; |
||
226 | $data['manufacturer_add_admin'] = '/administration/index.php?route=catalog/manufacturer/add&token=' . $data['token_admin']; |
||
227 | $data['information_add_admin'] = '/administration/index.php?route=catalog/information/add&token=' . $data['token_admin']; |
||
228 | $data['category_all_admin'] = '/administration/index.php?route=catalog/category&token=' . $data['token_admin']; |
||
229 | $data['product_all_admin'] = '/administration/index.php?route=catalog/product&token=' . $data['token_admin']; |
||
230 | $data['filter_all_admin'] = '/administration/index.php?route=catalog/filter&token=' . $data['token_admin']; |
||
231 | $data['attribute_all_admin'] = '/administration/index.php?route=catalog/attribute&token=' . $data['token_admin']; |
||
232 | $data['option_all_admin'] = '/administration/index.php?route=catalog/option&token=' . $data['token_admin']; |
||
233 | $data['manufacturer_all_admin'] = '/administration/index.php?route=catalog/manufacturer&token=' . $data['token_admin']; |
||
234 | $data['review_all_admin'] = '/administration/index.php?route=catalog/review&token=' . $data['token_admin']; |
||
235 | $data['information_all_admin'] = '/administration/index.php?route=catalog/information&token=' . $data['token_admin']; |
||
236 | $data['orders_pending_admin'] = '/administration/index.php?route=sale/order&token=' . $data['token_admin'] . '&filter_order_status=1'; |
||
237 | $data['orders_processing_admin'] = '/administration/index.php?route=sale/order&token=' . $data['token_admin'] . '&filter_order_status=1'; |
||
238 | $data['orders_orders_today'] = '/administration/index.php?route=sale/order&token=' . $data['token_admin'] . '&filter_date_added=' . date('Y-m-d'); |
||
239 | $data['all_orders_admin'] = '/administration/index.php?route=sale/order&token=' . $data['token_admin']; |
||
240 | $data['return_admin'] = '/administration/index.php?route=sale/return&token=' . $data['token_admin']; |
||
241 | $data['adminbar_logout'] = '/administration/index.php?route=common/logout&token=' . $data['token_admin']; |
||
242 | // |
||
243 | |||
244 | // language |
||
245 | $data['text_adminbar_edit'] = $this->language->get('text_adminbar_edit'); |
||
246 | $data['text_adminbar_dashboard'] = $this->language->get('text_adminbar_dashboard'); |
||
247 | $data['text_adminbar_add'] = $this->language->get('text_adminbar_add'); |
||
248 | $data['text_adminbar_category'] = $this->language->get('text_adminbar_category'); |
||
249 | $data['text_adminbar_product'] = $this->language->get('text_adminbar_product'); |
||
250 | $data['text_adminbar_filter'] = $this->language->get('text_adminbar_filter'); |
||
251 | $data['text_adminbar_attribute'] = $this->language->get('text_adminbar_attribute'); |
||
252 | $data['text_adminbar_option'] = $this->language->get('text_adminbar_option'); |
||
253 | $data['text_adminbar_manufacturer'] = $this->language->get('text_adminbar_manufacturer'); |
||
254 | $data['text_adminbar_information'] = $this->language->get('text_adminbar_information'); |
||
255 | $data['text_adminbar_catalog'] = $this->language->get('text_adminbar_catalog'); |
||
256 | $data['text_adminbar_categories'] = $this->language->get('text_adminbar_categories'); |
||
257 | $data['text_adminbar_products'] = $this->language->get('text_adminbar_products'); |
||
258 | $data['text_adminbar_filters'] = $this->language->get('text_adminbar_filters'); |
||
259 | $data['text_adminbar_attributes'] = $this->language->get('text_adminbar_attributes'); |
||
260 | $data['text_adminbar_options'] = $this->language->get('text_adminbar_options'); |
||
261 | $data['text_adminbar_manufacturers'] = $this->language->get('text_adminbar_manufacturers'); |
||
262 | $data['text_adminbar_review'] = $this->language->get('text_adminbar_review'); |
||
263 | $data['text_adminbar_informations'] = $this->language->get('text_adminbar_informations'); |
||
264 | $data['text_adminbar_sale'] = $this->language->get('text_adminbar_sale'); |
||
265 | $data['text_adminbar_orders_pending'] = $this->language->get('text_adminbar_orders_pending'); |
||
266 | $data['text_adminbar_orders_processing'] = $this->language->get('text_adminbar_orders_processing'); |
||
267 | $data['text_adminbar_orders_today'] = $this->language->get('text_adminbar_orders_today'); |
||
268 | $data['text_adminbar_all_orders'] = $this->language->get('text_adminbar_all_orders'); |
||
269 | $data['text_adminbar_return'] = $this->language->get('text_adminbar_return'); |
||
270 | $data['text_adminbar_logout'] = $this->language->get('text_adminbar_logout'); |
||
271 | // |
||
272 | } |
||
273 | // |
||
274 | |||
275 | // For page specific css |
||
276 | if (isset($this->request->get['route'])) { |
||
277 | if (isset($this->request->get['product_id'])) { |
||
278 | $class = '-' . $this->request->get['product_id']; |
||
279 | } elseif (isset($this->request->get['path'])) { |
||
280 | $class = '-' . $this->request->get['path']; |
||
281 | } elseif (isset($this->request->get['manufacturer_id'])) { |
||
282 | $class = '-' . $this->request->get['manufacturer_id']; |
||
283 | } elseif (isset($this->request->get['information_id'])) { |
||
284 | $class = '-' . $this->request->get['information_id']; |
||
285 | } else { |
||
286 | $class = ''; |
||
287 | } |
||
288 | |||
289 | $data['class'] = str_replace('/', '-', $this->request->get['route']) . $class; |
||
290 | } else { |
||
291 | $data['class'] = 'common-home'; |
||
292 | } |
||
293 | // |
||
294 | |||
295 | // https://opencartforum.com/topic/129529-reliz-ocstore-3020/?do=findComment&comment=1313914 |
||
296 | $data['search'] = $this->load->controller('common/search'); |
||
297 | $data['cart'] = $this->load->controller('common/cart'); |
||
298 | // |
||
299 | |||
300 | echo '<!--'; |
||
301 | print_r($this->session); |
||
302 | echo '-->'; |
||
303 | |||
304 | return $this->load->view('common/header', $data); |
||
305 | } |
||
306 | |||
307 | public function getcustommenuLink($parent, $child = null) |
||
308 | { |
||
309 | if ($this->config->get('configcustommenu_custommenu')) { |
||
310 | $item = empty($child) ? $parent : $child; |
||
311 | |||
312 | switch ($item['custommenu_type']) { |
||
313 | case 'category': |
||
314 | $route = 'product/category'; |
||
315 | |||
316 | if (!empty($child)) { |
||
317 | $args = 'path=' . $parent['link'] . '_' . $item['link']; |
||
318 | } else { |
||
319 | $args = 'path=' . $item['link']; |
||
320 | } |
||
321 | break; |
||
322 | case 'product': |
||
323 | $route = 'product/product'; |
||
324 | $args = 'product_id=' . $item['link']; |
||
325 | break; |
||
326 | case 'manufacturer': |
||
327 | $route = 'product/manufacturer/info'; |
||
328 | $args = 'manufacturer_id=' . $item['link']; |
||
329 | break; |
||
330 | case 'information': |
||
331 | $route = 'information/information'; |
||
332 | $args = 'information_id=' . $item['link']; |
||
333 | break; |
||
334 | default: |
||
335 | $tmp = explode('&', str_replace('index.php?route=', '', $item['link'])); |
||
336 | |||
337 | if (!empty($tmp)) { |
||
338 | $route = $tmp[0]; |
||
339 | unset($tmp[0]); |
||
340 | $args = (!empty($tmp)) ? implode('&', $tmp) : ''; |
||
341 | } else { |
||
342 | $route = $item['link']; |
||
343 | $args = ''; |
||
344 | } |
||
345 | |||
346 | break; |
||
347 | } |
||
348 | |||
349 | $check = stripos($item['link'], 'https'); |
||
350 | $checkbase = strpos($item['link'], '/'); |
||
351 | |||
352 | if ($check === 0 || $checkbase === 0) { |
||
353 | $link = $item['link']; |
||
354 | } else { |
||
355 | $link = $this->url->link($route, $args); |
||
356 | } |
||
357 | |||
358 | return $link; |
||
359 | } |
||
360 | } |
||
361 | } |
||
362 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.