first commit
This commit is contained in:
198
catalog/controller/common/cart.php
Normal file
198
catalog/controller/common/cart.php
Normal file
@ -0,0 +1,198 @@
|
||||
<?php
|
||||
namespace Opencart\Catalog\Controller\Common;
|
||||
/**
|
||||
* Class Cart
|
||||
*
|
||||
* @package Opencart\Catalog\Controller\Common
|
||||
*/
|
||||
class Cart extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function index(): string {
|
||||
$this->load->language('common/cart');
|
||||
|
||||
$totals = [];
|
||||
$taxes = $this->cart->getTaxes();
|
||||
$total = 0;
|
||||
|
||||
$this->load->model('checkout/cart');
|
||||
|
||||
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
|
||||
($this->model_checkout_cart->getTotals)($totals, $taxes, $total);
|
||||
}
|
||||
|
||||
$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']));
|
||||
|
||||
// Products
|
||||
$data['products'] = [];
|
||||
|
||||
$products = $this->model_checkout_cart->getProducts();
|
||||
|
||||
foreach ($products as $product) {
|
||||
if ($product['option']) {
|
||||
foreach ($product['option'] as $key => $option) {
|
||||
$product['option'][$key]['value'] = (oc_strlen($option['value']) > 20 ? oc_substr($option['value'], 0, 20) . '..' : $option['value']);
|
||||
}
|
||||
}
|
||||
|
||||
// Display prices
|
||||
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
|
||||
$unit_price = (float)$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;
|
||||
}
|
||||
|
||||
$description = '';
|
||||
|
||||
if ($product['subscription']) {
|
||||
if ($product['subscription']['trial_status']) {
|
||||
$trial_price = $this->currency->format($this->tax->calculate($product['subscription']['trial_price'], $product['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
|
||||
$trial_cycle = $product['subscription']['trial_cycle'];
|
||||
$trial_frequency = $this->language->get('text_' . $product['subscription']['trial_frequency']);
|
||||
$trial_duration = $product['subscription']['trial_duration'];
|
||||
|
||||
$description .= sprintf($this->language->get('text_subscription_trial'), $trial_price, $trial_cycle, $trial_frequency, $trial_duration);
|
||||
}
|
||||
|
||||
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
|
||||
$price = $this->currency->format($this->tax->calculate($product['subscription']['price'], $product['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
|
||||
}
|
||||
|
||||
$cycle = $product['subscription']['cycle'];
|
||||
$frequency = $this->language->get('text_' . $product['subscription']['frequency']);
|
||||
$duration = $product['subscription']['duration'];
|
||||
|
||||
if ($duration) {
|
||||
$description .= sprintf($this->language->get('text_subscription_duration'), $price, $cycle, $frequency, $duration);
|
||||
} else {
|
||||
$description .= sprintf($this->language->get('text_subscription_cancel'), $price, $cycle, $frequency);
|
||||
}
|
||||
}
|
||||
|
||||
$data['products'][] = [
|
||||
'cart_id' => $product['cart_id'],
|
||||
'thumb' => $product['image'],
|
||||
'name' => $product['name'],
|
||||
'model' => $product['model'],
|
||||
'option' => $product['option'],
|
||||
'subscription' => $description,
|
||||
'quantity' => $product['quantity'],
|
||||
'price' => $price,
|
||||
'total' => $total,
|
||||
'reward' => $product['reward'],
|
||||
'href' => $this->url->link('product/product', 'language=' . $this->config->get('config_language') . '&product_id=' . $product['product_id'])
|
||||
];
|
||||
}
|
||||
|
||||
// Gift Voucher
|
||||
$data['vouchers'] = [];
|
||||
|
||||
$vouchers = $this->model_checkout_cart->getVouchers();
|
||||
|
||||
foreach ($vouchers as $key => $voucher) {
|
||||
$data['vouchers'][] = [
|
||||
'key' => $key,
|
||||
'description' => $voucher['description'],
|
||||
'amount' => $this->currency->format($voucher['amount'], $this->session->data['currency'])
|
||||
];
|
||||
}
|
||||
|
||||
// Totals
|
||||
$data['totals'] = [];
|
||||
|
||||
foreach ($totals as $total) {
|
||||
$data['totals'][] = [
|
||||
'title' => $total['title'],
|
||||
'text' => $this->currency->format($total['value'], $this->session->data['currency'])
|
||||
];
|
||||
}
|
||||
|
||||
$data['list'] = $this->url->link('common/cart.info', 'language=' . $this->config->get('config_language'));
|
||||
$data['product_remove'] = $this->url->link('common/cart.removeProduct', 'language=' . $this->config->get('config_language'));
|
||||
$data['voucher_remove'] = $this->url->link('common/cart.removeVoucher', 'language=' . $this->config->get('config_language'));
|
||||
|
||||
$data['cart'] = $this->url->link('checkout/cart', 'language=' . $this->config->get('config_language'));
|
||||
$data['checkout'] = $this->url->link('checkout/checkout', 'language=' . $this->config->get('config_language'));
|
||||
|
||||
return $this->load->view('common/cart', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function info(): void {
|
||||
$this->response->setOutput($this->index());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function removeProduct(): void {
|
||||
$this->load->language('checkout/cart');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (isset($this->request->post['key'])) {
|
||||
$key = (int)$this->request->post['key'];
|
||||
} else {
|
||||
$key = 0;
|
||||
}
|
||||
|
||||
if (!$this->cart->has($key)) {
|
||||
$json['error'] = $this->language->get('error_product');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->cart->remove($key);
|
||||
|
||||
$json['success'] = $this->language->get('text_remove');
|
||||
|
||||
unset($this->session->data['shipping_method']);
|
||||
unset($this->session->data['shipping_methods']);
|
||||
unset($this->session->data['payment_method']);
|
||||
unset($this->session->data['payment_methods']);
|
||||
unset($this->session->data['reward']);
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function removeVoucher(): void {
|
||||
$this->load->language('checkout/cart');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (isset($this->request->get['key'])) {
|
||||
$key = $this->request->get['key'];
|
||||
} else {
|
||||
$key = '';
|
||||
}
|
||||
|
||||
if (!isset($this->session->data['vouchers'][$key])) {
|
||||
$json['error'] = $this->language->get('error_voucher');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$json['success'] = $this->language->get('text_remove');
|
||||
|
||||
unset($this->session->data['vouchers'][$key]);
|
||||
unset($this->session->data['shipping_method']);
|
||||
unset($this->session->data['shipping_methods']);
|
||||
unset($this->session->data['payment_method']);
|
||||
unset($this->session->data['payment_methods']);
|
||||
unset($this->session->data['reward']);
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
95
catalog/controller/common/column_left.php
Normal file
95
catalog/controller/common/column_left.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
namespace Opencart\Catalog\Controller\Common;
|
||||
/**
|
||||
* Class Column Left
|
||||
*
|
||||
* @package Opencart\Catalog\Controller\Common
|
||||
*/
|
||||
class ColumnLeft extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function index(): string {
|
||||
$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->getLayoutId((int)end($path));
|
||||
}
|
||||
|
||||
if ($route == 'product/product' && isset($this->request->get['product_id'])) {
|
||||
$this->load->model('catalog/product');
|
||||
|
||||
$layout_id = $this->model_catalog_product->getLayoutId((int)$this->request->get['product_id']);
|
||||
}
|
||||
|
||||
if ($route == 'product/manufacturer.info' && isset($this->request->get['manufacturer_id'])) {
|
||||
$this->load->model('catalog/manufacturer');
|
||||
|
||||
$layout_id = $this->model_catalog_manufacturer->getLayoutId((int)$this->request->get['manufacturer_id']);
|
||||
}
|
||||
|
||||
if ($route == 'information/information' && isset($this->request->get['information_id'])) {
|
||||
$this->load->model('catalog/information');
|
||||
|
||||
$layout_id = $this->model_catalog_information->getLayoutId((int)$this->request->get['information_id']);
|
||||
}
|
||||
|
||||
if ($route == 'cms/blog.info' && isset($this->request->get['blog_id'])) {
|
||||
$this->load->model('cms/blog');
|
||||
|
||||
$layout_id = $this->model_cms_blog->getLayoutId((int)$this->request->get['blog_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'] = [];
|
||||
|
||||
$modules = $this->model_design_layout->getModules($layout_id, 'column_left');
|
||||
|
||||
foreach ($modules as $module) {
|
||||
$part = explode('.', $module['code']);
|
||||
|
||||
if (isset($part[1]) && $this->config->get('module_' . $part[1] . '_status')) {
|
||||
$module_data = $this->load->controller('extension/' . $part[0] . '/module/' . $part[1]);
|
||||
|
||||
if ($module_data) {
|
||||
$data['modules'][] = $module_data;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($part[2])) {
|
||||
$setting_info = $this->model_setting_module->getModule($part[2]);
|
||||
|
||||
if ($setting_info && $setting_info['status']) {
|
||||
$output = $this->load->controller('extension/' . $part[0] . '/module/' . $part[1], $setting_info);
|
||||
|
||||
if ($output) {
|
||||
$data['modules'][] = $output;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->load->view('common/column_left', $data);
|
||||
}
|
||||
}
|
95
catalog/controller/common/column_right.php
Normal file
95
catalog/controller/common/column_right.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
namespace Opencart\Catalog\Controller\Common;
|
||||
/**
|
||||
* Class Column Right
|
||||
*
|
||||
* @package Opencart\Catalog\Controller\Common
|
||||
*/
|
||||
class ColumnRight extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function index(): string {
|
||||
$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->getLayoutId((int)end($path));
|
||||
}
|
||||
|
||||
if ($route == 'product/product' && isset($this->request->get['product_id'])) {
|
||||
$this->load->model('catalog/product');
|
||||
|
||||
$layout_id = $this->model_catalog_product->getLayoutId((int)$this->request->get['product_id']);
|
||||
}
|
||||
|
||||
if ($route == 'product/manufacturer.info' && isset($this->request->get['manufacturer_id'])) {
|
||||
$this->load->model('catalog/manufacturer');
|
||||
|
||||
$layout_id = $this->model_catalog_manufacturer->getLayoutId((int)$this->request->get['manufacturer_id']);
|
||||
}
|
||||
|
||||
if ($route == 'information/information' && isset($this->request->get['information_id'])) {
|
||||
$this->load->model('catalog/information');
|
||||
|
||||
$layout_id = $this->model_catalog_information->getLayoutId((int)$this->request->get['information_id']);
|
||||
}
|
||||
|
||||
if ($route == 'cms/blog.info' && isset($this->request->get['blog_id'])) {
|
||||
$this->load->model('cms/blog');
|
||||
|
||||
$layout_id = $this->model_cms_blog->getLayoutId((int)$this->request->get['blog_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'] = [];
|
||||
|
||||
$modules = $this->model_design_layout->getModules($layout_id, 'column_right');
|
||||
|
||||
foreach ($modules as $module) {
|
||||
$part = explode('.', $module['code']);
|
||||
|
||||
if (isset($part[1]) && $this->config->get('module_' . $part[1] . '_status')) {
|
||||
$module_data = $this->load->controller('extension/' . $part[0] . '/module/' . $part[1]);
|
||||
|
||||
if ($module_data) {
|
||||
$data['modules'][] = $module_data;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($part[2])) {
|
||||
$setting_info = $this->model_setting_module->getModule($part[2]);
|
||||
|
||||
if ($setting_info && $setting_info['status']) {
|
||||
$output = $this->load->controller('extension/' . $part[0] . '/module/' . $part[1], $setting_info);
|
||||
|
||||
if ($output) {
|
||||
$data['modules'][] = $output;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->load->view('common/column_right', $data);
|
||||
}
|
||||
}
|
95
catalog/controller/common/content_bottom.php
Normal file
95
catalog/controller/common/content_bottom.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
namespace Opencart\Catalog\Controller\Common;
|
||||
/**
|
||||
* Class Content Bottom
|
||||
*
|
||||
* @package Opencart\Catalog\Controller\Common
|
||||
*/
|
||||
class ContentBottom extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function index(): string {
|
||||
$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->getLayoutId((int)end($path));
|
||||
}
|
||||
|
||||
if ($route == 'product/product' && isset($this->request->get['product_id'])) {
|
||||
$this->load->model('catalog/product');
|
||||
|
||||
$layout_id = $this->model_catalog_product->getLayoutId((int)$this->request->get['product_id']);
|
||||
}
|
||||
|
||||
if ($route == 'product/manufacturer.info' && isset($this->request->get['manufacturer_id'])) {
|
||||
$this->load->model('catalog/manufacturer');
|
||||
|
||||
$layout_id = $this->model_catalog_manufacturer->getLayoutId((int)$this->request->get['manufacturer_id']);
|
||||
}
|
||||
|
||||
if ($route == 'information/information' && isset($this->request->get['information_id'])) {
|
||||
$this->load->model('catalog/information');
|
||||
|
||||
$layout_id = $this->model_catalog_information->getLayoutId((int)$this->request->get['information_id']);
|
||||
}
|
||||
|
||||
if ($route == 'cms/blog.info' && isset($this->request->get['blog_id'])) {
|
||||
$this->load->model('cms/blog');
|
||||
|
||||
$layout_id = $this->model_cms_blog->getLayoutId((int)$this->request->get['blog_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'] = [];
|
||||
|
||||
$modules = $this->model_design_layout->getModules($layout_id, 'content_bottom');
|
||||
|
||||
foreach ($modules as $module) {
|
||||
$part = explode('.', $module['code']);
|
||||
|
||||
if (isset($part[1]) && $this->config->get('module_' . $part[1] . '_status')) {
|
||||
$module_data = $this->load->controller('extension/' . $part[0] . '/module/' . $part[1]);
|
||||
|
||||
if ($module_data) {
|
||||
$data['modules'][] = $module_data;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($part[2])) {
|
||||
$setting_info = $this->model_setting_module->getModule($part[2]);
|
||||
|
||||
if ($setting_info && $setting_info['status']) {
|
||||
$output = $this->load->controller('extension/' . $part[0] . '/module/' . $part[1], $setting_info);
|
||||
|
||||
if ($output) {
|
||||
$data['modules'][] = $output;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->load->view('common/content_bottom', $data);
|
||||
}
|
||||
}
|
95
catalog/controller/common/content_top.php
Normal file
95
catalog/controller/common/content_top.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
namespace Opencart\Catalog\Controller\Common;
|
||||
/**
|
||||
* Class Content Top
|
||||
*
|
||||
* @package Opencart\Catalog\Controller\Common
|
||||
*/
|
||||
class ContentTop extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function index(): string {
|
||||
$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->getLayoutId((int)end($path));
|
||||
}
|
||||
|
||||
if ($route == 'product/product' && isset($this->request->get['product_id'])) {
|
||||
$this->load->model('catalog/product');
|
||||
|
||||
$layout_id = $this->model_catalog_product->getLayoutId((int)$this->request->get['product_id']);
|
||||
}
|
||||
|
||||
if ($route == 'product/manufacturer.info' && isset($this->request->get['manufacturer_id'])) {
|
||||
$this->load->model('catalog/manufacturer');
|
||||
|
||||
$layout_id = $this->model_catalog_manufacturer->getLayoutId((int)$this->request->get['manufacturer_id']);
|
||||
}
|
||||
|
||||
if ($route == 'information/information' && isset($this->request->get['information_id'])) {
|
||||
$this->load->model('catalog/information');
|
||||
|
||||
$layout_id = $this->model_catalog_information->getLayoutId((int)$this->request->get['information_id']);
|
||||
}
|
||||
|
||||
if ($route == 'cms/blog.info' && isset($this->request->get['blog_id'])) {
|
||||
$this->load->model('cms/blog');
|
||||
|
||||
$layout_id = $this->model_cms_blog->getLayoutId((int)$this->request->get['blog_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'] = [];
|
||||
|
||||
$modules = $this->model_design_layout->getModules($layout_id, 'content_top');
|
||||
|
||||
foreach ($modules as $module) {
|
||||
$part = explode('.', $module['code']);
|
||||
|
||||
if (isset($part[1]) && $this->config->get('module_' . $part[1] . '_status')) {
|
||||
$module_data = $this->load->controller('extension/' . $part[0] . '/module/' . $part[1]);
|
||||
|
||||
if ($module_data) {
|
||||
$data['modules'][] = $module_data;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($part[2])) {
|
||||
$setting_info = $this->model_setting_module->getModule($part[2]);
|
||||
|
||||
if ($setting_info && $setting_info['status']) {
|
||||
$output = $this->load->controller('extension/' . $part[0] . '/module/' . $part[1], $setting_info);
|
||||
|
||||
if ($output) {
|
||||
$data['modules'][] = $output;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->load->view('common/content_top', $data);
|
||||
}
|
||||
}
|
62
catalog/controller/common/cookie.php
Normal file
62
catalog/controller/common/cookie.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
namespace Opencart\Catalog\Controller\Common;
|
||||
/**
|
||||
* Class Cookie
|
||||
*
|
||||
* @package Opencart\Catalog\Controller\Common
|
||||
*/
|
||||
class Cookie extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function index(): string {
|
||||
if ($this->config->get('config_cookie_id') && !isset($this->request->cookie['policy'])) {
|
||||
$this->load->model('catalog/information');
|
||||
|
||||
$information_info = $this->model_catalog_information->getInformation($this->config->get('config_cookie_id'));
|
||||
|
||||
if ($information_info) {
|
||||
$this->load->language('common/cookie');
|
||||
|
||||
$data['text_cookie'] = sprintf($this->language->get('text_cookie'), $this->url->link('information/information.info', 'language=' . $this->config->get('config_language') . '&information_id=' . $information_info['information_id']));
|
||||
|
||||
$data['agree'] = $this->url->link('common/cookie.confirm', 'language=' . $this->config->get('config_language') . '&agree=1');
|
||||
$data['disagree'] = $this->url->link('common/cookie.confirm', 'language=' . $this->config->get('config_language') . '&agree=0');
|
||||
|
||||
return $this->load->view('common/cookie', $data);
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function confirm(): void {
|
||||
$json = [];
|
||||
|
||||
if ($this->config->get('config_cookie_id') && !isset($this->request->cookie['policy'])) {
|
||||
$this->load->language('common/cookie');
|
||||
|
||||
if (isset($this->request->get['agree'])) {
|
||||
$agree = (int)$this->request->get['agree'];
|
||||
} else {
|
||||
$agree = 0;
|
||||
}
|
||||
|
||||
$option = [
|
||||
'expires' => time() + 60 * 60 * 24 * 365,
|
||||
'path' => $this->config->get('session_path'),
|
||||
'SameSite' => $this->config->get('config_session_samesite')
|
||||
];
|
||||
|
||||
setcookie('policy', $agree, $option);
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
83
catalog/controller/common/currency.php
Normal file
83
catalog/controller/common/currency.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
namespace Opencart\Catalog\Controller\Common;
|
||||
/**
|
||||
* Class Currency
|
||||
*
|
||||
* @package Opencart\Catalog\Controller\Common
|
||||
*/
|
||||
class Currency extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function index(): string {
|
||||
$this->load->language('common/currency');
|
||||
|
||||
$data['action'] = $this->url->link('common/currency.save', 'language=' . $this->config->get('config_language'));
|
||||
|
||||
$data['code'] = $this->session->data['currency'];
|
||||
|
||||
$url_data = $this->request->get;
|
||||
|
||||
if (isset($url_data['route'])) {
|
||||
$route = $url_data['route'];
|
||||
} else {
|
||||
$route = $this->config->get('action_default');
|
||||
}
|
||||
|
||||
unset($url_data['route']);
|
||||
unset($url_data['_route_']);
|
||||
|
||||
$data['currencies'] = [];
|
||||
|
||||
$this->load->model('localisation/currency');
|
||||
|
||||
$results = $this->model_localisation_currency->getCurrencies();
|
||||
|
||||
foreach ($results as $result) {
|
||||
if ($result['status']) {
|
||||
$data['currencies'][] = [
|
||||
'title' => $result['title'],
|
||||
'code' => $result['code'],
|
||||
'symbol_left' => $result['symbol_left'],
|
||||
'symbol_right' => $result['symbol_right']
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$url = '';
|
||||
|
||||
if ($url_data) {
|
||||
$url .= '&' . urldecode(http_build_query($url_data, '', '&'));
|
||||
}
|
||||
|
||||
$data['redirect'] = $this->url->link($route, $url);
|
||||
|
||||
return $this->load->view('common/currency', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
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']);
|
||||
}
|
||||
|
||||
$option = [
|
||||
'expires' => time() + 60 * 60 * 24 * 30,
|
||||
'path' => '/',
|
||||
'SameSite' => 'Lax'
|
||||
];
|
||||
|
||||
setcookie('currency', $this->session->data['currency'], $option);
|
||||
|
||||
if (isset($this->request->post['redirect']) && substr($this->request->post['redirect'], 0, strlen($this->config->get('config_url'))) == $this->config->get('config_url')) {
|
||||
$this->response->redirect(str_replace('&', '&', $this->request->post['redirect']));
|
||||
} else {
|
||||
$this->response->redirect($this->url->link($this->config->get('action_default')));
|
||||
}
|
||||
}
|
||||
}
|
92
catalog/controller/common/footer.php
Normal file
92
catalog/controller/common/footer.php
Normal file
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
namespace Opencart\Catalog\Controller\Common;
|
||||
/**
|
||||
* Class Footer
|
||||
*
|
||||
* @package Opencart\Catalog\Controller\Common
|
||||
*/
|
||||
class Footer extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function index(): string {
|
||||
$this->load->language('common/footer');
|
||||
|
||||
$data['blog'] = $this->url->link('cms/blog', 'language=' . $this->config->get('config_language'));
|
||||
|
||||
$this->load->model('catalog/information');
|
||||
|
||||
$data['informations'] = [];
|
||||
|
||||
foreach ($this->model_catalog_information->getInformations() as $result) {
|
||||
if ($result['bottom']) {
|
||||
$data['informations'][] = [
|
||||
'title' => $result['title'],
|
||||
'href' => $this->url->link('information/information', 'language=' . $this->config->get('config_language') . '&information_id=' . $result['information_id'])
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$data['contact'] = $this->url->link('information/contact', 'language=' . $this->config->get('config_language'));
|
||||
$data['return'] = $this->url->link('account/returns.add', 'language=' . $this->config->get('config_language'));
|
||||
|
||||
if ($this->config->get('config_gdpr_id')) {
|
||||
$data['gdpr'] = $this->url->link('information/gdpr', 'language=' . $this->config->get('config_language'));
|
||||
} else {
|
||||
$data['gdpr'] = '';
|
||||
}
|
||||
|
||||
$data['sitemap'] = $this->url->link('information/sitemap', 'language=' . $this->config->get('config_language'));
|
||||
$data['manufacturer'] = $this->url->link('product/manufacturer', 'language=' . $this->config->get('config_language'));
|
||||
$data['voucher'] = $this->url->link('checkout/voucher', 'language=' . $this->config->get('config_language'));
|
||||
|
||||
if ($this->config->get('config_affiliate_status')) {
|
||||
$data['affiliate'] = $this->url->link('account/affiliate', 'language=' . $this->config->get('config_language') . (isset($this->session->data['customer_token']) ? '&customer_token=' . $this->session->data['customer_token'] : ''));
|
||||
} else {
|
||||
$data['affiliate'] = '';
|
||||
}
|
||||
|
||||
$data['special'] = $this->url->link('product/special', 'language=' . $this->config->get('config_language') . (isset($this->session->data['customer_token']) ? '&customer_token=' . $this->session->data['customer_token'] : ''));
|
||||
$data['account'] = $this->url->link('account/account', 'language=' . $this->config->get('config_language') . (isset($this->session->data['customer_token']) ? '&customer_token=' . $this->session->data['customer_token'] : ''));
|
||||
$data['order'] = $this->url->link('account/order', 'language=' . $this->config->get('config_language') . (isset($this->session->data['customer_token']) ? '&customer_token=' . $this->session->data['customer_token'] : ''));
|
||||
$data['wishlist'] = $this->url->link('account/wishlist', 'language=' . $this->config->get('config_language') . (isset($this->session->data['customer_token']) ? '&customer_token=' . $this->session->data['customer_token'] : ''));
|
||||
$data['newsletter'] = $this->url->link('account/newsletter', 'language=' . $this->config->get('config_language') . (isset($this->session->data['customer_token']) ? '&customer_token=' . $this->session->data['customer_token'] : ''));
|
||||
|
||||
$data['powered'] = sprintf($this->language->get('text_powered'), $this->config->get('config_name'), date('Y', time()));
|
||||
|
||||
// Who's Online
|
||||
if ($this->config->get('config_customer_online')) {
|
||||
$this->load->model('tool/online');
|
||||
|
||||
if (isset($this->request->server['HTTP_X_REAL_IP'])) {
|
||||
$ip = $this->request->server['HTTP_X_REAL_IP'];
|
||||
} elseif (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['bootstrap'] = 'catalog/view/javascript/bootstrap/js/bootstrap.bundle.min.js';
|
||||
|
||||
$data['scripts'] = $this->document->getScripts('footer');
|
||||
|
||||
$data['cookie'] = $this->load->controller('common/cookie');
|
||||
|
||||
return $this->load->view('common/footer', $data);
|
||||
}
|
||||
}
|
95
catalog/controller/common/header.php
Normal file
95
catalog/controller/common/header.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
namespace Opencart\Catalog\Controller\Common;
|
||||
/**
|
||||
* Class Header
|
||||
*
|
||||
* @package Opencart\Catalog\Controller\Common
|
||||
*/
|
||||
class Header extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function index(): string {
|
||||
// Analytics
|
||||
$data['analytics'] = [];
|
||||
|
||||
if (!$this->config->get('config_cookie_id') || (isset($this->request->cookie['policy']) && $this->request->cookie['policy'])) {
|
||||
$this->load->model('setting/extension');
|
||||
|
||||
$analytics = $this->model_setting_extension->getExtensionsByType('analytics');
|
||||
|
||||
foreach ($analytics as $analytic) {
|
||||
if ($this->config->get('analytics_' . $analytic['code'] . '_status')) {
|
||||
$data['analytics'][] = $this->load->controller('extension/' . $analytic['extension'] . '/analytics/' . $analytic['code'], $this->config->get('analytics_' . $analytic['code'] . '_status'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data['lang'] = $this->language->get('code');
|
||||
$data['direction'] = $this->language->get('direction');
|
||||
|
||||
$data['title'] = $this->document->getTitle();
|
||||
$data['base'] = $this->config->get('config_url');
|
||||
$data['description'] = $this->document->getDescription();
|
||||
$data['keywords'] = $this->document->getKeywords();
|
||||
|
||||
// Hard coding css so they can be replaced via the event's system.
|
||||
$data['bootstrap'] = 'catalog/view/stylesheet/bootstrap.css';
|
||||
$data['icons'] = 'catalog/view/stylesheet/fonts/fontawesome/css/all.min.css';
|
||||
$data['stylesheet'] = 'catalog/view/stylesheet/stylesheet.css';
|
||||
|
||||
// Hard coding scripts so they can be replaced via the event's system.
|
||||
$data['jquery'] = 'catalog/view/javascript/jquery/jquery-3.7.1.min.js';
|
||||
|
||||
$data['links'] = $this->document->getLinks();
|
||||
$data['styles'] = $this->document->getStyles();
|
||||
$data['scripts'] = $this->document->getScripts('header');
|
||||
|
||||
$data['name'] = $this->config->get('config_name');
|
||||
|
||||
if (is_file(DIR_IMAGE . $this->config->get('config_logo'))) {
|
||||
$data['logo'] = $this->config->get('config_url') . '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['home'] = $this->url->link('common/home', 'language=' . $this->config->get('config_language'));
|
||||
$data['wishlist'] = $this->url->link('account/wishlist', 'language=' . $this->config->get('config_language') . (isset($this->session->data['customer_token']) ? '&customer_token=' . $this->session->data['customer_token'] : ''));
|
||||
$data['logged'] = $this->customer->isLogged();
|
||||
|
||||
if (!$this->customer->isLogged()) {
|
||||
$data['register'] = $this->url->link('account/register', 'language=' . $this->config->get('config_language'));
|
||||
$data['login'] = $this->url->link('account/login', 'language=' . $this->config->get('config_language'));
|
||||
} else {
|
||||
$data['account'] = $this->url->link('account/account', 'language=' . $this->config->get('config_language') . '&customer_token=' . $this->session->data['customer_token']);
|
||||
$data['order'] = $this->url->link('account/order', 'language=' . $this->config->get('config_language') . '&customer_token=' . $this->session->data['customer_token']);
|
||||
$data['transaction'] = $this->url->link('account/transaction', 'language=' . $this->config->get('config_language') . '&customer_token=' . $this->session->data['customer_token']);
|
||||
$data['download'] = $this->url->link('account/download', 'language=' . $this->config->get('config_language') . '&customer_token=' . $this->session->data['customer_token']);
|
||||
$data['logout'] = $this->url->link('account/logout', 'language=' . $this->config->get('config_language'));
|
||||
}
|
||||
|
||||
$data['shopping_cart'] = $this->url->link('checkout/cart', 'language=' . $this->config->get('config_language'));
|
||||
$data['checkout'] = $this->url->link('checkout/checkout', 'language=' . $this->config->get('config_language'));
|
||||
$data['contact'] = $this->url->link('information/contact', 'language=' . $this->config->get('config_language'));
|
||||
$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);
|
||||
}
|
||||
}
|
26
catalog/controller/common/home.php
Normal file
26
catalog/controller/common/home.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
namespace Opencart\Catalog\Controller\Common;
|
||||
/**
|
||||
* Class Home
|
||||
*
|
||||
* @package Opencart\Catalog\Controller\Common
|
||||
*/
|
||||
class Home extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$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'));
|
||||
|
||||
$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));
|
||||
}
|
||||
}
|
59
catalog/controller/common/language.php
Normal file
59
catalog/controller/common/language.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
namespace Opencart\Catalog\Controller\Common;
|
||||
/**
|
||||
* Class Language
|
||||
*
|
||||
* @package Opencart\Catalog\Controller\Common
|
||||
*/
|
||||
class Language extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function index(): string {
|
||||
$this->load->language('common/language');
|
||||
|
||||
$url_data = $this->request->get;
|
||||
|
||||
if (isset($url_data['route'])) {
|
||||
$route = $url_data['route'];
|
||||
} else {
|
||||
$route = $this->config->get('action_default');
|
||||
}
|
||||
|
||||
unset($url_data['route']);
|
||||
unset($url_data['_route_']);
|
||||
unset($url_data['language']);
|
||||
|
||||
$url = '';
|
||||
|
||||
if ($url_data) {
|
||||
$url .= '&' . urldecode(http_build_query($url_data));
|
||||
}
|
||||
|
||||
// Added so the correct SEO language URL is used.
|
||||
$language_id = $this->config->get('config_language_id');
|
||||
|
||||
$data['languages'] = [];
|
||||
|
||||
$this->load->model('localisation/language');
|
||||
|
||||
$results = $this->model_localisation_language->getLanguages();
|
||||
|
||||
foreach ($results as $result) {
|
||||
$this->config->set('config_language_id', $result['language_id']);
|
||||
|
||||
$data['languages'][] = [
|
||||
'name' => $result['name'],
|
||||
'code' => $result['code'],
|
||||
'image' => $result['image'],
|
||||
'href' => $this->url->link($route, 'language=' . $result['code'] . $url, true)
|
||||
];
|
||||
}
|
||||
|
||||
$this->config->set('config_language_id', $language_id);
|
||||
|
||||
$data['code'] = $this->config->get('config_language');
|
||||
|
||||
return $this->load->view('common/language', $data);
|
||||
}
|
||||
}
|
39
catalog/controller/common/maintenance.php
Normal file
39
catalog/controller/common/maintenance.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
namespace Opencart\Catalog\Controller\Common;
|
||||
/**
|
||||
* Class Maintenance
|
||||
*
|
||||
* @package Opencart\Catalog\Controller\Common
|
||||
*/
|
||||
class Maintenance extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$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'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_maintenance'),
|
||||
'href' => $this->url->link('common/maintenance', 'language=' . $this->config->get('config_language'))
|
||||
];
|
||||
|
||||
$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));
|
||||
}
|
||||
}
|
55
catalog/controller/common/menu.php
Normal file
55
catalog/controller/common/menu.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
namespace Opencart\Catalog\Controller\Common;
|
||||
/**
|
||||
* Class Menu
|
||||
*
|
||||
* @package Opencart\Catalog\Controller\Common
|
||||
*/
|
||||
class Menu extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function index(): string {
|
||||
$this->load->language('common/menu');
|
||||
|
||||
// Menu
|
||||
$this->load->model('catalog/category');
|
||||
|
||||
$this->load->model('catalog/product');
|
||||
|
||||
$data['categories'] = [];
|
||||
|
||||
$categories = $this->model_catalog_category->getCategories(0);
|
||||
|
||||
foreach ($categories as $category) {
|
||||
if ($category['top']) {
|
||||
// Level 2
|
||||
$children_data = [];
|
||||
|
||||
$children = $this->model_catalog_category->getCategories($category['category_id']);
|
||||
|
||||
foreach ($children as $child) {
|
||||
$filter_data = [
|
||||
'filter_category_id' => $child['category_id'],
|
||||
'filter_sub_category' => true
|
||||
];
|
||||
|
||||
$children_data[] = [
|
||||
'name' => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
|
||||
'href' => $this->url->link('product/category', 'language=' . $this->config->get('config_language') . '&path=' . $category['category_id'] . '_' . $child['category_id'])
|
||||
];
|
||||
}
|
||||
|
||||
// Level 1
|
||||
$data['categories'][] = [
|
||||
'name' => $category['name'],
|
||||
'children' => $children_data,
|
||||
'column' => $category['column'] ? $category['column'] : 1,
|
||||
'href' => $this->url->link('product/category', 'language=' . $this->config->get('config_language') . '&path=' . $category['category_id'])
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->load->view('common/menu', $data);
|
||||
}
|
||||
}
|
106
catalog/controller/common/pagination.php
Normal file
106
catalog/controller/common/pagination.php
Normal file
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
namespace Opencart\Catalog\Controller\Common;
|
||||
/**
|
||||
* Class Pagination
|
||||
*
|
||||
* @package Opencart\Catalog\Controller\Common
|
||||
*/
|
||||
class Pagination extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @param array $setting
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function index(array $setting): string {
|
||||
if (isset($setting['total'])) {
|
||||
$total = $setting['total'];
|
||||
} else {
|
||||
$total = 0;
|
||||
}
|
||||
|
||||
if (isset($setting['page']) && $setting['page'] > 0) {
|
||||
$page = (int)$setting['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
if (isset($setting['limit']) && (int)$setting['limit']) {
|
||||
$limit = (int)$setting['limit'];
|
||||
} else {
|
||||
$limit = 10;
|
||||
}
|
||||
|
||||
if (isset($setting['url'])) {
|
||||
$url = str_replace('%7Bpage%7D', '{page}', (string)$setting['url']);
|
||||
} else {
|
||||
$url = '';
|
||||
}
|
||||
|
||||
$num_links = 8;
|
||||
$num_pages = ceil($total / $limit);
|
||||
|
||||
if ($url && $page > 1 && $num_pages < $page) {
|
||||
$back = true;
|
||||
} else {
|
||||
$back = false;
|
||||
}
|
||||
|
||||
$data['page'] = $page;
|
||||
|
||||
if ($page > 1) {
|
||||
$data['first'] = str_replace(['&page={page}', '?page={page}', '&page={page}'], '', $url);
|
||||
|
||||
if ($page - 1 === 1) {
|
||||
$data['prev'] = str_replace(['&page={page}', '?page={page}', '&page={page}'], '', $url);
|
||||
} else {
|
||||
$data['prev'] = str_replace('{page}', $page - 1, $url);
|
||||
}
|
||||
} else {
|
||||
$data['first'] = '';
|
||||
$data['prev'] = '';
|
||||
}
|
||||
|
||||
$data['links'] = [];
|
||||
|
||||
if ($num_pages > 1) {
|
||||
if ($num_pages <= $num_links) {
|
||||
$start = 1;
|
||||
$end = $num_pages;
|
||||
} else {
|
||||
$start = $page - floor($num_links / 2);
|
||||
$end = $page + floor($num_links / 2);
|
||||
|
||||
if ($start < 1) {
|
||||
$end += abs($start) + 1;
|
||||
$start = 1;
|
||||
}
|
||||
|
||||
if ($end > $num_pages) {
|
||||
$start -= ($end - $num_pages);
|
||||
$end = $num_pages;
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = $start; $i <= $end; $i++) {
|
||||
$data['links'][] = [
|
||||
'page' => $i,
|
||||
'href' => str_replace('{page}', $i, $url)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if ($num_pages > $page) {
|
||||
$data['next'] = str_replace('{page}', $page + 1, $url);
|
||||
$data['last'] = str_replace('{page}', $num_pages, $url);
|
||||
} else {
|
||||
$data['next'] = '';
|
||||
$data['last'] = '';
|
||||
}
|
||||
|
||||
if ($num_pages > 1 || $back) {
|
||||
return $this->load->view('common/pagination', $data);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
27
catalog/controller/common/search.php
Normal file
27
catalog/controller/common/search.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace Opencart\Catalog\Controller\Common;
|
||||
/**
|
||||
* Class Search
|
||||
*
|
||||
* @package Opencart\Catalog\Controller\Common
|
||||
*/
|
||||
class Search extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function index(): string {
|
||||
$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'] = '';
|
||||
}
|
||||
|
||||
$data['language'] = $this->config->get('config_language');
|
||||
|
||||
return $this->load->view('common/search', $data);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user