first commit
This commit is contained in:
69
extension/opencart/admin/controller/module/account.php
Normal file
69
extension/opencart/admin/controller/module/account.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Extension\Opencart\Module;
|
||||
/**
|
||||
* Class Account
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Extension\Opencart\Module
|
||||
*/
|
||||
class Account extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('extension/opencart/module/account');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_extension'),
|
||||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module')
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/opencart/module/account', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('extension/opencart/module/account.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module');
|
||||
|
||||
$data['module_account_status'] = $this->config->get('module_account_status');
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('extension/opencart/module/account', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('extension/opencart/module/account');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'extension/opencart/module/account')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('setting/setting');
|
||||
|
||||
$this->model_setting_setting->editSetting('module_account', $this->request->post);
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
175
extension/opencart/admin/controller/module/banner.php
Normal file
175
extension/opencart/admin/controller/module/banner.php
Normal file
@ -0,0 +1,175 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Extension\Opencart\Module;
|
||||
/**
|
||||
* Class Banner
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Extension\Opencart\Module
|
||||
*/
|
||||
class Banner extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('extension/opencart/module/banner');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_extension'),
|
||||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module')
|
||||
];
|
||||
|
||||
if (!isset($this->request->get['module_id'])) {
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/opencart/module/banner', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
} else {
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/opencart/module/banner', 'user_token=' . $this->session->data['user_token'] . '&module_id=' . $this->request->get['module_id'])
|
||||
];
|
||||
}
|
||||
|
||||
if (!isset($this->request->get['module_id'])) {
|
||||
$data['save'] = $this->url->link('extension/opencart/module/banner.save', 'user_token=' . $this->session->data['user_token']);
|
||||
} else {
|
||||
$data['save'] = $this->url->link('extension/opencart/module/banner.save', 'user_token=' . $this->session->data['user_token'] . '&module_id=' . $this->request->get['module_id']);
|
||||
}
|
||||
|
||||
$data['back'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module');
|
||||
|
||||
if (isset($this->request->get['module_id'])) {
|
||||
$this->load->model('setting/module');
|
||||
|
||||
$module_info = $this->model_setting_module->getModule($this->request->get['module_id']);
|
||||
}
|
||||
|
||||
if (isset($module_info['name'])) {
|
||||
$data['name'] = $module_info['name'];
|
||||
} else {
|
||||
$data['name'] = '';
|
||||
}
|
||||
|
||||
if (isset($module_info['banner_id'])) {
|
||||
$data['banner_id'] = $module_info['banner_id'];
|
||||
} else {
|
||||
$data['banner_id'] = '';
|
||||
}
|
||||
|
||||
$this->load->model('design/banner');
|
||||
|
||||
$data['banners'] = $this->model_design_banner->getBanners();
|
||||
|
||||
if (isset($module_info['effect'])) {
|
||||
$data['effect'] = $module_info['effect'];
|
||||
} else {
|
||||
$data['effect'] = '';
|
||||
}
|
||||
|
||||
if (isset($module_info['items'])) {
|
||||
$data['items'] = $module_info['items'];
|
||||
} else {
|
||||
$data['items'] = 4;
|
||||
}
|
||||
|
||||
if (isset($module_info['controls'])) {
|
||||
$data['controls'] = $module_info['controls'];
|
||||
} else {
|
||||
$data['controls'] = '';
|
||||
}
|
||||
|
||||
if (isset($module_info['indicators'])) {
|
||||
$data['indicators'] = $module_info['indicators'];
|
||||
} else {
|
||||
$data['indicators'] = '';
|
||||
}
|
||||
|
||||
if (isset($module_info['interval'])) {
|
||||
$data['interval'] = $module_info['interval'];
|
||||
} else {
|
||||
$data['interval'] = 5000;
|
||||
}
|
||||
|
||||
if (isset($module_info['width'])) {
|
||||
$data['width'] = $module_info['width'];
|
||||
} else {
|
||||
$data['width'] = '';
|
||||
}
|
||||
|
||||
if (isset($module_info['height'])) {
|
||||
$data['height'] = $module_info['height'];
|
||||
} else {
|
||||
$data['height'] = '';
|
||||
}
|
||||
|
||||
if (isset($module_info['status'])) {
|
||||
$data['status'] = $module_info['status'];
|
||||
} else {
|
||||
$data['status'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['module_id'])) {
|
||||
$data['module_id'] = (int)$this->request->get['module_id'];
|
||||
} else {
|
||||
$data['module_id'] = 0;
|
||||
}
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('extension/opencart/module/banner', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('extension/opencart/module/banner');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'extension/opencart/module/banner')) {
|
||||
$json['error']['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if ((oc_strlen($this->request->post['name']) < 3) || (oc_strlen($this->request->post['name']) > 64)) {
|
||||
$json['error']['name'] = $this->language->get('error_name');
|
||||
}
|
||||
|
||||
if (!$this->request->post['interval']) {
|
||||
$json['error']['interval'] = $this->language->get('error_interval');
|
||||
}
|
||||
|
||||
if (!$this->request->post['width']) {
|
||||
$json['error']['width'] = $this->language->get('error_width');
|
||||
}
|
||||
|
||||
if (!$this->request->post['height']) {
|
||||
$json['error']['height'] = $this->language->get('error_height');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('setting/module');
|
||||
|
||||
if (!$this->request->post['module_id']) {
|
||||
$json['module_id'] = $this->model_setting_module->addModule('opencart.banner', $this->request->post);
|
||||
} else {
|
||||
$this->model_setting_module->editModule($this->request->post['module_id'], $this->request->post);
|
||||
}
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
290
extension/opencart/admin/controller/module/bestseller.php
Normal file
290
extension/opencart/admin/controller/module/bestseller.php
Normal file
@ -0,0 +1,290 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Extension\Opencart\Module;
|
||||
/**
|
||||
* Class Best Seller
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Extension\Opencart\Module
|
||||
*/
|
||||
class BestSeller extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('extension/opencart/module/bestseller');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_extension'),
|
||||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module')
|
||||
];
|
||||
|
||||
if (!isset($this->request->get['module_id'])) {
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/opencart/module/bestseller', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
} else {
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/opencart/module/bestseller', 'user_token=' . $this->session->data['user_token'] . '&module_id=' . $this->request->get['module_id'])
|
||||
];
|
||||
}
|
||||
|
||||
if (!isset($this->request->get['module_id'])) {
|
||||
$data['save'] = $this->url->link('extension/opencart/module/bestseller.save', 'user_token=' . $this->session->data['user_token']);
|
||||
} else {
|
||||
$data['save'] = $this->url->link('extension/opencart/module/bestseller.save', 'user_token=' . $this->session->data['user_token'] . '&module_id=' . $this->request->get['module_id']);
|
||||
}
|
||||
|
||||
$data['back'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module');
|
||||
|
||||
if (isset($this->request->get['module_id'])) {
|
||||
$this->load->model('setting/module');
|
||||
|
||||
$module_info = $this->model_setting_module->getModule($this->request->get['module_id']);
|
||||
}
|
||||
|
||||
if (isset($module_info['name'])) {
|
||||
$data['name'] = $module_info['name'];
|
||||
} else {
|
||||
$data['name'] = '';
|
||||
}
|
||||
|
||||
if (isset($module_info['axis'])) {
|
||||
$data['axis'] = $module_info['axis'];
|
||||
} else {
|
||||
$data['axis'] ='';
|
||||
}
|
||||
|
||||
if (isset($module_info['limit'])) {
|
||||
$data['limit'] = $module_info['limit'];
|
||||
} else {
|
||||
$data['limit'] = 5;
|
||||
}
|
||||
|
||||
if (isset($module_info['width'])) {
|
||||
$data['width'] = $module_info['width'];
|
||||
} else {
|
||||
$data['width'] = 200;
|
||||
}
|
||||
|
||||
if (isset($module_info['height'])) {
|
||||
$data['height'] = $module_info['height'];
|
||||
} else {
|
||||
$data['height'] = 200;
|
||||
}
|
||||
|
||||
if (isset($module_info['status'])) {
|
||||
$data['status'] = $module_info['status'];
|
||||
} else {
|
||||
$data['status'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['module_id'])) {
|
||||
$data['module_id'] = (int)$this->request->get['module_id'];
|
||||
} else {
|
||||
$data['module_id'] = 0;
|
||||
}
|
||||
|
||||
$data['report'] = $this->getReport();
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('extension/opencart/module/bestseller', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('extension/opencart/module/bestseller');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'extension/opencart/module/bestseller')) {
|
||||
$json['error']['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if ((oc_strlen($this->request->post['name']) < 3) || (oc_strlen($this->request->post['name']) > 64)) {
|
||||
$json['error']['name'] = $this->language->get('error_name');
|
||||
}
|
||||
|
||||
if (!$this->request->post['width']) {
|
||||
$json['error']['width'] = $this->language->get('error_width');
|
||||
}
|
||||
|
||||
if (!$this->request->post['height']) {
|
||||
$json['error']['height'] = $this->language->get('error_height');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('setting/module');
|
||||
|
||||
if (!$this->request->post['module_id']) {
|
||||
$json['module_id'] = $this->model_setting_module->addModule('opencart.bestseller', $this->request->post);
|
||||
} else {
|
||||
$this->model_setting_module->editModule($this->request->post['module_id'], $this->request->post);
|
||||
}
|
||||
|
||||
$this->cache->delete('product');
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function install(): void {
|
||||
if ($this->user->hasPermission('modify', 'extension/opencart/module/bestseller')) {
|
||||
$this->load->model('extension/opencart/module/bestseller');
|
||||
|
||||
$this->model_extension_opencart_module_bestseller->install();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function uninstall(): void {
|
||||
if ($this->user->hasPermission('modify', 'extension/opencart/module/bestseller')) {
|
||||
$this->load->model('extension/opencart/module/bestseller');
|
||||
|
||||
$this->model_extension_opencart_module_bestseller->uninstall();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function report(): void {
|
||||
$this->load->language('extension/opencart/module/bestseller');
|
||||
|
||||
$this->response->setOutput($this->getReport());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReport(): string {
|
||||
if (isset($this->request->get['page']) && $this->request->get['route'] == 'extension/opencart/module/bestseller.report') {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$limit = 10;
|
||||
|
||||
$data['reports'] = [];
|
||||
|
||||
$this->load->model('extension/opencart/module/bestseller');
|
||||
$this->load->model('catalog/product');
|
||||
|
||||
$results = $this->model_extension_opencart_module_bestseller->getReports(($page - 1) * $limit, $limit);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$product_info = $this->model_catalog_product->getProduct($result['product_id']);
|
||||
|
||||
if ($product_info) {
|
||||
$product = $product_info['name'];
|
||||
} else {
|
||||
$product = '';
|
||||
}
|
||||
|
||||
$data['reports'][] = [
|
||||
'product' => $product,
|
||||
'total' => $result['total'],
|
||||
'edit' => $this->url->link('catalog/product.edit', 'user_token=' . $this->session->data['user_token'] . '&product_id=' . $result['product_id'])
|
||||
];
|
||||
}
|
||||
|
||||
$report_total = $this->model_extension_opencart_module_bestseller->getTotalReports();
|
||||
|
||||
$data['pagination'] = $this->load->controller('common/pagination', [
|
||||
'total' => $report_total,
|
||||
'page' => $page,
|
||||
'limit' => $limit,
|
||||
'url' => $this->url->link('extension/opencart/module/bestseller.report', 'user_token=' . $this->session->data['user_token'] . '&page={page}')
|
||||
]);
|
||||
|
||||
$data['results'] = sprintf($this->language->get('text_pagination'), ($report_total) ? (($page - 1) * $limit) + 1 : 0, ((($page - 1) * $limit) > ($report_total - $limit)) ? $report_total : ((($page - 1) * $limit) + $limit), $report_total, ceil($report_total / $limit));
|
||||
|
||||
return $this->load->view('extension/opencart/module/bestseller_report', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function sync(): void {
|
||||
$this->load->language('extension/opencart/module/bestseller');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (isset($this->request->get['page'])) {
|
||||
$page = (int)$this->request->get['page'];
|
||||
} else {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'extension/opencart/module/bestseller')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('extension/opencart/module/bestseller');
|
||||
$this->load->model('catalog/product');
|
||||
$this->load->model('sale/order');
|
||||
|
||||
$total = $this->model_catalog_product->getTotalProducts();
|
||||
$limit = 10;
|
||||
|
||||
$start = ($page - 1) * $limit;
|
||||
$end = $start > ($total - $limit) ? $total : ($start + $limit);
|
||||
|
||||
$product_data = [
|
||||
'start' => ($page - 1) * $limit,
|
||||
'limit' => $limit
|
||||
];
|
||||
|
||||
$results = $this->model_catalog_product->getProducts($product_data);
|
||||
|
||||
foreach ($results as $result) {
|
||||
$product_total = $this->model_sale_order->getTotalProductsByProductId($result['product_id']);
|
||||
|
||||
if ($product_total) {
|
||||
$this->model_extension_opencart_module_bestseller->editTotal($result['product_id'], $product_total);
|
||||
} else {
|
||||
$this->model_extension_opencart_module_bestseller->delete($result['product_id']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($end < $total) {
|
||||
$json['text'] = sprintf($this->language->get('text_next'), $end, $total);
|
||||
|
||||
$json['next'] = $this->url->link('extension/opencart/module/bestseller.sync', 'user_token=' . $this->session->data['user_token'] . '&page=' . ($page + 1), true);
|
||||
} else {
|
||||
$json['success'] = sprintf($this->language->get('text_next'), $end, $total);
|
||||
|
||||
$json['next'] = '';
|
||||
}
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
69
extension/opencart/admin/controller/module/category.php
Normal file
69
extension/opencart/admin/controller/module/category.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Extension\Opencart\Module;
|
||||
/**
|
||||
* Class Category
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Extension\Opencart\Module
|
||||
*/
|
||||
class Category extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('extension/opencart/module/category');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_extension'),
|
||||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module')
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/opencart/module/category', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('extension/opencart/module/category.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module');
|
||||
|
||||
$data['module_category_status'] = $this->config->get('module_category_status');
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('extension/opencart/module/category', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('extension/opencart/module/category');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'extension/opencart/module/category')) {
|
||||
$json['error']['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('setting/setting');
|
||||
|
||||
$this->model_setting_setting->editSetting('module_category', $this->request->post);
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
160
extension/opencart/admin/controller/module/featured.php
Normal file
160
extension/opencart/admin/controller/module/featured.php
Normal file
@ -0,0 +1,160 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Extension\Opencart\Module;
|
||||
/**
|
||||
* Class Featured
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Extension\Opencart\Module
|
||||
*/
|
||||
class Featured extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('extension/opencart/module/featured');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_extension'),
|
||||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module')
|
||||
];
|
||||
|
||||
if (!isset($this->request->get['module_id'])) {
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/opencart/module/featured', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
} else {
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/opencart/module/featured', 'user_token=' . $this->session->data['user_token'] . '&module_id=' . $this->request->get['module_id'])
|
||||
];
|
||||
}
|
||||
|
||||
if (!isset($this->request->get['module_id'])) {
|
||||
$data['save'] = $this->url->link('extension/opencart/module/featured.save', 'user_token=' . $this->session->data['user_token']);
|
||||
} else {
|
||||
$data['save'] = $this->url->link('extension/opencart/module/featured.save', 'user_token=' . $this->session->data['user_token'] . '&module_id=' . $this->request->get['module_id']);
|
||||
}
|
||||
|
||||
$data['back'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module');
|
||||
|
||||
if (isset($this->request->get['module_id'])) {
|
||||
$this->load->model('setting/module');
|
||||
|
||||
$module_info = $this->model_setting_module->getModule($this->request->get['module_id']);
|
||||
}
|
||||
|
||||
if (isset($module_info['name'])) {
|
||||
$data['name'] = $module_info['name'];
|
||||
} else {
|
||||
$data['name'] = '';
|
||||
}
|
||||
|
||||
$this->load->model('catalog/product');
|
||||
|
||||
$data['products'] = [];
|
||||
|
||||
if (!empty($module_info['product'])) {
|
||||
$products = $module_info['product'];
|
||||
} else {
|
||||
$products = [];
|
||||
}
|
||||
|
||||
foreach ($products as $product_id) {
|
||||
$product_info = $this->model_catalog_product->getProduct($product_id);
|
||||
|
||||
if ($product_info) {
|
||||
$data['products'][] = [
|
||||
'product_id' => $product_info['product_id'],
|
||||
'name' => $product_info['name']
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($module_info['axis'])) {
|
||||
$data['axis'] = $module_info['axis'];
|
||||
} else {
|
||||
$data['axis'] ='';
|
||||
}
|
||||
|
||||
if (isset($module_info['width'])) {
|
||||
$data['width'] = $module_info['width'];
|
||||
} else {
|
||||
$data['width'] = 200;
|
||||
}
|
||||
|
||||
if (isset($module_info['height'])) {
|
||||
$data['height'] = $module_info['height'];
|
||||
} else {
|
||||
$data['height'] = 200;
|
||||
}
|
||||
|
||||
if (isset($module_info['status'])) {
|
||||
$data['status'] = $module_info['status'];
|
||||
} else {
|
||||
$data['status'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['module_id'])) {
|
||||
$data['module_id'] = (int)$this->request->get['module_id'];
|
||||
} else {
|
||||
$data['module_id'] = 0;
|
||||
}
|
||||
|
||||
$data['user_token'] = $this->session->data['user_token'];
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('extension/opencart/module/featured', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('extension/opencart/module/featured');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'extension/opencart/module/featured')) {
|
||||
$json['error']['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if ((oc_strlen($this->request->post['name']) < 3) || (oc_strlen($this->request->post['name']) > 64)) {
|
||||
$json['error']['name'] = $this->language->get('error_name');
|
||||
}
|
||||
|
||||
if (!$this->request->post['width']) {
|
||||
$json['error']['width'] = $this->language->get('error_width');
|
||||
}
|
||||
|
||||
if (!$this->request->post['height']) {
|
||||
$json['error']['height'] = $this->language->get('error_height');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('setting/module');
|
||||
|
||||
if (!$this->request->post['module_id']) {
|
||||
$json['module_id'] = $this->model_setting_module->addModule('opencart.featured', $this->request->post);
|
||||
} else {
|
||||
$this->model_setting_module->editModule($this->request->post['module_id'], $this->request->post);
|
||||
}
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
69
extension/opencart/admin/controller/module/filter.php
Normal file
69
extension/opencart/admin/controller/module/filter.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Extension\Opencart\Module;
|
||||
/**
|
||||
* Class Filter
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Extension\Opencart\Module
|
||||
*/
|
||||
class Filter extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('extension/opencart/module/filter');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_extension'),
|
||||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module')
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/opencart/module/filter', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('extension/opencart/module/filter.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module');
|
||||
|
||||
$data['module_filter_status'] = $this->config->get('module_filter_status');
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('extension/opencart/module/filter', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('extension/opencart/module/filter');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'extension/opencart/module/filter')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('setting/setting');
|
||||
|
||||
$this->model_setting_setting->editSetting('module_filter', $this->request->post);
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
124
extension/opencart/admin/controller/module/html.php
Normal file
124
extension/opencart/admin/controller/module/html.php
Normal file
@ -0,0 +1,124 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Extension\Opencart\Module;
|
||||
/**
|
||||
* Class HTML
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Extension\Opencart\Module
|
||||
*/
|
||||
class HTML extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('extension/opencart/module/html');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$this->document->addScript('view/javascript/ckeditor/ckeditor.js');
|
||||
$this->document->addScript('view/javascript/ckeditor/adapters/jquery.js');
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_extension'),
|
||||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module')
|
||||
];
|
||||
|
||||
if (!isset($this->request->get['module_id'])) {
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/opencart/module/html', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
} else {
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/opencart/module/html', 'user_token=' . $this->session->data['user_token'] . '&module_id=' . $this->request->get['module_id'])
|
||||
];
|
||||
}
|
||||
|
||||
if (!isset($this->request->get['module_id'])) {
|
||||
$data['save'] = $this->url->link('extension/opencart/module/html.save', 'user_token=' . $this->session->data['user_token']);
|
||||
} else {
|
||||
$data['save'] = $this->url->link('extension/opencart/module/html.save', 'user_token=' . $this->session->data['user_token'] . '&module_id=' . $this->request->get['module_id']);
|
||||
}
|
||||
|
||||
$data['back'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module');
|
||||
|
||||
if (isset($this->request->get['module_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) {
|
||||
$this->load->model('setting/module');
|
||||
|
||||
$module_info = $this->model_setting_module->getModule($this->request->get['module_id']);
|
||||
}
|
||||
|
||||
if (isset($module_info['name'])) {
|
||||
$data['name'] = $module_info['name'];
|
||||
} else {
|
||||
$data['name'] = '';
|
||||
}
|
||||
|
||||
if (isset($module_info['module_description'])) {
|
||||
$data['module_description'] = $module_info['module_description'];
|
||||
} else {
|
||||
$data['module_description'] = [];
|
||||
}
|
||||
|
||||
$this->load->model('localisation/language');
|
||||
|
||||
$data['languages'] = $this->model_localisation_language->getLanguages();
|
||||
|
||||
if (isset($module_info['status'])) {
|
||||
$data['status'] = $module_info['status'];
|
||||
} else {
|
||||
$data['status'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['module_id'])) {
|
||||
$data['module_id'] = (int)$this->request->get['module_id'];
|
||||
} else {
|
||||
$data['module_id'] = 0;
|
||||
}
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('extension/opencart/module/html', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('extension/opencart/module/html');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'extension/opencart/module/html')) {
|
||||
$json['error']['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if ((oc_strlen($this->request->post['name']) < 3) || (oc_strlen($this->request->post['name']) > 64)) {
|
||||
$json['error']['name'] = $this->language->get('error_name');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('setting/module');
|
||||
|
||||
if (!$this->request->post['module_id']) {
|
||||
$json['module_id'] = $this->model_setting_module->addModule('opencart.html', $this->request->post);
|
||||
} else {
|
||||
$this->model_setting_module->editModule($this->request->post['module_id'], $this->request->post);
|
||||
}
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
69
extension/opencart/admin/controller/module/information.php
Normal file
69
extension/opencart/admin/controller/module/information.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Extension\Opencart\Module;
|
||||
/**
|
||||
* Class Information
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Extension\Opencart\Module
|
||||
*/
|
||||
class Information extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('extension/opencart/module/information');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_extension'),
|
||||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module')
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/opencart/module/information', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('extension/opencart/module/information.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module');
|
||||
|
||||
$data['module_information_status'] = $this->config->get('module_information_status');
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('extension/opencart/module/information', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('extension/opencart/module/information');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'extension/opencart/module/information')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('setting/setting');
|
||||
|
||||
$this->model_setting_setting->editSetting('module_information', $this->request->post);
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
145
extension/opencart/admin/controller/module/latest.php
Normal file
145
extension/opencart/admin/controller/module/latest.php
Normal file
@ -0,0 +1,145 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Extension\Opencart\Module;
|
||||
/**
|
||||
* Class Latest
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Extension\Opencart\Module
|
||||
*/
|
||||
class Latest extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('extension/opencart/module/latest');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_extension'),
|
||||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module')
|
||||
];
|
||||
|
||||
if (!isset($this->request->get['module_id'])) {
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/opencart/module/latest', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
} else {
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/opencart/module/latest', 'user_token=' . $this->session->data['user_token'] . '&module_id=' . $this->request->get['module_id'])
|
||||
];
|
||||
}
|
||||
|
||||
if (!isset($this->request->get['module_id'])) {
|
||||
$data['save'] = $this->url->link('extension/opencart/module/latest.save', 'user_token=' . $this->session->data['user_token']);
|
||||
} else {
|
||||
$data['save'] = $this->url->link('extension/opencart/module/latest.save', 'user_token=' . $this->session->data['user_token'] . '&module_id=' . $this->request->get['module_id']);
|
||||
}
|
||||
|
||||
$data['back'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module');
|
||||
|
||||
if (isset($this->request->get['module_id'])) {
|
||||
$this->load->model('setting/module');
|
||||
|
||||
$module_info = $this->model_setting_module->getModule($this->request->get['module_id']);
|
||||
}
|
||||
|
||||
if (isset($module_info['name'])) {
|
||||
$data['name'] = $module_info['name'];
|
||||
} else {
|
||||
$data['name'] = '';
|
||||
}
|
||||
|
||||
if (isset($module_info['axis'])) {
|
||||
$data['axis'] = $module_info['axis'];
|
||||
} else {
|
||||
$data['axis'] ='';
|
||||
}
|
||||
|
||||
if (isset($module_info['limit'])) {
|
||||
$data['limit'] = $module_info['limit'];
|
||||
} else {
|
||||
$data['limit'] = 5;
|
||||
}
|
||||
|
||||
if (isset($module_info['width'])) {
|
||||
$data['width'] = $module_info['width'];
|
||||
} else {
|
||||
$data['width'] = 200;
|
||||
}
|
||||
|
||||
if (isset($module_info['height'])) {
|
||||
$data['height'] = $module_info['height'];
|
||||
} else {
|
||||
$data['height'] = 200;
|
||||
}
|
||||
|
||||
if (isset($module_info['status'])) {
|
||||
$data['status'] = $module_info['status'];
|
||||
} else {
|
||||
$data['status'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['module_id'])) {
|
||||
$data['module_id'] = (int)$this->request->get['module_id'];
|
||||
} else {
|
||||
$data['module_id'] = 0;
|
||||
}
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('extension/opencart/module/latest', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('extension/opencart/module/latest');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'extension/opencart/module/latest')) {
|
||||
$json['error']['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if ((oc_strlen($this->request->post['name']) < 3) || (oc_strlen($this->request->post['name']) > 64)) {
|
||||
$json['error']['name'] = $this->language->get('error_name');
|
||||
}
|
||||
|
||||
if (!$this->request->post['width']) {
|
||||
$json['error']['width'] = $this->language->get('error_width');
|
||||
}
|
||||
|
||||
if (!$this->request->post['height']) {
|
||||
$json['error']['height'] = $this->language->get('error_height');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('setting/module');
|
||||
|
||||
if (!$this->request->post['module_id']) {
|
||||
$json['module_id'] = $this->model_setting_module->addModule('opencart.latest', $this->request->post);
|
||||
} else {
|
||||
$this->model_setting_module->editModule($this->request->post['module_id'], $this->request->post);
|
||||
}
|
||||
|
||||
$this->cache->delete('product');
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
145
extension/opencart/admin/controller/module/special.php
Normal file
145
extension/opencart/admin/controller/module/special.php
Normal file
@ -0,0 +1,145 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Extension\Opencart\Module;
|
||||
/**
|
||||
* Class Special
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Extension\Opencart\Module
|
||||
*/
|
||||
class Special extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('extension/opencart/module/special');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_extension'),
|
||||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module')
|
||||
];
|
||||
|
||||
if (!isset($this->request->get['module_id'])) {
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/opencart/module/special', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
} else {
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/opencart/module/special', 'user_token=' . $this->session->data['user_token'] . '&module_id=' . $this->request->get['module_id'])
|
||||
];
|
||||
}
|
||||
|
||||
if (!isset($this->request->get['module_id'])) {
|
||||
$data['save'] = $this->url->link('extension/opencart/module/special.save', 'user_token=' . $this->session->data['user_token']);
|
||||
} else {
|
||||
$data['save'] = $this->url->link('extension/opencart/module/special.save', 'user_token=' . $this->session->data['user_token'] . '&module_id=' . $this->request->get['module_id']);
|
||||
}
|
||||
|
||||
$data['back'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module');
|
||||
|
||||
if (isset($this->request->get['module_id'])) {
|
||||
$this->load->model('setting/module');
|
||||
|
||||
$module_info = $this->model_setting_module->getModule($this->request->get['module_id']);
|
||||
}
|
||||
|
||||
if (isset($module_info['name'])) {
|
||||
$data['name'] = $module_info['name'];
|
||||
} else {
|
||||
$data['name'] = '';
|
||||
}
|
||||
|
||||
if (isset($module_info['axis'])) {
|
||||
$data['axis'] = $module_info['axis'];
|
||||
} else {
|
||||
$data['axis'] ='';
|
||||
}
|
||||
|
||||
if (isset($module_info['limit'])) {
|
||||
$data['limit'] = $module_info['limit'];
|
||||
} else {
|
||||
$data['limit'] = 5;
|
||||
}
|
||||
|
||||
if (isset($module_info['width'])) {
|
||||
$data['width'] = $module_info['width'];
|
||||
} else {
|
||||
$data['width'] = 200;
|
||||
}
|
||||
|
||||
if (isset($module_info['height'])) {
|
||||
$data['height'] = $module_info['height'];
|
||||
} else {
|
||||
$data['height'] = 200;
|
||||
}
|
||||
|
||||
if (isset($module_info['status'])) {
|
||||
$data['status'] = $module_info['status'];
|
||||
} else {
|
||||
$data['status'] = '';
|
||||
}
|
||||
|
||||
if (isset($this->request->get['module_id'])) {
|
||||
$data['module_id'] = (int)$this->request->get['module_id'];
|
||||
} else {
|
||||
$data['module_id'] = 0;
|
||||
}
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('extension/opencart/module/special', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('extension/opencart/module/special');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'extension/opencart/module/special')) {
|
||||
$json['error']['warning'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if ((oc_strlen($this->request->post['name']) < 3) || (oc_strlen($this->request->post['name']) > 64)) {
|
||||
$json['error']['name'] = $this->language->get('error_name');
|
||||
}
|
||||
|
||||
if (!$this->request->post['width']) {
|
||||
$json['error']['width'] = $this->language->get('error_width');
|
||||
}
|
||||
|
||||
if (!$this->request->post['height']) {
|
||||
$json['error']['height'] = $this->language->get('error_height');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('setting/module');
|
||||
|
||||
if (!$this->request->post['module_id']) {
|
||||
$json['module_id'] = $this->model_setting_module->addModule('opencart.special', $this->request->post);
|
||||
} else {
|
||||
$this->model_setting_module->editModule($this->request->post['module_id'], $this->request->post);
|
||||
}
|
||||
|
||||
$this->cache->delete('product');
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
70
extension/opencart/admin/controller/module/store.php
Normal file
70
extension/opencart/admin/controller/module/store.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Extension\Opencart\Module;
|
||||
/**
|
||||
* Class Store
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Extension\Opencart\Module
|
||||
*/
|
||||
class Store extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function index(): void {
|
||||
$this->load->language('extension/opencart/module/store');
|
||||
|
||||
$this->document->setTitle($this->language->get('heading_title'));
|
||||
|
||||
$data['breadcrumbs'] = [];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_home'),
|
||||
'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('text_extension'),
|
||||
'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module')
|
||||
];
|
||||
|
||||
$data['breadcrumbs'][] = [
|
||||
'text' => $this->language->get('heading_title'),
|
||||
'href' => $this->url->link('extension/opencart/module/store', 'user_token=' . $this->session->data['user_token'])
|
||||
];
|
||||
|
||||
$data['save'] = $this->url->link('extension/opencart/module/store.save', 'user_token=' . $this->session->data['user_token']);
|
||||
$data['back'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=module');
|
||||
|
||||
$data['module_store_admin'] = $this->config->get('module_store_admin');
|
||||
$data['module_store_status'] = $this->config->get('module_store_status');
|
||||
|
||||
$data['header'] = $this->load->controller('common/header');
|
||||
$data['column_left'] = $this->load->controller('common/column_left');
|
||||
$data['footer'] = $this->load->controller('common/footer');
|
||||
|
||||
$this->response->setOutput($this->load->view('extension/opencart/module/store', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function save(): void {
|
||||
$this->load->language('extension/opencart/module/store');
|
||||
|
||||
$json = [];
|
||||
|
||||
if (!$this->user->hasPermission('modify', 'extension/opencart/module/store')) {
|
||||
$json['error'] = $this->language->get('error_permission');
|
||||
}
|
||||
|
||||
if (!$json) {
|
||||
$this->load->model('setting/setting');
|
||||
|
||||
$this->model_setting_setting->editSetting('module_store', $this->request->post);
|
||||
|
||||
$json['success'] = $this->language->get('text_success');
|
||||
}
|
||||
|
||||
$this->response->addHeader('Content-Type: application/json');
|
||||
$this->response->setOutput(json_encode($json));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user