ltsecurityinc安防产品在线商城代码

This commit is contained in:
2026-09-14 17:47:10 +08:00
parent 57d8444c15
commit 6a3c9c5bd8
14539 changed files with 1775310 additions and 0 deletions
@@ -0,0 +1,103 @@
<?php
/**
* Plumrocket Inc.
*
* NOTICE OF LICENSE
*
* This source file is subject to the End-user License Agreement
* that is available through the world-wide-web at this URL:
* http://wiki.plumrocket.net/wiki/EULA
* If you are unable to obtain it through the world-wide-web, please
* send an email to support@plumrocket.com so we can send you a copy immediately.
*
* @package Plumrocket_GeoIPLookup
* @copyright Copyright (c) 2020 Plumrocket Inc. (http://www.plumrocket.com)
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
*/
declare(strict_types=1);
namespace Plumrocket\GeoIPLookup\Block\Adminhtml\System\Config\Data\Buttons;
use Magento\Framework\Data\Form\Element\AbstractElement;
class AbstractBlock extends \Magento\Config\Block\System\Config\Form\Field
{
/**
* Template path
*/
public $template = "system/config/button.phtml";
/**
* Button Label
*/
public $buttonLabel;
/**
* @var \Plumrocket\GeoIPLookup\Helper\Config
*/
public $configHelper;
/**
* @param \Plumrocket\GeoIPLookup\Helper\Config $configHelper
* @param \Magento\Backend\Block\Template\Context $context
* @param array $data
*/
public function __construct(
\Plumrocket\GeoIPLookup\Helper\Config $configHelper,
\Magento\Backend\Block\Template\Context $context,
array $data = []
) {
parent::__construct($context, $data);
$this->configHelper = $configHelper;
}
/**
* @return $this|\Magento\Config\Block\System\Config\Form\Field
*/
protected function _prepareLayout()
{
parent::_prepareLayout();
if (!$this->getTemplate()) {
$this->setTemplate($this->template);
}
return $this;
}
/**
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @return string
*/
public function render(AbstractElement $element)
{
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
return parent::render($element);
}
/**
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @return string
*/
protected function _getElementHtml(AbstractElement $element)
{
$originalData = $element->getOriginalData();
$buttonLabel = !empty($originalData['button_label']) ? $originalData['button_label'] : $this->buttonLabel;
$this->addData(
[
'button_label' => __($buttonLabel),
'html_id' => $element->getHtmlId(),
'onclick' => $this->getOnclick($element->getHtmlId())
]
);
return $this->_toHtml();
}
/**
* @return string
*/
public function getOnclick($htmlId = null)
{
return 'return false;';
}
}
@@ -0,0 +1,43 @@
<?php
/**
* Plumrocket Inc.
*
* NOTICE OF LICENSE
*
* This source file is subject to the End-user License Agreement
* that is available through the world-wide-web at this URL:
* http://wiki.plumrocket.net/wiki/EULA
* If you are unable to obtain it through the world-wide-web, please
* send an email to support@plumrocket.com so we can send you a copy immediately.
*
* @package Plumrocket_GeoIPLookup
* @copyright Copyright (c) 2020 Plumrocket Inc. (http://www.plumrocket.com)
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
*/
declare(strict_types=1);
namespace Plumrocket\GeoIPLookup\Block\Adminhtml\System\Config\Data\Buttons;
use Plumrocket\GeoIPLookup\Helper\Config;
class Connection extends AbstractBlock
{
/**
* Button Label
*/
public $buttonLabel = 'Test Connection';
/**
* @param $htmlId
* @return null|string
*/
public function getOnclick($htmlId = null)
{
return sprintf(
'window.prGeoIptestApiConnection(\'%s\', \'%s\'); return false;',
$this->getUrl('prgeoiplookup/test/ipapiEndpoint'),
$htmlId
);
}
}
@@ -0,0 +1,48 @@
<?php
/**
* Plumrocket Inc.
*
* NOTICE OF LICENSE
*
* This source file is subject to the End-user License Agreement
* that is available through the world-wide-web at this URL:
* http://wiki.plumrocket.net/wiki/EULA
* If you are unable to obtain it through the world-wide-web, please
* send an email to support@plumrocket.com so we can send you a copy immediately.
*
* @package Plumrocket_GeoIPLookup
* @copyright Copyright (c) 2020 Plumrocket Inc. (http://www.plumrocket.com)
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
*/
declare(strict_types=1);
namespace Plumrocket\GeoIPLookup\Block\Adminhtml\System\Config\Data\Buttons;
class Install extends AbstractBlock
{
/**
* Button Label
*/
public $buttonLabel = 'Install Database';
/**
* @return string
*/
public function getOnclick($htmlId = null)
{
$serviceId = mb_substr($htmlId, 0, mb_strrpos($htmlId, "_"));
$urlAutomatic = $this->getUrl(
'prgeoiplookup/import/autoimport',
['dataId' => $serviceId]
);
$urlProgress = $this->getUrl(
'prgeoiplookup/import/importprogress',
['dataId' => $serviceId, 'is_progress' => 1]
);
return "window.runInstallation('$serviceId', '$urlAutomatic', '$urlProgress'); return false;";
}
}
@@ -0,0 +1,100 @@
<?php
/**
* Plumrocket Inc.
*
* NOTICE OF LICENSE
*
* This source file is subject to the End-user License Agreement
* that is available through the world-wide-web at this URL:
* http://wiki.plumrocket.net/wiki/EULA
* If you are unable to obtain it through the world-wide-web, please
* send an email to support@plumrocket.com so we can send you a copy immediately.
*
* @package Plumrocket_GeoIPLookup
* @copyright Copyright (c) 2018 Plumrocket Inc. (http://www.plumrocket.com)
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
*/
namespace Plumrocket\GeoIPLookup\Block\Adminhtml\System\Config\Data;
use Plumrocket\GeoIPLookup\Helper\Config;
class Enable extends \Magento\Config\Block\System\Config\Form\Field
{
/**
* @var \Plumrocket\GeoIPLookup\Helper\Data
*/
private $dataHelper;
/**
* @var \Plumrocket\GeoIPLookup\Model\Data\Import\Iptocountry
*/
private $ipToCountry;
/**
* @var \Plumrocket\GeoIPLookup\Model\Data\Import\Maxmindgeoip
*/
private $maxmindGeoIp;
/**
* Enable constructor.
*
* @param \Plumrocket\GeoIPLookup\Helper\Data $dataHelper
* @param \Plumrocket\GeoIPLookup\Model\Data\Import\Iptocountry $ipToCountry
* @param \Plumrocket\GeoIPLookup\Model\Data\Import\Maxmindgeoip $maxmindGeoIp
* @param \Magento\Backend\Block\Template\Context $context
* @param array $data
*/
public function __construct(
\Plumrocket\GeoIPLookup\Helper\Data $dataHelper,
\Plumrocket\GeoIPLookup\Model\Data\Import\Iptocountry $ipToCountry,
\Plumrocket\GeoIPLookup\Model\Data\Import\Maxmindgeoip $maxmindGeoIp,
\Magento\Backend\Block\Template\Context $context,
array $data = []
) {
$this->dataHelper = $dataHelper;
$this->ipToCountry = $ipToCountry;
$this->maxmindGeoIp = $maxmindGeoIp;
parent::__construct($context, $data);
}
/**
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @return string
*/
protected function _renderValue(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$dataVersion = null;
$elementId = $element->getId();
$modelName = $this->dataHelper->getModelNameByElementId($elementId, false, true);
$tooltip = '';
switch ($modelName) {
case Config::IPTOCOUNTRY_GROUP:
$dataVersion = $this->ipToCountry->getInstalledMessage();
break;
case Config::MAXMIND_GROUP:
$dataVersion = $this->maxmindGeoIp->getInstalledMessage();
break;
}
if (! $dataVersion) {
$element->setDisabled('disabled');
$form = $element->getForm();
$serviceId = mb_substr($elementId, 0, mb_strrpos($elementId, "_"));
$fieldset = $form->getElement($serviceId);
$title = __('Please install %1 in order to enable this IP Geolocation method.', $fieldset->getLegend());
$tooltip .= '<div id="' . $serviceId . '_tooltip" class="tooltip">
<span><span><img src="' . $this->getViewFileUrl('Plumrocket_Base::images/error_msg_icon.gif')
. '" style="margin-top: 2px;float: right;" /></span></span>';
$tooltip .= '<div class="tooltip-content">' . $title . '</div></div>';
}
$html = '<td class="value with-tooltip">';
$html .= $this->_getElementHtml($element) . $tooltip;
$html .= '</td>';
return $html;
}
}
@@ -0,0 +1,97 @@
<?php
/**
* Plumrocket Inc.
*
* NOTICE OF LICENSE
*
* This source file is subject to the End-user License Agreement
* that is available through the world-wide-web at this URL:
* http://wiki.plumrocket.net/wiki/EULA
* If you are unable to obtain it through the world-wide-web, please
* send an email to support@plumrocket.com so we can send you a copy immediately.
*
* @package Plumrocket_GeoIPLookup
* @copyright Copyright (c) 2018 Plumrocket Inc. (http://www.plumrocket.com)
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
*/
namespace Plumrocket\GeoIPLookup\Block\Adminhtml\System\Config\Data;
use Plumrocket\GeoIPLookup\Helper\Config;
class Status extends \Magento\Config\Block\System\Config\Form\Field
{
/**
* @var \Plumrocket\GeoIPLookup\Helper\Data
*/
private $dataHelper;
/**
* @var \Plumrocket\GeoIPLookup\Model\Data\Import\Iptocountry
*/
private $ipToCountry;
/**
* @var \Plumrocket\GeoIPLookup\Model\Data\Import\Maxmindgeoip
*/
private $maxmindGeoIp;
/**
* Status constructor.
*
* @param \Plumrocket\GeoIPLookup\Helper\Data $dataHelper
* @param \Plumrocket\GeoIPLookup\Model\Data\Import\Iptocountry $ipToCountry
* @param \Plumrocket\GeoIPLookup\Model\Data\Import\Maxmindgeoip $maxmindGeoIp
* @param \Magento\Backend\Block\Template\Context $context
* @param array $data
*/
public function __construct(
\Plumrocket\GeoIPLookup\Helper\Data $dataHelper,
\Plumrocket\GeoIPLookup\Model\Data\Import\Iptocountry $ipToCountry,
\Plumrocket\GeoIPLookup\Model\Data\Import\Maxmindgeoip $maxmindGeoIp,
\Magento\Backend\Block\Template\Context $context,
array $data = []
) {
$this->dataHelper = $dataHelper;
$this->ipToCountry = $ipToCountry;
$this->maxmindGeoIp = $maxmindGeoIp;
parent::__construct($context, $data);
}
/**
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @return string
*/
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$dataVersion = null;
$elementId = $element->getId();
$modelName = $this->dataHelper->getModelNameByElementId($elementId, false, true);
switch ($modelName) {
case Config::IPTOCOUNTRY_GROUP:
$dataVersion = $this->ipToCountry->getInstalledMessage();
break;
case Config::MAXMIND_GROUP:
$dataVersion = $this->maxmindGeoIp->getInstalledMessage();
break;
}
$elementStyle = ($dataVersion) ? "color: green" : "color: red";
$elementText = $dataVersion ?: __('Not Installed')->render();
$html = '
<div id="' . $elementId . '" class="status-container">
<span class="status" style="' . $elementStyle . '">' . $elementText . '</span>
<div class="progress-container" style="display: none;">
<div class="progress-bar w3-light-grey w3-border">
<div class="progress-value w3-container w3-blue w3-center" style="width:0%">0%</div>
</div>
<div class="progress-title"></div>
</div>
</div>
';
return $html;
}
}
@@ -0,0 +1,43 @@
<?php
/**
* Plumrocket Inc.
*
* NOTICE OF LICENSE
*
* This source file is subject to the End-user License Agreement
* that is available through the world-wide-web at this URL:
* http://wiki.plumrocket.net/wiki/EULA
* If you are unable to obtain it through the world-wide-web, please
* send an email to support@plumrocket.com so we can send you a copy immediately.
*
* @package Plumrocket_GeoIPLookup
* @copyright Copyright (c) 2018 Plumrocket Inc. (http://www.plumrocket.com)
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
*/
namespace Plumrocket\GeoIPLookup\Block\Adminhtml\System\Config\Data\Test;
class Api extends \Magento\Config\Block\System\Config\Form\Field
{
/**
* Rest Api Static Path
*/
const REST_PATH = 'rest/V1/prgeoiplookup/';
/**
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @return string
*/
public function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$html = '<p id="hidden_field_api_url">' . $this->getRestApiUrl() . '</p>'
. '<a id="rest_ip_test" target="_blank" href=""></a>';
return $html;
}
private function getRestApiUrl()
{
return $this->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB) . self::REST_PATH;
}
}
@@ -0,0 +1,42 @@
<?php
/**
* Plumrocket Inc.
*
* NOTICE OF LICENSE
*
* This source file is subject to the End-user License Agreement
* that is available through the world-wide-web at this URL:
* http://wiki.plumrocket.net/wiki/EULA
* If you are unable to obtain it through the world-wide-web, please
* send an email to support@plumrocket.com so we can send you a copy immediately.
*
* @package Plumrocket_GeoIPLookup
* @copyright Copyright (c) 2018 Plumrocket Inc. (http://www.plumrocket.com)
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
*/
namespace Plumrocket\GeoIPLookup\Block\Adminhtml\System\Config\Data\Test;
class Button extends \Plumrocket\GeoIPLookup\Block\Adminhtml\System\Config\Data\Buttons\AbstractBlock
{
/**
* Button Label
*/
public $buttonLabel = 'Get Location From IP';
/**
* @param null $htmlId
* @return string
*/
public function getOnclick($htmlId = null)
{
$urlTest = $this->getUrl(
'prgeoiplookup/test/index'
);
return sprintf(
'window.geoipTest(\'%s\'); return false;',
$urlTest
);
}
}
@@ -0,0 +1,53 @@
<?php
/**
* Plumrocket Inc.
*
* NOTICE OF LICENSE
*
* This source file is subject to the End-user License Agreement
* that is available through the world-wide-web at this URL:
* http://wiki.plumrocket.net/wiki/EULA
* If you are unable to obtain it through the world-wide-web, please
* send an email to support@plumrocket.com so we can send you a copy immediately.
*
* @package Plumrocket_GeoIPLookup
* @copyright Copyright (c) 2018 Plumrocket Inc. (http://www.plumrocket.com)
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
*/
namespace Plumrocket\GeoIPLookup\Block\Adminhtml\System\Config\Data\Test;
class Ipaddress extends \Magento\Config\Block\System\Config\Form\Field
{
/**
* @var \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress
*/
private $remoteAddress;
/**
* Ipaddress constructor.
*
* @param \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress
* @param \Magento\Backend\Block\Template\Context $context
* @param array $data
*/
public function __construct(
\Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress,
\Magento\Backend\Block\Template\Context $context,
array $data = []
) {
$this->remoteAddress = $remoteAddress;
parent::__construct($context, $data);
}
/**
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @return string
*/
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$ip = $this->remoteAddress->getRemoteAddress();
$element->setValue($ip);
return parent::_getElementHtml($element);
}
}
@@ -0,0 +1,34 @@
<?php
/**
* Plumrocket Inc.
*
* NOTICE OF LICENSE
*
* This source file is subject to the End-user License Agreement
* that is available through the world-wide-web at this URL:
* http://wiki.plumrocket.net/wiki/EULA
* If you are unable to obtain it through the world-wide-web, please
* send an email to support@plumrocket.com so we can send you a copy immediately.
*
* @package Plumrocket_GeoIPLookup
* @copyright Copyright (c) 2018 Plumrocket Inc. (http://www.plumrocket.com)
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
*/
namespace Plumrocket\GeoIPLookup\Block\Adminhtml\System\Config\Data\Test;
class Map extends \Magento\Config\Block\System\Config\Form\Field
{
/**
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @return string
*/
public function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$html = __('Open in')
. " <a id='prgeoiplookup_google_map' target='_blank' href='https://www.google.com/maps'>"
. __('Google Maps') . "</a>";
return $html;
}
}
@@ -0,0 +1,144 @@
<?php
/**
* Plumrocket Inc.
*
* NOTICE OF LICENSE
*
* This source file is subject to the End-user License Agreement
* that is available through the world-wide-web at this URL:
* http://wiki.plumrocket.net/wiki/EULA
* If you are unable to obtain it through the world-wide-web, please
* send an email to support@plumrocket.com so we can send you a copy immediately.
*
* @package Plumrocket_GeoIPLookup
* @copyright Copyright (c) 2020 Plumrocket Inc. (http://www.plumrocket.com)
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
*/
declare(strict_types=1);
namespace Plumrocket\GeoIPLookup\Block\Adminhtml\System\Config\Form;
use Magento\Backend\Block\Template\Context;
use Magento\Backend\Model\UrlInterface;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\View\Element\Html\Select as HtmlSelect;
use Plumrocket\GeoIPLookup\Api\LocationsListInterface;
use Plumrocket\GeoIPLookup\Helper\Config;
use Plumrocket\GeoIPLookup\Model\System\Config\Source\GeoTargeting;
/**
* @since 1.2.2
*/
class GeoTargetingMultiSelect extends Field
{
/**
* @var \Plumrocket\GeoIPLookup\Model\System\Config\Source\GeoTargeting
*/
private $geoIPRestrictions;
/**
* @var \Plumrocket\GeoIPLookup\Helper\Config
*/
private $config;
/**
* @var \Magento\Backend\Model\UrlInterface
*/
private $backendUrl;
/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Plumrocket\GeoIPLookup\Model\System\Config\Source\GeoTargeting $geoIPRestrictions
* @param \Plumrocket\GeoIPLookup\Helper\Config $config
* @param \Magento\Backend\Model\UrlInterface $backendUrl
* @param array $data
*/
public function __construct(
Context $context,
GeoTargeting $geoIPRestrictions,
Config $config,
UrlInterface $backendUrl,
array $data = []
) {
parent::__construct($context, $data);
$this->geoIPRestrictions = $geoIPRestrictions;
$this->config = $config;
$this->backendUrl = $backendUrl;
}
/**
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @return string
*/
protected function _getElementHtml(AbstractElement $element)
{
$html = $this->getGeoIpRestrictionsNotice();
$value = $element->getEscapedValue();
$extraParams = ' multiple';
if (! $this->config->isConfiguredForUse()) {
$extraParams .= ' readonly="readonly"';
$value = LocationsListInterface::ALL;
}
/** @var HtmlSelect $select */
$select = $this->getLayout()->createBlock(HtmlSelect::class);
$optionArray = $this->geoIPRestrictions->toOptionArray();
$select->setOptions($optionArray)
->setId($element->getId())
->setName($element->getName())
->setValue(explode(',', $value))
->setExtraParams($extraParams)
->setClass($element->getClass());
$html .= $select->toHtml();
return $html;
}
public function getGeoIpRestrictionsNotice($withContainer = true)
{
$href = $this->backendUrl->getUrl('adminhtml/system_config/edit', [
'section' => 'prgeoiplookup',
]);
$message = '';
switch (true) {
case ! $this->config->isModuleEnabled():
$message = __(
'The GDPR Geo Targeting is disabled. Click <a target="_blank" href="%1">here</a> to open ' .
'Plumrocket IP Geolocation Lookup configuration and enable extension.',
$href
);
break;
case ! $this->config->getEnableMethodsNumber():
$message = __(
'Please enable at least one IP geolocation lookup database in order to use GDPR Geo Targeting. ' .
'Click <a target="_blank" href="%1">here</a> to open Plumrocket IP Geolocation Lookup configuration ' .
'and enable databases.',
$href
);
break;
}
return (bool) $withContainer && ! empty($message)
? $this->getPreparedNoticeHtml($message)
: $message;
}
/**
* @param $message
* @return string
*/
public function getPreparedNoticeHtml($message): string
{
$style = 'style="margin: 25px 5px;color: #eb5202;background: none;font-size:14px"';
return "<div $style><div><i>$message</i></div></div>";
}
}
@@ -0,0 +1,89 @@
<?php
/**
* Plumrocket Inc.
*
* NOTICE OF LICENSE
*
* This source file is subject to the End-user License Agreement
* that is available through the world-wide-web at this URL:
* http://wiki.plumrocket.net/wiki/EULA
* If you are unable to obtain it through the world-wide-web, please
* send an email to support@plumrocket.com so we can send you a copy immediately.
*
* @package Plumrocket_GeoIPLookup
* @copyright Copyright (c) 2020 Plumrocket Inc. (http://www.plumrocket.com)
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
*/
declare(strict_types=1);
namespace Plumrocket\GeoIPLookup\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\View\Element\Html\Select as HtmlSelect;
use Plumrocket\GeoIPLookup\Api\LocationsListInterface;
use Plumrocket\GeoIPLookup\Helper\Config;
use Plumrocket\GeoIPLookup\Model\System\Config\Source\GeoTargetingStates;
/**
* @since 1.2.2
*/
class StatesGeoTargetingMultiSelect extends Field
{
/**
* @var \Plumrocket\GeoIPLookup\Model\System\Config\Source\GeoTargetingStates
*/
private $geoTargetingStates;
/**
* @var \Plumrocket\GeoIPLookup\Helper\Config
*/
private $config;
/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Plumrocket\GeoIPLookup\Model\System\Config\Source\GeoTargetingStates $geoTargetingStates
* @param \Plumrocket\GeoIPLookup\Helper\Config $config
* @param array $data
*/
public function __construct(
Context $context,
GeoTargetingStates $geoTargetingStates,
Config $config,
array $data = []
) {
parent::__construct($context, $data);
$this->geoTargetingStates = $geoTargetingStates;
$this->config = $config;
}
/**
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @return string
*/
protected function _getElementHtml(AbstractElement $element)
{
$value = $element->getEscapedValue();
$extraParams = ' multiple';
if (! $this->config->isConfiguredForUse()) {
$extraParams .= ' readonly="readonly"';
$value = LocationsListInterface::ALL;
}
/** @var HtmlSelect $select */
$select = $this->getLayout()->createBlock(HtmlSelect::class);
$optionArray = $this->geoTargetingStates->toOptionArray();
$select->setOptions($optionArray)
->setId($element->getId())
->setName($element->getName())
->setValue(explode(',', $value))
->setExtraParams($extraParams)
->setClass($element->getClass());
return $select->toHtml();
}
}
@@ -0,0 +1,73 @@
<?php
/**
* Plumrocket Inc.
*
* NOTICE OF LICENSE
*
* This source file is subject to the End-user License Agreement
* that is available through the world-wide-web at this URL:
* http://wiki.plumrocket.net/wiki/EULA
* If you are unable to obtain it through the world-wide-web, please
* send an email to support@plumrocket.com so we can send you a copy immediately.
*
* @package Plumrocket_GeoIPLookup
* @copyright Copyright (c) 2018 Plumrocket Inc. (http://www.plumrocket.com)
* @license http://wiki.plumrocket.net/wiki/EULA End-user License Agreement
*/
namespace Plumrocket\GeoIPLookup\Block\Adminhtml\System\Config;
class Notice extends \Magento\Config\Block\System\Config\Form\Field
{
/**
* @var \Plumrocket\GeoIPLookup\Helper\Config
*/
private $config;
/**
* Notice constructor.
*
* @param \Plumrocket\GeoIPLookup\Helper\Config $config
* @param \Magento\Backend\Block\Template\Context $context
* @param array $data
*/
public function __construct(
\Plumrocket\GeoIPLookup\Helper\Config $config,
\Magento\Backend\Block\Template\Context $context,
array $data = []
) {
$this->config = $config;
parent::__construct($context, $data);
}
/**
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @return string
*/
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$elementId = $element->getId();
$html = '';
$enableMethodsNumber = $this->config->getEnableMethodsNumber();
if ($enableMethodsNumber < 2) {
$text = __("Please Note!");
if ($enableMethodsNumber == 0) {
$text .= " " . __("You must enable at least one service for this extension to function properly.");
}
$text .= " " . __("We recommend to enable 2 or more services
below to provide the most accurate IP geolocation results.
");
$html .= '
<tr>
<td class="label" colspan="4" style="text-align:left;">
<div id="' . $elementId . '" class="prgeoiplookup-service-notice">' . $text . '</div>
</td>
</tr>
';
}
return $html;
}
}