diff options
author | Jesús <heckyel@hyperbola.info> | 2019-08-18 21:14:58 -0500 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2019-08-18 21:14:58 -0500 |
commit | 2eed7b082f83630301e51f57ca8394de228a8605 (patch) | |
tree | 1d19962d22d30f99317d9276e4bae7744fc93fc2 /public/catalog/controller/common | |
download | librecart-2eed7b082f83630301e51f57ca8394de228a8605.tar.lz librecart-2eed7b082f83630301e51f57ca8394de228a8605.tar.xz librecart-2eed7b082f83630301e51f57ca8394de228a8605.zip |
first commit
Diffstat (limited to 'public/catalog/controller/common')
-rw-r--r-- | public/catalog/controller/common/cart.php | 142 | ||||
-rw-r--r-- | public/catalog/controller/common/column_left.php | 74 | ||||
-rw-r--r-- | public/catalog/controller/common/column_right.php | 74 | ||||
-rw-r--r-- | public/catalog/controller/common/content_bottom.php | 74 | ||||
-rw-r--r-- | public/catalog/controller/common/content_top.php | 74 | ||||
-rw-r--r-- | public/catalog/controller/common/currency.php | 64 | ||||
-rw-r--r-- | public/catalog/controller/common/footer.php | 63 | ||||
-rw-r--r-- | public/catalog/controller/common/header.php | 82 | ||||
-rw-r--r-- | public/catalog/controller/common/home.php | 21 | ||||
-rw-r--r-- | public/catalog/controller/common/language.php | 59 | ||||
-rw-r--r-- | public/catalog/controller/common/maintenance.php | 30 | ||||
-rw-r--r-- | public/catalog/controller/common/menu.php | 46 | ||||
-rw-r--r-- | public/catalog/controller/common/search.php | 16 |
13 files changed, 819 insertions, 0 deletions
diff --git a/public/catalog/controller/common/cart.php b/public/catalog/controller/common/cart.php new file mode 100644 index 0000000..ebe9e5e --- /dev/null +++ b/public/catalog/controller/common/cart.php @@ -0,0 +1,142 @@ +<?php +class ControllerCommonCart extends Controller { + public function index() { + $this->load->language('common/cart'); + + // Totals + $this->load->model('setting/extension'); + + $totals = array(); + $taxes = $this->cart->getTaxes(); + $total = 0; + + // Because __call can not keep var references so we put them into an array. + $total_data = array( + 'totals' => &$totals, + 'taxes' => &$taxes, + 'total' => &$total + ); + + // Display prices + if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { + $sort_order = array(); + + $results = $this->model_setting_extension->getExtensions('total'); + + foreach ($results as $key => $value) { + $sort_order[$key] = $this->config->get('total_' . $value['code'] . '_sort_order'); + } + + array_multisort($sort_order, SORT_ASC, $results); + + foreach ($results as $result) { + if ($this->config->get('total_' . $result['code'] . '_status')) { + $this->load->model('extension/total/' . $result['code']); + + // We have to put the totals in an array so that they pass by reference. + $this->{'model_extension_total_' . $result['code']}->getTotal($total_data); + } + } + + $sort_order = array(); + + foreach ($totals as $key => $value) { + $sort_order[$key] = $value['sort_order']; + } + + array_multisort($sort_order, SORT_ASC, $totals); + } + + $data['text_items'] = sprintf($this->language->get('text_items'), $this->cart->countProducts() + (isset($this->session->data['vouchers']) ? count($this->session->data['vouchers']) : 0), $this->currency->format($total, $this->session->data['currency'])); + + $this->load->model('tool/image'); + $this->load->model('tool/upload'); + + $data['products'] = array(); + + foreach ($this->cart->getProducts() as $product) { + if ($product['image']) { + $image = $this->model_tool_image->resize($product['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_cart_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_cart_height')); + } else { + $image = ''; + } + + $option_data = array(); + + foreach ($product['option'] as $option) { + if ($option['type'] != 'file') { + $value = $option['value']; + } else { + $upload_info = $this->model_tool_upload->getUploadByCode($option['value']); + + if ($upload_info) { + $value = $upload_info['name']; + } else { + $value = ''; + } + } + + $option_data[] = array( + 'name' => $option['name'], + 'value' => (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value), + 'type' => $option['type'] + ); + } + + // Display prices + if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) { + $unit_price = $this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')); + + $price = $this->currency->format($unit_price, $this->session->data['currency']); + $total = $this->currency->format($unit_price * $product['quantity'], $this->session->data['currency']); + } else { + $price = false; + $total = false; + } + + $data['products'][] = array( + 'cart_id' => $product['cart_id'], + 'thumb' => $image, + 'name' => $product['name'], + 'model' => $product['model'], + 'option' => $option_data, + 'recurring' => ($product['recurring'] ? $product['recurring']['name'] : ''), + 'quantity' => $product['quantity'], + 'price' => $price, + 'total' => $total, + 'href' => $this->url->link('product/product', 'product_id=' . $product['product_id']) + ); + } + + // Gift Voucher + $data['vouchers'] = array(); + + if (!empty($this->session->data['vouchers'])) { + foreach ($this->session->data['vouchers'] as $key => $voucher) { + $data['vouchers'][] = array( + 'key' => $key, + 'description' => $voucher['description'], + 'amount' => $this->currency->format($voucher['amount'], $this->session->data['currency']) + ); + } + } + + $data['totals'] = array(); + + foreach ($totals as $total) { + $data['totals'][] = array( + 'title' => $total['title'], + 'text' => $this->currency->format($total['value'], $this->session->data['currency']), + ); + } + + $data['cart'] = $this->url->link('checkout/cart'); + $data['checkout'] = $this->url->link('checkout/checkout', '', true); + + return $this->load->view('common/cart', $data); + } + + public function info() { + $this->response->setOutput($this->index()); + } +}
\ No newline at end of file diff --git a/public/catalog/controller/common/column_left.php b/public/catalog/controller/common/column_left.php new file mode 100644 index 0000000..9889172 --- /dev/null +++ b/public/catalog/controller/common/column_left.php @@ -0,0 +1,74 @@ +<?php +class ControllerCommonColumnLeft extends Controller { + public function index() { + $this->load->model('design/layout'); + + if (isset($this->request->get['route'])) { + $route = (string)$this->request->get['route']; + } else { + $route = 'common/home'; + } + + $layout_id = 0; + + if ($route == 'product/category' && isset($this->request->get['path'])) { + $this->load->model('catalog/category'); + + $path = explode('_', (string)$this->request->get['path']); + + $layout_id = $this->model_catalog_category->getCategoryLayoutId(end($path)); + } + + if ($route == 'product/product' && isset($this->request->get['product_id'])) { + $this->load->model('catalog/product'); + + $layout_id = $this->model_catalog_product->getProductLayoutId($this->request->get['product_id']); + } + + if ($route == 'information/information' && isset($this->request->get['information_id'])) { + $this->load->model('catalog/information'); + + $layout_id = $this->model_catalog_information->getInformationLayoutId($this->request->get['information_id']); + } + + if (!$layout_id) { + $layout_id = $this->model_design_layout->getLayout($route); + } + + if (!$layout_id) { + $layout_id = $this->config->get('config_layout_id'); + } + + $this->load->model('setting/module'); + + $data['modules'] = array(); + + $modules = $this->model_design_layout->getLayoutModules($layout_id, 'column_left'); + + foreach ($modules as $module) { + $part = explode('.', $module['code']); + + if (isset($part[0]) && $this->config->get('module_' . $part[0] . '_status')) { + $module_data = $this->load->controller('extension/module/' . $part[0]); + + if ($module_data) { + $data['modules'][] = $module_data; + } + } + + if (isset($part[1])) { + $setting_info = $this->model_setting_module->getModule($part[1]); + + if ($setting_info && $setting_info['status']) { + $output = $this->load->controller('extension/module/' . $part[0], $setting_info); + + if ($output) { + $data['modules'][] = $output; + } + } + } + } + + return $this->load->view('common/column_left', $data); + } +} diff --git a/public/catalog/controller/common/column_right.php b/public/catalog/controller/common/column_right.php new file mode 100644 index 0000000..1d91a33 --- /dev/null +++ b/public/catalog/controller/common/column_right.php @@ -0,0 +1,74 @@ +<?php +class ControllerCommonColumnRight extends Controller { + public function index() { + $this->load->model('design/layout'); + + if (isset($this->request->get['route'])) { + $route = (string)$this->request->get['route']; + } else { + $route = 'common/home'; + } + + $layout_id = 0; + + if ($route == 'product/category' && isset($this->request->get['path'])) { + $this->load->model('catalog/category'); + + $path = explode('_', (string)$this->request->get['path']); + + $layout_id = $this->model_catalog_category->getCategoryLayoutId(end($path)); + } + + if ($route == 'product/product' && isset($this->request->get['product_id'])) { + $this->load->model('catalog/product'); + + $layout_id = $this->model_catalog_product->getProductLayoutId($this->request->get['product_id']); + } + + if ($route == 'information/information' && isset($this->request->get['information_id'])) { + $this->load->model('catalog/information'); + + $layout_id = $this->model_catalog_information->getInformationLayoutId($this->request->get['information_id']); + } + + if (!$layout_id) { + $layout_id = $this->model_design_layout->getLayout($route); + } + + if (!$layout_id) { + $layout_id = $this->config->get('config_layout_id'); + } + + $this->load->model('setting/module'); + + $data['modules'] = array(); + + $modules = $this->model_design_layout->getLayoutModules($layout_id, 'column_right'); + + foreach ($modules as $module) { + $part = explode('.', $module['code']); + + if (isset($part[0]) && $this->config->get('module_' . $part[0] . '_status')) { + $module_data = $this->load->controller('extension/module/' . $part[0]); + + if ($module_data) { + $data['modules'][] = $module_data; + } + } + + if (isset($part[1])) { + $setting_info = $this->model_setting_module->getModule($part[1]); + + if ($setting_info && $setting_info['status']) { + $output = $this->load->controller('extension/module/' . $part[0], $setting_info); + + if ($output) { + $data['modules'][] = $output; + } + } + } + } + + return $this->load->view('common/column_right', $data); + } +} diff --git a/public/catalog/controller/common/content_bottom.php b/public/catalog/controller/common/content_bottom.php new file mode 100644 index 0000000..6c84732 --- /dev/null +++ b/public/catalog/controller/common/content_bottom.php @@ -0,0 +1,74 @@ +<?php +class ControllerCommonContentBottom extends Controller { + public function index() { + $this->load->model('design/layout'); + + if (isset($this->request->get['route'])) { + $route = (string)$this->request->get['route']; + } else { + $route = 'common/home'; + } + + $layout_id = 0; + + if ($route == 'product/category' && isset($this->request->get['path'])) { + $this->load->model('catalog/category'); + + $path = explode('_', (string)$this->request->get['path']); + + $layout_id = $this->model_catalog_category->getCategoryLayoutId(end($path)); + } + + if ($route == 'product/product' && isset($this->request->get['product_id'])) { + $this->load->model('catalog/product'); + + $layout_id = $this->model_catalog_product->getProductLayoutId($this->request->get['product_id']); + } + + if ($route == 'information/information' && isset($this->request->get['information_id'])) { + $this->load->model('catalog/information'); + + $layout_id = $this->model_catalog_information->getInformationLayoutId($this->request->get['information_id']); + } + + if (!$layout_id) { + $layout_id = $this->model_design_layout->getLayout($route); + } + + if (!$layout_id) { + $layout_id = $this->config->get('config_layout_id'); + } + + $this->load->model('setting/module'); + + $data['modules'] = array(); + + $modules = $this->model_design_layout->getLayoutModules($layout_id, 'content_bottom'); + + foreach ($modules as $module) { + $part = explode('.', $module['code']); + + if (isset($part[0]) && $this->config->get('module_' . $part[0] . '_status')) { + $module_data = $this->load->controller('extension/module/' . $part[0]); + + if ($module_data) { + $data['modules'][] = $module_data; + } + } + + if (isset($part[1])) { + $setting_info = $this->model_setting_module->getModule($part[1]); + + if ($setting_info && $setting_info['status']) { + $output = $this->load->controller('extension/module/' . $part[0], $setting_info); + + if ($output) { + $data['modules'][] = $output; + } + } + } + } + + return $this->load->view('common/content_bottom', $data); + } +} diff --git a/public/catalog/controller/common/content_top.php b/public/catalog/controller/common/content_top.php new file mode 100644 index 0000000..aab7957 --- /dev/null +++ b/public/catalog/controller/common/content_top.php @@ -0,0 +1,74 @@ +<?php +class ControllerCommonContentTop extends Controller { + public function index() { + $this->load->model('design/layout'); + + if (isset($this->request->get['route'])) { + $route = (string)$this->request->get['route']; + } else { + $route = 'common/home'; + } + + $layout_id = 0; + + if ($route == 'product/category' && isset($this->request->get['path'])) { + $this->load->model('catalog/category'); + + $path = explode('_', (string)$this->request->get['path']); + + $layout_id = $this->model_catalog_category->getCategoryLayoutId(end($path)); + } + + if ($route == 'product/product' && isset($this->request->get['product_id'])) { + $this->load->model('catalog/product'); + + $layout_id = $this->model_catalog_product->getProductLayoutId($this->request->get['product_id']); + } + + if ($route == 'information/information' && isset($this->request->get['information_id'])) { + $this->load->model('catalog/information'); + + $layout_id = $this->model_catalog_information->getInformationLayoutId($this->request->get['information_id']); + } + + if (!$layout_id) { + $layout_id = $this->model_design_layout->getLayout($route); + } + + if (!$layout_id) { + $layout_id = $this->config->get('config_layout_id'); + } + + $this->load->model('setting/module'); + + $data['modules'] = array(); + + $modules = $this->model_design_layout->getLayoutModules($layout_id, 'content_top'); + + foreach ($modules as $module) { + $part = explode('.', $module['code']); + + if (isset($part[0]) && $this->config->get('module_' . $part[0] . '_status')) { + $module_data = $this->load->controller('extension/module/' . $part[0]); + + if ($module_data) { + $data['modules'][] = $module_data; + } + } + + if (isset($part[1])) { + $setting_info = $this->model_setting_module->getModule($part[1]); + + if ($setting_info && $setting_info['status']) { + $output = $this->load->controller('extension/module/' . $part[0], $setting_info); + + if ($output) { + $data['modules'][] = $output; + } + } + } + } + + return $this->load->view('common/content_top', $data); + } +} diff --git a/public/catalog/controller/common/currency.php b/public/catalog/controller/common/currency.php new file mode 100644 index 0000000..441669d --- /dev/null +++ b/public/catalog/controller/common/currency.php @@ -0,0 +1,64 @@ +<?php +class ControllerCommonCurrency extends Controller { + public function index() { + $this->load->language('common/currency'); + + $data['action'] = $this->url->link('common/currency/currency', '', $this->request->server['HTTPS']); + + $data['code'] = $this->session->data['currency']; + + $this->load->model('localisation/currency'); + + $data['currencies'] = array(); + + $results = $this->model_localisation_currency->getCurrencies(); + + foreach ($results as $result) { + if ($result['status']) { + $data['currencies'][] = array( + 'title' => $result['title'], + 'code' => $result['code'], + 'symbol_left' => $result['symbol_left'], + 'symbol_right' => $result['symbol_right'] + ); + } + } + + if (!isset($this->request->get['route'])) { + $data['redirect'] = $this->url->link('common/home'); + } else { + $url_data = $this->request->get; + + unset($url_data['_route_']); + + $route = $url_data['route']; + + unset($url_data['route']); + + $url = ''; + + if ($url_data) { + $url = '&' . urldecode(http_build_query($url_data, '', '&')); + } + + $data['redirect'] = $this->url->link($route, $url, $this->request->server['HTTPS']); + } + + return $this->load->view('common/currency', $data); + } + + public function currency() { + if (isset($this->request->post['code'])) { + $this->session->data['currency'] = $this->request->post['code']; + + unset($this->session->data['shipping_method']); + unset($this->session->data['shipping_methods']); + } + + if (isset($this->request->post['redirect'])) { + $this->response->redirect($this->request->post['redirect']); + } else { + $this->response->redirect($this->url->link('common/home')); + } + } +}
\ No newline at end of file diff --git a/public/catalog/controller/common/footer.php b/public/catalog/controller/common/footer.php new file mode 100644 index 0000000..6820e9a --- /dev/null +++ b/public/catalog/controller/common/footer.php @@ -0,0 +1,63 @@ +<?php +class ControllerCommonFooter extends Controller { + public function index() { + $this->load->language('common/footer'); + + $this->load->model('catalog/information'); + + $data['informations'] = array(); + + foreach ($this->model_catalog_information->getInformations() as $result) { + if ($result['bottom']) { + $data['informations'][] = array( + 'title' => $result['title'], + 'href' => $this->url->link('information/information', 'information_id=' . $result['information_id']) + ); + } + } + + $data['contact'] = $this->url->link('information/contact'); + $data['return'] = $this->url->link('account/return/add', '', true); + $data['sitemap'] = $this->url->link('information/sitemap'); + $data['tracking'] = $this->url->link('information/tracking'); + $data['manufacturer'] = $this->url->link('product/manufacturer'); + $data['voucher'] = $this->url->link('account/voucher', '', true); + $data['affiliate'] = $this->url->link('affiliate/login', '', true); + $data['special'] = $this->url->link('product/special'); + $data['account'] = $this->url->link('account/account', '', true); + $data['order'] = $this->url->link('account/order', '', true); + $data['wishlist'] = $this->url->link('account/wishlist', '', true); + $data['newsletter'] = $this->url->link('account/newsletter', '', true); + + $data['powered'] = sprintf($this->language->get('text_powered'), $this->config->get('config_name'), date('Y', time())); + + // Whos Online + if ($this->config->get('config_customer_online')) { + $this->load->model('tool/online'); + + if (isset($this->request->server['REMOTE_ADDR'])) { + $ip = $this->request->server['REMOTE_ADDR']; + } else { + $ip = ''; + } + + if (isset($this->request->server['HTTP_HOST']) && isset($this->request->server['REQUEST_URI'])) { + $url = ($this->request->server['HTTPS'] ? 'https://' : 'http://') . $this->request->server['HTTP_HOST'] . $this->request->server['REQUEST_URI']; + } else { + $url = ''; + } + + if (isset($this->request->server['HTTP_REFERER'])) { + $referer = $this->request->server['HTTP_REFERER']; + } else { + $referer = ''; + } + + $this->model_tool_online->addOnline($ip, $this->customer->getId(), $url, $referer); + } + + $data['scripts'] = $this->document->getScripts('footer'); + + return $this->load->view('common/footer', $data); + } +} diff --git a/public/catalog/controller/common/header.php b/public/catalog/controller/common/header.php new file mode 100644 index 0000000..ba6546d --- /dev/null +++ b/public/catalog/controller/common/header.php @@ -0,0 +1,82 @@ +<?php +class ControllerCommonHeader extends Controller { + public function index() { + // Analytics + $this->load->model('setting/extension'); + + $data['analytics'] = array(); + + $analytics = $this->model_setting_extension->getExtensions('analytics'); + + foreach ($analytics as $analytic) { + if ($this->config->get('analytics_' . $analytic['code'] . '_status')) { + $data['analytics'][] = $this->load->controller('extension/analytics/' . $analytic['code'], $this->config->get('analytics_' . $analytic['code'] . '_status')); + } + } + + if ($this->request->server['HTTPS']) { + $server = $this->config->get('config_ssl'); + } else { + $server = $this->config->get('config_url'); + } + + if (is_file(DIR_IMAGE . $this->config->get('config_icon'))) { + $this->document->addLink($server . 'image/' . $this->config->get('config_icon'), 'icon'); + } + + $data['title'] = $this->document->getTitle(); + + $data['base'] = $server; + $data['description'] = $this->document->getDescription(); + $data['keywords'] = $this->document->getKeywords(); + $data['links'] = $this->document->getLinks(); + $data['styles'] = $this->document->getStyles(); + $data['scripts'] = $this->document->getScripts('header'); + $data['lang'] = $this->language->get('code'); + $data['direction'] = $this->language->get('direction'); + + $data['name'] = $this->config->get('config_name'); + + if (is_file(DIR_IMAGE . $this->config->get('config_logo'))) { + $data['logo'] = $server . 'image/' . $this->config->get('config_logo'); + } else { + $data['logo'] = ''; + } + + $this->load->language('common/header'); + + // Wishlist + if ($this->customer->isLogged()) { + $this->load->model('account/wishlist'); + + $data['text_wishlist'] = sprintf($this->language->get('text_wishlist'), $this->model_account_wishlist->getTotalWishlist()); + } else { + $data['text_wishlist'] = sprintf($this->language->get('text_wishlist'), (isset($this->session->data['wishlist']) ? count($this->session->data['wishlist']) : 0)); + } + + $data['text_logged'] = sprintf($this->language->get('text_logged'), $this->url->link('account/account', '', true), $this->customer->getFirstName(), $this->url->link('account/logout', '', true)); + + $data['home'] = $this->url->link('common/home'); + $data['wishlist'] = $this->url->link('account/wishlist', '', true); + $data['logged'] = $this->customer->isLogged(); + $data['account'] = $this->url->link('account/account', '', true); + $data['register'] = $this->url->link('account/register', '', true); + $data['login'] = $this->url->link('account/login', '', true); + $data['order'] = $this->url->link('account/order', '', true); + $data['transaction'] = $this->url->link('account/transaction', '', true); + $data['download'] = $this->url->link('account/download', '', true); + $data['logout'] = $this->url->link('account/logout', '', true); + $data['shopping_cart'] = $this->url->link('checkout/cart'); + $data['checkout'] = $this->url->link('checkout/checkout', '', true); + $data['contact'] = $this->url->link('information/contact'); + $data['telephone'] = $this->config->get('config_telephone'); + + $data['language'] = $this->load->controller('common/language'); + $data['currency'] = $this->load->controller('common/currency'); + $data['search'] = $this->load->controller('common/search'); + $data['cart'] = $this->load->controller('common/cart'); + $data['menu'] = $this->load->controller('common/menu'); + + return $this->load->view('common/header', $data); + } +} diff --git a/public/catalog/controller/common/home.php b/public/catalog/controller/common/home.php new file mode 100644 index 0000000..259156b --- /dev/null +++ b/public/catalog/controller/common/home.php @@ -0,0 +1,21 @@ +<?php +class ControllerCommonHome extends Controller { + public function index() { + $this->document->setTitle($this->config->get('config_meta_title')); + $this->document->setDescription($this->config->get('config_meta_description')); + $this->document->setKeywords($this->config->get('config_meta_keyword')); + + if (isset($this->request->get['route'])) { + $this->document->addLink($this->config->get('config_url'), 'canonical'); + } + + $data['column_left'] = $this->load->controller('common/column_left'); + $data['column_right'] = $this->load->controller('common/column_right'); + $data['content_top'] = $this->load->controller('common/content_top'); + $data['content_bottom'] = $this->load->controller('common/content_bottom'); + $data['footer'] = $this->load->controller('common/footer'); + $data['header'] = $this->load->controller('common/header'); + + $this->response->setOutput($this->load->view('common/home', $data)); + } +} diff --git a/public/catalog/controller/common/language.php b/public/catalog/controller/common/language.php new file mode 100644 index 0000000..d48cb0f --- /dev/null +++ b/public/catalog/controller/common/language.php @@ -0,0 +1,59 @@ +<?php +class ControllerCommonLanguage extends Controller { + public function index() { + $this->load->language('common/language'); + + $data['action'] = $this->url->link('common/language/language', '', $this->request->server['HTTPS']); + + $data['code'] = $this->session->data['language']; + + $this->load->model('localisation/language'); + + $data['languages'] = array(); + + $results = $this->model_localisation_language->getLanguages(); + + foreach ($results as $result) { + if ($result['status']) { + $data['languages'][] = array( + 'name' => $result['name'], + 'code' => $result['code'] + ); + } + } + + if (!isset($this->request->get['route'])) { + $data['redirect'] = $this->url->link('common/home'); + } else { + $url_data = $this->request->get; + + unset($url_data['_route_']); + + $route = $url_data['route']; + + unset($url_data['route']); + + $url = ''; + + if ($url_data) { + $url = '&' . urldecode(http_build_query($url_data, '', '&')); + } + + $data['redirect'] = $this->url->link($route, $url, $this->request->server['HTTPS']); + } + + return $this->load->view('common/language', $data); + } + + public function language() { + if (isset($this->request->post['code'])) { + $this->session->data['language'] = $this->request->post['code']; + } + + if (isset($this->request->post['redirect'])) { + $this->response->redirect($this->request->post['redirect']); + } else { + $this->response->redirect($this->url->link('common/home')); + } + } +}
\ No newline at end of file diff --git a/public/catalog/controller/common/maintenance.php b/public/catalog/controller/common/maintenance.php new file mode 100644 index 0000000..f2533e7 --- /dev/null +++ b/public/catalog/controller/common/maintenance.php @@ -0,0 +1,30 @@ +<?php +class ControllerCommonMaintenance extends Controller { + public function index() { + $this->load->language('common/maintenance'); + + $this->document->setTitle($this->language->get('heading_title')); + + if ($this->request->server['SERVER_PROTOCOL'] == 'HTTP/1.1') { + $this->response->addHeader('HTTP/1.1 503 Service Unavailable'); + } else { + $this->response->addHeader('HTTP/1.0 503 Service Unavailable'); + } + + $this->response->addHeader('Retry-After: 3600'); + + $data['breadcrumbs'] = array(); + + $data['breadcrumbs'][] = array( + 'text' => $this->language->get('text_maintenance'), + 'href' => $this->url->link('common/maintenance') + ); + + $data['message'] = $this->language->get('text_message'); + + $data['header'] = $this->load->controller('common/header'); + $data['footer'] = $this->load->controller('common/footer'); + + $this->response->setOutput($this->load->view('common/maintenance', $data)); + } +} diff --git a/public/catalog/controller/common/menu.php b/public/catalog/controller/common/menu.php new file mode 100644 index 0000000..de11f9e --- /dev/null +++ b/public/catalog/controller/common/menu.php @@ -0,0 +1,46 @@ +<?php +class ControllerCommonMenu extends Controller { + public function index() { + $this->load->language('common/menu'); + + // Menu + $this->load->model('catalog/category'); + + $this->load->model('catalog/product'); + + $data['categories'] = array(); + + $categories = $this->model_catalog_category->getCategories(0); + + foreach ($categories as $category) { + if ($category['top']) { + // Level 2 + $children_data = array(); + + $children = $this->model_catalog_category->getCategories($category['category_id']); + + foreach ($children as $child) { + $filter_data = array( + 'filter_category_id' => $child['category_id'], + 'filter_sub_category' => true + ); + + $children_data[] = array( + 'name' => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''), + 'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']) + ); + } + + // Level 1 + $data['categories'][] = array( + 'name' => $category['name'], + 'children' => $children_data, + 'column' => $category['column'] ? $category['column'] : 1, + 'href' => $this->url->link('product/category', 'path=' . $category['category_id']) + ); + } + } + + return $this->load->view('common/menu', $data); + } +} diff --git a/public/catalog/controller/common/search.php b/public/catalog/controller/common/search.php new file mode 100644 index 0000000..930a726 --- /dev/null +++ b/public/catalog/controller/common/search.php @@ -0,0 +1,16 @@ +<?php +class ControllerCommonSearch extends Controller { + public function index() { + $this->load->language('common/search'); + + $data['text_search'] = $this->language->get('text_search'); + + if (isset($this->request->get['search'])) { + $data['search'] = $this->request->get['search']; + } else { + $data['search'] = ''; + } + + return $this->load->view('common/search', $data); + } +}
\ No newline at end of file |