Skip to content

Commit

Permalink
Merge pull request #70 from mageplaza/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
chuccv authored Jul 18, 2023
2 parents 569d041 + 1d3f569 commit ecd2f68
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 27 deletions.
23 changes: 6 additions & 17 deletions Block/Adminhtml/System/Config/ColorPicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,23 @@
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.
*
* @param Context $context
* @param array $data
*/
public function __construct(
Context $context, array $data = []
Context $context,
array $data = []
) {
parent::__construct($context, $data);
}
Expand All @@ -53,20 +55,7 @@ protected function _getElementHtml(AbstractElement $element)
$html = $element->getElementHtml();
$value = $element->getData('value');

$html .= '<script type="text/javascript">
require(["jquery","jquery/colorpicker/js/colorpicker"], function ($) {
$(document).ready(function () {
var $el = $("#' . $element->getHtmlId() . '");
$el.css("backgroundColor", "' . $value . '");
$el.ColorPicker({
color: "' . $value . '",
onChange: function (hsb, hex, rgb) {
$el.css("backgroundColor", "#" + hex).val("#" + hex);
}
});
});
});
</script>';
$html .= AbstractData::getHtmlJqColorPicker($element->getHtmlId(), $value);

return $html;
}
Expand Down
52 changes: 49 additions & 3 deletions Helper/AbstractData.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function __construct(
StoreManagerInterface $storeManager
) {
$this->objectManager = $objectManager;
$this->storeManager = $storeManager;
$this->storeManager = $storeManager;

parent::__construct($context);
}
Expand Down Expand Up @@ -111,7 +111,7 @@ public function isEnabledNotificationUpdate($storeId = null)
$noticeType = in_array(NoticeType::TYPE_NEWUPDATE, $noticeType);
}

return $isEnable && $noticeType;
return $isEnable && $noticeType;
}

/**
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -352,4 +352,50 @@ 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 '';
}

/**
* getHtmlJqColorPicker
*
* @param string $htmlId // id of the input html
* @param string|null $value
*
* @return string
*/
public static function getHtmlJqColorPicker(string $htmlId, $value = '')
{
return <<<HTML
<script type="text/javascript">
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);
}
});
});
});
</script>
HTML;
}
}
14 changes: 8 additions & 6 deletions Helper/Validate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];

/**
Expand Down Expand Up @@ -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;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down

0 comments on commit ecd2f68

Please sign in to comment.