Nickbur /
Sunrise-CMS
| 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 ControllerDesignLayout extends \Divine\Engine\Core\Controller |
||
|
0 ignored issues
–
show
|
|||
| 24 | { |
||
| 25 | private $error = array(); |
||
| 26 | |||
| 27 | public function index() |
||
|
0 ignored issues
–
show
|
|||
| 28 | { |
||
| 29 | $this->load->language('design/layout'); |
||
| 30 | |||
| 31 | $this->document->setTitle($this->language->get('heading_title')); |
||
| 32 | |||
| 33 | $this->load->model('design/layout'); |
||
| 34 | |||
| 35 | $this->getList(); |
||
| 36 | } |
||
| 37 | |||
| 38 | public function add() |
||
| 39 | { |
||
| 40 | $this->load->language('design/layout'); |
||
| 41 | |||
| 42 | $this->document->setTitle($this->language->get('heading_title')); |
||
| 43 | |||
| 44 | $this->load->model('design/layout'); |
||
| 45 | |||
| 46 | if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) { |
||
| 47 | $this->model_design_layout->addLayout($this->request->post); |
||
| 48 | |||
| 49 | $this->session->data['success'] = $this->language->get('text_success'); |
||
| 50 | |||
| 51 | $url = ''; |
||
| 52 | |||
| 53 | if (isset($this->request->get['sort'])) { |
||
| 54 | $url .= '&sort=' . $this->request->get['sort']; |
||
| 55 | } |
||
| 56 | |||
| 57 | if (isset($this->request->get['order'])) { |
||
| 58 | $url .= '&order=' . $this->request->get['order']; |
||
| 59 | } |
||
| 60 | |||
| 61 | if (isset($this->request->get['page'])) { |
||
| 62 | $url .= '&page=' . $this->request->get['page']; |
||
| 63 | } |
||
| 64 | |||
| 65 | $this->response->redirect($this->url->link('design/layout', 'token=' . $this->session->data['token'] . $url, true)); |
||
| 66 | } |
||
| 67 | |||
| 68 | $this->getForm(); |
||
| 69 | } |
||
| 70 | |||
| 71 | public function edit() |
||
| 72 | { |
||
| 73 | $this->load->language('design/layout'); |
||
| 74 | |||
| 75 | $this->document->setTitle($this->language->get('heading_title')); |
||
| 76 | |||
| 77 | $this->load->model('design/layout'); |
||
| 78 | |||
| 79 | if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) { |
||
| 80 | $this->model_design_layout->editLayout($this->request->get['layout_id'], $this->request->post); |
||
| 81 | |||
| 82 | $this->session->data['success'] = $this->language->get('text_success'); |
||
| 83 | |||
| 84 | $url = ''; |
||
| 85 | |||
| 86 | if (isset($this->request->get['sort'])) { |
||
| 87 | $url .= '&sort=' . $this->request->get['sort']; |
||
| 88 | } |
||
| 89 | |||
| 90 | if (isset($this->request->get['order'])) { |
||
| 91 | $url .= '&order=' . $this->request->get['order']; |
||
| 92 | } |
||
| 93 | |||
| 94 | if (isset($this->request->get['page'])) { |
||
| 95 | $url .= '&page=' . $this->request->get['page']; |
||
| 96 | } |
||
| 97 | |||
| 98 | $this->response->redirect($this->url->link('design/layout', 'token=' . $this->session->data['token'] . $url, true)); |
||
| 99 | } |
||
| 100 | |||
| 101 | $this->getForm(); |
||
| 102 | } |
||
| 103 | |||
| 104 | public function delete() |
||
| 105 | { |
||
| 106 | $this->load->language('design/layout'); |
||
| 107 | |||
| 108 | $this->document->setTitle($this->language->get('heading_title')); |
||
| 109 | |||
| 110 | $this->load->model('design/layout'); |
||
| 111 | |||
| 112 | if (isset($this->request->post['selected']) && $this->validateDelete()) { |
||
| 113 | foreach ($this->request->post['selected'] as $layout_id) { |
||
| 114 | $this->model_design_layout->deleteLayout($layout_id); |
||
| 115 | } |
||
| 116 | |||
| 117 | $this->session->data['success'] = $this->language->get('text_success'); |
||
| 118 | |||
| 119 | $url = ''; |
||
| 120 | |||
| 121 | if (isset($this->request->get['sort'])) { |
||
| 122 | $url .= '&sort=' . $this->request->get['sort']; |
||
| 123 | } |
||
| 124 | |||
| 125 | if (isset($this->request->get['order'])) { |
||
| 126 | $url .= '&order=' . $this->request->get['order']; |
||
| 127 | } |
||
| 128 | |||
| 129 | if (isset($this->request->get['page'])) { |
||
| 130 | $url .= '&page=' . $this->request->get['page']; |
||
| 131 | } |
||
| 132 | |||
| 133 | $this->response->redirect($this->url->link('design/layout', 'token=' . $this->session->data['token'] . $url, true)); |
||
| 134 | } |
||
| 135 | |||
| 136 | $this->getList(); |
||
| 137 | } |
||
| 138 | |||
| 139 | protected function getList() |
||
| 140 | { |
||
| 141 | if (isset($this->request->get['sort'])) { |
||
| 142 | $sort = $this->request->get['sort']; |
||
| 143 | } else { |
||
| 144 | $sort = 'name'; |
||
| 145 | } |
||
| 146 | |||
| 147 | if (isset($this->request->get['order'])) { |
||
| 148 | $order = $this->request->get['order']; |
||
| 149 | } else { |
||
| 150 | $order = 'ASC'; |
||
| 151 | } |
||
| 152 | |||
| 153 | if (isset($this->request->get['page'])) { |
||
| 154 | $page = $this->request->get['page']; |
||
| 155 | } else { |
||
| 156 | $page = 1; |
||
| 157 | } |
||
| 158 | |||
| 159 | $url = ''; |
||
| 160 | |||
| 161 | if (isset($this->request->get['sort'])) { |
||
| 162 | $url .= '&sort=' . $this->request->get['sort']; |
||
| 163 | } |
||
| 164 | |||
| 165 | if (isset($this->request->get['order'])) { |
||
| 166 | $url .= '&order=' . $this->request->get['order']; |
||
| 167 | } |
||
| 168 | |||
| 169 | if (isset($this->request->get['page'])) { |
||
| 170 | $url .= '&page=' . $this->request->get['page']; |
||
| 171 | } |
||
| 172 | |||
| 173 | $data['breadcrumbs'] = array(); |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
| 174 | |||
| 175 | $data['breadcrumbs'][] = array( |
||
| 176 | 'text' => $this->language->get('text_home'), |
||
| 177 | 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) |
||
| 178 | ); |
||
| 179 | |||
| 180 | $data['breadcrumbs'][] = array( |
||
| 181 | 'text' => $this->language->get('heading_title'), |
||
| 182 | 'href' => $this->url->link('design/layout', 'token=' . $this->session->data['token'] . $url, true) |
||
| 183 | ); |
||
| 184 | |||
| 185 | $data['add'] = $this->url->link('design/layout/add', 'token=' . $this->session->data['token'] . $url, true); |
||
| 186 | $data['delete'] = $this->url->link('design/layout/delete', 'token=' . $this->session->data['token'] . $url, true); |
||
| 187 | |||
| 188 | $data['layouts'] = array(); |
||
| 189 | |||
| 190 | $filter_data = array( |
||
| 191 | 'sort' => $sort, |
||
| 192 | 'order' => $order, |
||
| 193 | 'start' => ($page - 1) * $this->config->get('config_limit_admin'), |
||
| 194 | 'limit' => $this->config->get('config_limit_admin') |
||
| 195 | ); |
||
| 196 | |||
| 197 | $layout_total = $this->model_design_layout->getTotalLayouts(); |
||
| 198 | |||
| 199 | $results = $this->model_design_layout->getLayouts($filter_data); |
||
| 200 | |||
| 201 | foreach ($results as $result) { |
||
| 202 | $data['layouts'][] = array( |
||
| 203 | 'layout_id' => $result['layout_id'], |
||
| 204 | 'name' => $result['name'], |
||
| 205 | 'edit' => $this->url->link('design/layout/edit', 'token=' . $this->session->data['token'] . '&layout_id=' . $result['layout_id'] . $url, true) |
||
| 206 | ); |
||
| 207 | } |
||
| 208 | |||
| 209 | $data['heading_title'] = $this->language->get('heading_title'); |
||
| 210 | |||
| 211 | $data['text_list'] = $this->language->get('text_list'); |
||
| 212 | $data['text_no_results'] = $this->language->get('text_no_results'); |
||
| 213 | $data['text_confirm'] = $this->language->get('text_confirm'); |
||
| 214 | |||
| 215 | $data['column_name'] = $this->language->get('column_name'); |
||
| 216 | $data['column_action'] = $this->language->get('column_action'); |
||
| 217 | |||
| 218 | $data['button_add'] = $this->language->get('button_add'); |
||
| 219 | $data['button_edit'] = $this->language->get('button_edit'); |
||
| 220 | $data['button_delete'] = $this->language->get('button_delete'); |
||
| 221 | |||
| 222 | if (isset($this->error['warning'])) { |
||
| 223 | $data['error_warning'] = $this->error['warning']; |
||
| 224 | } else { |
||
| 225 | $data['error_warning'] = ''; |
||
| 226 | } |
||
| 227 | |||
| 228 | if (isset($this->session->data['success'])) { |
||
| 229 | $data['success'] = $this->session->data['success']; |
||
| 230 | |||
| 231 | unset($this->session->data['success']); |
||
| 232 | } else { |
||
| 233 | $data['success'] = ''; |
||
| 234 | } |
||
| 235 | |||
| 236 | if (isset($this->request->post['selected'])) { |
||
| 237 | $data['selected'] = (array) $this->request->post['selected']; |
||
| 238 | } else { |
||
| 239 | $data['selected'] = array(); |
||
| 240 | } |
||
| 241 | |||
| 242 | $url = ''; |
||
| 243 | |||
| 244 | if ($order == 'ASC') { |
||
| 245 | $url .= '&order=DESC'; |
||
| 246 | } else { |
||
| 247 | $url .= '&order=ASC'; |
||
| 248 | } |
||
| 249 | |||
| 250 | if (isset($this->request->get['page'])) { |
||
| 251 | $url .= '&page=' . $this->request->get['page']; |
||
| 252 | } |
||
| 253 | |||
| 254 | $data['sort_name'] = $this->url->link('design/layout', 'token=' . $this->session->data['token'] . '&sort=name' . $url, true); |
||
| 255 | |||
| 256 | $url = ''; |
||
| 257 | |||
| 258 | if (isset($this->request->get['sort'])) { |
||
| 259 | $url .= '&sort=' . $this->request->get['sort']; |
||
| 260 | } |
||
| 261 | |||
| 262 | if (isset($this->request->get['order'])) { |
||
| 263 | $url .= '&order=' . $this->request->get['order']; |
||
| 264 | } |
||
| 265 | |||
| 266 | $pagination = new \Divine\Engine\Library\Pagination(); |
||
| 267 | $pagination->total = $layout_total; |
||
| 268 | $pagination->page = $page; |
||
| 269 | $pagination->limit = $this->config->get('config_limit_admin'); |
||
| 270 | $pagination->url = $this->url->link('design/layout', 'token=' . $this->session->data['token'] . $url . '&page={page}', true); |
||
| 271 | |||
| 272 | $data['pagination'] = $pagination->render(); |
||
| 273 | |||
| 274 | $data['results'] = sprintf($this->language->get('text_pagination'), ($layout_total) ? (($page - 1) * $this->config->get('config_limit_admin')) + 1 : 0, ((($page - 1) * $this->config->get('config_limit_admin')) > ($layout_total - $this->config->get('config_limit_admin'))) ? $layout_total : ((($page - 1) * $this->config->get('config_limit_admin')) + $this->config->get('config_limit_admin')), $layout_total, ceil($layout_total / $this->config->get('config_limit_admin'))); |
||
| 275 | |||
| 276 | $data['sort'] = $sort; |
||
| 277 | $data['order'] = $order; |
||
| 278 | |||
| 279 | $data['header'] = $this->load->controller('common/header'); |
||
| 280 | $data['column'] = $this->load->controller('common/column_left'); |
||
| 281 | $data['footer'] = $this->load->controller('common/footer'); |
||
| 282 | |||
| 283 | $this->response->setOutput($this->load->view('design/layout_list', $data)); |
||
| 284 | } |
||
| 285 | |||
| 286 | protected function getForm() |
||
| 287 | { |
||
| 288 | $data['heading_title'] = $this->language->get('heading_title'); |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
| 289 | |||
| 290 | $data['text_form'] = !isset($this->request->get['layout_id']) ? $this->language->get('text_add') : $this->language->get('text_edit'); |
||
| 291 | $data['text_route'] = $this->language->get('text_route'); |
||
| 292 | $data['text_module'] = $this->language->get('text_module'); |
||
| 293 | $data['text_default'] = $this->language->get('text_default'); |
||
| 294 | $data['text_content_top'] = $this->language->get('text_content_top'); |
||
| 295 | $data['text_content_bottom'] = $this->language->get('text_content_bottom'); |
||
| 296 | $data['text_column'] = $this->language->get('text_column'); |
||
| 297 | $data['text_edit'] = $this->language->get('text_edit'); |
||
| 298 | $data['text_remove'] = $this->language->get('text_remove'); |
||
| 299 | |||
| 300 | $data['entry_name'] = $this->language->get('entry_name'); |
||
| 301 | $data['entry_route'] = $this->language->get('entry_route'); |
||
| 302 | $data['entry_module'] = $this->language->get('entry_module'); |
||
| 303 | |||
| 304 | $data['button_save'] = $this->language->get('button_save'); |
||
| 305 | $data['button_cancel'] = $this->language->get('button_cancel'); |
||
| 306 | $data['button_route_add'] = $this->language->get('button_route_add'); |
||
| 307 | $data['button_module_add'] = $this->language->get('button_module_add'); |
||
| 308 | $data['button_edit'] = $this->language->get('button_edit'); |
||
| 309 | $data['button_remove'] = $this->language->get('button_remove'); |
||
| 310 | |||
| 311 | if (isset($this->error['warning'])) { |
||
| 312 | $data['error_warning'] = $this->error['warning']; |
||
| 313 | } else { |
||
| 314 | $data['error_warning'] = ''; |
||
| 315 | } |
||
| 316 | |||
| 317 | if (isset($this->error['name'])) { |
||
| 318 | $data['error_name'] = $this->error['name']; |
||
| 319 | } else { |
||
| 320 | $data['error_name'] = ''; |
||
| 321 | } |
||
| 322 | |||
| 323 | $url = ''; |
||
| 324 | |||
| 325 | if (isset($this->request->get['sort'])) { |
||
| 326 | $url .= '&sort=' . $this->request->get['sort']; |
||
| 327 | } |
||
| 328 | |||
| 329 | if (isset($this->request->get['order'])) { |
||
| 330 | $url .= '&order=' . $this->request->get['order']; |
||
| 331 | } |
||
| 332 | |||
| 333 | if (isset($this->request->get['page'])) { |
||
| 334 | $url .= '&page=' . $this->request->get['page']; |
||
| 335 | } |
||
| 336 | |||
| 337 | $data['breadcrumbs'] = array(); |
||
| 338 | |||
| 339 | $data['breadcrumbs'][] = array( |
||
| 340 | 'text' => $this->language->get('text_home'), |
||
| 341 | 'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], true) |
||
| 342 | ); |
||
| 343 | |||
| 344 | $data['breadcrumbs'][] = array( |
||
| 345 | 'text' => $this->language->get('heading_title'), |
||
| 346 | 'href' => $this->url->link('design/layout', 'token=' . $this->session->data['token'] . $url, true) |
||
| 347 | ); |
||
| 348 | |||
| 349 | if (!isset($this->request->get['layout_id'])) { |
||
| 350 | $data['action'] = $this->url->link('design/layout/add', 'token=' . $this->session->data['token'] . $url, true); |
||
| 351 | } else { |
||
| 352 | $data['action'] = $this->url->link('design/layout/edit', 'token=' . $this->session->data['token'] . '&layout_id=' . $this->request->get['layout_id'] . $url, true); |
||
| 353 | } |
||
| 354 | |||
| 355 | $data['cancel'] = $this->url->link('design/layout', 'token=' . $this->session->data['token'] . $url, true); |
||
| 356 | |||
| 357 | $data['token'] = $this->session->data['token']; |
||
| 358 | |||
| 359 | if (isset($this->request->get['layout_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) { |
||
| 360 | $layout_info = $this->model_design_layout->getLayout($this->request->get['layout_id']); |
||
| 361 | } |
||
| 362 | |||
| 363 | if (isset($this->request->post['name'])) { |
||
| 364 | $data['name'] = $this->request->post['name']; |
||
| 365 | } elseif (!empty($layout_info)) { |
||
| 366 | $data['name'] = $layout_info['name']; |
||
| 367 | } else { |
||
| 368 | $data['name'] = ''; |
||
| 369 | } |
||
| 370 | |||
| 371 | if (isset($this->request->post['layout_route'])) { |
||
| 372 | $data['layout_routes'] = $this->request->post['layout_route']; |
||
| 373 | } elseif (isset($this->request->get['layout_id'])) { |
||
| 374 | $data['layout_routes'] = $this->model_design_layout->getLayoutRoutes($this->request->get['layout_id']); |
||
| 375 | } else { |
||
| 376 | $data['layout_routes'] = array(); |
||
| 377 | } |
||
| 378 | |||
| 379 | $data['extensions'] = array(); |
||
| 380 | |||
| 381 | // Get a list of installed modules |
||
| 382 | $this->load->model('extension/extension'); |
||
| 383 | $extensions = $this->model_extension_extension->getInstalled('module'); |
||
| 384 | |||
| 385 | // Add all the modules which have multiple settings for each module |
||
| 386 | foreach ($extensions as $code) { |
||
| 387 | $this->load->language('extension/module/' . $code); |
||
| 388 | |||
| 389 | $module_data = array(); |
||
| 390 | |||
| 391 | $this->load->model('extension/module'); |
||
| 392 | $modules = $this->model_extension_module->getModulesByCode($code); |
||
| 393 | |||
| 394 | foreach ($modules as $module) { |
||
| 395 | $module_data[] = array( |
||
| 396 | 'name' => strip_tags($module['name']), |
||
| 397 | 'code' => $code . '.' . $module['module_id'] |
||
| 398 | ); |
||
| 399 | } |
||
| 400 | |||
| 401 | \Tracy\Debugger::barDump($modules); |
||
| 402 | |||
| 403 | if ($this->config->has($code . '_status') || $module_data) { |
||
| 404 | $data['extensions'][] = array( |
||
| 405 | 'name' => strip_tags($this->language->get('heading_title')), |
||
| 406 | 'code' => $code, |
||
| 407 | 'module' => $module_data |
||
| 408 | ); |
||
| 409 | } |
||
| 410 | } |
||
| 411 | |||
| 412 | // Modules layout |
||
| 413 | if (isset($this->request->post['layout_module'])) { |
||
| 414 | $layout_modules = $this->request->post['layout_module']; |
||
| 415 | } elseif (isset($this->request->get['layout_id'])) { |
||
| 416 | $layout_modules = $this->model_design_layout->getLayoutModules($this->request->get['layout_id']); |
||
| 417 | } else { |
||
| 418 | $layout_modules = array(); |
||
| 419 | } |
||
| 420 | |||
| 421 | $data['layout_modules'] = array(); |
||
| 422 | |||
| 423 | // Add all the modules which have multiple settings for each module |
||
| 424 | foreach ($layout_modules as $layout_module) { |
||
| 425 | $part = explode('.', $layout_module['code']); |
||
| 426 | |||
| 427 | $this->load->language('extension/module/' . $part[0]); |
||
| 428 | |||
| 429 | if (!isset($part[1])) { |
||
| 430 | $data['layout_modules'][] = array( |
||
| 431 | 'name' => strip_tags($this->language->get('heading_title')), |
||
| 432 | 'code' => $layout_module['code'], |
||
| 433 | 'edit' => $this->url->link('extension/module/' . $part[0], 'token=' . $this->session->data['token'], true), |
||
| 434 | 'position' => $layout_module['position'], |
||
| 435 | 'sort_order' => $layout_module['sort_order'] |
||
| 436 | ); |
||
| 437 | } else { |
||
| 438 | $module_info = $this->model_extension_module->getModule($part[1]); |
||
| 439 | |||
| 440 | if ($module_info) { |
||
| 441 | $data['layout_modules'][] = array( |
||
| 442 | 'name' => strip_tags($module_info['name']), |
||
| 443 | 'code' => $layout_module['code'], |
||
| 444 | 'edit' => $this->url->link('extension/module/' . $part[0], 'token=' . $this->session->data['token'] . '&module_id=' . $part[1], true), |
||
| 445 | 'position' => $layout_module['position'], |
||
| 446 | 'sort_order' => $layout_module['sort_order'] |
||
| 447 | ); |
||
| 448 | } |
||
| 449 | } |
||
| 450 | } |
||
| 451 | |||
| 452 | $data['header'] = $this->load->controller('common/header'); |
||
| 453 | $data['column'] = $this->load->controller('common/column_left'); |
||
| 454 | $data['footer'] = $this->load->controller('common/footer'); |
||
| 455 | |||
| 456 | $this->response->setOutput($this->load->view('design/layout_form', $data)); |
||
| 457 | } |
||
| 458 | |||
| 459 | protected function validateForm() |
||
| 460 | { |
||
| 461 | if (!$this->user->hasPermission('modify', 'design/layout')) { |
||
| 462 | $this->error['warning'] = $this->language->get('error_permission'); |
||
| 463 | } |
||
| 464 | |||
| 465 | if ((\voku\helper\UTF8::strlen($this->request->post['name']) < 3) || (\voku\helper\UTF8::strlen($this->request->post['name']) > 64)) { |
||
| 466 | $this->error['name'] = $this->language->get('error_name'); |
||
| 467 | } |
||
| 468 | |||
| 469 | return !$this->error; |
||
| 470 | } |
||
| 471 | |||
| 472 | protected function validateDelete() |
||
| 473 | { |
||
| 474 | if (!$this->user->hasPermission('modify', 'design/layout')) { |
||
| 475 | $this->error['warning'] = $this->language->get('error_permission'); |
||
| 476 | } |
||
| 477 | |||
| 478 | $this->load->model('catalog/product'); |
||
| 479 | $this->load->model('catalog/category'); |
||
| 480 | $this->load->model('catalog/information'); |
||
| 481 | $this->load->model('catalog/manufacturer'); |
||
| 482 | $this->load->model('blog/article'); |
||
| 483 | $this->load->model('blog/category'); |
||
| 484 | |||
| 485 | foreach ($this->request->post['selected'] as $layout_id) { |
||
| 486 | if ($this->config->get('config_layout_id') == $layout_id) { |
||
| 487 | $this->error['warning'] = $this->language->get('error_default'); |
||
| 488 | } |
||
| 489 | |||
| 490 | $product_total = $this->model_catalog_product->getTotalProductsByLayoutId($layout_id); |
||
| 491 | |||
| 492 | if ($product_total) { |
||
| 493 | $this->error['warning'] = sprintf($this->language->get('error_product'), $product_total); |
||
| 494 | } |
||
| 495 | |||
| 496 | $category_total = $this->model_catalog_category->getTotalCategoriesByLayoutId($layout_id); |
||
| 497 | |||
| 498 | if ($category_total) { |
||
| 499 | $this->error['warning'] = sprintf($this->language->get('error_category'), $category_total); |
||
| 500 | } |
||
| 501 | |||
| 502 | $manufacturer_total = $this->model_catalog_manufacturer->getTotalManufacturerByLayoutId($layout_id); |
||
| 503 | |||
| 504 | if ($manufacturer_total) { |
||
| 505 | $this->error['warning'] = sprintf($this->language->get('error_manufacturer'), $manufacturer_total); |
||
| 506 | } |
||
| 507 | |||
| 508 | $information_total = $this->model_catalog_information->getTotalInformationsByLayoutId($layout_id); |
||
| 509 | |||
| 510 | if ($information_total) { |
||
| 511 | $this->error['warning'] = sprintf($this->language->get('error_information'), $information_total); |
||
| 512 | } |
||
| 513 | |||
| 514 | $blog_article_total = $this->model_blog_article->getTotalArticlesByLayoutId($layout_id); |
||
| 515 | |||
| 516 | if ($blog_article_total) { |
||
| 517 | $this->error['warning'] = sprintf($this->language->get('error_blog_article'), $blog_article_total); |
||
| 518 | } |
||
| 519 | |||
| 520 | $blog_category_total = $this->model_blog_category->getTotalCategoriesByLayoutId($layout_id); |
||
| 521 | |||
| 522 | if ($blog_category_total) { |
||
| 523 | $this->error['warning'] = sprintf($this->language->get('error_blog_category'), $blog_category_total); |
||
| 524 | } |
||
| 525 | } |
||
| 526 | |||
| 527 | return !$this->error; |
||
| 528 | } |
||
| 529 | } |
||
| 530 |
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.