From b92017f5f6d6045abe93e4aba7fb7c044c648d60 Mon Sep 17 00:00:00 2001 From: Nikolay Savin Date: Wed, 4 May 2022 01:24:06 +0600 Subject: [PATCH] v 3.0.1 --- _build/build.config.php | 2 +- core/components/minishop2/docs/changelog.txt | 8 +++ core/components/minishop2/docs/readme.txt | 4 +- .../elements/plugins/plugin.minishop2.php | 1 + .../storage/db/cartdbhandler.class.php | 7 +++ .../storage/db/orderdbhandler.class.php | 9 ++++ .../minishop2/lexicon/ru/setting.inc.php | 2 +- .../model/minishop2/minishop2.class.php | 54 +++++++++---------- .../model/minishop2/mscarthandler.class.php | 2 +- .../minishop2/msdeliveryhandler.class.php | 2 +- .../model/minishop2/msorderhandler.class.php | 2 +- .../minishop2/mspaymenthandler.class.php | 2 +- 12 files changed, 61 insertions(+), 34 deletions(-) diff --git a/_build/build.config.php b/_build/build.config.php index 9124ba7eb..861b1b9bd 100644 --- a/_build/build.config.php +++ b/_build/build.config.php @@ -4,7 +4,7 @@ const PKG_NAME = 'miniShop2'; define('PKG_NAME_LOWER', strtolower(PKG_NAME)); -const PKG_VERSION = '3.0.0'; +const PKG_VERSION = '3.0.1'; const PKG_RELEASE = 'pl'; const PKG_AUTO_INSTALL = true; diff --git a/core/components/minishop2/docs/changelog.txt b/core/components/minishop2/docs/changelog.txt index 22d689b41..49e96d860 100644 --- a/core/components/minishop2/docs/changelog.txt +++ b/core/components/minishop2/docs/changelog.txt @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [3.0.1-pl] - 2022-05-04 + +### Changed +- Old controllers msCartHandler, msOrderHandler, msDeliveryHandler, msPaymentHandler are marked as deprecated with usage error logged +- The configuration required for JS controllers no longer depends on the included js files and is always available +- DB storage controllers got additional checks +- Update Copyrights + ## [3.0.0-pl] - 2022-04-27 ### Added diff --git a/core/components/minishop2/docs/readme.txt b/core/components/minishop2/docs/readme.txt index 4a3d392b3..bfa2016de 100644 --- a/core/components/minishop2/docs/readme.txt +++ b/core/components/minishop2/docs/readme.txt @@ -2,7 +2,9 @@ miniShop2 -------------------- Author: Vasiliy Naumkin +Owner: MODX RSC – Russian Speaking Community https://github.com/modx-pro +Support and development Nikolay Savin https://t.me/biz87 -------------------- Feel free to suggest ideas/improvements/bugs on GitHub: -http://github.com/bezumkin/miniShop2/issues +https://github.com/modx-pro/miniShop2 diff --git a/core/components/minishop2/elements/plugins/plugin.minishop2.php b/core/components/minishop2/elements/plugins/plugin.minishop2.php index b87f477c5..bb7299bdd 100644 --- a/core/components/minishop2/elements/plugins/plugin.minishop2.php +++ b/core/components/minishop2/elements/plugins/plugin.minishop2.php @@ -33,6 +33,7 @@ break; case 'OnLoadWebDocument': + /** @var miniShop2 $miniShop2 */ $miniShop2 = $modx->getService('miniShop2'); $registerFrontend = $modx->getOption('ms2_register_frontend', null, '1'); if ($miniShop2 && $registerFrontend) { diff --git a/core/components/minishop2/handlers/storage/db/cartdbhandler.class.php b/core/components/minishop2/handlers/storage/db/cartdbhandler.class.php index 587025c1f..5dde25a07 100644 --- a/core/components/minishop2/handlers/storage/db/cartdbhandler.class.php +++ b/core/components/minishop2/handlers/storage/db/cartdbhandler.class.php @@ -119,6 +119,10 @@ public function add($cartItem) public function change($key, $count) { + if (empty($this->products)) { + return $this->get(); + } + foreach ($this->products as $product) { $properties = $product->get('properties'); if ($key === $properties['key']) { @@ -137,6 +141,9 @@ public function change($key, $count) public function remove($key) { + if (empty($this->products)) { + return $this->get(); + } foreach ($this->products as $k => $product) { $properties = $product->get('properties'); if ($key === $properties['key']) { diff --git a/core/components/minishop2/handlers/storage/db/orderdbhandler.class.php b/core/components/minishop2/handlers/storage/db/orderdbhandler.class.php index 04bdd1c9b..e901e8785 100644 --- a/core/components/minishop2/handlers/storage/db/orderdbhandler.class.php +++ b/core/components/minishop2/handlers/storage/db/orderdbhandler.class.php @@ -32,6 +32,9 @@ public function get() public function add($key, $value = '') { + if (empty($this->msOrder)) { + return $this->get(); + } switch ($key) { case 'delivery': case 'payment': @@ -49,6 +52,9 @@ public function add($key, $value = '') public function remove($key) { + if (empty($this->msOrder)) { + return $this->get(); + } switch ($key) { case 'delivery': case 'payment': @@ -65,6 +71,9 @@ public function remove($key) public function clean() { + if (empty($this->msOrder)) { + return []; + } $fields = $this->get(); foreach ($fields as $key => $value) { switch ($key) { diff --git a/core/components/minishop2/lexicon/ru/setting.inc.php b/core/components/minishop2/lexicon/ru/setting.inc.php index b3ce214c4..cfc0593a3 100644 --- a/core/components/minishop2/lexicon/ru/setting.inc.php +++ b/core/components/minishop2/lexicon/ru/setting.inc.php @@ -130,7 +130,7 @@ По умолчанию к настройкам jgrowl.
Если вы хотите использовать собственную библиотеку - укажите путь к ее настройкам здесь, или очистите параметр и загрузите их вручную через шаблон сайта."; $_lang['setting_ms2_register_frontend'] = 'Добавлять js и css из комплекта ms2 файлы в DOM дерево'; -$_lang['setting_ms2_register_frontend_desc'] = "Разрешить добавление в DOM дерево ссылок на js и css файлы из комплекта ms2"; +$_lang['setting_ms2_register_frontend_desc'] = 'Разрешить добавление в DOM дерево ссылок на js и css файлы из комплекта ms2'; $_lang['setting_ms2_payment_paypal_api_url'] = 'Url api запросов PayPal'; diff --git a/core/components/minishop2/model/minishop2/minishop2.class.php b/core/components/minishop2/model/minishop2/minishop2.class.php index 8a2c9b01a..7424f2c47 100644 --- a/core/components/minishop2/model/minishop2/minishop2.class.php +++ b/core/components/minishop2/model/minishop2/minishop2.class.php @@ -2,7 +2,7 @@ class miniShop2 { - public $version = '3.0.0-pl'; + public $version = '3.0.1-pl'; /** @var modX $modx */ public $modx; /** @var pdoFetch $pdoTools */ @@ -120,34 +120,34 @@ public function registerFrontend($ctx = 'web') $js .= '?v=' . substr(md5($this->version), 0, 10); } $this->modx->regClientScript(str_replace($config['pl'], $config['vl'], $js)); + } + + $message_setting = array( + 'close_all_message' => $this->modx->lexicon('ms2_message_close_all'), + ); - $message_setting = array( - 'close_all_message' => $this->modx->lexicon('ms2_message_close_all'), - ); - - $js_setting = array( - 'cssUrl' => $this->config['cssUrl'] . 'web/', - 'jsUrl' => $this->config['jsUrl'] . 'web/', - 'actionUrl' => $this->config['actionUrl'], - 'ctx' => $ctx, - 'price_format' => json_decode( - $this->modx->getOption('ms2_price_format', null, '[2, ".", " "]'), - true - ), - 'price_format_no_zeros' => (bool)$this->modx->getOption('ms2_price_format_no_zeros', null, true), - 'weight_format' => json_decode( - $this->modx->getOption('ms2_weight_format', null, '[3, ".", " "]'), - true - ), - 'weight_format_no_zeros' => (bool)$this->modx->getOption('ms2_weight_format_no_zeros', null, true), - ); - - $data = json_encode(array_merge($message_setting, $js_setting), true); - $this->modx->regClientStartupScript( - '', + $js_setting = array( + 'cssUrl' => $this->config['cssUrl'] . 'web/', + 'jsUrl' => $this->config['jsUrl'] . 'web/', + 'actionUrl' => $this->config['actionUrl'], + 'ctx' => $ctx, + 'price_format' => json_decode( + $this->modx->getOption('ms2_price_format', null, '[2, ".", " "]'), true - ); - } + ), + 'price_format_no_zeros' => (bool)$this->modx->getOption('ms2_price_format_no_zeros', null, true), + 'weight_format' => json_decode( + $this->modx->getOption('ms2_weight_format', null, '[3, ".", " "]'), + true + ), + 'weight_format_no_zeros' => (bool)$this->modx->getOption('ms2_weight_format_no_zeros', null, true), + ); + + $data = json_encode(array_merge($message_setting, $js_setting), true); + $this->modx->regClientStartupScript( + '', + true + ); // Register notify plugin JS $message_js = trim($this->modx->getOption('ms2_frontend_message_js')); diff --git a/core/components/minishop2/model/minishop2/mscarthandler.class.php b/core/components/minishop2/model/minishop2/mscarthandler.class.php index 90a1f44f5..eb0e33921 100644 --- a/core/components/minishop2/model/minishop2/mscarthandler.class.php +++ b/core/components/minishop2/model/minishop2/mscarthandler.class.php @@ -1,4 +1,4 @@ modx->log(1, 'Deprecated: use handlers from catalog core/components/minishop2/handlers/'); require_once dirname(__FILE__, 3) . '/handlers/mscarthandler.class.php'; diff --git a/core/components/minishop2/model/minishop2/msdeliveryhandler.class.php b/core/components/minishop2/model/minishop2/msdeliveryhandler.class.php index 0830a033e..2ba5f685b 100644 --- a/core/components/minishop2/model/minishop2/msdeliveryhandler.class.php +++ b/core/components/minishop2/model/minishop2/msdeliveryhandler.class.php @@ -1,4 +1,4 @@ modx->log(1, 'Deprecated: use handlers from catalog core/components/minishop2/handlers/'); require_once dirname(__FILE__, 3) . '/handlers/msdeliveryhandler.class.php'; diff --git a/core/components/minishop2/model/minishop2/msorderhandler.class.php b/core/components/minishop2/model/minishop2/msorderhandler.class.php index ccd9cb5a3..cec2d84ca 100644 --- a/core/components/minishop2/model/minishop2/msorderhandler.class.php +++ b/core/components/minishop2/model/minishop2/msorderhandler.class.php @@ -1,4 +1,4 @@ modx->log(1, 'Deprecated: use handlers from catalog core/components/minishop2/handlers/'); require_once dirname(__FILE__, 3) . '/handlers/msorderhandler.class.php'; diff --git a/core/components/minishop2/model/minishop2/mspaymenthandler.class.php b/core/components/minishop2/model/minishop2/mspaymenthandler.class.php index 81293a3a9..d1f23ce27 100644 --- a/core/components/minishop2/model/minishop2/mspaymenthandler.class.php +++ b/core/components/minishop2/model/minishop2/mspaymenthandler.class.php @@ -1,4 +1,4 @@ modx->log(1, 'Deprecated: use handlers from catalog core/components/minishop2/handlers/'); require_once dirname(__FILE__, 3) . '/handlers/mspaymenthandler.class.php';