init
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace WeltPixel\Backend\Block\Adminhtml;
|
||||
|
||||
/**
|
||||
* Class Debugger
|
||||
* @package WeltPixel\Backend\Block\Adminhtml
|
||||
*/
|
||||
class Debugger extends \Magento\Backend\Block\Widget\Grid\Container
|
||||
{
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_controller = 'weltpixelbackend_debugger';
|
||||
$this->_blockGroup = 'WeltPixel_Backend';
|
||||
parent::_construct();
|
||||
$this->removeButton('add');
|
||||
$this->addButton(
|
||||
'only-custom',
|
||||
[
|
||||
'label' => __("Only Custom Modules"),
|
||||
'onclick' => 'setLocation(\'' . $this->getUrl('*/*/rewritescustom') . '\')',
|
||||
'class' => 'primary'
|
||||
]
|
||||
);
|
||||
$this->addButton(
|
||||
'all-core',
|
||||
[
|
||||
'label' => __("All Magento Modules"),
|
||||
'onclick' => 'setLocation(\'' . $this->getUrl('*/*/rewritesall') . '\')',
|
||||
'class' => 'secondary'
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
namespace WeltPixel\Backend\Block\Adminhtml\Grid\Renderer;
|
||||
|
||||
/**
|
||||
* Class RewriteStatus
|
||||
* @package WeltPixel\Backend\Block\Adminhtml\Grid\Renderer
|
||||
*/
|
||||
class RewriteStatus extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
|
||||
{
|
||||
|
||||
/**
|
||||
* Prepare link to display in grid
|
||||
*
|
||||
* @param \Magento\Framework\DataObject $row
|
||||
* @return string
|
||||
*/
|
||||
public function render(\Magento\Framework\DataObject $row)
|
||||
{
|
||||
$statusClass = 'ok';
|
||||
$statusMessage = __('OK');
|
||||
if (!$row->getStatus()) {
|
||||
$statusClass = 'nok';
|
||||
$statusMessage = __('CHECK REWRITE');
|
||||
}
|
||||
|
||||
return '<span class="rewrite-status rewrite-status-'.$statusClass.'">' . $statusMessage .'</span>';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace WeltPixel\Backend\Block\Adminhtml;
|
||||
|
||||
/**
|
||||
* Class Licenses
|
||||
* @package WeltPixel\Backend\Block\Adminhtml
|
||||
*/
|
||||
class Licenses extends \Magento\Backend\Block\Template
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLicensePostUrl()
|
||||
{
|
||||
return $this->getUrl('weltpixel_backend/licenses/post');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLicensesUrl()
|
||||
{
|
||||
return $this->getUrl('weltpixel_backend/licenses/index');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
namespace WeltPixel\Backend\Block\Adminhtml;
|
||||
|
||||
/**
|
||||
* Class ModulesVersion
|
||||
* @package WeltPixel\Backend\Block\Adminhtml
|
||||
*/
|
||||
class ModulesVersion extends \Magento\Backend\Block\Template
|
||||
{
|
||||
const MODULE_VERSIONS = 'https://www.weltpixel.com/weltpixel_extensions.json';
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\App\DeploymentConfig
|
||||
*/
|
||||
protected $deploymentConfig;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\Component\ComponentRegistrarInterface
|
||||
*/
|
||||
protected $componentRegistrar;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\Filesystem\Directory\ReadFactory
|
||||
*/
|
||||
protected $readFactory;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $latestVersions;
|
||||
|
||||
/**
|
||||
* @param \Magento\Framework\App\DeploymentConfig $deploymentConfig
|
||||
* @param \Magento\Framework\Component\ComponentRegistrarInterface $componentRegistrar
|
||||
* @param \Magento\Framework\Filesystem\Directory\ReadFactory $readFactory
|
||||
* @param \Magento\Backend\Block\Template\Context $context
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
\Magento\Framework\App\DeploymentConfig $deploymentConfig,
|
||||
\Magento\Framework\Component\ComponentRegistrarInterface $componentRegistrar,
|
||||
\Magento\Framework\Filesystem\Directory\ReadFactory $readFactory,
|
||||
\Magento\Backend\Block\Template\Context $context,
|
||||
array $data = []
|
||||
) {
|
||||
$this->deploymentConfig = $deploymentConfig;
|
||||
$this->readFactory = $readFactory;
|
||||
$this->componentRegistrar = $componentRegistrar;
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function getModulesLatestVersions()
|
||||
{
|
||||
$curl = curl_init(self::MODULE_VERSIONS);
|
||||
|
||||
curl_setopt($curl, CURLOPT_HEADER, 0);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 3);
|
||||
curl_setopt($curl, CURLOPT_TIMEOUT, 3);
|
||||
$response = curl_exec($curl);
|
||||
|
||||
$latestVersions = json_decode($response, true);
|
||||
|
||||
return $latestVersions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getModuleVersions()
|
||||
{
|
||||
$this->latestVersions = $this->getModulesLatestVersions();
|
||||
$modules = $this->deploymentConfig->get('modules');
|
||||
|
||||
$moduleDetails = [];
|
||||
|
||||
foreach ($modules as $moduleName => $isEnabled) {
|
||||
if (strpos($moduleName, 'WeltPixel_') !== false || strpos($moduleName, 'WeSupply_') !== false) {
|
||||
$moduleDetails[$moduleName]['enabled'] = $isEnabled;
|
||||
$moduleDetails[$moduleName]['version'] = $this->getComposerVersion($moduleName, \Magento\Framework\Component\ComponentRegistrar::MODULE);
|
||||
if (isset($this->latestVersions['modules'][$moduleName]['version'])) {
|
||||
$moduleDetails[$moduleName]['latest_version'] = $this->latestVersions['modules'][$moduleName]['version'];
|
||||
$moduleDetails[$moduleName]['theme_module'] = $this->latestVersions['modules'][$moduleName]['theme_module'];
|
||||
} else {
|
||||
$moduleDetails[$moduleName]['latest_version'] = __('N/A');
|
||||
$moduleDetails[$moduleName]['theme_module'] = false;
|
||||
}
|
||||
/** Adding latest version comparison messages */
|
||||
if (version_compare($moduleDetails[$moduleName]['latest_version'], $moduleDetails[$moduleName]['version']) < 1) {
|
||||
$moduleDetails[$moduleName]['status_message'] = __('Up to Date');
|
||||
$moduleDetails[$moduleName]['status'] = true;
|
||||
} else {
|
||||
$moduleDetails[$moduleName]['status_message'] = __('Update needed');
|
||||
$moduleDetails[$moduleName]['status'] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $moduleDetails;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getThemeVersions()
|
||||
{
|
||||
$themeDetails = [];
|
||||
|
||||
$themes = [
|
||||
'Pearl' => 'frontend/Pearl/weltpixel',
|
||||
'Pearl custom' => 'frontend/Pearl/weltpixel_custom'
|
||||
];
|
||||
foreach ($themes as $name => $theme) {
|
||||
$themeVersion = $this->getComposerVersion($theme, \Magento\Framework\Component\ComponentRegistrar::THEME);
|
||||
if ($themeVersion != 'N/A') {
|
||||
$themeDetails[$name]['version'] = $themeVersion;
|
||||
if (isset($this->latestVersions['themes'][$name])) {
|
||||
$themeDetails[$name]['latest_version'] = $this->latestVersions['themes'][$name];
|
||||
} else {
|
||||
$themeDetails[$name]['latest_version'] = __('N/A');
|
||||
}
|
||||
/** Adding latest version comparison messages */
|
||||
if (version_compare($themeDetails[$name]['latest_version'], $themeDetails[$name]['version']) < 1) {
|
||||
$themeDetails[$name]['status_message'] = __('Up to Date');
|
||||
$themeDetails[$name]['status'] = true;
|
||||
} else {
|
||||
$themeDetails[$name]['status_message'] = __('Update needed');
|
||||
$themeDetails[$name]['status'] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $themeDetails;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $moduleName
|
||||
* @return string
|
||||
*/
|
||||
protected function getComposerVersion($moduleName, $type)
|
||||
{
|
||||
$path = $this->componentRegistrar->getPath(
|
||||
$type,
|
||||
$moduleName
|
||||
);
|
||||
|
||||
if (!$path) {
|
||||
return __('N/A');
|
||||
}
|
||||
|
||||
$dirReader = $this->readFactory->create($path);
|
||||
$composerJsonData = $dirReader->readFile('composer.json');
|
||||
$data = json_decode($composerJsonData, true);
|
||||
return $data['version'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace WeltPixel\Backend\Block\Adminhtml\System\Config;
|
||||
|
||||
/**
|
||||
* Class Extensions
|
||||
* @package WeltPixel\Backend\Block\Adminhtml\System\Config
|
||||
*/
|
||||
class Extensions extends \Magento\Config\Block\System\Config\Form\Fieldset
|
||||
{
|
||||
public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
|
||||
{
|
||||
return '<iframe id="weltpixel_store" width="100%" src="https://www.weltpixel.com/store/index.html?id=' . uniqid() .'" ></iframe>';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* @category WeltPixel
|
||||
* @package WeltPixel_Backend
|
||||
* @copyright Copyright (c) 2018 Weltpixel
|
||||
* @author Weltpixel TEAM
|
||||
*/
|
||||
|
||||
namespace WeltPixel\Backend\Block\Adminhtml\System\Config\Form\Field;
|
||||
|
||||
use Magento\Framework\Data\Form\Element\AbstractElement;
|
||||
|
||||
/**
|
||||
* Class Disable
|
||||
* @package WeltPixel\Backend\Block\System\Config\Form\Field
|
||||
*/
|
||||
class Disable extends \Magento\Config\Block\System\Config\Form\Field
|
||||
{
|
||||
protected function _getElementHtml(AbstractElement $element)
|
||||
{
|
||||
$element->setDisabled('disabled');
|
||||
return $element->getElementHtml();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* @category WeltPixel
|
||||
* @package WeltPixel_Backend
|
||||
* @copyright Copyright (c) 2018 Weltpixel
|
||||
* @author Weltpixel TEAM
|
||||
*/
|
||||
|
||||
namespace WeltPixel\Backend\Block\Adminhtml\System\Config\Form\Field;
|
||||
|
||||
use Magento\Framework\Data\Form\Element\AbstractElement;
|
||||
|
||||
/**
|
||||
* Class EmptyField
|
||||
* @package WeltPixel\Backend\Block\System\Config\Form\Field
|
||||
*/
|
||||
class EmptyField extends \Magento\Config\Block\System\Config\Form\Field
|
||||
{
|
||||
protected function _getElementHtml(AbstractElement $element)
|
||||
{
|
||||
return '';
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
namespace WeltPixel\Backend\Block\Adminhtml\System\Config;
|
||||
|
||||
use Magento\Config\Block\System\Config\Form\Field;
|
||||
use Magento\Framework\Data\Form\Element\AbstractElement;
|
||||
|
||||
/**
|
||||
* Class Notification
|
||||
* @package WeltPixel\Backend\Block\Adminhtml\System\Config
|
||||
*/
|
||||
class Notification extends Field
|
||||
{
|
||||
protected $_template = 'WeltPixel_Backend::system/config/notification.phtml';
|
||||
|
||||
/**
|
||||
* @param AbstractElement $element
|
||||
* @return string
|
||||
*/
|
||||
protected function _getElementHtml(AbstractElement $element)
|
||||
{
|
||||
return $this->_toHtml();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
namespace WeltPixel\Backend\Block\Adminhtml\System\Config;
|
||||
|
||||
use Magento\Config\Block\System\Config\Form\Field;
|
||||
use Magento\Framework\Data\Form\Element\AbstractElement;
|
||||
|
||||
/**
|
||||
* Class SystemInformation
|
||||
* @package WeltPixel\Backend\Block\Adminhtml\System\Config
|
||||
*/
|
||||
class SystemInformation extends Field
|
||||
{
|
||||
protected $_template = 'WeltPixel_Backend::system/config/information.phtml';
|
||||
|
||||
/**
|
||||
* @param AbstractElement $element
|
||||
* @return string
|
||||
*/
|
||||
protected function _getElementHtml(AbstractElement $element)
|
||||
{
|
||||
return $this->_toHtml();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMagentoMode() {
|
||||
return $this->_appState->getMode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMagentoPath() {
|
||||
return $this->getRootDirectory()->getAbsolutePath();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user