ltsecurityinc安防产品在线商城代码
This commit is contained in:
+54
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Plumrocket_Base
|
||||
* @copyright Copyright (c) 2020 Plumrocket Inc. (https://plumrocket.com)
|
||||
* @license https://plumrocket.com/license End-user License Agreement
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Plumrocket\Base\Block\Adminhtml\System\Config\Developer;
|
||||
|
||||
use Magento\Config\Block\System\Config\Form\Field;
|
||||
use Magento\Framework\Data\Form\Element\AbstractElement;
|
||||
|
||||
/**
|
||||
* @since 2.3.0
|
||||
*/
|
||||
class DebugInfo extends Field
|
||||
{
|
||||
/**
|
||||
* Customize button.
|
||||
*
|
||||
* @param AbstractElement $element
|
||||
* @return string
|
||||
*/
|
||||
protected function _getElementHtml(AbstractElement $element)
|
||||
{
|
||||
$element->setData('value', __('Download Technical Report'));
|
||||
$element->setData('class', 'action-default');
|
||||
$element->setData('onclick', "window.location.assign('{$this->getActionUrl()}')");
|
||||
return parent::_getElementHtml($element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get download url.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getActionUrl(): string
|
||||
{
|
||||
return $this->_urlBuilder->getUrl('plumbase/debug/download');
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable scope label.
|
||||
*
|
||||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
|
||||
* @return string
|
||||
*/
|
||||
protected function _renderScopeLabel(AbstractElement $element): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Plumrocket_Base
|
||||
* @copyright Copyright (c) 2020 Plumrocket Inc. (https://plumrocket.com)
|
||||
* @license https://plumrocket.com/license End-user License Agreement
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Plumrocket\Base\Block\Adminhtml\System\Config\Developer;
|
||||
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Config\Block\System\Config\Form\Field;
|
||||
use Magento\Framework\App\Filesystem\DirectoryList;
|
||||
use Magento\Framework\Data\Form\Element\AbstractElement;
|
||||
use Magento\Framework\Stdlib\DateTime\DateTime;
|
||||
|
||||
/**
|
||||
* @since 2.3.0
|
||||
*/
|
||||
class MagentoInfo extends Field
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\App\Filesystem\DirectoryList
|
||||
*/
|
||||
private $directoryList;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\Stdlib\DateTime\DateTime
|
||||
*/
|
||||
private $dateTime;
|
||||
|
||||
/**
|
||||
* MagentoInfo constructor.
|
||||
*
|
||||
* @param \Magento\Backend\Block\Template\Context $context
|
||||
* @param \Magento\Framework\App\Filesystem\DirectoryList $directoryList
|
||||
* @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
DirectoryList $directoryList,
|
||||
DateTime $dateTime,
|
||||
array $data = []
|
||||
) {
|
||||
parent::__construct($context, $data);
|
||||
$this->directoryList = $directoryList;
|
||||
$this->dateTime = $dateTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render fieldset html
|
||||
*
|
||||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
|
||||
* @return string
|
||||
*/
|
||||
public function render(AbstractElement $element) : string
|
||||
{
|
||||
$field = (string) $element->getData('field_config/id');
|
||||
$element->setValue($this->getMagentoData($field));
|
||||
return parent::render($element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get magento detail.
|
||||
*
|
||||
* @param string $field
|
||||
* @return string
|
||||
*/
|
||||
private function getMagentoData(string $field)
|
||||
{
|
||||
switch ($field) {
|
||||
case 'magento_mode':
|
||||
return $this->_appState->getMode();
|
||||
case 'magento_path':
|
||||
return $this->directoryList->getRoot();
|
||||
case 'time':
|
||||
return $this->dateTime->date();
|
||||
case 'php_server_logs_status':
|
||||
return ini_get('log_errors') ? "Enabled" : "Disabled";
|
||||
case 'php_server_logs_path':
|
||||
return ini_get('error_log') ?? '';
|
||||
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable scope label.
|
||||
*
|
||||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
|
||||
* @return string
|
||||
*/
|
||||
protected function _renderScopeLabel(AbstractElement $element) : string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Plumrocket_Base
|
||||
* @copyright Copyright (c) 2020 Plumrocket Inc. (https://plumrocket.com)
|
||||
* @license https://plumrocket.com/license End-user License Agreement
|
||||
*/
|
||||
|
||||
namespace Plumrocket\Base\Block\Adminhtml\System\Config\Form;
|
||||
|
||||
use Magento\Backend\Block\Template;
|
||||
use Magento\Framework\Data\Form\Element\AbstractElement;
|
||||
use Magento\Framework\Data\Form\Element\Renderer\RendererInterface;
|
||||
|
||||
/**
|
||||
* @deprecated since 2.3.1
|
||||
* @see \Plumrocket\Base\Block\Adminhtml\System\Config\Form\ColorPicker
|
||||
*/
|
||||
class Color extends Template implements RendererInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_template = 'Plumrocket_Base::system/config/color.phtml';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_pathId;
|
||||
|
||||
/**
|
||||
* Render fieldset html
|
||||
*
|
||||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
|
||||
* @return string
|
||||
*/
|
||||
public function render(AbstractElement $element)
|
||||
{
|
||||
$this->_pathId = str_replace('__', '_', $element->getId());
|
||||
return $this->toHtml();
|
||||
}
|
||||
|
||||
/**
|
||||
* Receive path id
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPathId()
|
||||
{
|
||||
return $this->_pathId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Plumrocket_Base
|
||||
* @copyright Copyright (c) 2020 Plumrocket Inc. (https://plumrocket.com)
|
||||
* @license https://plumrocket.com/license End-user License Agreement
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Plumrocket\Base\Block\Adminhtml\System\Config\Form;
|
||||
|
||||
use Magento\Backend\Block\Template;
|
||||
use Magento\Config\Block\System\Config\Form\Field;
|
||||
use Magento\Framework\Data\Form\Element\AbstractElement;
|
||||
|
||||
/**
|
||||
* Color picker for system settings
|
||||
*
|
||||
* For using you have to load Plumrocket_Base::css/lib/pickr/monolith.min.css on the page
|
||||
*
|
||||
* @since 2.3.1
|
||||
* @deprecated since 2.5.4
|
||||
* @see \Plumrocket\ExtendedAdminUi\Block\Adminhtml\System\Config\Form\ColorPicker
|
||||
*/
|
||||
class ColorPicker extends Field
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function _getElementHtml(AbstractElement $element)
|
||||
{
|
||||
$element->addClass('pr-color-picker-value');
|
||||
|
||||
$pickerPlaceholderId = $element->getHtmlId() . '_color_picker';
|
||||
$pickerContainerHtml = '<div id="' . $pickerPlaceholderId . '"></div>' ;
|
||||
|
||||
/** @var Template $pickerConfigsBlock */
|
||||
$pickerConfigsBlock = $this->getLayout()->createBlock(Template::class);
|
||||
$pickerConfigsBlock
|
||||
->setTemplate('Plumrocket_Base::system/config/color_picker.phtml')
|
||||
->setData('elementId', $element->getHtmlId())
|
||||
->setData('pickerId', $pickerPlaceholderId)
|
||||
->setData('currentValue', $element->getEscapedValue())
|
||||
->setData('disabled', $element->getData('disabled'));
|
||||
|
||||
return "{$pickerContainerHtml}{$element->getElementHtml()}{$pickerConfigsBlock->toHtml()}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Decorate field row html
|
||||
*
|
||||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
|
||||
* @param string $html
|
||||
* @return string
|
||||
*/
|
||||
protected function _decorateRowHtml(AbstractElement $element, $html)
|
||||
{
|
||||
return '<tr id="row_' . $element->getHtmlId() . '" class="pr-color-picker-field">' . $html . '</tr>';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Plumrocket_Base
|
||||
* @copyright Copyright (c) 2020 Plumrocket Inc. (https://plumrocket.com)
|
||||
* @license https://plumrocket.com/license End-user License Agreement
|
||||
*/
|
||||
|
||||
namespace Plumrocket\Base\Block\Adminhtml\System\Config\Form;
|
||||
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Cms\Model\Wysiwyg\Config;
|
||||
use Magento\Config\Block\System\Config\Form\Field;
|
||||
use Magento\Framework\Data\Form\Element\AbstractElement;
|
||||
|
||||
/**
|
||||
* @deprecated since 2.5.10 - base should not contain shared admin UI elements except Serial and Version.
|
||||
* @see \Plumrocket\ExtendedAdminUi\Block\Adminhtml\System\Config\Form\Editor
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Editor extends Field
|
||||
{
|
||||
/**
|
||||
* If field has attribute witch started with this prefix, value will be set to wysiwyg config
|
||||
* Wysiwyg key is symbols after prefix
|
||||
* @since 2.3.1
|
||||
*/
|
||||
public const EDITOR_CONFIG_ATTRIBUTE_PREFIX = 'pr_editor_';
|
||||
|
||||
/**
|
||||
* @var \Magento\Cms\Model\Wysiwyg\Config
|
||||
*/
|
||||
protected $_wysiwygConfig;
|
||||
|
||||
/**
|
||||
* @param \Magento\Backend\Block\Template\Context $context
|
||||
* @param \Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Config $wysiwygConfig,
|
||||
array $data = []
|
||||
) {
|
||||
$this->_wysiwygConfig = $wysiwygConfig;
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get element html
|
||||
*
|
||||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
|
||||
* @return string
|
||||
*/
|
||||
protected function _getElementHtml(AbstractElement $element)
|
||||
{
|
||||
$fieldConfig = $element->getData('field_config');
|
||||
|
||||
$config = $this->_wysiwygConfig->getConfig();
|
||||
|
||||
foreach ($fieldConfig as $key => $value) {
|
||||
if (strpos($key, self::EDITOR_CONFIG_ATTRIBUTE_PREFIX) === 0) {
|
||||
$wysiwygKey = str_replace(self::EDITOR_CONFIG_ATTRIBUTE_PREFIX, '', $key);
|
||||
$config->setData($wysiwygKey, $value);
|
||||
}
|
||||
}
|
||||
|
||||
$element->setConfig($config);
|
||||
|
||||
return $element->getElementHtml() . $this->_getJs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Receive js html
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function _getJs()
|
||||
{
|
||||
return "<script>require(['Magento_Variable/variables']);</script>";
|
||||
}
|
||||
}
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Plumrocket_Base
|
||||
* @copyright Copyright (c) 2020 Plumrocket Inc. (https://plumrocket.com)
|
||||
* @license https://plumrocket.com/license End-user License Agreement
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Plumrocket\Base\Block\Adminhtml\System\Config\Form;
|
||||
|
||||
use Magento\Backend\Block\Template;
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Framework\Data\Form\Element\AbstractElement;
|
||||
use Magento\Framework\Data\Form\Element\Renderer\RendererInterface;
|
||||
use Magento\Framework\Phrase;
|
||||
use Plumrocket\Base\Model\Extension\GetInstallationType;
|
||||
use Plumrocket\Base\ViewModel\GetExtensionInformationWithUpdates;
|
||||
|
||||
/**
|
||||
* @since 2.3.0
|
||||
*/
|
||||
class Extensions extends Template implements RendererInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_template = 'Plumrocket_Base::system/config/extensions.phtml';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $htmlId = '';
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\Base\ViewModel\GetExtensionInformationWithUpdates
|
||||
*/
|
||||
private $extensionInformationWithUpdates;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\Base\Model\Extension\GetInstallationType
|
||||
*/
|
||||
private $getInstallationType;
|
||||
|
||||
/**
|
||||
* Extensions constructor.
|
||||
*
|
||||
* @param \Magento\Backend\Block\Template\Context $context
|
||||
* @param \Plumrocket\Base\ViewModel\GetExtensionInformationWithUpdates $extensionInformationWithUpdates
|
||||
* @param \Plumrocket\Base\Model\Extension\GetInstallationType $getInstallationType
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
GetExtensionInformationWithUpdates $extensionInformationWithUpdates,
|
||||
GetInstallationType $getInstallationType,
|
||||
array $data = []
|
||||
) {
|
||||
parent::__construct($context, $data);
|
||||
$this->extensionInformationWithUpdates = $extensionInformationWithUpdates;
|
||||
$this->getInstallationType = $getInstallationType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render fieldset html
|
||||
*
|
||||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
|
||||
* @return string
|
||||
*/
|
||||
public function render(AbstractElement $element): string
|
||||
{
|
||||
$this->htmlId = $element->getId();
|
||||
return $this->toHtml();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of extensions.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getExtensions(): array
|
||||
{
|
||||
return $this->extensionInformationWithUpdates->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get label.
|
||||
*
|
||||
* @param array $extension
|
||||
* @return string
|
||||
*/
|
||||
public function getLabel(array $extension): string
|
||||
{
|
||||
$installationType = $this->getInstallationType->execute($extension['moduleName']);
|
||||
if ($installationType === GetInstallationType::COMPOSER_INSTALL_TYPE) {
|
||||
return "{$extension['name']} {$extension['installedVersion']} (composer)";
|
||||
}
|
||||
return "{$extension['name']} {$extension['installedVersion']}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get label for extension with available update.
|
||||
*
|
||||
* @param array $extension
|
||||
* @return \Magento\Framework\Phrase
|
||||
*/
|
||||
public function getNewUpdateLabel(array $extension): Phrase
|
||||
{
|
||||
$count = count($extension['updates']);
|
||||
return $count === 1 ? __('New Update Available') : __('%1 New Updates Available', $count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get html id.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHtmlId(): string
|
||||
{
|
||||
return $this->htmlId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,283 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Plumrocket_Base
|
||||
* @copyright Copyright (c) 2020 Plumrocket Inc. (https://plumrocket.com)
|
||||
* @license https://plumrocket.com/license End-user License Agreement
|
||||
*/
|
||||
|
||||
namespace Plumrocket\Base\Block\Adminhtml\System\Config\Form;
|
||||
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Config\Block\System\Config\Form\Field;
|
||||
use Magento\Framework\Data\Form\Element\AbstractElement;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Plumrocket\Base\Api\ExtensionAuthorizationRepositoryInterface;
|
||||
use Plumrocket\Base\Model\Extension\Authorization\Factory;
|
||||
use Plumrocket\Base\Model\Extension\Authorization\Key;
|
||||
use Plumrocket\Base\Model\IsModuleInMarketplace;
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Serial extends Field
|
||||
{
|
||||
/**
|
||||
* @var \Plumrocket\Base\Model\IsModuleInMarketplace
|
||||
*/
|
||||
private $isModuleInMarketplace;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\Base\Api\ExtensionAuthorizationRepositoryInterface
|
||||
*/
|
||||
private $extensionAuthorizationRepository;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\Base\Model\Extension\Authorization\Key
|
||||
*/
|
||||
private $authorizationKey;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\Base\Model\Extension\Authorization\Factory
|
||||
*/
|
||||
private $extensionAuthorizationFactory;
|
||||
|
||||
/**
|
||||
* @param \Magento\Backend\Block\Template\Context $context
|
||||
* @param \Plumrocket\Base\Model\IsModuleInMarketplace $isModuleInMarketplace
|
||||
* @param \Plumrocket\Base\Api\ExtensionAuthorizationRepositoryInterface $extensionAuthorizationRepository
|
||||
* @param \Plumrocket\Base\Model\Extension\Authorization\Key $authorizationKey
|
||||
* @param \Plumrocket\Base\Model\Extension\Authorization\Factory $extensionAuthorizationFactory
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
IsModuleInMarketplace $isModuleInMarketplace,
|
||||
ExtensionAuthorizationRepositoryInterface $extensionAuthorizationRepository,
|
||||
Key $authorizationKey,
|
||||
Factory $extensionAuthorizationFactory,
|
||||
array $data = []
|
||||
) {
|
||||
parent::__construct($context, $data);
|
||||
$this->isModuleInMarketplace = $isModuleInMarketplace;
|
||||
$this->extensionAuthorizationRepository = $extensionAuthorizationRepository;
|
||||
$this->authorizationKey = $authorizationKey;
|
||||
$this->extensionAuthorizationFactory = $extensionAuthorizationFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render element value
|
||||
*
|
||||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
|
||||
* @return string
|
||||
*/
|
||||
protected function _renderValue(AbstractElement $element)
|
||||
{
|
||||
$html = '<td class="value with-tooltip">';
|
||||
$html .= $this->_getElementHtml($element);
|
||||
|
||||
$moduleName = $this->getModuleNameFromElement($element);
|
||||
|
||||
try {
|
||||
$authorization = $this->extensionAuthorizationRepository->get($moduleName);
|
||||
} catch (NoSuchEntityException $e) {
|
||||
$authorization = $this->extensionAuthorizationFactory->create($moduleName);
|
||||
}
|
||||
if ($this->authorizationKey->get($moduleName)) {
|
||||
if ($authorization->isAuthorized()) {
|
||||
$title = 'Thank you! Your serial key is accepted. You can start using extension.';
|
||||
$icon = $this->getViewFileUrl('Plumrocket_Base::images/success_msg_icon.gif');
|
||||
$html .= '<div class="tooltip">' .
|
||||
"<span><span><img src=\"{$icon}\" style=\"margin-top: 2px;float: right;\" /></span></span>";
|
||||
$html .= '<div class="tooltip-content">' . $title . '</div></div>';
|
||||
} else {
|
||||
$icon = $this->getViewFileUrl('Plumrocket_Base::images/error_msg_icon.gif');
|
||||
$html .= '<div class="tooltip">' .
|
||||
'<span><span><img src="'.$icon.'" style="margin-top: 2px;float: right;" /></span></span>' .
|
||||
'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->isModuleInMarketplace->execute($moduleName)) {
|
||||
$html .= '<p class="note">' .
|
||||
'<span>You can find Serial Key in your Plumrocket Store account. ' .
|
||||
'If you have any questions, please contact us at ' .
|
||||
'<a href="mailto:support@plumrocket.com">support@plumrocket.com</a>.</span></p>';
|
||||
} else {
|
||||
$html .= '<p class="note"><span>You can find <strong>Serial Key</strong> in your account at ' .
|
||||
'<a target="_blank" href="https://plumrocket.com/downloadable/customer/products">' .
|
||||
'plumrocket.com' .
|
||||
'</a>. For manual ' .
|
||||
'<a target="_blank" href="https://plumrocket.com/docs/general/magento-license-installation">' .
|
||||
'click here</a>.</span></p>';
|
||||
}
|
||||
|
||||
$html .= '</td>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve HTML markup for given form element
|
||||
*
|
||||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
|
||||
* @return string
|
||||
*/
|
||||
public function render(AbstractElement $element)
|
||||
{
|
||||
$fields = [
|
||||
'plumbase_order_id' => __('Marketplace Order ID'),
|
||||
'plumbase_account_email' => __('Marketplace Account Email')
|
||||
];
|
||||
|
||||
$moduleName = $this->getModuleNameFromElement($element);
|
||||
$hideMarketplaceFields = ! $this->isModuleInMarketplace->execute($moduleName) ? 'style="display:none;"' : '';
|
||||
$marketplaceFields = '';
|
||||
|
||||
if ($this->isModuleInMarketplace->execute($moduleName)) {
|
||||
$commentText = __(
|
||||
'You can find Marketplace Order ID and Email in your Magento Marketplace Account. ' .
|
||||
'If you have any questions, please contact us at ' .
|
||||
'<a href="mailto:support@plumrocket.com">support@plumrocket.com</a>'
|
||||
);
|
||||
} else {
|
||||
$commentText = __(
|
||||
'You can find Marketplace Order ID and Email in your Magento Marketplace Account. ' .
|
||||
'For manual <a target="_blank" href="%1">click here</a>.',
|
||||
'https://plumrocket.com/docs/general/marketplace-license-installation'
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($fields as $key => $value) {
|
||||
$comment = ($key === 'plumbase_account_email') ? '<p class="note">
|
||||
<span>' . $commentText . '</span></p>' : '';
|
||||
|
||||
$marketplaceFields .= '
|
||||
<tr ' . $hideMarketplaceFields . ' id="row_'. $key . '">
|
||||
<td class="label">
|
||||
<label for="' . $key . '">' . $value . '</label>
|
||||
</td>
|
||||
<td class="value">
|
||||
<input id="' . $key . '" class="input-text" type="text"/>
|
||||
' . $comment . '
|
||||
</td>
|
||||
</tr>
|
||||
';
|
||||
}
|
||||
|
||||
$marketplaceFields .= '
|
||||
<tr ' . $hideMarketplaceFields . '>
|
||||
<td class="label"></td>
|
||||
<td class="value">
|
||||
<button id="plumbase_activate_extension"
|
||||
title="' . __("Activate Extension") . '"
|
||||
type="button"
|
||||
class="scalable"
|
||||
onclick="false;">
|
||||
<span>
|
||||
<span>
|
||||
<span> ' . __("Activate Extension") . '</span>
|
||||
</span>
|
||||
</span>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
';
|
||||
|
||||
$serialKeyHtml = parent::render($element);
|
||||
$value = (string) $element->getValue();
|
||||
|
||||
if (empty($value) && $this->isModuleInMarketplace->execute($moduleName)) {
|
||||
$serialKeyHtml = str_replace("<tr", "<tr style='display:none;'", $serialKeyHtml)
|
||||
. $marketplaceFields . $this->_js($element->getHtmlId(), $moduleName);
|
||||
}
|
||||
|
||||
return $serialKeyHtml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get JavaScript code for serial key field.
|
||||
*
|
||||
* @param string $serialKeyId
|
||||
* @param string $moduleName
|
||||
* @return string
|
||||
*/
|
||||
private function _js(string $serialKeyId, string $moduleName): string
|
||||
{
|
||||
return "
|
||||
<script>
|
||||
require([
|
||||
'jquery',
|
||||
'mage/translate',
|
||||
'mage/storage',
|
||||
'Magento_Ui/js/modal/alert',
|
||||
'domReady!'
|
||||
], function ($, __, storage, alert) {
|
||||
var button = $('#plumbase_activate_extension'),
|
||||
orderId = $('#plumbase_order_id'),
|
||||
accountEmail = $('#plumbase_account_email'),
|
||||
serialKey = $('#" . $serialKeyId . "'),
|
||||
messageBlock = $(\".page-main-actions\"),
|
||||
plumbaseMessageBlockEl;
|
||||
|
||||
button.on('click', function(el) {
|
||||
jQuery('body').loader('show');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '" . $this->getUrl('plumbase/call') . "',
|
||||
data: {
|
||||
order_id :orderId.val(),
|
||||
account_email :accountEmail.val(),
|
||||
module :'" . $moduleName . "'
|
||||
},
|
||||
success: function(response) {
|
||||
var json = JSON.parse(response);
|
||||
|
||||
if (typeof json.data != 'undefined') {
|
||||
serialKey.val(json.data);
|
||||
}
|
||||
|
||||
if (typeof json.error != 'undefined') {
|
||||
var plbMessage = '<div id=\'plumbaseMessageBlockError\' class=\'message message-error error\'><div data-ui-id=\'messages-message-error\'>'
|
||||
+ json.error
|
||||
+ '</div></div><br>';
|
||||
|
||||
plumbaseMessageBlockEl = $('#plumbaseMessageBlockError');
|
||||
|
||||
if (plumbaseMessageBlockEl.length > 0) {
|
||||
plumbaseMessageBlockEl.html(json.error);
|
||||
} else if (messageBlock.length > 0) {
|
||||
messageBlock.after(plbMessage);
|
||||
}
|
||||
} else {
|
||||
plumbaseMessageBlockEl = $('#plumbaseMessageBlockError');
|
||||
if (plumbaseMessageBlockEl.length > 0) {
|
||||
plumbaseMessageBlockEl.hide();
|
||||
}
|
||||
}
|
||||
|
||||
if (json.hash) {
|
||||
serialKey.parents('tr').show();
|
||||
button.parents('tr').hide();
|
||||
orderId.parents('tr').hide();
|
||||
accountEmail.parents('tr').hide();
|
||||
}
|
||||
|
||||
jQuery('body').loader('hide');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get extension name from it xml.
|
||||
*
|
||||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
|
||||
* @return array|mixed|string
|
||||
*/
|
||||
public function getModuleNameFromElement(AbstractElement $element)
|
||||
{
|
||||
return $element->getData('field_config/pr_extension_name') ?: $element->getHint()->getText();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Plumrocket_Base
|
||||
* @copyright Copyright (c) 2022 Plumrocket Inc. (https://plumrocket.com)
|
||||
* @license https://plumrocket.com/license End-user License Agreement
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Plumrocket\Base\Block\Adminhtml\System\Config\Form;
|
||||
|
||||
use Magento\Framework\Data\Form\Element\AbstractElement;
|
||||
|
||||
/**
|
||||
* Toolbar fieldset without any visible elements.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
class ToolbarFieldset extends \Magento\Config\Block\System\Config\Form\Fieldset
|
||||
{
|
||||
|
||||
/**
|
||||
* Render field group without header and footer
|
||||
*
|
||||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
|
||||
* @return string
|
||||
*/
|
||||
public function render(AbstractElement $element)
|
||||
{
|
||||
$this->setElement($element);
|
||||
return $this->_getChildrenElementsHtml($element);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,257 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Plumrocket_Base
|
||||
* @copyright Copyright (c) 2020 Plumrocket Inc. (https://plumrocket.com)
|
||||
* @license https://plumrocket.com/license End-user License Agreement
|
||||
*/
|
||||
|
||||
namespace Plumrocket\Base\Block\Adminhtml\System\Config\Form;
|
||||
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Config\Block\System\Config\Form\Field;
|
||||
use Magento\Framework\Data\Form\Element\AbstractElement;
|
||||
use Magento\Framework\Exception\NotFoundException;
|
||||
use Magento\Framework\Serialize\SerializerInterface;
|
||||
use Plumrocket\Base\Api\Data\ExtensionInformationInterface;
|
||||
use Plumrocket\Base\Api\GetExtensionInformationInterface;
|
||||
use Plumrocket\Base\Api\GetModuleVersionInterface;
|
||||
use Plumrocket\Base\Model\Extension\Updates\Get;
|
||||
use Plumrocket\Base\Model\IsModuleInMarketplace;
|
||||
|
||||
/**
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Version extends Field
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_template = 'Plumrocket_Base::system/config/info_panel.phtml';
|
||||
|
||||
/**
|
||||
* @deprecated since 2.7.0
|
||||
* @var string
|
||||
* @see \Plumrocket\Base\Api\Data\ExtensionInformationInterface::getDocumentationLink
|
||||
*/
|
||||
protected $wikiLink;
|
||||
|
||||
/**
|
||||
* @deprecated since 2.7.0
|
||||
* @var string
|
||||
* @see \Plumrocket\Base\Api\Data\ExtensionInformationInterface::getTitle
|
||||
*/
|
||||
protected $moduleTitle;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\Base\Api\GetModuleVersionInterface
|
||||
*/
|
||||
private $getModuleVersion;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\Base\Api\GetExtensionInformationInterface
|
||||
*/
|
||||
private $getExtensionInformation;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\Data\Form\Element\AbstractElement
|
||||
*/
|
||||
private $element;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\Base\Model\IsModuleInMarketplace
|
||||
*/
|
||||
private $isModuleInMarketplace;
|
||||
|
||||
/**
|
||||
* @var \Plumrocket\Base\Model\Extension\Updates\Get
|
||||
*/
|
||||
private $getUpdates;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\Serialize\SerializerInterface
|
||||
*/
|
||||
private $serializer;
|
||||
|
||||
/**
|
||||
* @param \Magento\Backend\Block\Template\Context $context
|
||||
* @param \Plumrocket\Base\Api\GetModuleVersionInterface $getModuleVersion
|
||||
* @param \Plumrocket\Base\Api\GetExtensionInformationInterface $getExtensionInformation
|
||||
* @param \Plumrocket\Base\Model\IsModuleInMarketplace $isModuleInMarketplace
|
||||
* @param \Plumrocket\Base\Model\Extension\Updates\Get $getUpdates
|
||||
* @param \Magento\Framework\Serialize\SerializerInterface $serializer
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
GetModuleVersionInterface $getModuleVersion,
|
||||
GetExtensionInformationInterface $getExtensionInformation,
|
||||
IsModuleInMarketplace $isModuleInMarketplace,
|
||||
Get $getUpdates,
|
||||
SerializerInterface $serializer,
|
||||
array $data = []
|
||||
) {
|
||||
parent::__construct($context, $data);
|
||||
$this->getModuleVersion = $getModuleVersion;
|
||||
$this->getExtensionInformation = $getExtensionInformation;
|
||||
$this->isModuleInMarketplace = $isModuleInMarketplace;
|
||||
$this->getUpdates = $getUpdates;
|
||||
$this->serializer = $serializer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render version field considering request parameter
|
||||
*
|
||||
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
|
||||
* @return string
|
||||
*/
|
||||
public function render(AbstractElement $element)
|
||||
{
|
||||
$this->element = $element;
|
||||
return $this->toHtml();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get module name like SocialLoginFree.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModuleName(): string
|
||||
{
|
||||
if ($this->element && $this->element->getData('field_config/pr_extension_name')) {
|
||||
return (string) $this->element->getData('field_config/pr_extension_name');
|
||||
}
|
||||
return (string) parent::getModuleName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Receive url to extension documentation
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getWikiLink(): string
|
||||
{
|
||||
return $this->wikiLink ?: $this->getExtensionInformation->execute(
|
||||
$this->getModuleName()
|
||||
)->getDocumentationLink();
|
||||
}
|
||||
|
||||
/**
|
||||
* Receive extension name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getModuleTitle(): string
|
||||
{
|
||||
return $this->moduleTitle ?: $this->getExtensionInformation->execute($this->getModuleName())->getTitle();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get extension information.
|
||||
*
|
||||
* @return \Plumrocket\Base\Api\Data\ExtensionInformationInterface
|
||||
*/
|
||||
public function getExtensionInformation(): ExtensionInformationInterface
|
||||
{
|
||||
return $this->getExtensionInformation->execute($this->getModuleName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get extension version.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVersion(): string
|
||||
{
|
||||
return $this->getModuleVersion->execute($this->getModuleName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this is a marketplace copy of extension.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isModuleInMarketplace(): bool
|
||||
{
|
||||
return $this->isModuleInMarketplace->execute($this->getModuleName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get link url for our logo.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLogoUrl(): string
|
||||
{
|
||||
return $this->isModuleInMarketplace()
|
||||
? 'https://marketplace.magento.com/partner/Plumrocket'
|
||||
: 'https://plumrocket.com';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get url for requesting new feature.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRequestNewFeatureUrl(): string
|
||||
{
|
||||
if ($this->isModuleInMarketplace()) {
|
||||
return 'mailto:support@plumrocket.com';
|
||||
}
|
||||
$subject = urlencode("New Feature Request for {$this->getModuleTitle()} v{$this->getVersion()}");
|
||||
return 'https://plumrocket.com/contacts?department=3&from=extension_panel&subject=' . $subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get changelogs of new versions.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getNewUpdates(): array
|
||||
{
|
||||
try {
|
||||
$updates = $this->getUpdates->execute([$this->getModuleName()]);
|
||||
return $updates[$this->getModuleName()] ?? [];
|
||||
} catch (NotFoundException $e) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ulr for update version.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUpdateUrl(): string
|
||||
{
|
||||
if ($this->isModuleInMarketplace()) {
|
||||
return 'https://marketplace.magento.com/downloadable/customer/products/';
|
||||
}
|
||||
return $this->getWikiLink() ?: 'https://plumrocket.com/index.php/downloadable/customer/products/';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get changelogs of new versions.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRateUsUrl(): string
|
||||
{
|
||||
$extensionInfo = $this->getExtensionInformation();
|
||||
if ($this->isModuleInMarketplace()) {
|
||||
return $extensionInfo->getMarketplaceUrl();
|
||||
}
|
||||
return $extensionInfo->getUrl() ? $extensionInfo->getUrl() . '#leave-review' : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize data.
|
||||
*
|
||||
* @param string|array $data
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize($data): string
|
||||
{
|
||||
return str_replace(['\r', '\n'], ' ', $this->serializer->serialize($data));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user