first commit
This commit is contained in:
36
admininistrator/controller/event/currency.php
Normal file
36
admininistrator/controller/event/currency.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Event;
|
||||
/**
|
||||
* Class Currency
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Event
|
||||
*/
|
||||
class Currency extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
*
|
||||
* model/setting/setting/editSetting
|
||||
* model/localisation/currency/addCurrency
|
||||
* model/localisation/currency/editCurrency
|
||||
*
|
||||
* @param string $route
|
||||
* @param array $args
|
||||
* @param mixed $output
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function index(string &$route, array &$args, mixed &$output): void {
|
||||
if ($route == 'model/setting/setting/editSetting' && $args[0] == 'config' && isset($args[1]['config_currency'])) {
|
||||
$currency = $args[1]['config_currency'];
|
||||
} else {
|
||||
$currency = $this->config->get('config_currency');
|
||||
}
|
||||
|
||||
$this->load->model('setting/extension');
|
||||
|
||||
$extension_info = $this->model_setting_extension->getExtensionByCode('currency', $this->config->get('config_currency_engine'));
|
||||
|
||||
if ($extension_info) {
|
||||
$this->load->controller('extension/' . $extension_info['extension'] . '/currency/' . $extension_info['code'] . '.currency', $currency);
|
||||
}
|
||||
}
|
||||
}
|
40
admininistrator/controller/event/debug.php
Normal file
40
admininistrator/controller/event/debug.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Event;
|
||||
/**
|
||||
* Class Debug
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Event
|
||||
*/
|
||||
class Debug extends \Opencart\System\Engine\Controller {
|
||||
/**
|
||||
* @param string $route
|
||||
* @param array $args
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function before(string &$route, array &$args): void {
|
||||
if ($route == 'common/home') { // add the route you want to test
|
||||
//$this->session->data['debug'][$route] = microtime();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $route
|
||||
* @param array $args
|
||||
* @param mixed $output
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function after(string $route, array &$args, mixed &$output): void {
|
||||
if ($route == 'common/home') { // add the route you want to test
|
||||
if (isset($this->session->data['debug'][$route])) {
|
||||
$log_data = [
|
||||
'route' => $route,
|
||||
'time' => microtime() - $this->session->data['debug'][$route]
|
||||
];
|
||||
|
||||
$this->log->write($route);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
61
admininistrator/controller/event/language.php
Normal file
61
admininistrator/controller/event/language.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Event;
|
||||
/**
|
||||
* Class Language
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Event
|
||||
*/
|
||||
class Language extends \Opencart\System\Engine\Controller {
|
||||
// view/*/before
|
||||
// Dump all the language vars into the template.
|
||||
/**
|
||||
* @param string $route
|
||||
* @param array $args
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function index(string &$route, array &$args): void {
|
||||
foreach ($this->language->all() as $key => $value) {
|
||||
if (!isset($args[$key])) {
|
||||
$args[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// controller/*/before
|
||||
// 1. Before controller load store all current loaded language data.
|
||||
/**
|
||||
* @param string $route
|
||||
* @param array $args
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function before(string &$route, array &$args): void {
|
||||
$data = $this->language->all();
|
||||
|
||||
if ($data) {
|
||||
$this->language->set('backup', json_encode($data));
|
||||
}
|
||||
}
|
||||
|
||||
// controller/*/after
|
||||
// 2. After controller load restore old language data.
|
||||
/**
|
||||
* @param string $route
|
||||
* @param array $args
|
||||
* @param mixed $output
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function after(string &$route, array &$args, mixed &$output): void {
|
||||
$data = json_decode($this->language->get('backup'), true);
|
||||
|
||||
if (is_array($data)) {
|
||||
$this->language->clear();
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$this->language->set($key, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
67
admininistrator/controller/event/statistics.php
Normal file
67
admininistrator/controller/event/statistics.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
namespace Opencart\Admin\Controller\Event;
|
||||
/**
|
||||
* Class Statistics
|
||||
*
|
||||
* @package Opencart\Admin\Controller\Event
|
||||
*/
|
||||
class Statistics extends \Opencart\System\Engine\Controller {
|
||||
// admin/model/catalog/review/addReview/after
|
||||
/**
|
||||
* @param string $route
|
||||
* @param array $args
|
||||
* @param mixed $output
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addReview(string &$route, array &$args, mixed &$output): void {
|
||||
$this->load->model('report/statistics');
|
||||
|
||||
$this->model_report_statistics->addValue('review', 1);
|
||||
}
|
||||
|
||||
// admin/model/catalog/review/deleteReview/after
|
||||
|
||||
/**
|
||||
* @param string $route
|
||||
* @param array $args
|
||||
* @param mixed $output
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteReview(string &$route, array &$args, mixed &$output): void {
|
||||
$this->load->model('report/statistics');
|
||||
|
||||
$this->model_report_statistics->removeValue('review', 1);
|
||||
}
|
||||
|
||||
// admin/model/sale/returns/addReturn/after
|
||||
|
||||
/**
|
||||
* @param string $route
|
||||
* @param array $args
|
||||
* @param mixed $output
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addReturn(string &$route, array &$args, mixed &$output): void {
|
||||
$this->load->model('report/statistics');
|
||||
|
||||
$this->model_report_statistics->addValue('returns', 1);
|
||||
}
|
||||
|
||||
// admin/model/sale/returns/deleteReturn/after
|
||||
|
||||
/**
|
||||
* @param string $route
|
||||
* @param array $args
|
||||
* @param mixed $output
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteReturn(string &$route, array &$args, mixed &$output): void {
|
||||
$this->load->model('report/statistics');
|
||||
|
||||
$this->model_report_statistics->removeValue('returns', 1);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user