/catalog/model/pavcustom/admin/controller/module/pavcustom.php

https://gitlab.com/fcupen/PHP-SHOPPING · PHP · 152 lines · 119 code · 33 blank · 0 comment · 11 complexity · 2a2e04dcee8680b106ed635150b2b8d1 MD5 · raw file

  1. <?php
  2. class ControllerModulePavcustom extends Controller {
  3. private $error = array();
  4. public function index() {
  5. $this->language->load('module/pavcustom');
  6. $this->document->setTitle($this->language->get('heading_title'));
  7. $this->load->model('setting/setting');
  8. if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
  9. $action = $this->request->post['pavcustom_module']['action'];
  10. unset( $this->request->post['pavcustom_module']['action'] );
  11. $this->model_setting_setting->editSetting('pavcustom', $this->request->post);
  12. $this->session->data['success'] = $this->language->get('text_success');
  13. if( $action == 'saveedit' ){
  14. $this->redirect($this->url->link('module/pavcustom', 'token=' . $this->session->data['token'], 'SSL'));
  15. }else {
  16. $this->redirect($this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'));
  17. }
  18. }
  19. $this->data['heading_title'] = $this->language->get('heading_title');
  20. $this->data['text_enabled'] = $this->language->get('text_enabled');
  21. $this->data['text_disabled'] = $this->language->get('text_disabled');
  22. $this->data['text_content_top'] = $this->language->get('text_content_top');
  23. $this->data['text_content_bottom'] = $this->language->get('text_content_bottom');
  24. $this->data['text_column_left'] = $this->language->get('text_column_left');
  25. $this->data['text_column_right'] = $this->language->get('text_column_right');
  26. $this->data['text_browse'] = $this->language->get('text_browse');
  27. $this->data['text_clear'] = $this->language->get('text_clear');
  28. $this->data['text_select_all'] = $this->language->get('text_select_all');
  29. $this->data['text_unselect_all'] = $this->language->get('text_unselect_all');
  30. $this->data['entry_store'] = $this->language->get('entry_store');
  31. $this->data['help_store'] = $this->language->get('help_store');
  32. $this->data['entry_description'] = $this->language->get('entry_description');
  33. $this->data['entry_layout'] = $this->language->get('entry_layout');
  34. $this->data['entry_position'] = $this->language->get('entry_position');
  35. $this->data['entry_status'] = $this->language->get('entry_status');
  36. $this->data['entry_sort_order'] = $this->language->get('entry_sort_order');
  37. $this->data['button_save'] = $this->language->get('button_save');
  38. $this->data['button_cancel'] = $this->language->get('button_cancel');
  39. $this->data['button_add_module'] = $this->language->get('button_add_module');
  40. $this->data['button_remove'] = $this->language->get('button_remove');
  41. $this->data['entry_module_class'] = $this->language->get( 'entry_module_class' );
  42. $this->data['entry_module_title'] = $this->language->get( 'entry_module_title' );
  43. $this->data['tab_module'] = $this->language->get('tab_module');
  44. if (isset($this->error['warning'])) {
  45. $this->data['error_warning'] = $this->error['warning'];
  46. } else {
  47. $this->data['error_warning'] = '';
  48. }
  49. $this->load->model('setting/store');
  50. $store_default = array(
  51. 'store_id' => '0',
  52. 'name' => $this->config->get('config_name') . $this->language->get('text_default'),
  53. 'url' => HTTP_CATALOG,
  54. );
  55. $stores = $this->model_setting_store->getStores();
  56. array_unshift($stores, $store_default);
  57. $this->data['stores'] = $stores;
  58. $this->data['breadcrumbs'] = array();
  59. $this->data['breadcrumbs'][] = array(
  60. 'text' => $this->language->get('text_home'),
  61. 'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'),
  62. 'separator' => false
  63. );
  64. $this->data['breadcrumbs'][] = array(
  65. 'text' => $this->language->get('text_module'),
  66. 'href' => $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'),
  67. 'separator' => ' :: '
  68. );
  69. $this->data['breadcrumbs'][] = array(
  70. 'text' => $this->language->get('heading_title'),
  71. 'href' => $this->url->link('module/pavcustom', 'token=' . $this->session->data['token'], 'SSL'),
  72. 'separator' => ' :: '
  73. );
  74. $this->data['action'] = $this->url->link('module/pavcustom', 'token=' . $this->session->data['token'], 'SSL');
  75. $this->data['cancel'] = $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL');
  76. $this->data['token'] = $this->session->data['token'];
  77. $this->data['modules'] = array();
  78. $this->data['positions'] = array( 'mainmenu',
  79. 'slideshow',
  80. 'showcase',
  81. 'promotion',
  82. 'content_top',
  83. 'column_left',
  84. 'column_right',
  85. 'content_bottom',
  86. 'mass_bottom',
  87. 'footer_top',
  88. 'footer_center',
  89. 'footer_bottom'
  90. );
  91. if (isset($this->request->post['pavcustom_module'])) {
  92. $this->data['modules'] = $this->request->post['pavcustom_module'];
  93. } elseif ($this->config->get('pavcustom_module')) {
  94. $this->data['modules'] = $this->config->get('pavcustom_module');
  95. }
  96. $this->load->model('design/layout');
  97. $this->data['layouts'][] = array('layout_id'=>99999, 'name' => $this->language->get('all_page') );
  98. $this->data['layouts'] = array_merge($this->data['layouts'],$this->model_design_layout->getLayouts());
  99. $this->load->model('localisation/language');
  100. $this->data['languages'] = $this->model_localisation_language->getLanguages();
  101. $this->template = 'module/pavcustom.tpl';
  102. $this->children = array(
  103. 'common/header',
  104. 'common/footer'
  105. );
  106. $this->response->setOutput($this->render());
  107. }
  108. protected function validate() {
  109. if (!$this->user->hasPermission('modify', 'module/pavcustom')) {
  110. $this->error['warning'] = $this->language->get('error_permission');
  111. }
  112. if (!$this->error) {
  113. return true;
  114. } else {
  115. return false;
  116. }
  117. }
  118. }
  119. ?>