PageRenderTime 23ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/catalog/controller/module/category.php

https://gitlab.com/hazelnuts23/unitedfoodstuff
PHP | 196 lines | 171 code | 25 blank | 0 comment | 55 complexity | 38afab5817304dd8599e23d523b5d2e7 MD5 | raw file
  1. <?php
  2. class ControllerModuleCategory extends Controller
  3. {
  4. public function index()
  5. {
  6. $this->load->language('module/category');
  7. if (!isset($this->request->get['route'])) {
  8. $this->load->language('information/information');
  9. if (isset($this->request->get['information_id'])) {
  10. $information_id = (int)$this->request->get['information_id'];
  11. } else {
  12. $information_id = 0;
  13. }
  14. $information_info = $this->model_catalog_information->getInformation($information_id);
  15. if (isset($this->request->get['information_id'])) {
  16. $data['heading_title'] = $information_info['title'];
  17. } else {
  18. $data['heading_title'] = $this->language->get('heading_title');
  19. }
  20. if (isset($this->request->get['path'])) {
  21. $parts = explode('_', (string)$this->request->get['path']);
  22. } else {
  23. $parts = array();
  24. }
  25. $data['page'] = 'info';
  26. $info_array = $this->model_catalog_information->getInformationSelect();
  27. foreach ($info_array as $info_data) {
  28. $data['info_cat'][] = array(
  29. 'href' => $this->url->link('information/information', 'information_id=' . $info_data['info_id']),
  30. 'information_id' => $info_data['info_id'],
  31. 'name' => $info_data['info_title']);
  32. }
  33. if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/category.tpl')) {
  34. return $this->load->view($this->config->get('config_template') . '/template/module/category.tpl', $data);
  35. } else {
  36. return $this->load->view('unitedfoodstuff/template/module/category.tpl', $data);
  37. }
  38. } else {
  39. if (($this->request->get['route'] == 'information/information' || $this->request->get['route'] == 'common/home')) {
  40. $this->load->language('information/information');
  41. if (isset($this->request->get['information_id'])) {
  42. $information_id = (int)$this->request->get['information_id'];
  43. } else {
  44. $information_id = 0;
  45. }
  46. $information_info = $this->model_catalog_information->getInformation($information_id);
  47. if (isset($this->request->get['information_id'])) {
  48. $data['heading_title'] = $information_info['title'];
  49. } else {
  50. $data['heading_title'] = $this->language->get('heading_title');
  51. }
  52. if (isset($this->request->get['path'])) {
  53. $parts = explode('_', (string)$this->request->get['path']);
  54. } else {
  55. $parts = array();
  56. }
  57. $data['page'] = 'info';
  58. $info_array = $this->model_catalog_information->getInformationSelect();
  59. foreach ($info_array as $info_data) {
  60. $data['info_cat'][] = array(
  61. 'href' => $this->url->link('information/information', 'information_id=' . $info_data['info_id']),
  62. 'information_id' => $info_data['info_id'],
  63. 'name' => $info_data['info_title']);
  64. }
  65. if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/category.tpl')) {
  66. return $this->load->view($this->config->get('config_template') . '/template/module/category.tpl', $data);
  67. } else {
  68. return $this->load->view('unitedfoodstuff/template/module/category.tpl', $data);
  69. }
  70. } else if ($this->request->get['route'] == 'product/category' || $this->request->get['route'] == 'product/product') {
  71. $this->load->language('product/category');
  72. if (isset($this->request->get['path'])) {
  73. $path = (int)$this->request->get['path'];
  74. } else {
  75. $path = 0;
  76. }
  77. $data['heading_title'] = 'PRODUCTS';
  78. $data['path'] = $path;
  79. $data['name'] = 'All Products';
  80. $data['href'] = $this->url->link('product/category', 'path=' . $path);
  81. $data['page'] = 'products';
  82. if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/category.tpl')) {
  83. return $this->load->view($this->config->get('config_template') . '/template/module/category.tpl', $data);
  84. } else {
  85. return $this->load->view('default/template/module/category.tpl', $data);
  86. }
  87. } else if ($this->request->get['route'] == 'information/contact' || $this->request->get['route'] == 'information/enquiry') {
  88. $this->load->language('product/category');
  89. if (isset($this->request->get['path'])) {
  90. $path = (int)$this->request->get['path'];
  91. } else {
  92. $path = 0;
  93. }
  94. $data['heading_title'] = 'PRODUCTS';
  95. $data['path'] = $path;
  96. $data['text_contact'] = 'Contact Us';
  97. $data['href_contact'] = $this->url->link('information/contact');
  98. $data['text_enquiry'] = 'Enquiry';
  99. $data['href_enquiry'] = $this->url->link('information/enquiry');
  100. $data['page'] = 'contact';
  101. if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/category.tpl')) {
  102. return $this->load->view($this->config->get('config_template') . '/template/module/category.tpl', $data);
  103. } else {
  104. return $this->load->view('default/template/module/category.tpl', $data);
  105. }
  106. } else {
  107. $this->load->language('product/category');
  108. if (isset($this->request->get['path'])) {
  109. $path = (int)$this->request->get['path'];
  110. } else {
  111. $path = 0;
  112. }
  113. $product_info = $this->model_catalog_product->getProduct($path);
  114. if (isset($this->request->get['product_id'])) {
  115. $data['heading_title'] = $product_info['title'];
  116. } else {
  117. $data['heading_title'] = $this->language->get('heading_title');
  118. }
  119. if (isset($this->request->get['path'])) {
  120. $parts = explode('_', (string)$this->request->get['path']);
  121. } else {
  122. $parts = array();
  123. }
  124. if (isset($parts[0])) {
  125. $data['category_id'] = $parts[0];
  126. } else {
  127. $data['category_id'] = 0;
  128. }
  129. if (isset($parts[1])) {
  130. $data['child_id'] = $parts[1];
  131. } else {
  132. $data['child_id'] = 0;
  133. }
  134. $this->load->model('catalog/category');
  135. $this->load->model('catalog/product');
  136. $data['categories'] = array();
  137. $categories = $this->model_catalog_category->getCategories(0);
  138. foreach ($categories as $category) {
  139. $children_data = array();
  140. if ($category['category_id'] == $data['category_id']) {
  141. $children = $this->model_catalog_category->getCategories($category['category_id']);
  142. foreach ($children as $child) {
  143. $filter_data = array('filter_category_id' => $child['category_id'], 'filter_sub_category' => true);
  144. $children_data[] = array(
  145. 'category_id' => $child['category_id'],
  146. 'name' => $child['name'],
  147. 'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])
  148. );
  149. }
  150. }
  151. $filter_data = array(
  152. 'filter_category_id' => $category['category_id'],
  153. 'filter_sub_category' => true
  154. );
  155. $data['categories'][] = array(
  156. 'category_id' => $category['category_id'],
  157. 'name' => $category['name'],
  158. 'children' => $children_data,
  159. 'href' => $this->url->link('product/category', 'path=' . $category['category_id'])
  160. );
  161. }
  162. $data['page'] = 'others';
  163. if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/category.tpl')) {
  164. return $this->load->view($this->config->get('config_template') . '/template/module/category.tpl', $data);
  165. } else {
  166. return $this->load->view('default/template/module/category.tpl', $data);
  167. }
  168. }
  169. }
  170. }
  171. }