From bbede4145c4be6fbc767224a6fa6f8d418e59e5d Mon Sep 17 00:00:00 2001 From: chuccv Date: Thu, 22 Jun 2023 08:53:20 +0700 Subject: [PATCH 1/6] - add extractBody form oldOfZend --- Helper/AbstractData.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Helper/AbstractData.php b/Helper/AbstractData.php index c56a053..73928ff 100755 --- a/Helper/AbstractData.php +++ b/Helper/AbstractData.php @@ -352,4 +352,19 @@ public function getEdition() { return $this->objectManager->get(ProductMetadataInterface::class)->getEdition(); } + + /** + * Extract the body from a response string + * + * @param string $response_str + * @return string + */ + public static function extractBody($response_str) + { + $parts = preg_split('|(?:\r\n){2}|m', $response_str, 2); + if (isset($parts[1])) { + return $parts[1]; + } + return ''; + } } From d3ea3e363b11737f1b869a6bc11a1e258dfab40d Mon Sep 17 00:00:00 2001 From: chuccv Date: Tue, 4 Jul 2023 11:19:32 +0700 Subject: [PATCH 2/6] - use ColorPicker --- Helper/AbstractData.php | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/Helper/AbstractData.php b/Helper/AbstractData.php index 73928ff..de5e5a4 100755 --- a/Helper/AbstractData.php +++ b/Helper/AbstractData.php @@ -82,7 +82,7 @@ public function __construct( StoreManagerInterface $storeManager ) { $this->objectManager = $objectManager; - $this->storeManager = $storeManager; + $this->storeManager = $storeManager; parent::__construct($context); } @@ -111,7 +111,7 @@ public function isEnabledNotificationUpdate($storeId = null) $noticeType = in_array(NoticeType::TYPE_NEWUPDATE, $noticeType); } - return $isEnable && $noticeType; + return $isEnable && $noticeType; } /** @@ -207,7 +207,7 @@ public function getCurrentUrl() public function versionCompare($ver, $operator = '>=') { $productMetadata = $this->objectManager->get(ProductMetadataInterface::class); - $version = $productMetadata->getVersion(); //will return the magento version + $version = $productMetadata->getVersion(); //will return the magento version return version_compare($version, $ver, $operator); } @@ -357,6 +357,7 @@ public function getEdition() * Extract the body from a response string * * @param string $response_str + * * @return string */ public static function extractBody($response_str) @@ -365,6 +366,36 @@ public static function extractBody($response_str) if (isset($parts[1])) { return $parts[1]; } + return ''; } + + /** + * getHtmlJqColorPicker + * + * @param string $htmlId + * @param string $value + * + * @return string + */ + public static function getHtmlJqColorPicker(string $htmlId, string $value) + { + return << + require(["jquery","jquery/colorpicker/js/colorpicker"], function ($) { + $(document).ready(function () { + + var el = $("#{$htmlId}"); + el.css("backgroundColor", "{$value}"); + el.ColorPicker({ + color: "{$value}", + onChange: function (hsb, hex, rgb) { + el.css("backgroundColor", "#" + hex).val("#" + hex); + } + }); + }); + }); + +HTML; + } } From 49032afbcd72213448a06fe6f1dec822137fda3c Mon Sep 17 00:00:00 2001 From: chuccv Date: Tue, 4 Jul 2023 17:10:36 +0700 Subject: [PATCH 3/6] - fix Index for SocialId --- Helper/AbstractData.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Helper/AbstractData.php b/Helper/AbstractData.php index de5e5a4..6a6ca46 100755 --- a/Helper/AbstractData.php +++ b/Helper/AbstractData.php @@ -378,7 +378,7 @@ public static function extractBody($response_str) * * @return string */ - public static function getHtmlJqColorPicker(string $htmlId, string $value) + public static function getHtmlJqColorPicker(string $htmlId, $value = '') { return << From bea11aa329318fd2afffba9c6ff7667f72319c31 Mon Sep 17 00:00:00 2001 From: chuccv Date: Wed, 5 Jul 2023 08:35:03 +0700 Subject: [PATCH 4/6] - format code --- Block/Adminhtml/System/Config/ColorPicker.php | 23 +++++-------------- Helper/AbstractData.php | 6 ++--- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/Block/Adminhtml/System/Config/ColorPicker.php b/Block/Adminhtml/System/Config/ColorPicker.php index 621e9df..c9eecfe 100644 --- a/Block/Adminhtml/System/Config/ColorPicker.php +++ b/Block/Adminhtml/System/Config/ColorPicker.php @@ -24,13 +24,14 @@ use Magento\Backend\Block\Template\Context; use Magento\Config\Block\System\Config\Form\Field; use Magento\Framework\Data\Form\Element\AbstractElement; +use Mageplaza\Core\Helper\AbstractData; /** * Class ColorPicker * @package Mageplaza\Core\Block\Adminhtml\System\Config */ -class ColorPicker extends Field { - +class ColorPicker extends Field +{ /** * Colorpicker constructor. * @@ -38,7 +39,8 @@ class ColorPicker extends Field { * @param array $data */ public function __construct( - Context $context, array $data = [] + Context $context, + array $data = [] ) { parent::__construct($context, $data); } @@ -53,20 +55,7 @@ protected function _getElementHtml(AbstractElement $element) $html = $element->getElementHtml(); $value = $element->getData('value'); - $html .= ''; + $html .= AbstractData::getHtmlJqColorPicker($element->getHtmlId(), $value); return $html; } diff --git a/Helper/AbstractData.php b/Helper/AbstractData.php index 6a6ca46..6afce9b 100755 --- a/Helper/AbstractData.php +++ b/Helper/AbstractData.php @@ -373,8 +373,8 @@ public static function extractBody($response_str) /** * getHtmlJqColorPicker * - * @param string $htmlId - * @param string $value + * @param string $htmlId // id of the input html + * @param string|null $value * * @return string */ @@ -395,7 +395,7 @@ public static function getHtmlJqColorPicker(string $htmlId, $value = '') }); }); }); - + HTML; } } From 5cead9e8ac43996779623ac510adbbe76069d593 Mon Sep 17 00:00:00 2001 From: chuccv Date: Tue, 18 Jul 2023 08:24:55 +0700 Subject: [PATCH 5/6] - check if DEV_ENV. --- Helper/Validate.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Helper/Validate.php b/Helper/Validate.php index 0fd2a3f..916fccc 100755 --- a/Helper/Validate.php +++ b/Helper/Validate.php @@ -34,7 +34,7 @@ class Validate extends AbstractData { const MODULE_TYPE_FREE = 1; const MODULE_TYPE_PAID = 2; -// const DEV_ENV = ['localhost', 'dev', '127.0.0.1', '192.168.', 'demo.']; + // const DEV_ENV = ['localhost', 'dev', '127.0.0.1', '192.168.', 'demo.']; const DEV_ENV = []; /** @@ -170,11 +170,13 @@ public function getModuleList() $this->_mageplazaModules = []; $allowList = true; - $hostName = $this->_urlBuilder->getBaseUrl(); - foreach (self::DEV_ENV as $env) { - if (strpos($hostName, $env) !== false) { - $allowList = false; - break; + if (count(self::DEV_ENV)) { + $hostName = $this->_urlBuilder->getBaseUrl(); + foreach (self::DEV_ENV as $env) { + if (strpos($hostName, $env) !== false) { + $allowList = false; + break; + } } } From 1d3f569a33519e34a33871e28cd1860f1d2ace8d Mon Sep 17 00:00:00 2001 From: chuccv Date: Tue, 18 Jul 2023 09:00:15 +0700 Subject: [PATCH 6/6] -update composer --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 649943d..f0c5b80 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "mageplaza/module-core", "description": "Mageplaza Core for Magento 2", "type": "magento2-module", - "version": "1.5.3", + "version": "1.5.4", "license": "proprietary", "authors": [ {