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
+97
View File
@@ -0,0 +1,97 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
namespace Olegnax\Core\Block\Adminhtml\Modules;
use Magento\Backend\Block\Template;
use Magento\Backend\Block\Template\Context;
use Magento\Framework\App\DeploymentConfig;
use Olegnax\Core\Helper\ModuleInfo;
/** @noinspection ClassNameCollisionInspection */
class Update extends Template
{
const CACHE_KEY_PREFIX = 'OLEGNAX_';
const CACHE_TAG = 'extensions';
/**
* @var ModuleInfo
*/
protected $helper;
/**
* @var DeploymentConfig
*/
protected $deploymentConfig;
public function __construct(
Context $context,
DeploymentConfig $deploymentConfig,
ModuleInfo $helper,
array $data = []
) {
$this->deploymentConfig = $deploymentConfig;
$this->helper = $helper;
parent::__construct($context, $data);
$this->addData(['cache_lifetime' => 86400, 'cache_tags' => [self::CACHE_TAG]]);
}
/**
* Forsed update Data
*/
public function ForsedUpdate()
{
$this->helper->getData(true);
}
/**
* @return array
*/
public function getModuleVersions()
{
$modules = $this->deploymentConfig->get('modules');
$modules = array_filter($modules, [$this, 'filter_module'], ARRAY_FILTER_USE_KEY);
$_modules = [];
foreach ($modules as $moduleName => $enabled) {
$module = $this->helper->getModuleInfo($moduleName);
if (empty($module)) {
continue;
}
$module['enabled'] = $enabled;
$_modules[$moduleName] = $module;
}
return $_modules;
}
public function filter_module($moduleName)
{
return preg_match('/^olegnax_/i', $moduleName);
}
/**
* @return array
*/
public function getThemeVersions()
{
$themes = [
'Athlete2' => 'frontend/Olegnax/athlete2',
];
$_themes = [];
foreach ($themes as $themeName => $path) {
$theme = $this->helper->getThemeInfo($path, $themeName, false);
if (empty($theme)) {
continue;
}
$_themes[$themeName] = $theme;
}
return $_themes;
}
}
+71
View File
@@ -0,0 +1,71 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
namespace Olegnax\Core\Block\Adminhtml;
use Olegnax\Core\Block\Template;
class Notice extends Template
{
protected $collector;
protected function _toHtml()
{
$contents = $this->getColection();
$content = $this->itemSelection($contents);
return $content;
}
/**
* @return array
*/
protected function getColection()
{
$contents = [];
$colection = $this->loadColection();
if ($colection && $colection->getSize()) {
foreach ($colection as $notice) {
$content = $notice->getOxContent();
if (!empty($content)) {
$contents[] = $content;
}
}
}
return $contents;
}
protected function loadColection()
{
if ($this->collector) {
return $this->collector->create();
}
return null;
}
/**
* @param array $contents
* @return string
*/
protected function itemSelection($contents = [])
{
if (!empty($contents)) {
$key = array_rand($contents);
$contents = (string)$contents[$key];
} else {
$contents = '';
}
return $contents;
}
}
+43
View File
@@ -0,0 +1,43 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
namespace Olegnax\Core\Block\Adminhtml;
use Magento\Framework\View\Element\Template\Context;
use Olegnax\Core\Model\ResourceModel\Inbox\Collection\OxContentFactory;
class NoticeContent extends Notice
{
public function __construct(
Context $context,
OxContentFactory $collector,
array $data = []
) {
$this->collector = $collector;
parent::__construct($context, $data);
}
/**
* @return OxContentFactory
*/
protected function loadColection()
{
if ($this->collector) {
$location = $this->getLocation();
if (empty($location)) {
$location = 'global';
}
return $this->collector->create()->addFieldToFilter('ox_type', $location);
}
return null;
}
}
+43
View File
@@ -0,0 +1,43 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
namespace Olegnax\Core\Block\Adminhtml;
use Magento\Framework\View\Element\Template\Context;
use Olegnax\Core\Model\ResourceModel\Inbox\Collection\OxContentPFactory;
class NoticeContentP extends Notice
{
public function __construct(
Context $context,
OxContentPFactory $collector,
array $data = []
) {
$this->collector = $collector;
parent::__construct($context, $data);
}
/**
* @return OxContentPFactory
*/
protected function loadColection()
{
if ($this->collector) {
$location = $this->getLocation();
if (empty($location)) {
$location = 'global';
}
return $this->collector->create()->addFieldToFilter('ox_type', $location);
}
return null;
}
}
+33
View File
@@ -0,0 +1,33 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
namespace Olegnax\Core\Block\Adminhtml;
use Magento\Framework\View\Element\Template\Context;
use Olegnax\Core\Model\ResourceModel\Inbox\Collection\OxNewsFactory;
class NoticeNews extends Notice
{
public function __construct(
Context $context,
OxNewsFactory $collector,
array $data = []
) {
$this->collector = $collector;
parent::__construct($context, $data);
}
/**
* @param array $contents
* @return string
*/
protected function itemSelection($contents = [])
{
return implode('', $contents);
}
}
+202
View File
@@ -0,0 +1,202 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
namespace Olegnax\Core\Block\Adminhtml;
use Exception;
use Magento\Framework\Component\ComponentRegistrar;
use Magento\Framework\Component\ComponentRegistrarInterface;
use Magento\Framework\DataObject;
use Magento\Framework\Filesystem\Directory\ReadFactory;
use Magento\Framework\Module\ModuleListInterface;
use Magento\Framework\View\Element\Template\Context;
use Olegnax\Core\Model\ResourceModel\Inbox\Collection\OxUpdateFactory;
class NoticeUpdate extends Notice
{
public function __construct(
Context $context,
OxUpdateFactory $collector,
array $data = []
) {
$this->collector = $collector;
parent::__construct($context, $data);
}
/**
* @return string
*/
protected function getColection()
{
$contents = [];
$colection = $this->loadColection();
if ($colection && $colection->getSize()) {
foreach ($colection as $notice) {
/** @noinspection PhpUnusedLocalVariableInspection */
$validate = [];
try {
$_validate = $notice->getOxValidate();
$_validate = json_decode($_validate, true);
$validate = $_validate;
} catch (Exception $exception) {
$validate = [];
}
if (!$this->checkExtNeedUpdate($validate)) {
continue;
}
$content = $notice->getOxContent();
if (!empty($content)) {
$contents [] = $content;
}
}
}
return $contents;
}
protected function checkExtNeedUpdate($validate)
{
if (!empty($validate)) {
if (is_array($validate) && array_key_exists('extension_update', $validate)) {
return $this->validateExtNeedUpdate($validate['extension_update'], 'Olegnax');
}
}
return false;
}
protected function validateExtNeedUpdate($extensions, $vendor = '')
{
$extensionsName = $this->validateExt($extensions, $vendor);
if (!is_array($extensionsName)) {
return false;
}
$extensionsName = array_filter($extensionsName, function ($value) {
return 1 === $value;
});
$extensionsName = array_keys($extensionsName);
return $extensionsName;
}
protected function validateExt($extensions, $vendor = '', $diff = false)
{
$extensions = $this->prepareExtValue($extensions);
if (empty($extensions)) {
return true;
}
$extensionsName = array_keys($extensions);
$modules = $this->getInstalledExt($vendor);
if ($diff) {
$extensionsName = array_diff($extensionsName, $modules);
} else {
$extensionsName = array_intersect($extensionsName, $modules);
}
if (empty($extensionsName)) {
return false;
}
$_extensions = [];
foreach ($extensionsName as $extensionName) {
$_extensions[$extensionName] = $this->validateVersion($extensionName, $extensions[$extensionName]);
}
return $_extensions;
}
protected function prepareExtValue($extension)
{
$extensions = [];
if (preg_match_all('/([a-z0-9_]+)(\s\(([^\(\)]+)\))*/i', $extension, $matches, PREG_SET_ORDER)) {
foreach ($matches as $matche) {
$name = $matche[1];
$version = isset($matche[3]) ? $matche[3] : null;
$extensions[$name] = $version;
}
}
return $extensions;
}
protected function getInstalledExt($vendor = '')
{
$modules = $this->_loadObject(ModuleListInterface::class)->getNames();
$dispatchResult = new DataObject($modules);
$modules = $dispatchResult->toArray();
if (!empty($filter)) {
$_modules = [];
foreach ($modules as $module) {
$_module = explode('_', $module);
$_vendor = array_shift($_module);
if ($vendor == $_vendor) {
$_modules[] = $module;
}
}
$modules = $_modules;
}
$modules = array_filter($modules);
sort($modules, SORT_STRING);
return $modules;
}
protected function validateVersion($moduleName, $version)
{
$cur_version = $this->getComposerVersion($moduleName);
if (is_string($version) && is_string($cur_version)) {
return version_compare($version, $cur_version);
}
return 0;
}
protected function getComposerVersion($moduleName, $type = ComponentRegistrar::MODULE)
{
$path = $this->_loadObject(ComponentRegistrarInterface::class)->getPath($type, $moduleName);
if ($path) {
$dirReader = $this->_loadObject(ReadFactory::class)->create($path);
if ($dirReader->isExist('composer.json')) {
$data = $dirReader->readFile('composer.json');
$data = json_decode($data, true);
if (isset($data['version'])) {
return $data['version'];
}
}
if ($dirReader->isExist('etc/module.xml')) {
$data = $dirReader->readFile('etc/module.xml');
if (preg_match('/setup_version="([^\"]+)"/i', $data, $matches)) {
return $matches[1];
}
}
}
return '';
}
/**
* @param array $contents
* @return string
*/
protected function itemSelection($contents = [])
{
return implode('', $contents);
}
protected function validateExtInstalled($extensions, $vendor = '')
{
return $this->validateExt($extensions, $vendor);
}
}
@@ -0,0 +1,165 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
namespace Olegnax\Core\Block\Adminhtml\System\Config\Form;
use Magento\Backend\Block\Context;
use Magento\Backend\Model\Auth\Session;
use Magento\Config\Block\System\Config\Form\Fieldset;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Framework\View\Helper\Js;
use Olegnax\Core\Block\Adminhtml\NoticeContent;
use Olegnax\Core\Helper\ModuleInfo;
class Info extends Fieldset
{
/**
* @var ModuleInfo
*/
protected $moduleInfo;
/**
* @var NoticeContent
*/
protected $content;
/**
* Info constructor.
* @param Context $context
* @param Session $authSession
* @param Js $jsHelper
* @param NoticeContent $content
* @param ModuleInfo $moduleInfo
* @param array $data
*/
public function __construct(
Context $context,
Session $authSession,
Js $jsHelper,
NoticeContent $content,
ModuleInfo $moduleInfo,
array $data = []
) {
$this->content = $content;
$this->moduleInfo = $moduleInfo;
parent::__construct($context, $authSession, $jsHelper, $data);
}
/**
* Retrieve HTML markup for given form element
*
* @param AbstractElement $element
* @return string
*/
public function render(AbstractElement $element)
{
$html = $this->_toTPL();
$html .= $this->getContent();
if ($element->getIsNested()) {
$html = '<tr class="nested"><td colspan="4">' . $html . '</td></tr>';
}
return $html;
}
/**
* Template to string
*
* @param array $data
* @return string
*/
public function _toTPL($data = [])
{
ob_start();
$this->toTPL(array_replace($this->getModuleInfo(), $data));
return (string)ob_get_clean();
}
/**
* Template
*
* @param array $data
*/
public function toTPL($data = [])
{
$rightUrls = [
'docs' => __('User Guide'),
];
$rightBlock = '';
foreach ($rightUrls as $key => $label) {
if (isset($data[$key]) && !empty($data[$key])) {
$rightBlock .= '<div class="ox-info-block__' . $key . '"><a href="' . $this->escapeUrl($data[$key]) . '" target="_blank">' . $label . '</a></div>';
}
}
$rightBlock .= $this->rightCustomBlocks($data);
?>
<div class="ox-info-block">
<a href="https://olegnax.com/" target="_blank" class="ox-info-block__logo"></a>
<div class="ox-info-block__title"><?= $this->escapeHtml($data['title']); ?></div>
<?= $this->leftCustomBlocks($data); ?>
<?php if ($data['update_status']): ?>
<div class="ox-info-block__version expired">
<div class="ox-module-version">v<?= $this->escapeHtml($data['setup_version']); ?> <span class="ox-server-version">v<?= $this->escapeHtml($data['server_version']) ?></span><?php if (isset($data['url_changelog']) && !empty($data['url_changelog'])): ?> <a href="<?= $this->escapeUrl($data['url_changelog']) ?>" target="_blank"><?= __("What's New") ?></a></div><?php endif; ?>
</div>
<?php else: ?>
<div class="ox-info-block__version">
<div class="ox-module-version">v<?= $this->escapeHtml($data['setup_version']); ?></div>
</div>
<?php endif; ?>
<?php if (array_key_exists('pro', $data)): ?>
<a target="_blank" class="ox-pro-version" href="<?php echo $data['pro'] ?>"><?php echo __('Get Pro'); ?></a>
<?php endif; ?>
<?php if (!empty($rightBlock)): ?><div class="ox-info-block__right"><?= $rightBlock; ?></div><?php endif; ?>
</div>
<?php
}
/**
* Right Custom Blocks
*
* @param array $data
* @return string
*/
protected function rightCustomBlocks($data = [])
{
return '';
}
/**
* Left Custom Blocks
*
* @param array $data
* @return string
*/
protected function leftCustomBlocks($data = [])
{
return '';
}
/**
* Get Module info
*
* @return array
*/
protected function getModuleInfo()
{
return $this->moduleInfo->getModuleInfo($this->getModuleName());
}
/**
* Show notice
*
* @return string
*/
protected function getContent()
{
$this->content->setData('location', $this->getModuleName());
return $this->content->toHtml();
}
}
@@ -0,0 +1,59 @@
<?php
namespace Olegnax\Core\Block\Adminhtml\System\Config\Form;
use Magento\Backend\Block\Context;
use Magento\Backend\Model\Auth\Session;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\View\Helper\Js;
use Olegnax\Athlete2\Helper\Helper;
use Olegnax\Core\Block\Adminhtml\NoticeContent;
use Olegnax\Core\Helper\ModuleInfo;
class InfoTheme extends Info
{
/**
* @var mixed
*/
protected $_helper;
public function __construct(
Context $context,
Session $authSession,
Js $jsHelper,
NoticeContent $content,
ModuleInfo $moduleInfo,
array $data = []
) {
parent::__construct($context, $authSession, $jsHelper, $content, $moduleInfo, $data);
}
protected function rightCustomBlocks($data = [])
{
if (!$this->moduleInfo->isActive('Olegnax_Athlete2')) {
return '';
}
$this->_helper = ObjectManager::getInstance()->get(Helper::class);
$code = $this->_helper->getSystemDefaultValue('athlete2_license/general/code');
$license = $this->_helper->get();
$status = !empty($license)
&& isset($license->data->the_key)
&& $license->data->the_key == $code
&& $license->data->status == "active";
$supportExpired = isset($license->notices->support);
$notice = [];
if ($status) {
$notice[] = '<div class="ox-info-block__support support-' . ($supportExpired ? 'expired' : 'active') . '"><div class="wrapper"><span class="label">' . __('Support') . '</span>';
if ($supportExpired) {
$notice[] = '<a href="https://themeforest.net/item/athlete2-strong-magento-2-theme/23693737" target="_blank">' . __('Renew') . '</a>';
} else {
$notice[] = '<a href="https://olegnax.com/help" target="_blank">' . __('Active') . '</a>';
}
$notice[] = '</div></div>';
}
return implode($notice);
}
}
+156
View File
@@ -0,0 +1,156 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
namespace Olegnax\Core\Block;
use Magento\Framework\View\Element\AbstractBlock;
class ChildTemplate extends Template
{
public function __call($method, $args)
{
$parent = $this->getParentBlock();
if ($parent) {
return call_user_func_array([$parent, $method], $args);
}
return null;
}
public function __isset($name)
{
$parent = $this->getParentBlock();
if ($parent) {
return isset($parent->{$name});
}
return false;
}
public function __get($name)
{
$parent = $this->getParentBlock();
if ($parent) {
return $parent->{$name};
}
return null;
}
/**
* Retrieve child block by name
*
* @param string $alias
* @return AbstractBlock|bool
*/
public function getChildBlock($alias)
{
$parent = $this->getParentBlock();
$layout = $parent->getLayout();
if (!$layout) {
return false;
}
$name = $layout->getChildName($parent->getNameInLayout(), $alias);
if ($name) {
return $layout->getBlock($name);
}
return false;
}
/**
* Retrieve child block HTML
*
* @param string $alias
* @param boolean $useCache
* @return string
*/
public function getChildHtml($alias = '', $useCache = true)
{
$parent = $this->getParentBlock();
$layout = $parent->getLayout();
if (!$layout) {
return '';
}
$name = $parent->getNameInLayout();
$out = '';
if ($alias) {
$childName = $layout->getChildName($name, $alias);
if ($childName) {
$out = $layout->renderElement($childName, $useCache);
}
} else {
foreach ($layout->getChildNames($name) as $child) {
$out .= $layout->renderElement($child, $useCache);
}
}
return $out;
}
/**
* Render output of child child element
*
* @param string $alias
* @param string $childChildAlias
* @param bool $useCache
* @return string
*/
public function getChildChildHtml($alias, $childChildAlias = '', $useCache = true)
{
$parent = $this->getParentBlock();
$layout = $parent->getLayout();
if (!$layout) {
return '';
}
$childName = $layout->getChildName($parent->getNameInLayout(), $alias);
if (!$childName) {
return '';
}
$out = '';
if ($childChildAlias) {
$childChildName = $layout->getChildName($childName, $childChildAlias);
$out = $layout->renderElement($childChildName, $useCache);
} else {
foreach ($layout->getChildNames($childName) as $childChild) {
$out .= $layout->renderElement($childChild, $useCache);
}
}
return $out;
}
/**
* Retrieves sorted list of child names
*
* @return array
*/
public function getChildNames()
{
$parent = $this->getParentBlock();
$layout = $parent->getLayout();
if (!$layout) {
return [];
}
return $layout->getChildNames($parent->getNameInLayout());
}
/**
* Get a group of child blocks
*
* Returns an array of <alias> => <block>
* or an array of <alias> => <callback_result>
* The callback currently supports only $this methods and passes the alias as parameter
*
* @param string $groupName
* @return array
*/
public function getGroupChildNames($groupName)
{
$parent = $this->getParentBlock();
return $parent->getLayout()->getGroupChildNames($parent->getNameInLayout(),
$groupName);
}
}
+51
View File
@@ -0,0 +1,51 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
namespace Olegnax\Core\Block;
use Magento\Customer\Model\Session;
use Magento\Framework\App\ObjectManager;
use Magento\Store\Model\ScopeInterface;
class SimpleTemplate extends \Magento\Framework\View\Element\Template
{
public function isLoggedIn()
{
return $this->getSession()->isLoggedIn();
}
public function getSession()
{
return ObjectManager::getInstance()->create(Session::class);
}
public function getConfig($path, $storeCode = null)
{
return $this->getSystemValue($path, $storeCode);
}
public function getSystemValue($path, $storeCode = null)
{
$value = $this->_scopeConfig->getValue($path, ScopeInterface::SCOPE_STORE, $storeCode);
if (is_null($value)) {
$value = '';
}
return $value;
}
protected function _loadObject($object)
{
return $this->_getObjectManager()->get($object);
}
protected function _getObjectManager()
{
return ObjectManager::getInstance();
}
}
+130
View File
@@ -0,0 +1,130 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
namespace Olegnax\Core\Block;
use Magento\Customer\Model\Form;
use Magento\Store\Model\ScopeInterface;
use Olegnax\Core\Helper\Helper as HelperHelper;
use Olegnax\Core\Helper\ProductImage as HelperProductImage;
abstract class Template extends SimpleTemplate
{
const CHILD_TEMPLATE = ChildTemplate::class;
// Helper Product Image //
public function getImage(
$product,
$imageId,
$template = HelperProductImage::TEMPLATE,
array $attributes = [],
$properties = []
) {
return $this->getHelperProductImage()->getImage($product, $imageId, $template, $attributes, $properties);
}
public function getHelperProductImage()
{
return $this->_loadObject(HelperProductImage::class);
}
public function getImageHover(
$product,
$imageId,
$imageId_hover,
$template = HelperProductImage::HOVER_TEMPLATE,
array $attributes = [],
$properties = []
) {
return $this->getHelperProductImage()->getImageHover($product, $imageId, $imageId_hover, $template, $attributes,
$properties);
}
public function getResizedImage(
$product,
$imageId,
$size,
$template = HelperProductImage::TEMPLATE,
array $attributes = [],
$properties = []
) {
return $this->getHelperProductImage()->getResizedImage($product, $imageId, $size, $template, $attributes,
$properties);
}
public function getResizedImageHover(
$product,
$imageId,
$imageId_hover,
$size,
$template = HelperProductImage::HOVER_TEMPLATE,
array $attributes = [],
$properties = []
) {
return $this->getHelperProductImage()->getResizedImageHover($product, $imageId, $imageId_hover, $size,
$template, $attributes, $properties);
}
public function hasHoverImage($product, $imageId, $imageId_hover)
{
return $this->getHelperProductImage()->hasHoverImage($product, $imageId, $imageId_hover);
}
public function getUrlResizedImage($product, $image, $size, $properties = [])
{
return $this->getHelperProductImage()->getUrlResizedImage($product, $image, $size, $properties);
}
public function isLoggedIn()
{
return $this->getHelper()->isLoggedIn();
}
// Helper Helper //
public function getHelper()
{
return $this->_loadObject(HelperHelper::class);
}
public function getWishlistCount()
{
return $this->getHelper()->getWishlistCount();
}
public function getCompareListUrl()
{
return $this->getHelper()->getCompareListUrl();
}
function getCompareListCount()
{
return $this->getHelper()->getCompareListCount();
}
public function isAutocompleteDisabled()
{
return (bool)!$this->getSystemValue(Form::XML_PATH_ENABLE_AUTOCOMPLETE);
}
public function getBlockTemplateProcessor($content = '')
{
if (empty($content) || !is_string($content)) {
$content = '';
}
return $this->getHelper()->getBlockTemplateProcessor($content);
}
public function getBaseUrl()
{
return $this->getHelper()->getBaseUrl();
}
}
@@ -0,0 +1,65 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
namespace Olegnax\Core\Controller\Adminhtml\Modules;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Backend\Model\View\Result\Page;
use Magento\Framework\Controller\ResultInterface;
use Magento\Framework\View\Result\PageFactory;
/** @noinspection ClassNameCollisionInspection */
class Update extends Action
{
const ADMIN_RESOURCE = 'Olegnax_Core::Modules_Update';
protected $resultPageFactory;
/**
* Constructor
*
* @param Context $context
* @param PageFactory $resultPageFactory
*/
public function __construct(
Context $context,
PageFactory $resultPageFactory
) {
$this->resultPageFactory = $resultPageFactory;
parent::__construct($context);
}
/**
* Init page
*
* @param Page $resultPage
* @return Page
*/
public function initPage($resultPage)
{
$resultPage->setActiveMenu('Olegnax_Core::Olegnax_Core')
->addBreadcrumb(__('Modules'), __('Modules'));
return $resultPage;
}
/**
* Execute view action
*
* @return ResultInterface
*/
public function execute()
{
$resultPage = $this->resultPageFactory->create();
$resultPage->getConfig()->getTitle()->prepend((__('Olegnax Modules')));
return $resultPage;
}
}
+451
View File
@@ -0,0 +1,451 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
namespace Olegnax\Core\Helper;
use Exception;
use Magento\Catalog\Helper\Product\Compare;
use Magento\Cms\Model\Template\FilterProvider;
use Magento\Customer\Model\Session;
use Magento\Framework\App\Area;
use Magento\Framework\App\Cache\Frontend\Pool;
use Magento\Framework\App\Cache\TypeListInterface;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\Config\Storage\WriterInterface;
use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Framework\App\Helper\Context;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\App\ProductMetadataInterface;
use Magento\Framework\App\State;
use Magento\Framework\UrlInterface;
use Magento\Framework\View\DesignInterface;
use Magento\Store\Model\ScopeInterface;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Wishlist\Helper\Data;
use Olegnax\Core\Block\ChildTemplate;
use Psr\Log\LoggerInterface;
class Helper extends AbstractHelper
{
const XML_PATH_CORE_LAZY = 'olegnax_core_settings/general/lazyload';
const CONFIG_MODULE = 'olegnax_core_settings';
const CHILD_TEMPLATE = ChildTemplate::class;
/**
* @var ObjectManager
*/
protected $objectManager;
/**
* @var array
*/
protected $isArea = [];
/**
* @var LoggerInterface
*/
public $logger;
public function __construct(
Context $context,
LoggerInterface $logger
)
{
$this->logger = $logger;
parent::__construct($context);
if (!$this->getModuleConfig(
'general/install_date',
0,
ScopeConfigInterface::SCOPE_TYPE_DEFAULT
)
) {
$this->setModuleConfig('general/install_date', time());
}
}
/**
* @return bool
*/
public function isEnabled()
{
return true;
}
public function setModuleConfig(
$path,
$value,
$scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
$scopeId = 0
) {
if (!empty($path)) {
$path = static::CONFIG_MODULE . '/' . $path;
}
return $this->setSystemValue($path, $value, $scope, $scopeId);
}
public function setSystemValue($path, $value, $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeId = 0)
{
$result = $this->_loadObject(WriterInterface::class)->save($path, $value, $scope, $scopeId);
$this->scopeConfig->clean();
return $result;
}
public function deleteSystemValue($path, $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeId = 0)
{
$result = $this->_loadObject(WriterInterface::class)->delete($path, $scope, $scopeId);
$this->scopeConfig->clean();
return $result;
}
/**
* @param string $path
* @return mixed
*/
public function _loadObject($path)
{
return ObjectManager::getInstance()->get($path);
}
/**
* @return string
*/
public function getThemeCode()
{
/** @var DesignInterface $appState */
$appState = $this->_loadObject(DesignInterface::class);
return $appState->getDesignTheme()->getCode();
}
/**
* @return bool
*/
public function isMobileTheme()
{
return (bool) preg_match('@^Olegnax\/a2m@', $this->getThemeCode());
}
/**
* @return bool
*/
public function isLazyLoadEnabled(){
return (bool) $this->getSystemValue(static::XML_PATH_CORE_LAZY);
}
/**
* @param string $path
* @param integer $storeCode
* @param string $scopeType
* @return mixed
*/
public function getModuleConfig($path = '', $storeCode = null, $scopeType = ScopeInterface::SCOPE_STORE)
{
if (empty($path)) {
$path = static::CONFIG_MODULE;
} else {
$path = static::CONFIG_MODULE . '/' . $path;
}
return $this->getSystemValue($path, $storeCode, $scopeType);
}
/**
* @param string $path
* @param integer $storeCode
* @param string $scopeType
* @return mixed
*/
public function getSystemValue($path, $storeCode = null, $scopeType = ScopeInterface::SCOPE_STORE)
{
$value = $this->scopeConfig->getValue(
$path,
$scopeType,
$storeCode
);
if (is_null($value)) {
$value = '';
}
return $value;
}
/**
* @param string $path
* @return mixed
*/
public function getSystemDefaultValue($path)
{
return $this->getSystemValue(
$path,
0,
ScopeConfigInterface::SCOPE_TYPE_DEFAULT
);
}
/**
* @return bool
*/
public function isAdmin()
{
return $this->isArea(Area::AREA_ADMINHTML);
}
/**
* @param string $area
* @return bool
*/
public function isArea($area = Area::AREA_FRONTEND)
{
if (!isset($this->isArea[$area])) {
/** @var State $state */
$state = $this->_loadObject(State::class);
try {
$this->isArea[$area] = ($state->getAreaCode() == $area);
} catch ( Exception $e) {
$this->isArea[$area] = false;
}
}
return $this->isArea[$area];
}
/**
* @param string $path
* @param array $arguments
* @return mixed
*/
public function _createObject($path, $arguments = [])
{
return ObjectManager::getInstance()->create($path, $arguments);
}
public function getLayoutTemplateHtml($block, $option_path = '', $fileName = '', $arguments = [])
{
$value = $this->getSystemValue($option_path);
if (is_string($value) || is_numeric($value)) {
return $this->getLayoutTemplateHtmlbyValue($block, $value, $fileName, $arguments);
}
return '';
}
/**
* @param string $path
* @param integer $storeCode
* @return mixed
*/
public function getConfig($path, $storeCode = null)
{
return $this->getSystemValue($path, $storeCode);
}
public function getLayoutTemplateHtmlbyValue(
$block,
$value = null,
$fileName = null,
$arguments = [],
$separator = '/'
) {
$_fileName = '';
if (empty($fileName)) {
$blockTemplate = $block->getTemplate();
if (preg_match('/(\.[^\.]+?)$/', $blockTemplate)) {
$fileName = preg_replace('/(\.[^\.]+?)$/', '%s%s$1', $blockTemplate);
} else {
$fileName .= '%s%s';
}
if (!preg_match('#([^_\:])_([^_\:])\:\:#i', $fileName)) {
$className = array_slice(array_filter(explode('\\', get_class($block))), 0, 2);
if ('Magento' !== $className[0]) {
$fileName = implode('_', $className) . '::' . $fileName;
}
}
} else {
$_fileName = $fileName;
}
$blockName = $separator . $block->getNameInLayout() . $separator . $_fileName . $separator . $value;
$fileName = sprintf($fileName, $separator, $value);
while ($block->getLayout()->getBlock($blockName)) {
$blockName .= '_0';
}
$_block = $block->getLayout()->createBlock(static::CHILD_TEMPLATE, $blockName);
$block->setChild($_block->getNameInLayout(), $_block);
if (!empty($arguments) && is_array($arguments)) {
$_block->addData($arguments);
}
$content = $_block->setTemplate($fileName)->toHtml();
return $content;
}
public function isLoggedIn()
{
return $this->_loadObject(Session::class)->isLoggedIn();
}
public function getWishlistCount()
{
return $this->_loadObject(Data::class)->getItemCount();
}
/**
* Get Product version
*
* @return string
*/
function getVersion()
{
return $this->_loadObject(ProductMetadataInterface::class)->getVersion();
}
/**
* @param string $version
* @param string $operator
* @return bool
*/
function getVersionCompare($version, $operator = '<=')
{
return version_compare($this->getVersion(), $version, $operator);
}
/**
* @return bool
*/
public function isLegacyJQuery() {
return $this->getVersionCompare('2.3.2');
}
public function getCompareListUrl()
{
return $this->_loadObject(Compare::class)->getListUrl();
}
public function getCompareListCount()
{
return $this->_loadObject(Compare::class)->getItemCount();
}
public function getBaseUrl($type = UrlInterface::URL_TYPE_LINK, $secure = null)
{
return $this->getStore()->getBaseUrl($type, $secure);
}
public function getStore()
{
/** @var StoreManagerInterface $storeManager */
$storeManager = $this->_loadObject(StoreManagerInterface::class);
return $storeManager->getStore();
}
public function isMobile()
{
$regex_match = "/(nokia|iphone|android|motorola|^mot\-|softbank|foma|docomo|kddi|up\.browser|up\.link|"
. "htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|"
. "blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam\-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|"
. "symbian|smartphone|mmp|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte\-|longcos|pantech|gionee|^sie\-|portalmmm|"
. "jig\s browser|hiptop|^ucweb|^benq|haier|^lct|opera\s*mobi|opera\*mini|320x320|240x320|176x220"
. ")/i";
if (preg_match($regex_match, strtolower((string)$_SERVER['HTTP_USER_AGENT']))) {
return TRUE;
}
if ((strpos(strtolower((string)$_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml') > 0) or ((isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE'])))) {
return TRUE;
}
$mobile_ua = strtolower(substr($_SERVER['HTTP_USER_AGENT'], 0, 4));
$mobile_agents = array(
'w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac',
'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno',
'ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-',
'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-',
'newt','noki','oper','palm','pana','pant','phil','play','port','prox',
'qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar',
'sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-',
'tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp',
'wapr','webc','winw','winw','xda ','xda-');
if (in_array($mobile_ua,$mobile_agents)) {
return TRUE;
}
if (isset($_SERVER['ALL_HTTP']) && strpos(strtolower((string)$_SERVER['ALL_HTTP']),'OperaMini') > 0) {
return TRUE;
}
return FALSE;
}
public function getBlockTemplateProcessor($content = '')
{
if (empty($content) || !is_string($content)) {
$content = '';
}
$blockFilter = $this->_loadObject(FilterProvider::class)->getBlockFilter();
return $blockFilter->filter(trim($content));
}
public function getUrl($route = '', $params = [])
{
/** @var UrlInterface $urlBuilder */
$urlBuilder = $this->_loadObject(UrlInterface::class);
return $urlBuilder->getUrl($route, $params);
}
public function isHomePage()
{
$currentUrl = $this->getUrl('', ['_current' => true]);
$urlRewrite = $this->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true]);
return $currentUrl == $urlRewrite;
}
public function clearCache()
{
/** @var TypeListInterface $cacheTypeList */
$cacheTypeList = $this->_loadObject(TypeListInterface::class);
$types = [
'config',
'layout',
'block_html',
'collections',
'reflection',
'db_ddl',
'eav',
'config_integration',
'config_integration_api',
'full_page',
'translate',
'config_webservice',
];
foreach ($types as $type) {
$cacheTypeList->cleanType($type);
}
/** @var Pool $CacheFrontendPool */
$CacheFrontendPool = $this->_loadObject(Pool::class);
foreach ($CacheFrontendPool as $cacheFrontend) {
$cacheFrontend->getBackend()->clean();
}
}
public function getLogger()
{
return $this->logger;
}
public function log($level, $plugin, $message, array $context = [])
{
$message = sprintf('%s: %s', $plugin, trim($message));
$this->getLogger()->log($level, $message, $context);
// $this->getLogger()->debug($message, $context);
}
public function debug($plugin, $message, array $context = [])
{
$this->log(100, $plugin, $message, $context);
}
}
+738
View File
@@ -0,0 +1,738 @@
<?php
/**
* Copyright © All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Olegnax\Core\Helper;
use Exception;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Framework\App\Helper\Context;
use Magento\Framework\App\State;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Filesystem;
use Magento\Framework\Filesystem\Directory\WriteInterface;
use Magento\Framework\Filesystem\Glob;
use Magento\Framework\Filesystem\Io\File;
use Magento\Framework\Image\AdapterFactory;
use Magento\Framework\Image\Factory;
use Magento\Framework\UrlInterface;
use Magento\Store\Model\StoreManagerInterface;
/**
* Description of Image
*
* @author Master
*/
class Image extends AbstractHelper
{
const BASE_TEMPLATE_FILE_NAME = '{dirname}/{destinationSubdir}/{filename}_{width}_{height}.{extension}';
protected $_baseFile;
/**
* @var int
*/
protected $_width;
/**
* @var int
*/
protected $_height;
/**
* Default quality value (for JPEG images only).
*
* @var int
*/
protected $_quality = 90;
/**
* @var bool
*/
protected $_keepAspectRatio = true;
/**
* @var bool
*/
protected $_keepFrame = true;
/**
* @var bool
*/
protected $_keepTransparency = true;
/**
* @var bool
*/
protected $_constrainOnly = true;
/**
* @var bool
*/
protected $_cropOnly = false;
protected $_resizeTemplate = '';
/**
* @var int[]
*/
protected $_backgroundColor = [255, 255, 255];
/**
* @var \Magento\Framework\Image
*/
protected $_processor;
/**
* @var string
*/
protected $_destinationSubdir;
/**
* @var WriteInterface
*/
protected $_mediaDirectory;
/**
* Store Manager
*
* @var StoreManagerInterface
*/
protected $_storeManager;
/**
* @var Factory
*/
protected $_imageFactory;
/**
* @var array
*/
protected $attributes;
/**
* @var File
*/
protected $_file;
protected $_appState;
/**
* @var AdapterFactory
*/
protected $adapterFactory;
/**
* @var string
*/
private $__file;
public function __construct(
Context $context,
Filesystem $filesystem,
Factory $imageFactory,
File $file,
State $appState,
StoreManagerInterface $storeManager,
AdapterFactory $adapterFactory
) {
$this->_mediaDirectory = $filesystem->getDirectoryRead(DirectoryList::MEDIA);
$this->_imageFactory = $imageFactory;
$this->_file = $file;
$this->_storeManager = $storeManager;
$this->_appState = $appState;
$this->adapterFactory = $adapterFactory;
parent::__construct($context);
}
/**
* @return bool
*/
public function checkDependencies() {
try {
$this->adapterFactory->create();
return true;
} catch (Exception $e) {
$this->_logger->critical($e->getMessage());
return false;
}
}
public function adaptiveResize($size, $fileTemplate = null)
{
if (!empty($fileTemplate)) {
$this->setFileTemplate($fileTemplate);
}
try {
[$width, $height] = $this->prepareSize($size);
$this->setWidth($width);
$this->setHeight($height);
if ($this->_keepAspectRatio && $this->_cropOnly) {
$this->crop();
}
$this->resize();
} catch (Exception $e) {
if (State::MODE_DEVELOPER == $this->_appState->getMode()) {
$this->_logger->warning("Olegnax Core. Can\'t resize image, skipping. The file does not exist or not accessible: " . $e,
[$this->_baseFile]);
}
}
return $this;
}
public function setFileTemplate($fileTemplate)
{
$this->_resizeTemplate = $fileTemplate;
return $this;
}
private function prepareSize($size)
{
if (is_array($size) && 1 >= count($size)) {
$size = array_shift($size);
}
if (!is_array($size)) {
$size = [$size, $size];
}
$size = array_map('intval', $size);
$size = array_map('abs', $size);
return $size;
}
public function crop()
{
if ($this->_width == 0 && $this->_height == 0 && !$this->getBaseFile()) {
return $this;
}
if ($this->_fileExists($this->getResizedFile())) {
return $this;
}
$_imageSrcWidth = $this->getImageProcessor()->getOriginalWidth();
$_imageSrcHeight = $this->getImageProcessor()->getOriginalHeight();
$_imageSrcRatio = $_imageSrcWidth / $_imageSrcHeight;
$_ratio = $this->_width / $this->_height;
if ($_imageSrcRatio != $_ratio) {
if (1 > $_imageSrcRatio) {
$newHeight = round($_imageSrcWidth / $_ratio);
$deltHeight = $_imageSrcHeight - $newHeight;
$_deltHeight = floor($deltHeight / 2);
$__deltHeight = $deltHeight % 2;
$this->getImageProcessor()->crop($_deltHeight + $__deltHeight, 0, 0, $_deltHeight);
} elseif (1 < $_imageSrcRatio) {
$newWidth = round($_imageSrcHeight * $_ratio);
$deltWidth = $_imageSrcWidth - $newWidth;
$_deltWidth = floor($deltWidth / 2);
$__deltWidth = $deltWidth % 2;
$this->getImageProcessor()->crop(0, $_deltWidth + $__deltWidth, $_deltWidth, 0);
}
}
return $this;
}
/**
* @return string
*/
public function getBaseFile()
{
return $this->_baseFile;
}
/**
* Set filenames for base file and new file
*
* @param string $file
*
* @return Image
*/
public function setBaseFile($file)
{
if ($this->_fileExists($file)) {
$this->_baseFile = $file;
} elseif (State::MODE_DEVELOPER == $this->_appState->getMode()) {
$this->_logger->warning(__('Olegnax Core. The file does not exist or not accessible: ') . $file);
}
return $this;
}
/**
* First check this file on FS
* If it doesn't exist - try to download it from DB
*
* @param string $filename
*
* @return bool
*/
protected function _fileExists($filename)
{
return $this->_file->fileExists($this->_mediaDirectory->getAbsolutePath($filename));
}
/**
* @return string
*/
private function getResizedFile()
{
$path_data = pathinfo($this->getBaseFile());
if (is_array($path_data) && !empty($path_data)) {
if (array_key_exists('extension', $path_data)) {
$filename = str_replace(
[
'{dirname}',
'{basename}',
'{extension}',
'{filename}',
'{width}',
'{height}',
'{originalWidth}',
'{originalHeight}',
'{destinationSubdir}',
'{keepFrame}',
'{constrainOnly}',
'{keepAspectRatio}',
'{crop}',
'{keepTransparency}',
'{quality}',
],
[
$path_data['dirname'],
$path_data['basename'],
$path_data['extension'],
$path_data['filename'],
$this->getWidth(),
$this->getHeight(),
$this->getOriginalWidth(),
$this->getOriginalHeight(),
$this->getDestinationSubdir(),
$this->getQuality(),
$this->_keepFrame,
$this->_constrainOnly,
$this->_keepAspectRatio,
$this->_cropOnly,
$this->_keepTransparency,
],
$this->_resizeTemplate
);
return $filename;
}
}
return '';
}
/**
* @return int
*/
public function getWidth()
{
return $this->_width ?: $this->getOriginalWidth();
}
/**
* @param int $width
*
* @return Image
*/
public function setWidth($width)
{
$this->_width = abs((int)$width);
return $this;
}
/**
* @return int|null
*/
public function getOriginalWidth()
{
return $this->getImageProcessor()->getOriginalWidth();
}
/**
* @return \Magento\Framework\Image
*/
public function getImageProcessor()
{
if (!$this->_processor) {
$filename = $this->getBaseFile() ? $this->_mediaDirectory->getAbsolutePath($this->getBaseFile()) : null;
$this->_processor = $this->_imageFactory->create($filename);
}
$this->_processor->keepAspectRatio($this->_keepAspectRatio);
$this->_processor->keepFrame($this->_keepFrame);
$this->_processor->keepTransparency($this->_keepTransparency);
$this->_processor->constrainOnly($this->_constrainOnly);
$this->_processor->backgroundColor($this->_backgroundColor);
$this->_processor->quality($this->_quality);
return $this->_processor;
}
/**
* @return int
*/
public function getHeight()
{
return $this->_height ?: $this->getOriginalHeight();
}
/**
* @param int $height
*
* @return $this
*/
public function setHeight($height)
{
$this->_height = abs((int)$height);
return $this;
}
/**
* @return int|null
*/
public function getOriginalHeight()
{
return $this->getImageProcessor()->getOriginalHeight();
}
/**
* @return string
*/
public function getDestinationSubdir()
{
return $this->_destinationSubdir;
}
/**
* @param string $dir
*
* @return $this
*/
public function setDestinationSubdir($dir)
{
$this->_destinationSubdir = $dir;
return $this;
}
/**
* Get image quality
*
* @return int
*/
public function getQuality()
{
return $this->_quality;
}
/**
* Set image quality, values in percentage from 0 to 100
*
* @param int $quality
*
* @return $this
*/
public function setQuality($quality)
{
$quality = abs((int)$quality);
if (0 < $quality) {
$this->_quality = $quality;
}
return $this;
}
/**
* @return $this
* @see \Magento\Framework\Image\Adapter\AbstractAdapter
*/
public function resize()
{
if ($this->_width == 0
&& $this->_height == 0
|| !$this->getBaseFile()
|| !$this->_fileExists($this->getBaseFile())
) {
return $this;
}
$resizedFile = $this->getResizedFile();
if ($resizedFile && $this->_fileExists($resizedFile)) {
return $this;
}
$new_filename = $this->_mediaDirectory->getAbsolutePath($resizedFile);
$this->getImageProcessor()->resize($this->_width, $this->_height);
$this->getImageProcessor()->save($new_filename);
return $this;
}
/**
* @param \Magento\Framework\Image $processor
*
* @return $this
*/
public function setImageProcessor($processor)
{
$this->_processor = $processor;
return $this;
}
/**
* @return string
* @throws NoSuchEntityException
*/
public function getUrl()
{
$media_url = $this->_storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_MEDIA);
if ($this->getBaseFile()) {
$resizedFile = $this->getResizedFile();
if ($resizedFile && $this->_fileExists($resizedFile)) {
return $media_url . $this->getResizedFile();
}
}
return $media_url . $this->__file;
}
/**
* @param string $size
*
* @return $this
*/
public function setSize($size)
{
// determine width and height from string
$width = $height = 0;
if (is_numeric($size)) {
$width = $height = $size;
} elseif (is_array($size)) {
if (1 >= count($size)) {
[$width, $height] = $size;
} else {
$width = $height = array_shift($size);
}
} elseif (is_string($size)) {
[$width, $height] = explode('x', strtolower($size), 2);
}
foreach (['width', 'height'] as $wh) {
${$wh} = (int)${$wh};
if (empty(${$wh})) {
${$wh} = null;
}
}
// set sizes
$this->setWidth($width)->setHeight($height);
return $this;
}
/**
* @param $file
*
* @throws Exception
*/
public function removeResized($file)
{
if (!empty($file)) {
$this->init($file);
}
$file = $this->getBaseFile();
if (!empty($file)) {
$new_filename = pathinfo($file);
$filename = implode(
'_',
[
$new_filename['filename'],
'*',
]
);
$new_filename['filename'] = $filename . '.' . $new_filename['extension'];
$pattern = implode(
'/',
[
$this->getDestinationSubdir(),
$new_filename['dirname'],
$new_filename['filename'],
]
);
$pattern = $this->_mediaDirectory->getAbsolutePath($pattern);
$files = Glob::glob($pattern);
if (!empty($files)) {
foreach ($files as $_file) {
if ($this->_fileExists($_file)) {
$this->_file->rm($_file);
}
}
}
}
}
/**
* @param $file
* @param array $attributes
*
* @return $this
* @throws Exception
*/
public function init($file, $attributes = [])
{
$this->_reset();
$this->__file = $file;
$this->setBaseFile($file);
$this->attributes = $attributes;
$this->setImageProperties();
return $this;
}
/**
* Resset all attributes
*/
protected function _reset()
{
$this->_processor = null;
$this->_baseFile = null;
$this->setQuality(90);
$this->setFileTemplate(static::BASE_TEMPLATE_FILE_NAME);
$this->setBackgroundColor([255, 255, 255]);
$this->setConstrainOnly(true);
$this->setDestinationSubdir('resized');
$this->setKeepAspectRatio(true);
$this->setKeepFrame(true);
$this->setKeepTransparency(true);
$this->setWidth(null);
$this->setHeight(null);
}
/**
* @param int[] $rgbArray
*
* @return $this
*/
public function setBackgroundColor(array $rgbArray)
{
$this->_backgroundColor = $rgbArray;
return $this;
}
/**
* @param bool $flag
*
* @return $this
*/
public function setConstrainOnly($flag)
{
$this->_constrainOnly = $flag && $flag !== 'false';
return $this;
}
/**
* @param bool $keep
*
* @return $this
*/
public function setKeepAspectRatio($keep)
{
$this->_keepAspectRatio = $keep && $keep !== 'false';
return $this;
}
/**
* @param bool $keep
*
* @return $this
*/
public function setKeepFrame($keep)
{
$this->_keepFrame = $keep && $keep !== 'false';
return $this;
}
/**
* @param bool $keep
*
* @return $this
*/
public function setKeepTransparency($keep)
{
$this->_keepTransparency = $keep && $keep !== 'false';
return $this;
}
/**
* Set image properties
*
* @return $this
*/
protected function setImageProperties()
{
// Set 'keep frame' flag
$frame = $this->getAttribute('frame');
if (!empty($frame)) {
$this->setKeepFrame($frame);
}
// Set 'quality'
$quality = $this->getAttribute('quality');
if (!empty($quality)) {
$this->setQuality($quality);
}
// Set 'constrain only' flag
$constrain = $this->getAttribute('constrain');
if (!empty($constrain)) {
$this->setConstrainOnly($constrain);
}
// Set 'keep aspect ratio' flag
$aspectRatio = $this->getAttribute('aspect_ratio');
if (!empty($aspectRatio)) {
$this->setKeepAspectRatio($aspectRatio);
}
// Set 'keep $crop' flag
$crop = $this->getAttribute('crop');
if (!empty($crop)) {
$this->seCropOnly($crop);
}
// Set 'transparency' flag
$transparency = $this->getAttribute('transparency');
if (!empty($transparency)) {
$this->setKeepTransparency($transparency);
}
// Set background color
$background = (array)$this->getAttribute('background');
if (!empty($background)) {
$this->setBackgroundColor($background);
}
$fileTemplate = $this->getAttribute('fileTemplate');
$this->setFileTemplate(!empty($fileTemplate) ? $fileTemplate : static::BASE_TEMPLATE_FILE_NAME);
return $this;
}
/**
* Retrieve image attribute
*
* @param string $name
*
* @return string
*/
protected function getAttribute($name)
{
return $this->attributes[$name] ?? null;
}
/**
* @param bool $flag
*
* @return $this
*/
public function seCropOnly($flag)
{
$this->_cropOnly = $flag && $flag !== 'false';
return $this;
}
}
+330
View File
@@ -0,0 +1,330 @@
<?php
namespace Olegnax\Core\Helper;
use Exception;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\Helper\Context;
use Magento\Framework\App\ProductMetadataInterface;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Component\ComponentRegistrar;
use Magento\Framework\Component\ComponentRegistrarInterface;
use Magento\Framework\Filesystem\Directory\ReadFactory;
use Magento\Framework\HTTP\Adapter\CurlFactory;
use Magento\Framework\HTTP\AsyncClient\Request;
use Magento\Framework\HTTP\PhpEnvironment\RemoteAddress;
use Magento\Framework\Module\ModuleListInterface;
use Psr\Log\LoggerInterface;
class ModuleInfo extends Helper
{
const MODULE_URL = 'https://olegnax.com/extras/products-status/magento2_modules.json';
const CACHE_PERIOD = 24 * 60 * 60;
const XML_PATH_CACHE = 'olegnax_core/module/cache';
const XML_PATH_CACHE_DATE = 'olegnax_core/module/datacache';
/**
* @var ProductMetadataInterface
*/
protected $productMetadata;
/**
* @var CurlFactory
*/
protected $curlFactory;
/**
* @var RemoteAddress
*/
protected $remoteAddress;
/**
* @var RequestInterface
*/
protected $request;
/**
* @var array
*/
protected $data;
/**
* @var string
*/
protected $_moduleUrl;
/**
* @var ComponentRegistrarInterface
*/
protected $componentRegistrar;
/**
* @var ModuleListInterface
*/
protected $moduleList;
/**
* @var ReadFactory
*/
protected $readFactory;
public function __construct(
Context $context,
LoggerInterface $logger,
CurlFactory $curlFactory,
ProductMetadataInterface $productMetadata,
RemoteAddress $remoteAddress,
ComponentRegistrarInterface $componentRegistrar,
ModuleListInterface $moduleList,
ReadFactory $readFactory,
RequestInterface $request
) {
$this->curlFactory = $curlFactory;
$this->moduleList = $moduleList;
$this->productMetadata = $productMetadata;
$this->remoteAddress = $remoteAddress;
$this->componentRegistrar = $componentRegistrar;
$this->readFactory = $readFactory;
$this->request = $request;
parent::__construct($context, $logger);
}
public function getServer(
$name
) {
return $this->request->getServer($name);
}
public function getModuleInfo($moduleName, $onlyInstalled = true)
{
$data = $this->getModule($moduleName);
if ('' == $data['setup_version'] && $onlyInstalled) {
return [];
}
$apiData = $this->getData();
if (array_key_exists($moduleName, $apiData)) {
$data = array_replace($data, $apiData[$moduleName]);
}
if (!isset($data['theme_module'])) {
$data['theme_module'] = false;
}
$data['server_version'] = isset($data['version']) ? $data['version'] : $data['setup_version'];
$data['update_status'] = version_compare(
$data['server_version'],
$data['setup_version'],
'>'
);
return $data;
}
/**
* @param string $moduleName
* @return bool
*/
public function isActive($moduleName){
return $this->_moduleManager->isEnabled($moduleName);
}
protected function getModule($name)
{
$module = $this->moduleList->getOne($name);
if (empty($module)) {
$module = [
'name' => $name,
'setup_version' => $this->getComposerVersion($name),
];
}
if (empty($module['setup_version'])) {
$module['setup_version'] = $this->getComposerVersion($name);
}
$module['title'] = str_replace('_', ' ', $module['name']);
return (array)$module;
}
protected function getComposerVersion($moduleName, $type = ComponentRegistrar::MODULE)
{
$path = $this->componentRegistrar->getPath($type, $moduleName);
if ($path) {
$dirReader = $this->readFactory->create($path);
if ($dirReader->isExist('composer.json')) {
$data = $dirReader->readFile('composer.json');
$data = json_decode($data, true);
if (isset($data['version'])) {
return $data['version'];
}
}
if ($dirReader->isExist('etc/module.xml')) {
$data = $dirReader->readFile('etc/module.xml');
if (preg_match('/setup_version="([^\"]+)"/i', $data, $matches)) {
return $matches[1];
}
}
}
return '';
}
public function getData($forsed = false)
{
$date = (int)$this->getSystemDefaultValue(static::XML_PATH_CACHE_DATE);
try {
if (empty($this->data)) {
$this->data = $this->decodeData($this->getSystemDefaultValue(static::XML_PATH_CACHE));
}
if ($date + static::CACHE_PERIOD < time() || $forsed || empty($this->data)) {
$this->data = $this->decodeData($this->loadData());
if (!empty($this->data)) {
$this->setSystemValue(
static::XML_PATH_CACHE,
json_encode($this->data),
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
0
);
$this->setSystemValue(
static::XML_PATH_CACHE_DATE,
time(),
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
0
);
}
}
} catch (Exception $e) {
$this->data = [];
}
return $this->data;
}
private function decodeData($data = '')
{
if (empty($data)) {
return [];
}
return (array)json_decode($data, true);
}
protected function loadData()
{
$curl = $this->curlFactory->create();
$curl->setConfig(
[
'timeout' => 2,
'maxredirects' => 5,
'useragent' => sprintf(
'Olegnax: %s/%s (%s)',
$this->productMetadata->getName(),
$this->productMetadata->getVersion(),
$this->productMetadata->getEdition()
),
'referer' => $this->getSystemDefaultValue('web/unsecure/base_url'),
'verifypeer' => 0,
'verifyhost' => 0,
]
);
$curl->write(Request::METHOD_GET, $this->getModuleUrl());
$data = $curl->read();
$curl->close();
if(!empty($data)){
$data = preg_split('/^\r?$/m', $data, 2);
if(!empty($data) && isset($data[1])){
$data = trim($data[1]);
return $data;
}
}
return '[]';
}
public function getModuleUrl()
{
if ($this->_moduleUrl === null) {
$this->_moduleUrl = self::MODULE_URL . $this->getHash();
}
return $this->_moduleUrl;
}
public function getHash()
{
$args = ['hash' => base64_encode($this->getCurrentIp())];
$args = array_filter($args);
$query = '';
if (!empty($args)) {
$query = '?' . http_build_query($args);
}
return $query;
}
public function getCurrentIp()
{
$variable = [
'HTTP_X_REAL_IP',
'HTTP_CLIENT_IP',
'HTTP_X_FORWARDED_FOR'
];
$value = array_map([$this, 'getServer'], $variable);
$value = array_filter($value);
$value = array_map('trim', $value);
$value[] = $this->getRemoteAddress();
$value = array_filter($value);
$value = implode(',', $value);
return $value;
}
public function getRemoteAddress()
{
return $this->remoteAddress->getRemoteAddress();
}
public function getThemeInfo($themePath, $themeName = null, $onlyInstalled = true)
{
$data = $this->getTheme($themePath);
if ('' == $data['setup_version'] && $onlyInstalled) {
return [];
}
if (empty($themeName) && isset($data['name']) && !empty($data['name'])) {
$themeName = $data['name'];
}
$apiData = $this->getData();
if (!empty($themeName) && array_key_exists($themeName, $apiData)) {
$data = array_replace($data, $apiData[$themeName]);
}
$data['server_version'] = isset($data['version']) ? $data['version'] : $data['setup_version'];
$data['update_status'] = version_compare(
$data['server_version'],
$data['setup_version'],
'>'
);
return $data;
}
private function getTheme($themePath)
{
$theme = [
'path' => $themePath,
'setup_version' => $this->getComposerVersion($themePath, ComponentRegistrar::THEME),
];
$theme['established'] = !empty($theme['setup_version']);
$name = $this->getThemeName($themePath);
if (!empty($name)) {
$theme['name'] = $name;
}
return (array)$theme;
}
protected function getThemeName($path)
{
$path = $this->componentRegistrar->getPath(ComponentRegistrar::THEME, $path);
if ($path) {
$dirReader = $this->readFactory->create($path);
if ($dirReader->isExist('theme.xml')) {
$data = $dirReader->readFile('theme.xml');
if (preg_match('/<title>([^<>]+)<\/title>/i', $data, $matches)) {
return $matches[1];
}
}
}
return null;
}
}
+549
View File
@@ -0,0 +1,549 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
namespace Olegnax\Core\Helper;
use Exception;
use Magento\Catalog\Block\Product\Image as CatalogBlockProductImage;
use Magento\Catalog\Helper\Image;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\Product\Image\ParamsBuilder;
use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Framework\App\Helper\Context;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\App\ProductMetadataInterface;
use Magento\Framework\Config\View;
use Magento\Framework\View\ConfigInterface;
/**
* Description of Image
*
* @author Master
*/
class ProductImage extends AbstractHelper
{
const TEMPLATE = 'Magento_Catalog::product/image_with_borders.phtml';
const HOVER_TEMPLATE = 'Magento_Catalog::product/hover_image_with_borders.phtml';
/**
* @var Image
*/
protected $imageHelper;
/**
* @var ConfigInterface
*/
protected $viewConfig;
/**
* @var View
*/
protected $configView;
/**
* @var ParamsBuilder
*/
private $imageParamsBuilder;
/**
* @var string
*/
protected $_magentoVersion;
/**
* ProductImage constructor.
*
* @param Context $context
* @param Image $imageHelper
* @param ConfigInterface $viewConfig
* @param ParamsBuilder $imageParamsBuilder
*/
public function __construct(
Context $context,
Image $imageHelper,
ConfigInterface $viewConfig,
ParamsBuilder $imageParamsBuilder
) {
$this->imageHelper = $imageHelper;
$this->viewConfig = $viewConfig;
$this->imageParamsBuilder = $imageParamsBuilder;
parent::__construct($context);
}
/**
* @param Product $product
* @param string $imageId
* @param string $imageIdHover
* @param string $template
* @param array $attributes
* @param array $properties
*
* @return mixed
*/
public function getImageHover(
Product $product,
$imageId,
$imageIdHover,
$template = self::HOVER_TEMPLATE,
array $attributes = [],
$properties = []
) {
if (!$this->hasHoverImage($product, $imageId, $imageIdHover)) {
return $this->getImage($product, $imageId, self::TEMPLATE, $attributes, $properties);
}
$image = $this->_getImage($product, $imageId, $properties)->getUrl();
$imageMiscParams = $this->getImageParams($imageId);
$image_hoverMiscParams = $this->getImageParams($imageIdHover);
$image_hover = $this->resizeImage(
$product,
$imageIdHover,
[
$imageMiscParams['image_width'],
$imageMiscParams['image_height'],
],
$properties
)->getUrl();
$data = [
'data' => [
'template' => $template,
'product_id' => $product->getId(),
'product' => $product,
'image_id' => $imageId,
'image_hover_id' => $imageIdHover,
'image_url' => $image,
'image_hover_url' => $image_hover,
'label' => $this->getLabel($product, $imageMiscParams['image_type']),
'label_hover' => $this->getLabel($product, $image_hoverMiscParams['image_type']),
'width' => $imageMiscParams['image_width'],
'height' => $imageMiscParams['image_height'],
'ratio' => $this->getRatio($imageMiscParams['image_width'], $imageMiscParams['image_height']),
'class' => $this->getClass($attributes),
'custom_attributes' => $this->getStringCustomAttributes($attributes),
],
];
return $this->_createTemplate($data);
}
/**
* @param Product $product
* @param string $imageId
* @param string $imageId_hover
*
* @return bool
*/
public function hasHoverImage(Product $product, $imageId, $imageId_hover)
{
if ($imageId != $imageId_hover) {
$_imageId = $this->getImageParams($imageId);
$_imageId_hover = $this->getImageParams($imageId_hover);
if ($_imageId['image_type'] !== $_imageId_hover['image_type']) {
$image = $product->getData($_imageId['image_type']);
$image_hover = $product->getData($_imageId_hover['image_type']);
return $image && $image_hover && 'no_selection' !== $image_hover && $image !== $image_hover;
}
}
return false;
}
/**
* @param int $imageId
*
* @return array
*/
public function getImageParams($imageId)
{
$viewImageConfig = $this->getConfigView()->getMediaAttributes(
'Magento_Catalog',
Image::MEDIA_TYPE_CONFIG_NODE,
$imageId
);
$imageMiscParams = $this->imageParamsBuilder->build($viewImageConfig);
if (empty($imageMiscParams)) {
$imageMiscParams = $this->getDefaultParams();
$this->_logger->critical(sprintf('No options found for "%s" images!', $imageId));
}
return $imageMiscParams;
}
/**
* Retrieve config view
*
* @return View
*/
protected function getConfigView()
{
if (!$this->configView) {
$this->configView = $this->viewConfig->getViewConfig();
}
return $this->configView;
}
/**
* @return array
*/
protected function getDefaultParams()
{
return [
"image_type" => "small_image",
"image_height" => 240,
"image_width" => 240,
"background" => [255, 255, 255],
"quality" => 80,
"keep_aspect_ratio" => true,
"keep_frame" => true,
"keep_transparency" => true,
"constrain_only" => true,
];
}
/**
* @param Product $product
* @param string $imageId
* @param string $template
* @param array $attributes
* @param array $properties
*
* @return mixed
*/
public function getImage(
Product $product,
$imageId,
$template = self::TEMPLATE,
array $attributes = [],
$properties = []
) {
$image = $this->_getImage($product, $imageId, $properties);
$imageMiscParams = $this->getImageParams($imageId);
$data = [
'data' => [
'template' => $template,
'product_id' => $product->getId(),
'product' => $product,
'image_id' => $imageId,
'image_url' => $image->getUrl(),
'label' => $this->getLabel($product, $imageMiscParams['image_type']),
'width' => $imageMiscParams['image_width'],
'height' => $imageMiscParams['image_height'],
'ratio' => $this->getRatio($imageMiscParams['image_width'], $imageMiscParams['image_height']),
'class' => $this->getClass($attributes),
'custom_attributes' => $this->getStringCustomAttributes($attributes),
],
];
return $this->_createTemplate($data);
}
/**
* @param Product $product
* @param string $imageId
* @param array $properties
*
* @return Image
*/
private function _getImage(Product $product, $imageId, $properties = [])
{
return $this->imageHelper->init($product, $imageId, $properties);
}
/**
* @param Product $product
*
* @param string $imageType
*
* @return string
*/
private function getLabel(Product $product, string $imageType): string
{
$label = "";
if (!empty($imageType)) {
$label = $product->getData($imageType . '_' . 'label');
}
if (empty($label)) {
$label = $product->getName();
}
return (string)$label;
}
/**
* Calculate image ratio
*
* @param $width
* @param $height
*
* @return float
*/
private function getRatio(int $width, int $height): float
{
if ($width && $height) {
return $height / $width;
}
return 1.0;
}
/**
* Retrieve image class for HTML element
*
* @param array $attributes
*
* @return string
*/
private function getClass(array $attributes): string
{
return $attributes['class'] ?? 'product-image-photo';
}
/**
* Retrieve image custom attributes for HTML element
*
* @param array $attributes
*
* @return string|array
*/
private function getStringCustomAttributes(array $attributes)
{
if (!$this->compareVersion()) {
return $attributes;
}
$result = [];
foreach ($attributes as $name => $value) {
$result[] = $name . '="' . $value . '"';
}
return !empty($result) ? implode(' ', $result) : '';
}
/**
* @return string
*/
private function getMagentoVersion()
{
if (!$this->_magentoVersion) {
$this->_magentoVersion = ObjectManager::getInstance()->get(ProductMetadataInterface::class)->getVersion();
}
return $this->_magentoVersion;
}
/**
* @param $version
*
* @return bool
*/
protected function compareVersion($version = '2.4.0')
{
return version_compare($this->getMagentoVersion(), $version, '<');
}
/**
* @param array $data
*
* @return CatalogBlockProductImage
*/
private function _createTemplate($data = [])
{
return ObjectManager::getInstance()->create(CatalogBlockProductImage::class, $data);
}
/**
* @param Product $product
* @param string $imageId
* @param array|int $size
* @param array $properties
*
* @return Image
*/
public function resizeImage(Product $product, $imageId, $size, $properties = [])
{
$size = $this->prepareSize($size);
$image = $this->_getImage($product, $imageId, $properties);
$image->resize($size[0], $size[1]);
return $image;
}
/**
* @param array|int $size
*
* @return array
*/
private function prepareSize($size)
{
if (is_array($size) && 1 >= count($size)) {
$size = array_shift($size);
}
if (!is_array($size)) {
$size = [$size, $size];
}
$size = array_map('floatval', $size);
$size = array_map('abs', $size);
return $size;
}
/**
* @param Product $product
* @param string $imageId
* @param string $imageId_hover
* @param array|int $size
* @param string $template
* @param array $attributes
* @param array $properties
*
* @return CatalogBlockProductImage|mixed
*/
public function getResizedImageHover(
Product $product,
$imageId,
$imageId_hover,
$size,
$template = self::HOVER_TEMPLATE,
array $attributes = [],
$properties = []
) {
if (!is_array($template)) {
$template = [
$template,
self::TEMPLATE,
];
} else {
foreach ([self::HOVER_TEMPLATE, self::TEMPLATE] as $key => $value) {
if (!isset($template[$key]) || empty($template[$key])) {
$template[$key] = $value;
}
}
}
if (!$this->hasHoverImage($product, $imageId, $imageId_hover)) {
return $this->getResizedImage($product, $imageId, $size, $template[1], $attributes, $properties);
}
$imageMiscParams = $this->getImageParams($imageId);
if (empty($size)) {
$size = [$imageMiscParams['image_width'], $imageMiscParams['image_height']];
} elseif (is_array($size)) {
foreach (['image_width', 'image_height'] as $key => $value) {
if (!isset($size[$key]) || empty($size[$key])) {
$size[$key] = $imageMiscParams[$value];
}
}
}
$image = $this->resizeImage($product, $imageId, $size, $properties);
try {
[
$imageMiscParams['image_width'],
$imageMiscParams['image_height']
] = $image->getResizedImageInfo();
} catch (Exception $e) {
$this->_logger->error("OX Product Image: " . $e->getMessage());
$imageMiscParams['image_width'] = $imageMiscParams['image_height'] = 1;
}
$image = $image->getUrl();
$image_hover = $this->resizeImage($product, $imageId_hover, $size, $properties)->getUrl();
$image_hoverMiscParams = $this->getImageParams($imageId_hover);
if (array_key_exists('class', $attributes)) {
unset($attributes['class']);
}
$data = [
'data' => [
'template' => $template[0],
'product_id' => $product->getId(),
'product' => $product,
'image_id' => $imageId,
'image_hover_id' => $imageId_hover,
'image_url' => $image,
'image_hover_url' => $image_hover,
'label' => $this->getLabel($product, $imageMiscParams['image_type']),
'label_hover' => $this->getLabel($product, $image_hoverMiscParams['image_type']),
'width' => $imageMiscParams['image_width'],
'height' => $imageMiscParams['image_height'],
'ratio' => $this->getRatio($imageMiscParams['image_width'], $imageMiscParams['image_height']),
'class' => $this->getClass($attributes),
'custom_attributes' => $this->getStringCustomAttributes($attributes),
],
];
return $this->_createTemplate($data);
}
/**
* @param Product $product
* @param string $imageId
* @param array|int $size
* @param string $template
* @param array $attributes
* @param array $properties
*
* @return CatalogBlockProductImage|mixed
*/
public function getResizedImage(
Product $product,
$imageId,
$size,
$template = self::TEMPLATE,
array $attributes = [],
$properties = []
) {
$imageMiscParams = $this->getImageParams($imageId);
if (empty($size)) {
return $this->getImage($product, $imageId, $template, $attributes, $properties);
}
if (is_array($size)) {
foreach (['image_width', 'image_height'] as $key => $value) {
if (!isset($size[$key]) || empty($size[$key])) {
$size[$key] = $imageMiscParams[$value];
}
}
}
$image = $this->resizeImage($product, $imageId, $size, $properties);
$imageMiscParams = $this->getImageParams($imageId);
try {
[
$imageMiscParams['image_width'],
$imageMiscParams['image_height']
] = $image->getResizedImageInfo();
} catch (Exception $e) {
$this->_logger->error("OX Product Image: " . $e->getMessage());
$imageMiscParams['image_width'] = $imageMiscParams['image_height'] = 1;
}
$data = [
'data' => [
'template' => $template,
'product_id' => $product->getId(),
'product' => $product,
'image_id' => $imageId,
'image_url' => $image->getUrl(),
'label' => $this->getLabel($product, $imageMiscParams['image_type']),
'width' => $imageMiscParams['image_width'],
'height' => $imageMiscParams['image_height'],
'ratio' => $this->getRatio($imageMiscParams['image_width'], $imageMiscParams['image_height']),
'class' => $this->getClass($attributes),
'custom_attributes' => $this->getStringCustomAttributes($attributes),
],
];
return $this->_createTemplate($data);
}
/**
* @param Product $product
* @param string $image
* @param array|int $size
* @param array $properties
*
* @return string
*/
public function getUrlResizedImage(Product $product, $image, $size, $properties = [])
{
$image = $this->resizeImage($product, $image, $size, $properties);
return $image->getUrl();
}
}
+19
View File
@@ -0,0 +1,19 @@
<?php
/*
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2021 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
namespace Olegnax\Core\Logger;
use Magento\Framework\Logger\Handler\Base;
use Monolog\Logger;
class Debug extends Base
{
protected $loggerType = Logger::DEBUG;
protected $fileName = '/var/log/olegnax.log';
}
+13
View File
@@ -0,0 +1,13 @@
<?php
/*
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2021 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
namespace Olegnax\Core\Logger;
class Logger extends \Monolog\Logger
{
}
+38
View File
@@ -0,0 +1,38 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
namespace Olegnax\Core\Model\Config\Source;
use Magento\Framework\Option\ArrayInterface;
/**
* @api
* @since 100.0.2
*/
class Noyes implements ArrayInterface
{
/**
* Options getter
*
* @return array
*/
public function toOptionArray()
{
return [['value' => 0, 'label' => __('No')], ['value' => 1, 'label' => __('Yes')]];
}
/**
* Get options in "key-value" format
*
* @return array
*/
public function toArray()
{
return [0 => __('No'), 1 => __('Yes')];
}
}
+38
View File
@@ -0,0 +1,38 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
namespace Olegnax\Core\Model\Config\Source;
use Magento\Framework\Option\ArrayInterface;
/**
* @api
* @since 100.0.2
*/
class Yesno implements ArrayInterface
{
/**
* Options getter
*
* @return array
*/
public function toOptionArray()
{
return [['value' => 1, 'label' => __('Yes')], ['value' => 0, 'label' => __('No')]];
}
/**
* Get options in "key-value" format
*
* @return array
*/
public function toArray()
{
return [1 => __('Yes'), 0 => __('No')];
}
}
+558
View File
@@ -0,0 +1,558 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
namespace Olegnax\Core\Model;
use Exception;
use Magento\AdminNotification\Model\InboxFactory;
use Magento\Framework\App\DeploymentConfig;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\App\ProductMetadataInterface;
use Magento\Framework\Component\ComponentRegistrar;
use Magento\Framework\Component\ComponentRegistrarInterface;
use Magento\Framework\Config\ConfigOptionsListConstants;
use Magento\Framework\DataObject;
use Magento\Framework\Filesystem\Directory\ReadFactory;
use Magento\Framework\HTTP\Adapter\CurlFactory;
use Magento\Framework\HTTP\AsyncClient\Request;
use Magento\Framework\Model\AbstractModel;
use Magento\Framework\Module\ModuleListInterface;
use Magento\Framework\Notification\MessageInterface;
use Magento\Store\Model\StoreManagerInterface;
use Olegnax\Core\Helper\Helper;
use Olegnax\Core\Model\ResourceModel\Inbox\Collection\ExistsFactory;
use Olegnax\Core\Model\ResourceModel\Inbox\Collection\ExpiredFactory;
use Olegnax\Core\Model\ResourceModel\Inbox\Collection\OxContent;
use Olegnax\Core\Model\ResourceModel\Inbox\Collection\OxContentP;
use Olegnax\Core\Model\ResourceModel\Inbox\Collection\OXFactory;
use Olegnax\Core\Model\ResourceModel\Inbox\Collection\OxUpdate;
use SimpleXMLElement;
class Feed extends AbstractModel
{
/**
* @var string
*/
const FEED_URL = "olegnax.com/extras/products-status/feed.xml";
/**
* @var integer
*/
const FREQUENCY = 24;
/**
* @var integer
*/
const REMOVE_FREQUENCY = 6;
/**
*
* @var ObjectManager
*/
public $_objectManager;
/**
* Feed url
*
* @var string
*/
protected $_feedUrl;
/**
* @return $this
*/
public function checkUpdate()
{
if ($this->getFrequency() + $this->getLastUpdate() > time()) {
return $this;
}
$feedData = [];
$feedXml = $this->getFeedXml();
$installDate = strtotime($this->_loadObject(DeploymentConfig::class)->get(ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE));
$types = [];
if ($feedXml && $feedXml->channel && $feedXml->channel->item) {
foreach ($feedXml->channel->item as $item) {
$severity = isset($item->severity) ? (int)$item->severity : MessageInterface::SEVERITY_NOTICE;
$type = isset($item->type) ? $this->escapeString($item->type) : null;
$extensionUpdate = $this->validateExtNeedUpdate($item->extensionUpdate, 'Olegnax');
$validate = [];
if ($extensionUpdate) {
$type = OxUpdate::TYPE_UPDATE;
$validate = [
'extension_update' => $extensionUpdate,
];
}
$pubDate = strtotime((string)$item->pubDate);
$expirationDate = (string)$item->expirationDate ? strtotime((string)$item->expirationDate) : null;
if ($installDate > $pubDate) {
continue;
}
if ($expirationDate && $expirationDate < gmdate('U')) {
continue;
}
if ($item->extension_update && !$extensionUpdate) {
continue;
}
if (!$type && MessageInterface::SEVERITY_NOTICE > $severity) {
continue;
}
if (!$this->validateExtInstalled($item->extension, 'Olegnax')) {
continue;
}
if (!$this->validateExtNotInstalled($item->extensionNot, 'Olegnax')) {
continue;
}
if (!$this->validateExtInstalled($item->extension3D)) {
continue;
}
if ($type) {
if (OxContent::TYPE_CONTENT > $severity) {
$severity = OxContent::TYPE_CONTENT;
}
$types[] = $type;
} else {
if (OxContent::TYPE_CONTENT == $severity || OxContentP::TYPE_CONTENT == $severity) {
$type = 'global';
$types[] = $type;
}
}
$_feedData = [
'severity' => $severity,
'date_added' => date('Y-m-d H:i:s', $pubDate),
'date_expire' => $expirationDate,
'title' => $this->escapeString($item->title),
'description' => $this->escapeString($item->description),
'url' => $this->escapeString($item->link),
'ox_content' => (string)$item->content,
'ox_image' => (string)$item->image,
'ox_type' => $type,
'ox_validate' => json_encode($validate),
'isOX' => 1,
];
if ($type && !in_array($type, ['update'])) {
$_feedData['is_read'] = 1;
$_feedData['is_remove'] = 1;
}
$feedData[] = $_feedData;
}
if ($feedData) {
if (!empty($types)) {
$this->removeOXType($types);
}
$this->_loadObject(InboxFactory::class)->create()->parse(array_reverse($feedData));
}
}
$this->setLastUpdate();
return $this;
}
/**
* @return int
*/
public function getFrequency()
{
return self::FREQUENCY * 3600;
}
/**
* @return Helper
*/
protected function helper(){
return $this->_loadObject( Helper::class);
}
/**
* @return int
*/
public function getLastUpdate()
{
return (int)$this->helper()->getModuleConfig('admin_notifications/lastcheck');
}
/**
* @return SimpleXMLElement
*/
public function getFeedXml()
{
try {
$data = $this->getFeedData();
$xml = new SimpleXMLElement($data);
} catch (Exception $e) {
$xml = new SimpleXMLElement('<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"></rss>');
}
return $xml;
}
/**
* @return string
*/
public function getFeedData()
{
$curl = $this->_loadObject(CurlFactory::class)->create();
$curl->setConfig(
[
'timeout' => 2,
'maxredirects' => 5,
'useragent' => $this->getUserAgent(),
'referer' => $this->getCurrentUrl(),
'verifypeer' => false,
'verifyhost' => false,
]
);
$curl->write( Request::METHOD_GET, $this->getFeedUrl(), '1.0');
$data = $curl->read();
if ($data === false || $data === '') {
return '';
}
$data = preg_split('/^\r?$/m', $data, 2);
$data = trim($data[1]);
$curl->close();
return $data;
}
/**
* @param string $object
* @return mixed
*/
protected function _loadObject($object)
{
return $this->_getObjectManager()->get($object);
}
/**
* @return ObjectManager
*/
protected function _getObjectManager()
{
if (!$this->_objectManager) {
$this->_objectManager = ObjectManager::getInstance();
}
return $this->_objectManager;
}
/**
* @return string
*/
protected function getUserAgent()
{
return sprintf("Olegnax: %s/%s (%s)", $this->getProductMetadata()->getName(),
$this->getProductMetadata()->getVersion(), $this->getProductMetadata()->getEdition());
}
/**
* @return ProductMetadataInterface
*/
protected function getProductMetadata()
{
return $this->_loadObject(ProductMetadataInterface::class);
}
/**
* @return StoreManagerInterface
*/
public function getCurrentUrl()
{
return $this->_loadObject(StoreManagerInterface::class)->getStore()->getBaseUrl();
}
/**
* @return string
*/
public function getFeedUrl()
{
$httpPath = $this->getScheme();
if ($this->_feedUrl === null) {
$this->_feedUrl = $httpPath . self::FEED_URL;
}
return $this->_feedUrl;
}
/**
* @return string
*/
private function getScheme()
{
return 'https://';
// $url = $this->_loadObject(StoreManagerInterface::class)->getStore()->getBaseUrl();
// $scheme = parse_url($url, PHP_URL_SCHEME);
// if (empty($scheme)) {
// $scheme = 'http';
// }
//
// return $scheme . '://';
}
/**
* @param SimpleXMLElement $data
* @return string
*/
private function escapeString(SimpleXMLElement $data)
{
return htmlspecialchars((string)$data);
}
/**
* @param string $extensions
* @param string $vendor
* @return bool|string
*/
protected function validateExtNeedUpdate($extensions, $vendor = '')
{
$extensionsName = $this->validateExt($extensions, $vendor);
if (!is_array($extensionsName)) {
return false;
}
$extensionsName = array_filter($extensionsName, function ($value) {
return 1 === $value;
});
$extensionsName = array_keys($extensionsName);
if (empty($extensionsName)) {
return false;
}
$extensions = $this->prepareExtValue($extensions);
$_extensions = [];
foreach ($extensionsName as $extensionName) {
$_extensions[] = sprintf('%s (%s)', $extensionName, $extensions[$extensionName]);
}
return implode(', ', $_extensions);
}
/**
* @param string $extensions
* @param string $vendor
* @param bool $diff
* @return array|bool
*/
protected function validateExt($extensions, $vendor = '', $diff = false)
{
$extensions = $this->prepareExtValue($extensions);
if (empty($extensions)) {
return true;
}
$extensionsName = array_keys($extensions);
$modules = $this->getInstalledExt($vendor);
if ($diff) {
$extensionsName = array_diff($extensionsName, $modules);
} else {
$extensionsName = array_intersect($extensionsName, $modules);
}
if (empty($extensionsName)) {
return false;
}
$_extensions = [];
foreach ($extensionsName as $extensionName) {
$_extensions[$extensionName] = $this->validateVersion($extensionName, $extensions[$extensionName]);
}
return $_extensions;
}
/**
* @param string $extension
* @return array
*/
protected function prepareExtValue($extension)
{
$extensions = [];
if (preg_match_all('/([a-z0-9_]+)(\s\(([^\(\)]+)\))*/i', $extension, $matches, PREG_SET_ORDER)) {
foreach ($matches as $matche) {
$name = $matche[1];
$version = isset($matche[3]) ? $matche[3] : null;
$extensions[$name] = $version;
}
}
return $extensions;
}
/**
* @param string $vendor
* @return array
*/
protected function getInstalledExt($vendor = '')
{
$modules = $this->_loadObject(ModuleListInterface::class)->getNames();
$dispatchResult = new DataObject($modules);
$modules = $dispatchResult->toArray();
if (!empty($filter)) {
$_modules = [];
foreach ($modules as $module) {
$_module = explode('_', $module);
$_vendor = array_shift($_module);
if ($vendor == $_vendor) {
$_modules[] = $module;
}
}
$modules = $_modules;
}
$modules = array_filter($modules);
sort($modules, SORT_STRING);
return $modules;
}
/**
* @param string $moduleName
* @param string $version
* @return string|null
*/
protected function validateVersion($moduleName, $version)
{
$cur_version = $this->getComposerVersion($moduleName);
if (is_string($version) && is_string($cur_version)) {
return version_compare($version, $cur_version);
}
return null;
}
/**
* @param string $moduleName
* @param string $type
* @return string|null
*/
protected function getComposerVersion($moduleName, $type = ComponentRegistrar::MODULE)
{
$path = $this->_loadObject(ComponentRegistrarInterface::class)->getPath($type, $moduleName);
if ($path) {
$dirReader = $this->_loadObject(ReadFactory::class)->create($path);
if ($dirReader->isExist('composer.json')) {
$data = $dirReader->readFile('composer.json');
$data = json_decode($data, true);
if (isset($data['version'])) {
return $data['version'];
}
}
if ($dirReader->isExist('etc/module.xml')) {
$data = $dirReader->readFile('etc/module.xml');
if (preg_match('/setup_version="([^\"]+)"/i', $data, $matches)) {
return $matches[1];
}
}
}
return '';
}
/**
* @param string $extensions
* @param string $vendor
* @return array|bool
*/
protected function validateExtInstalled($extensions, $vendor = '')
{
return $this->validateExt($extensions, $vendor);
}
/**
* @param string $extensions
* @param string $vendor
* @return array|bool
*/
protected function validateExtNotInstalled($extensions, $vendor = '')
{
return $this->validateExt($extensions, $vendor);
}
/**
* @param array $types
* @return $this
*/
public function removeOXType($types = [])
{
if (empty($types) || !is_array($types)) {
return $this;
}
$types = array_unique($types);
/** @var OXFactory $collection */
$collection = $this->_loadObject(OXFactory::class)->create()->addFieldToFilter('ox_type',
array('in' => $types));
foreach ($collection as $model) {
$model->setIsRemove(1)->save()->delete();
}
return $this;
}
/**
* @return $this
*/
public function setLastUpdate()
{
$this->helper()->setModuleConfig('admin_notifications/lastcheck', time());
return $this;
}
/**
* @return $this
*/
public function removeExpiredItems()
{
if ($this->getLastRemove() + self::REMOVE_FREQUENCY > time()) {
return $this;
}
/** @var ExpiredFactory $collection */
$collection = $this->_loadObject(ExpiredFactory::class)->create();
foreach ($collection as $model) {
$model->setIsRemove(1)->save()->delete();
}
$this->setLastRemove();
return $this;
}
/**
* @return int
*/
public function getLastRemove()
{
return (int)$this->helper()->getModuleConfig('admin_notifications/lastremove');
}
/**
* @return $this
*/
public function setLastRemove()
{
$this->helper()->setModuleConfig('admin_notifications/lastremove', time());
return $this;
}
/**
* @param SimpleXMLElement $link
* @return mixed
*/
private function isItemExists($link)
{
return $this->_loadObject(ExistsFactory::class)->create()->execute($this->escapeString($link));
}
}
@@ -0,0 +1,27 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
namespace Olegnax\Core\Model\ResourceModel\Inbox\Collection;
use Magento\AdminNotification\Model\ResourceModel\Inbox\Collection;
class Exists extends Collection
{
/**
* @param string $url
* @return bool
*/
public function execute(string $url)
{
$this->addFieldToFilter('url', $url);
return $this->getSize() > 0;
}
}
@@ -0,0 +1,22 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
namespace Olegnax\Core\Model\ResourceModel\Inbox\Collection;
class Expired extends OX
{
protected function _initSelect()
{
return parent::_initSelect()
->addFieldToFilter('is_remove', 0)
->addFieldToFilter('date_expire', ['lt' => date('Y-m-d H:i:s')]);
}
}
@@ -0,0 +1,21 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
namespace Olegnax\Core\Model\ResourceModel\Inbox\Collection;
use Magento\AdminNotification\Model\ResourceModel\Inbox\Collection;
class OX extends Collection
{
protected function _initSelect()
{
return parent::_initSelect()
->addFieldToFilter('isOX', 1);
}
}
@@ -0,0 +1,23 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
namespace Olegnax\Core\Model\ResourceModel\Inbox\Collection;
class OxContent extends OX
{
const TYPE_CONTENT = 5;
protected function _initSelect()
{
return parent::_initSelect()
->addFilter('is_remove', 1)
->addFieldToFilter('severity', self::TYPE_CONTENT);
}
}
@@ -0,0 +1,22 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
namespace Olegnax\Core\Model\ResourceModel\Inbox\Collection;
class OxContentP extends OX
{
const TYPE_CONTENT = 6;
protected function _initSelect()
{
return parent::_initSelect()
->addFilter('is_remove', 1)
->addFieldToFilter('severity', self::TYPE_CONTENT);
}
}
@@ -0,0 +1,26 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
namespace Olegnax\Core\Model\ResourceModel\Inbox\Collection;
use Magento\Framework\Notification\MessageInterface;
class OxNews extends OX
{
protected function _initSelect()
{
return parent::_initSelect()
->addFilter('is_remove', 0)
->addFilter('is_read', 0)
->addFieldToFilter('severity', ['gteq' => MessageInterface::SEVERITY_CRITICAL])
->setOrder('date_added')
->distinct(true);
}
}
@@ -0,0 +1,23 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
namespace Olegnax\Core\Model\ResourceModel\Inbox\Collection;
class OxUpdate extends OX
{
const TYPE_UPDATE = 'update';
protected function _initSelect()
{
return parent::_initSelect()
->addFieldToFilter('ox_type', self::TYPE_UPDATE)
->setOrder('date_added');
}
}
+27
View File
@@ -0,0 +1,27 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
namespace Olegnax\Core\Model;
use Magento\Backend\Block\Template\Context;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;
class Spacer extends Field {
public function __construct(
Context $context, array $data = []
) {
parent::__construct($context, $data);
}
protected function _decorateRowHtml( AbstractElement $element, $html)
{
return '<tr id="row_' . $element->getHtmlId() . '"><td></td><td colspan="2"><hr class="ox-settings-spacer"></td></tr>';
}
}
@@ -0,0 +1,89 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Athlete2
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Olegnax\Core\Observer\Frontend\View;
use Magento\Framework\DataObject;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\View\Element\AbstractBlock;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\LayoutInterface as ViewLayout;
use Olegnax\Core\Helper\Helper;
class BlockAbstractToHtmlAfter implements ObserverInterface
{
const BLOCK_NAME = 'ox_require.js';
const FIND_BLOCK_NAME = 'require.js';
const BLOCK_TEMPLATE = 'Olegnax_Core::require_js.phtml';
/**
* @var Helper
*/
protected $_helper;
/**
* @var ViewLayout
*/
protected $_viewLayout;
/**
* BlockAbstractToHtmlAfter constructor.
* @param Helper $helper
* @param ViewLayout $viewLayout
*/
public function __construct(
Helper $helper,
ViewLayout $viewLayout
) {
$this->_helper = $helper;
$this->_viewLayout = $viewLayout;
}
/**
* Execute observer
*
* @param Observer $observer
* @return void
*/
public function execute(
Observer $observer
) {
if (!$this->_helper->isEnabled()) {
return;
}
/** @var AbstractBlock $block */
$block = $observer->getData('block');
if (static::FIND_BLOCK_NAME == $block->getNameInLayout()) {
$_html = $block = $this->_viewLayout
->createBlock(
Template::class,
static::BLOCK_NAME,
[
'data' =>
[
'helper' => $this->_helper,
],
]
)
->setTemplate(static::BLOCK_TEMPLATE)
->toHtml();
if (empty($_html)) {
return;
}
/** @var DataObject $transport */
$transport = $observer->getData('transport');
/** @var string $html */
$html = $transport->getData('html');
$html .= $_html;
$transport->setData('html', $html);
$observer->setData('transport', $transport);
}
}
}
@@ -0,0 +1,73 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
namespace Olegnax\Core\Observer;
use Exception;
use Magento\Backend\Model\Auth\Session;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
use Olegnax\Core\Model\Feed;
use Olegnax\Core\Model\FeedFactory;
use Psr\Log\LoggerInterface;
class PredispatchAdminActionControllerObserver implements ObserverInterface
{
/**
* @var FeedFactory
*/
protected $_feedFactory;
/**
* @var Session
*/
protected $_backendAuthSession;
/**
* @var LoggerInterface
*/
private $logger;
/**
* @param FeedFactory $feedFactory
* @param Session $backendAuthSession
* @param LoggerInterface $logger
*/
public function __construct(
FeedFactory $feedFactory,
Session $backendAuthSession,
LoggerInterface $logger
) {
$this->_feedFactory = $feedFactory;
$this->_backendAuthSession = $backendAuthSession;
$this->logger = $logger;
}
/**
* Predispatch admin action controller
*
* @param Observer $observer
* @return void
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function execute(Observer $observer)
{
if ($this->_backendAuthSession->isLoggedIn()) {
try {
$feedModel = $this->_feedFactory->create();
/* @var $feedModel Feed */
$feedModel->checkUpdate();
$feedModel->removeExpiredItems();
} catch (Exception $exception) {
$this->logger->critical($exception);
}
}
}
}
@@ -0,0 +1,65 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*
* @noinspection PhpMissingFieldTypeInspection
*/
declare(strict_types=1);
namespace Olegnax\Core\Plugin\Backend\Magento\Cms\Model\Wysiwyg;
use Closure;
use Magento\Cms\Model\Wysiwyg\Validator as CmsValidator;
use Magento\Framework\Registry;
use Olegnax\Core\Helper\Helper;
class Validator
{
public const XML_PATH_DISABLE = 'athlete2_settings/general/cms_validator_disable';
public const VARIABLE_TO_DISABLE = 'ox_core_cms_validator_disable';
/**
* @var Helper
*/
protected $helper;
/**
* @var Registry
*/
protected $coreRegistry;
/**
* Validator constructor.
*
* @param Helper $helper
*/
public function __construct(
Helper $helper,
Registry $coreRegistry
) {
$this->helper = $helper;
$this->coreRegistry = $coreRegistry;
}
/**
* @param CmsValidator $subject
* @param Closure $proceed
* @param string $content
*
* @noinspection ReturnTypeCanBeDeclaredInspection
* @noinspection PhpUnusedParameterInspection
*/
public function aroundValidate(
CmsValidator $subject,
Closure $proceed,
string $content
) {
if (
!$this->helper->getConfig(static::XML_PATH_DISABLE)
&& !$this->coreRegistry->registry(static::VARIABLE_TO_DISABLE)
) {
$proceed($content);
}
}
}
@@ -0,0 +1,212 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
namespace Olegnax\Core\Plugin\Magento\Config\Controller\Adminhtml\System\Config;
use Closure;
use Exception;
use Magento\Backend\Model\View\Result\Redirect;
use Magento\Config\Controller\Adminhtml\System\Config\Save as Config;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Controller\Result\RedirectFactory;
use Magento\Framework\Message\ManagerInterface;
class Save
{
/**
* @var ManagerInterface
*/
protected $O0O;
/**
* @var RedirectFactory
*/
protected $O00;
/**
* @var RequestInterface
*/
protected $OOO;
/**
* Save constructor.
*
* @param RequestInterface $a
* @param ManagerInterface $messageManager
* @param RedirectFactory $resultRedirectFactory
*/
public function __construct(
RequestInterface $OOO,
ManagerInterface $O0O,
RedirectFactory $OO0
) {
$this->OOO = $OOO;
$this->O0O = $O0O;
$this->O00 = $OO0;
}
/**
* @param Config $OOOO
* @param Closure $OOO
*
* @return Redirect
*/
public function aroundExecute(
Config $OOOO,
Closure $OOO
) {
$O0OO = $this->OOO->getParam('section');
$O00O = $this->OO0('YWN0aXZl');
$OOOOOO = $this->OO0('Z2V0');
$OOOO0O = $this->OO0('ZGF0YQ==');
$OOO00O = $this->OO0('c3RhdHVz');
$OO0O0O = $this->OO0('YWN0aXZhdGlvbl9pZA==');
$O0OO0O = $this->OO0('dGhlX2tleQ==');
$O000 = time();
$OO0 = ScopeConfigInterface::SCOPE_TYPE_DEFAULT;
switch ($O0OO) {
case $this->OO0('YXRobGV0ZTJfc2V0dGluZ3M='):
case $this->OO0('YXRobGV0ZTJfZGVzaWdu'):
$OOO0 = $this->O0O('XE9sZWduYXhcQXRobGV0ZTJcSGVscGVyXEhlbHBlcg==');
if ($OOO0) {
$OO0OO = $this->OO0('Z2VuZXJhbC9pbnN0YWxsX2RhdGU=');
$OO0O0 = (int)$OOO0->getModuleConfig($OO0OO, 0, $OO0);
if ($OO0O0) {
if ($OO0O0 && $O000 > $OO0O0 + rand(27 * 44800, 28 * 49371)) {
if ($OOO0->$OOOOOO()
&& !is_string($OOO0->$OOOOOO())
&& $this->O00($this->O00($OOO0->$OOOOOO(), $OOOO0O), $OO0O0O)
&& $this->O00($this->O00($OOO0->$OOOOOO(), $OOOO0O), $O0OO0O)
&& $O00O == $this->O00($this->O00($OOO0->$OOOOOO(), $OOOO0O), $OOO00O)
) {
return $OOO();
}
} else {
return $OOO();
}
} else {
$OOO0->setModuleConfig($OO0OO, time(), $OO0, 0);
return $OOO();
}
}
break;
case $this->OO0('b2xlZ25heF9pbnN0YWdyYW1fcHJv'):
case $this->OO0('b2xlZ25heF9pbnN0YWdyYW1fcHJvX2FwcGVhcmFuY2U='):
$OO00 = $this->O0O('XE9sZWduYXhcSW5zdGFncmFtRmVlZFByb1xIZWxwZXJcSGVscGVy');
if ($OO00) {
$OO00O = $this->OO0('Z2VuZXJhbC9pbnN0YWxsX2RhdGU=');
$OO000 = (int)$OO00->getModuleConfig($OO00O, 0, $OO0);
if ($OO000) {
if ($OO000 > $O000 - rand(18900 * 64, 45 * 30720)) {
if ($OO00 && $OO00->$OOOOOO() && !is_string($OO00->$OOOOOO())
&& $this->O00($OO00->$OOOOOO(), $OOOO0O)) {
if (
$this->O00($this->O00($OO00->$OOOOOO(), $OOOO0O), $OOO00O) == $O00O
&& $this->O00($this->O00($OO00->$OOOOOO(), $OOOO0O), $O0OO0O)
&& $this->O00($this->O00($OO00->$OOOOOO(), $OOOO0O), $OO0O0O)
) {
return $OOO();
}
}
} else {
return $OOO();
}
} else {
$OO00->setModuleConfig($OO00O, time(), $OO0, 0);
return $OOO();
}
}
break;
case $this->OO0('b2xlZ25heF9pbmZpbml0ZXNjcm9sbF9wcm8='):
$O0O0 = $this->O0O('XE9sZWduYXhcSW5maW5pdGVTY3JvbGxQcm9cSGVscGVyXEhlbHBlcg==');
if ($O0O0) {
$O0O0O = $this->OO0('Z2VuZXJhbC9pbnN0YWxsX2RhdGU=');
$O0O00 = (int)$O0O0->getModuleConfig($O0O0O, 0, $OO0);
if ($O0O00) {
if ($O000 > $O0O00 + rand(9450 * 128, 246 * 5619)) {
if ($O0O0 && $O0O0->$OOOOOO() && !is_string($O0O0->$OOOOOO())
&& $this->O00($O0O0->$OOOOOO(), $OOOO0O)) {
if (
$this->O00($this->O00($O0O0->$OOOOOO(), $OOOO0O), $O0OO0O)
&& $this->O00($this->O00($O0O0->$OOOOOO(), $OOOO0O), $OO0O0O)
&& $O0O0->$OOOOOO()->data->status == $O00O) {
return $OOO();
}
}
} else {
return $OOO();
}
} else {
$O0O0->setModuleConfig($O0O0O, time(), $OO0, 0);
return $OOO();
}
}
break;
default:
return $OOO();
break;
}
$this->O0O->addErrorMessage($this->OO0('RXJyb3IgTDEgOiBDb25maWd1cmF0aW9uIHdhcyBub3Qgc2F2ZWQu'));
/** @var Redirect $O00 */
$O00 = $this->O00->create();
return $O00->setPath(
$this->OO0('YWRtaW5odG1sL3N5c3RlbV9jb25maWcvZWRpdA=='),
[
'_current' => ['section', 'website', 'store'],
'_nosid' => true,
]
);
}
/**
* @param string $b
*
* @return string
*/
private function OO0($b)
{
$a = '_';
$a .= 'd';
$f = '4' . $a;
$f .= 'e';
$k = '6' . $f;
$k .= 'c';
$z = 'e' . $k;
$z .= 'o';
$h = 's' . $z;
$h .= 'd';
$o = 'a' . $h;
$o .= 'e';
$oo = 'b' . $o;
return $oo($b);
}
/**
* @param string $object
*
* @return mixed
*/
private function O0O($object)
{
$object = $this->OO0($object);
if (class_exists($object)) {
return ObjectManager::getInstance()->get($object);
} else {
return null;
}
}
private function O00($a, $b)
{
return ($a && is_object($a) && !is_array($a) && isset($a->$b)) ? $a->$b : null;
}
}
@@ -0,0 +1,51 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
namespace Olegnax\Core\Plugin\Magento\Framework\View\TemplateEngine;
use Magento\Framework\Escaper;
use Magento\Framework\View\Element\BlockInterface;
use Magento\Framework\View\TemplateEngine\Php as TemplateEnginePhp;
class Php
{
/**
* @var Escaper
*/
private $escaper;
/**
* Php constructor.
* @param Escaper $escaper
*/
public function __construct(Escaper $escaper)
{
$this->escaper = $escaper;
}
/**
* @param TemplateEnginePhp $subject
* @param BlockInterface $block
* @param string $fileName
* @param array $dictionary
* @return array
*/
public function beforeRender(
TemplateEnginePhp $subject,
BlockInterface $block,
$fileName,
array $dictionary = []
) {
if (!isset($dictionary['escaper'])) {
$dictionary['escaper'] = $this->escaper;
}
return [$block, $fileName, $dictionary];
}
}
+158
View File
@@ -0,0 +1,158 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/)
* @license https://olegnax.com/license
*/
namespace Olegnax\Core\Setup;
use Magento\Framework\DB\Ddl\Table;
use Magento\Framework\Setup\InstallSchemaInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
class InstallSchema implements InstallSchemaInterface
{
/** @noinspection PhpUnusedParameterInspection */
/**
* {@inheritdoc}
*/
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
$this->_install($setup);
$setup->endSetup();
}
private function _install(SchemaSetupInterface $setup)
{
$tables = [
'adminnotification_inbox' => [
'notification_id' => [
'identity' => true,
'nullable' => false,
'primary' => true,
'unsigned' => true,
'comment' => 'Notification id',
],
'severity' => [
'type' => Table::TYPE_SMALLINT,
'unsigned' => true,
'nullable' => false,
'identity' => false,
'default' => '0',
'comment' => 'Problem type',
],
'date_added' => [
'type' => Table::TYPE_TIMESTAMP,
'nullable' => false,
'on_update' => false,
'default' => 'CURRENT_TIMESTAMP',
'comment' => 'Create date',
],
'title' => [
'type' => 'varchar',
'size' => 255,
'nullable' => false,
'comment' => 'Title',
],
'description' => [
'type' => Table::TYPE_TEXT,
'nullable' => true,
'comment' => 'Description',
],
'url' => [
'type' => 'varchar',
'size' => 255,
'nullable' => true,
'comment' => 'Url',
],
'is_read' => [
'type' => Table::TYPE_SMALLINT,
'unsigned' => true,
'nullable' => false,
'identity' => false,
'default' => '0',
'comment' => 'Flag if notification read',
],
'is_remove' => [
'type' => Table::TYPE_SMALLINT,
'unsigned' => true,
'nullable' => false,
'identity' => false,
'default' => '0',
'comment' => 'Flag if notification might be removed'
],
'ox_content' => [
'type' => Table::TYPE_TEXT,
'nullable' => true,
'comment' => 'News content',
],
'ox_image' => [
'type' => Table::TYPE_TEXT,
'nullable' => true,
'comment' => 'News image',
],
'ox_validate' => [
'type' => Table::TYPE_TEXT,
'nullable' => true,
'comment' => 'Validate',
],
'ox_type' => [
'type' => Table::TYPE_TEXT,
'nullable' => true,
'comment' => 'Type Content',
],
'date_expire' => [
'type' => Table::TYPE_DATETIME,
'nullable' => true,
'comment' => 'Date Expire',
],
'isOX' => [
'type' => Table::TYPE_SMALLINT,
'nullable' => false,
'default' => 0,
'comment' => 'is olegnax news',
],
],
];
$connection = $setup->getConnection();
foreach ($tables as $table_name => $table) {
$exist = $setup->tableExists($table_name);
if ($exist) {
$_table = $setup->getTable($table_name);
} else {
$_table = $setup->getConnection()->newTable($setup->getTable($table_name));
}
foreach ($table as $field_name => $field) {
foreach ([
'type' => Table::TYPE_INTEGER,
'size' => null,
'comment' => 'Added by plugin',
] as $attr_name => $attr) {
if (!array_key_exists($attr_name, $field)) {
$field[$attr_name] = $attr;
}
}
if ($exist) {
$connection->addColumn($_table, $field_name, $field);
} else {
$_tableType = $field['type'];
$_tableSize = $field['size'];
$_tableComment = $field['comment'];
unset($field['type'], $field['size'], $field['comment']);
$_table->addColumn($field_name, $_tableType, $_tableSize, $field, $_tableComment);
}
}
if (!$exist) {
$connection->createTable($_table);
}
}
}
}
+200
View File
@@ -0,0 +1,200 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/)
* @license https://olegnax.com/license
*/
namespace Olegnax\Core\Setup;
use Magento\Framework\DB\Ddl\Table;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Framework\Setup\UpgradeSchemaInterface;
class UpgradeSchema implements UpgradeSchemaInterface
{
/**
* {@inheritdoc}
*/
public function upgrade(
SchemaSetupInterface $setup,
ModuleContextInterface $context
) {
$setup->startSetup();
$this->applyUpgradeFunctions($setup, $context);
$setup->endSetup();
}
private function applyUpgradeFunctions(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
$methods = $this->getUpgradeFunctions($context->getVersion());
foreach ($methods as $method) {
call_user_func_array([$this, $method], [$setup, $context]);
}
}
private function getUpgradeFunctions($low_version = '1.0.0')
{
$methods = get_class_methods($this);
foreach ($methods as $key => $method) {
if (preg_match('/^upgrade_(.+)$/i', $method, $matches)) {
if (version_compare($low_version, $matches[1], '<')) {
continue;
}
}
unset($methods[$key]);
}
$methods = array_filter($methods);
$methods = array_unique($methods);
sort($methods);
return $methods;
}
public function upgrade_1_0_6(
SchemaSetupInterface $setup,
/** @noinspection PhpUnusedParameterInspection */
ModuleContextInterface $context
) {
$connection = $setup->getConnection();
$connection->truncateTable($setup->getTable('adminnotification_inbox'));
}
public function upgrade_99_0_1(
SchemaSetupInterface $setup,
/** @noinspection PhpUnusedParameterInspection */
ModuleContextInterface $context
) {
$tables = [
'adminnotification_inbox' => [
'notification_id' => [
'identity' => true,
'nullable' => false,
'primary' => true,
'unsigned' => true,
'comment' => 'Notification id',
],
'severity' => [
'type' => Table::TYPE_SMALLINT,
'unsigned' => true,
'nullable' => false,
'identity' => false,
'default' => '0',
'comment' => 'Problem type',
],
'date_added' => [
'type' => Table::TYPE_TIMESTAMP,
'nullable' => false,
'on_update' => false,
'default' => 'CURRENT_TIMESTAMP',
'comment' => 'Create date',
],
'title' => [
'type' => 'varchar',
'size' => 255,
'nullable' => false,
'comment' => 'Title',
],
'description' => [
'type' => Table::TYPE_TEXT,
'nullable' => true,
'comment' => 'Description',
],
'url' => [
'type' => 'varchar',
'size' => 255,
'nullable' => true,
'comment' => 'Url',
],
'is_read' => [
'type' => Table::TYPE_SMALLINT,
'unsigned' => true,
'nullable' => false,
'identity' => false,
'default' => '0',
'comment' => 'Flag if notification read',
],
'is_remove' => [
'type' => Table::TYPE_SMALLINT,
'unsigned' => true,
'nullable' => false,
'identity' => false,
'default' => '0',
'comment' => 'Flag if notification might be removed'
],
'ox_content' => [
'type' => Table::TYPE_TEXT,
'nullable' => true,
'comment' => 'News content',
],
'ox_image' => [
'type' => Table::TYPE_TEXT,
'nullable' => true,
'comment' => 'News image',
],
'ox_validate' => [
'type' => Table::TYPE_TEXT,
'nullable' => true,
'comment' => 'Validate',
],
'ox_type' => [
'type' => Table::TYPE_TEXT,
'nullable' => true,
'comment' => 'Type Content',
],
'date_expire' => [
'type' => Table::TYPE_DATETIME,
'nullable' => true,
'comment' => 'Date Expire',
],
'isOX' => [
'type' => Table::TYPE_SMALLINT,
'nullable' => false,
'default' => 0,
'comment' => 'is olegnax news',
],
],
];
$connection = $setup->getConnection();
foreach ($tables as $table_name => $table) {
$exist = $setup->tableExists($table_name);
if ($exist) {
$_table = $setup->getTable($table_name);
} else {
$_table = $setup->getConnection()->newTable($setup->getTable($table_name));
}
foreach ($table as $field_name => $field) {
foreach ([
'type' => Table::TYPE_INTEGER,
'size' => null,
'comment' => 'Added by plugin',
] as $attr_name => $attr) {
if (!array_key_exists($attr_name, $field)) {
$field[$attr_name] = $attr;
}
}
if ($exist) {
$connection->addColumn($_table, $field_name, $field);
} else {
$_tableType = $field['type'];
$_tableSize = $field['size'];
$_tableComment = $field['comment'];
unset($field['type'], $field['size'], $field['comment']);
$_table->addColumn($field_name, $_tableType, $_tableSize, $field, $_tableComment);
}
}
if (!$exist) {
$connection->createTable($_table);
}
}
}
}
+39
View File
@@ -0,0 +1,39 @@
{
"name": "olegnax/module-core",
"description": "Olegnax Core. Required by all Olegnax extensions and themes.",
"version": "1.3.4",
"type": "magento2-module",
"license": [
"OSL-3.0"
],
"require": {
"php": ">=7.1.3",
"ext-simplexml": "*",
"ext-json": "*",
"magento/module-catalog": "^103.0.0",
"magento/module-cms": "^103.0.0",
"magento/module-admin-notification": "^100.3.0",
"magento/module-store": "^101.0.0"
},
"keywords": [
"magento 2",
"olegnax",
"core"
],
"authors": [
{
"name": "Olegnax",
"email": "mail@olegnax.com",
"homepage": "https://olegnax.com",
"role": "Technical Support"
}
],
"autoload": {
"files": [
"registration.php"
],
"psr-4": {
"Olegnax\\Core\\": ""
}
}
}
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
<acl>
<resources>
<resource id="Magento_Backend::admin">
<resource id="Olegnax_Core::Olegnax_Core" sortOrder="10" title="Olegnax">
<resource id="Olegnax_Core::Modules_Update" sortOrder="10" title="Modules Update"/>
<resource id="Olegnax_Core::core_settings" sortOrder="10" title="Core Settings"/>
</resource>
</resource>
</resources>
</acl>
</config>
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Cms\Model\Wysiwyg\Validator">
<plugin name="Olegnax_Core_Plugin_Backend_Magento_Cms_Model_Wysiwyg_Validator"
type="Olegnax\Core\Plugin\Backend\Magento\Cms\Model\Wysiwyg\Validator"
sortOrder="10"
disabled="false"/>
</type>
<type name="Magento\Config\Controller\Adminhtml\System\Config\Save">
<plugin name="Olegnax_Core_Plugin_Magento_Config_Controller_Adminhtml_System_Config_Save"
type="Olegnax\Core\Plugin\Magento\Config\Controller\Adminhtml\System\Config\Save"
sortOrder="10"
disabled="false"/>
</type>
</config>
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="controller_action_predispatch">
<observer name="ox_adminnotification"
instance="Olegnax\Core\Observer\PredispatchAdminActionControllerObserver"/>
</event>
</config>
+12
View File
@@ -0,0 +1,12 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
<menu>
<add id="Olegnax_Core::Olegnax_Core" title="Olegnax" module="Olegnax_Core" sortOrder="10"
resource="Olegnax_Core::Olegnax_Core"/>
<add id="Olegnax_Core::Modules_Update" action="olegnax/modules/update" module="Olegnax_Core"
parent="Olegnax_Core::Olegnax_Core" resource="Olegnax_Core::Modules_Update" sortOrder="0"
title="Modules Info"/>
<add id="Olegnax_Core::Core_Settings" title="Core Settings" module="Olegnax_Core" sortOrder="10" action="adminhtml/system_config/edit/section/olegnax_core_settings" parent="Olegnax_Core::Olegnax_Core" resource="Olegnax_Core::core_settings"/>
</menu>
</config>
+9
View File
@@ -0,0 +1,9 @@
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="admin">
<route frontName="olegnax" id="olegnax">
<module before="Magento_Backend" name="Olegnax_Core"/>
</route>
</router>
</config>
+32
View File
@@ -0,0 +1,32 @@
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<tab id="olegnax" translate="label" sortOrder="10">
<label>Olegnax</label>
</tab>
<section id="olegnax_core_settings" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="10" translate="label">
<label>Core</label>
<tab>olegnax</tab>
<resource>Olegnax_Core::core_settings</resource>
<group id="info" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="1" translate="label">
<frontend_model>Olegnax\Core\Block\Adminhtml\System\Config\Form\Info</frontend_model>
</group>
<group id="general" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="10" translate="label">
<label>General</label>
<field id="lazyload" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="10" translate="label"
type="select">
<label>Lazy Load Enabled</label>
<frontend_class>on-off-trigger</frontend_class>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="owlcarousel" showInDefault="1" showInStore="1" showInWebsite="1" sortOrder="12" translate="label"
type="select">
<label>Owl Carousel Enabled</label>
<comment>If disabled, lazy load script and css will not be loaded. As a result Theme and extensions which rely on owl carsouel will not work and drop an error. So disable it only if you decided to not use owl carousel at all and removed all of the theme blocks and widgets which rely on owl carousel script.</comment>
<frontend_class>on-off-trigger</frontend_class>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
</group>
</section>
</system>
</config>
+11
View File
@@ -0,0 +1,11 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<olegnax_core_settings>
<general>
<lazyload>1</lazyload>
<owlcarousel>1</owlcarousel>
</general>
</olegnax_core_settings>
</default>
</config>
+30
View File
@@ -0,0 +1,30 @@
<?xml version="1.0" ?>
<!--
~ @author Olegnax
~ @package Olegnax_Core
~ @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
~ See COPYING.txt for license details.
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Framework\View\TemplateEngine\Php">
<plugin disabled="false" name="Olegnax_Core_Plugin_Magento_Framework_View_TemplateEngine_Php" sortOrder="10" type="Olegnax\Core\Plugin\Magento\Framework\View\TemplateEngine\Php"/>
</type>
<type name="Olegnax\Core\Logger\Debug">
<arguments>
<argument name="filesystem" xsi:type="object">Magento\Framework\Filesystem\Driver\File</argument>
</arguments>
</type>
<virtualType name="Olegnax\Core\Logger\Logger" type="Monolog\Logger">
<arguments>
<argument name="name" xsi:type="string">Olegnax</argument>
<argument name="handlers" xsi:type="array">
<item name="debug" xsi:type="object">Olegnax\Core\Logger\Debug</item>
</argument>
</arguments>
</virtualType>
<type name="Olegnax\Core\Helper\Helper">
<arguments>
<argument name="logger" xsi:type="object">Olegnax\Core\Logger\Logger</argument>
</arguments>
</type>
</config>
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © 2023 Olegnax. All rights reserved.
*
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="view_block_abstract_to_html_after">
<observer
name="olegnax_core_observer_frontend_view_blockabstracttohtmlafter_view_block_abstract_to_html_after"
instance="Olegnax\Core\Observer\Frontend\View\BlockAbstractToHtmlAfter"/>
</event>
</config>
+13
View File
@@ -0,0 +1,13 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Olegnax_Core" setup_version="1.3.4">
<sequence>
<module name="Magento_AdminNotification"/>
<module name="Magento_Catalog"/>
<module name="Magento_Cms"/>
<module name="Magento_Customer"/>
<module name="Magento_Store"/>
<module name="Magento_Wishlist"/>
</sequence>
</module>
</config>
+9
View File
@@ -0,0 +1,9 @@
<?php
use Magento\Framework\Component\ComponentRegistrar;
ComponentRegistrar::register(
ComponentRegistrar::MODULE,
'Olegnax_Core',
__DIR__
);
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="old_editor"/>
<head>
<css src="Olegnax_Core::onoff-trigger/on-off.css"/>
<link src="Olegnax_Core::onoff-trigger/on-off.js"/>
</head>
<body>
<referenceContainer name="page.content">
<container name="OX.content" htmlTag="div" htmlClass="block olegnax core notice content"
after="page.main.actions">
<block name="olegnax.core.notice.content" class="Olegnax\Core\Block\Adminhtml\NoticeContent"/>
</container>
<container name="OX.contentp" htmlTag="div" htmlClass="block olegnax core notice contentp"
after="page.main.actions">
<block name="olegnax.core.notice.contentp" class="Olegnax\Core\Block\Adminhtml\NoticeContentP"/>
</container>
<container name="OX.news" htmlTag="div" htmlClass="block olegnax core notice news"
after="page.main.actions">
<block name="olegnax.core.notice.news" class="Olegnax\Core\Block\Adminhtml\NoticeNews"/>
</container>
<container name="OX.update" htmlTag="div" htmlClass="block olegnax core notice update"
after="page.main.actions">
<block name="olegnax.core.notice.update" class="Olegnax\Core\Block\Adminhtml\NoticeUpdate"/>
</container>
</referenceContainer>
</body>
</page>
+7
View File
@@ -0,0 +1,7 @@
<?xml version="1.0" ?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<link src="Olegnax_Core::js/tools.js"/>
</head>
</page>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<link src="Magento_Backend::js/bootstrap/editor.js"/>
<css src="prototype/windows/themes/default.css"/>
</head>
</page>
@@ -0,0 +1,10 @@
<?xml version="1.0" ?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-1column"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="Olegnax\Core\Block\Adminhtml\Modules\Update" name="modules.update"
template="Olegnax_Core::modules/update.phtml"/>
</referenceContainer>
</body>
</page>
@@ -0,0 +1,137 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/)
* @license https://olegnax.com/license
*/
use Olegnax\Core\Block\Adminhtml\Modules\Update;
/** @var $block Update */
$block->ForsedUpdate();
$modules = $block->getModuleVersions();
$themes = $block->getThemeVersions();
?>
<div class="admin__page-section-item ox-admin__modules">
<div class="admin__page-section-item-content ox-admin__row">
<?php foreach ($modules as $module) : ?>
<?php if (is_array($module)): ?>
<div class="ox-admin__module us-<?php echo ($module['update_status']) ? 'nok' : 'ok'; ?>">
<div class="ox-admin__module-wrapper">
<?php if (array_key_exists('image', $module) && !empty($module['image'])): ?>
<div class="ox-admin__module-image">
<img src="<?php echo $module['image'] ?>" />
</div>
<?php endif; ?>
<div class="ox-admin__status-wrapper">
<span class="ox-module-status ox-module-status-<?php echo ($module['update_status']) ? 'nok' : 'ok'; ?>"><?php echo ($module['update_status']) ? __('Update Required') : __('Up to Date'); ?></span>
<?php if (array_key_exists('pro', $module)): ?>
<a target="_blank" class="ox-pro-version" href="<?php echo $module['pro'] ?>"><?php echo __('Get Pro'); ?></a>
<?php endif; ?>
</div>
<div class="ox-admin__module-title-wrapper">
<a target="_blank" href="<?= array_key_exists('url', $module) ?: '#'; ?>">
<span class="ox-module-title"><?php if (array_key_exists('title', $module)): echo $module['title']; else: echo $module['name']; endif; ?>
<?php if ($module['theme_module']) : ?>
<span class="ox-module-theme-info"><?php echo __('Theme module'); ?></span>
<?php endif; ?>
</span>
</a>
</div>
<div class="ox-admin__module-info">
<table>
<tr>
<td><?php echo $block->escapeHtml(__('Installed Version')); ?></td>
<td><?php echo $module['setup_version'] ?></td>
</tr>
<tr>
<td><?php echo $block->escapeHtml(__('Latest Version')); ?></td>
<td><span class="ox-server-version"><?php echo $module['server_version'] ?></span></td>
</tr>
<tr>
<td><?php echo $block->escapeHtml(__('Status')); ?></td>
<td><?php echo ($module['enabled']) ? __('Enabled') : __('Disabled') ?></td>
</tr>
<tr>
<td colspan="2"><span class="ox-module-full-name"><?php echo $module['name'] ?></span></td>
</tr>
</table>
</div>
<div class="ox-admin__modules-bottom">
<?php if (array_key_exists('docs', $module)): ?>
<a target="_blank" href="<?php echo $module['docs'] ?>"><span class="icon-docs"></span><?php echo __('Docs'); ?></a>
<?php endif; ?>
<?php if (array_key_exists('url_changelog', $module)): ?>
<a target="_blank" class="changelog-link" href="<?php echo $module['url_changelog'] ?>"><?php echo __('Changelog'); ?></a>
<?php endif; ?>
</div>
</div>
</div>
<?php endif; ?>
<?php endforeach; ?>
</div>
</div>
<div class="admin__page-section-item ox-admin__modules">
<div class="admin__page-section-item-title">
<h1 class="page-title"><?php echo $block->escapeHtml(__('Themes')); ?></h1>
</div>
<div class="admin__page-section-item-content ox-admin__row">
<?php foreach ($themes as $theme) : ?>
<div class="ox-admin__theme us-<?php echo ($theme['update_status']) ? 'nok' : 'ok'; ?>">
<div class="ox-admin__theme-wrapper">
<div class="ox-admin__theme-image">
<?php if (array_key_exists('image', $theme) && !empty($theme['image'])): ?>
<img src="<?php echo $theme['image'] ?>"/>
<?php endif; ?>
</div>
<div class="ox-admin__theme-content">
<div class="ox-admin__status-wrapper">
<?php if($theme['established']) : ?>
<span class="ox-module-status ox-module-status-<?php echo ($theme['update_status']) ? 'nok' : 'ok'; ?>"><?php echo ($theme['update_status']) ? __('Update Required') : __('Up to Date'); ?></span>
<?php else: ?>
<span class="ox-module-status ox-module-status-none"><?php echo __('Not Installed'); ?></span>
<?php endif; ?>
</div>
<div class="ox-admin__module-title-wrapper">
<a target="_blank" href="<?= array_key_exists('url', $theme) ?: '#'; ?>">
<span class="ox-module-title"><?php if (array_key_exists('title', $theme)): echo $theme['title']; else: echo $theme['name']; endif; echo __(' Theme'); ?></span>
</a>
</div>
<div class="ox-admin__module-info">
<table>
<?php if ($theme['established']) : ?>
<tr>
<td><?php echo $block->escapeHtml(__('Installed Version')); ?></td>
<td><?php echo $theme['setup_version'] ?></td>
</tr>
<?php endif; ?>
<tr>
<td><?php echo $block->escapeHtml(__('Latest Version')); ?></td>
<td><span class="ox-server-version"><?php echo $theme['server_version'] ?></span></td>
</tr>
</table>
</div>
<?php if (!$theme['established']) : ?>
<div class="ox-admin__module-actions">
<a href="https://themeforest.net/item/athlete2-strong-magento-2-theme/23693737" target="_blank" class="ox-button -green">Download</a><a href="https://athlete2.com/landing/" target="_blank" class="ox-underlined -black">Preview</a>
</div>
<?php endif; ?>
<div class="ox-admin__modules-bottom">
<span class="icon-docs"></span>
<?php if (array_key_exists('docs', $theme)): ?>
<a target="_blank" href="<?php echo $theme['docs'] ?>"><?php echo __('Docs'); ?></a>
<?php endif; ?>
<?php if (array_key_exists('url_changelog', $theme)): ?>
<a target="_blank" class="changelog-link" href="<?php echo $theme['url_changelog'] ?>"><?php echo __('Changelog'); ?></a>
<?php endif; ?>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
@@ -0,0 +1,27 @@
/**
* Olegnax
*
* NOTICE OF LICENSE
*
* This source file is subject to the Olegnax.com license that is
* available through the world-wide-web at this URL:
* https://olegnax.com/license
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2010-2021 Olegnax (http://olegnax.com/)
* @license https://olegnax.com/license
*/
@import "variables/_icons.less";
.lib-font-face(
@family-name: @icons-olegnax__font-name,
@font-path: @icons-olegnax__font-name-path,
@font-weight: normal,
@font-style: normal
);
@@ -0,0 +1,264 @@
/**
* Olegnax
*
* NOTICE OF LICENSE
*
* This source file is subject to the Olegnax.com license that is
* available through the world-wide-web at this URL:
* https://www.olegnax.com/license
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Olegnax
* @package Olegnax_Athlete2
* @copyright Copyright (c) 2010-2021 Olegnax (http://www.olegnax.com/)
* @license https://www.olegnax.com/license
*/
@athlete2__icon--support-tiny: '@{baseDir}Olegnax_Core/images/support-icon-tiny.png';
@athlete2__icon--docs-tiny: '@{baseDir}Olegnax_Core/images/docs-icon-tiny.png';
@ox-logo: '@{baseDir}Olegnax_Core/images/ox.png';
/* -------------------------------
Module Info block above settings
------------------------------- */
.ox-info-block{
padding-left: 108px;
position:relative;
box-shadow: 1px 4px 27px rgba(210, 225, 240, 0.54);
padding: 20px 30px;
display: flex;
flex-wrap:wrap;
min-height: 40px;
align-items: center;
margin-bottom: 30px;
padding-left:108px;
a{
border-bottom:1px solid;
text-decoration: none;
}
.ox-info-block__right{
width:100%;
display: flex;
align-items: center;
margin-top: 15px;
}
.ox-info-block__docs{
&:before{
content:'';
display: inline-block;
width:31px;
height:28px;
margin-right:15px;
background-image: url(@athlete2__icon--docs-tiny);
background-position: center;
background-repeat: no-repeat;
vertical-align: middle;
}
a{
font-weight: 600;
color:#1f1e32;
border-color:transparent;
transition:all 0.2s ease;
&:hover{
border-color:black;
}
}
}
.ox-info-block__support{
&:before{
content: '';
width: 1px;
height: 20px;
background: #e4e4e4;
display: inline-block;
position: relative;
margin-left: 25px;
vertical-align: middle;
margin-right: 25px;
top: -10px;
}
.label{
font-weight: 600;
color:#1f1e32;
display:block;
width: 100%;
padding: 0;
float: none;
text-align: left;
}
a{
font-weight:600;
font-size: 13px;
color:#1f1e32;
position: relative;
top: -3px;
transition:all 0.2s ease;
&:hover{
border-color:transparent;
}
}
.ox-wrapper{
display: inline-block;
padding-left: 43px;
position: relative;
&:before{
content:'';
display: inline-block;
width:29px;
height:26px;
margin-right:15px;
background-position: center;
background-repeat: no-repeat;
background-image: url(@athlete2__icon--support-tiny);
position: absolute;
left: 0;
top: 4px;
}
}
&.ox-support-expired{
.label{
color: #b4b4b4;
}
}
&.ox-support-active{
a{
&:after{
content: '';
width: 10px;
height: 10px;
background: #95d033;
display: inline-block;
border-radius: 6px;
position: relative;
margin-left: 5px;
}
}
}
}
.ox-info-block__logo{
line-height: 0;
display: block;
border: none;
text-decoration: none;
background: #2b292a;
width:78px;
position: absolute;
top:0;
bottom:0;
left:0;
&:before{
content:'';
display: block;
width:49px;
height:33px;
background-position: center;
background-repeat: no-repeat;
background-image: url(@ox-logo);
position: absolute;
top: 50%;
margin-top: -16px;
left: 50%;
margin-left: -25px;
}
}
.ox-info-block__title{
font-weight: 800;
color:#1f1e32;
font-size:16px;
&:after{
content: '';
width: 1px;
height: 20px;
background: #e4e4e4;
display: inline-block;
position: relative;
margin-left: 25px;
vertical-align: middle;
margin-right: 25px;
}
}
.ox-info-block__dev{
font-size: 13px;
font-weight: 600;
line-height: 1.2;
margin-right: 25px;
}
.ox-info-block__version{
margin-right:25px;
a{
transition:all 0.2s ease;
margin-left: 12px;
color:#494949;
border-bottom:1px solid;
text-decoration: none;
font-weight: 600;
&:hover{
border-color:transparent;
}
}
.ox-module-version{
color: #41362f;
font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-style: normal;
font-weight: 400;
line-height: 1.36;
font-size: 1.4rem;
}
.ox-modules-expired,
.ox-module-expired,
.ox-module-version,
.ox-theme-version{
&:before{
content: '';
width: 10px;
height: 10px;
background: #95d033;
display: inline-block;
border-radius: 6px;
position: relative;
margin-right: 10px;
}
}
.ox-modules-expired,
.ox-module-expired{
&:before{
background: #e35000;
}
}
.ox-modules-expired{
a{
margin-left: 0;
}
}
&.expired{
.ox-module-version,
.ox-theme-version{
&:before{
background: #e35000;
}
}
.ox-server-version{
font-weight: 700;
color:#e35000;
margin-left: 10px;
}
}
}
}
@media (min-width: 1380px){
.ox-info-block{
.ox-info-block__right{
width:auto;
margin-left: auto;
margin-top: 0;
}
}
}
@@ -0,0 +1,416 @@
/**
* Olegnax
*
* NOTICE OF LICENSE
*
* This source file is subject to the Olegnax.com license that is
* available through the world-wide-web at this URL:
* https://olegnax.com/license
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2010-2021 Olegnax (http://olegnax.com/)
* @license https://olegnax.com/license
*/
@import '_icons.less';
@import '_info-block.less';
.ox-pro-badge(){
text-decoration: none;
background: #d878dd;
color: #fff;
display: inline-block;
padding: 6px 15px;
border-radius: 14px;
font-size: 12px;
font-weight: 600;
line-height: 1;
box-shadow: 0 9px 16px -6px rgb(216, 120, 221);
border: none;
&:before{
content:'';
display:inline-block;
width: 10px;
height: 10px;
margin-right: 6px;
background-image: url(data:image/svg+xml;base64,PHN2ZyBpZD0iQm9sZCIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgMjQgMjQiIGhlaWdodD0iNTEyIiB2aWV3Qm94PSIwIDAgMjQgMjQiIHdpZHRoPSI1MTIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZmlsbD0id2hpdGUiIGQ9Im01LjU3NCAxNS4zNjItMS4yNjcgNy43NjdjLS4xMDEuNjE3LjU1OCAxLjA4IDEuMTAzLjc3N2w2LjU5LTMuNjQyIDYuNTkgMy42NDNjLjU0LjMgMS4yMDUtLjE1NCAxLjEwMy0uNzc3bC0xLjI2Ny03Ljc2NyA1LjM2LTUuNDk0Yy40MjUtLjQzNS4xODEtMS4xNzMtLjQyMy0xLjI2NWwtNy4zNzgtMS4xMjctMy4zMDctNy4wNDRjLS4yNDctLjUyNi0xLjExLS41MjYtMS4zNTcgMGwtMy4zMDYgNy4wNDMtNy4zNzggMS4xMjdjLS42MDYuMDkzLS44NDguODMtLjQyMyAxLjI2NXoiLz48L3N2Zz4=);
background-position: center;
background-repeat: no-repeat;
background-size: 10px 10px;
}
&:hover{
color: #fff;
}
}
.ox-info-block .ox-pro-version{
.ox-pro-badge();
}
.ox-button,
a.ox-button{
display: inline-block;
padding: 11px 22px;
border-radius: 18px;
font-size: 14px;
font-weight: 600;
line-height: 1;
margin-right: 10px;
margin-bottom: 8px;
text-decoration: none;
color: #fff;
transition: all 0.25s ease;
&.-green{
background: #91cf24;
box-shadow: 0 9px 16px -6px rgba(145, 207, 35, 0.8);
}
&.-purple{
background: #8f5ff1;
box-shadow: 0 9px 16px -6px rgba(143, 95, 241, 0.8);
}
&:hover{
&.-green{
box-shadow: 0 7px 11px -6px rgba(145, 207, 35, 0.8);
}
&.-purple{
box-shadow: 0 7px 11px -6px rgba(143, 95, 241, 0.8);
}
transform: translateY(3px);
}
}
.ox-underlined,
a.ox-underlined{
display: inline-block;
line-height: 21px;
font-size: 15px;
border-bottom: 2px solid;
font-weight: 600;
margin: 8px;
text-decoration: none;
position: relative;
top: -2px;
transition: all 0.25s ease;
&.-purple{
color: #8f5ff1;
border-color: #8f5ff1;
}
&.-black{
color:#000;
border-color: #000;
}
&:hover{
&,
&.-black,
&.-purple{
border-color: transparent;
}
}
}
.item-olegnax-core{
.submenu{
.level-1 > a{
color: #a79d95;
display: block;
font-size: 1.6rem;
font-weight: 600;
margin-bottom: .7rem;
padding: 1.25rem 1.5rem;
}
.item-modules-update {
margin-bottom: 1.5rem;
padding-bottom: 2rem!important;
border-bottom: 1px solid rgba(167, 157, 149, 0.3);
a{
&:before{
content: '';
background: url('@{baseDir}Olegnax_Core/images/info.png');
width: 16px;
height: 16px;
background-size:16px 16px;
background-position: center;
display: inline-block;
margin-right: 10px;
margin-bottom: -2px;
}
}
}
}
}
.admin__menu .item-olegnax-core.parent.level-0 > a:before {
content: @icon-olegnax__content;
font-family: @icons-olegnax__font-name;
}
.ox-settings-spacer {
margin: 2.2rem 0 1.2rem;
border: 0;
border-bottom: 1px solid #cccccc;
}
.ox-admin__table-wrapper{
box-shadow: 1px 10px 40px rgba(210,225,240,.52);
background: #fff;
padding: 30px;
}
.ox-admin__modules{
.admin__page-section-item-content{
margin-bottom: 60px;
}
.admin__table-secondary {
th,
td{
padding: 1.5rem;
text-align: center;
&:first-child{
text-align: left;
font-weight: 700;
}
}
tbody tr:nth-child(odd){
th,
td{
background-color: #f6f9fc;
}
}
}
.ox-module-status{
display: inline-block;
padding: 6px 15px;
border-radius: 14px;
font-size: 12px;
font-weight: 600;
line-height: 1;
margin-right: 5px;
margin-bottom: 8px;
}
.ox-module-status-ok{
background: #91cf24;
color: #fff;
box-shadow: 0 9px 16px -6px rgba(145, 207, 35, 0.84);
}
.ox-module-status-nok{
background: #e34426;
color: #fff;
box-shadow: 0 9px 16px -6px rgba(227, 38, 38, 0.47);
}
.ox-module-status-none{
background: #f3f6f8;
color: #201e33;
font-weight: bold;
font-size: 15px;
}
.ox-admin__theme,
.ox-admin__module{
&.us-nok{
.ox-admin__module-info{
.server-version{
font-weight: bold;
color:red;
}
}
}
}
.ox-admin__row{
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
margin-right: -15px;
margin-left: -15px;
}
.ox-admin__module{
position: relative;
width: 100%;
padding-right: 15px;
padding-left: 15px;
margin-bottom: 30px;
&:hover{
.ox-admin__module-wrapper {
box-shadow: 1px 4px 10px rgba(210, 225, 240, 0.69);
transform: translateY(3px);
}
}
}
.ox-admin__module-wrapper{
transition: all 300ms ease;
height: 100%;
padding:20px 0;
box-shadow: 1px 10px 40px rgba(210,225,240,.52);
background: #fff;
> div{
padding-left:20px;
padding-right:20px;
}
}
.ox-module-full-name{
word-break: break-all;
}
.ox-admin__theme{
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
position: relative;
width: 100%;
padding-right: 15px;
padding-left: 15px;
&:hover{
.ox-admin__theme-wrapper {
box-shadow: 1px 4px 10px rgba(210, 225, 240, 0.69);
transform: translateY(3px);
}
}
}
.ox-admin__theme-content{
display: flex;
flex-direction: column;
justify-content: center;
}
.ox-admin__theme-wrapper{
transition: all 300ms ease;
width: 100%;
display: flex;
height:100%;
box-shadow: 1px 10px 40px rgba(210,225,240,.52);
background: #fff;
.ox-admin__theme-content{
padding: 35px;
}
}
.ox-admin__module-image,
.ox-admin__theme-image{
background: #f6f9fc;
img{
width:100%;
height:auto;
}
}
.ox-admin__status-wrapper{
margin-bottom:8px;
.ox-pro-version{
.ox-pro-badge();
margin-bottom: 8px;
}
}
.ox-admin__module-title-wrapper{
margin-bottom: 20px;
a{
text-decoration: none;
}
.ox-module-title{
color: black;
font-size:16px;
font-weight: 700;
}
.ox-module-theme-info{
font-size: 13px;
display: block;
font-weight: 600;
}
}
.ox-admin__theme-wrapper{
.ox-admin__module-title-wrapper{
.ox-module-title{
font-size:24px;
}
}
.ox-admin__module-info {
padding: 20px;
}
}
.ox-admin__module-info {
background:#f6f9fc;
padding: 20px 0;
table{
width: 100%;
line-height: 1.8;
th,
td{
text-align: right;
&:first-child{
text-align: left;
}
}
}
}
.ox-admin__module-actions{
margin-top: 15px;
}
.ox-admin__modules-bottom{
margin-top: 25px;
display:flex;
flex-wrap:wrap;
.icon-docs{
display:inline-block;
width:18px;
height:22px;
margin-right:10px;
background-image: url(data:image/svg+xml;base64,PHN2ZyBpZD0iQ2FwYV8xIiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCA1MTIgNTEyIiBoZWlnaHQ9IjUxMiIgdmlld0JveD0iMCAwIDUxMiA1MTIiIHdpZHRoPSI1MTIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGc+PHBhdGggZD0ibTM1Ny4xMDUgMGgtMzEyLjA2OXY1MTJoNDIxLjkyOHYtNDAyLjMzM3ptOC43OTUgNTEuMTY4IDQ5LjgwNiA0OS43MmgtNDkuODA2em0tMjkwLjg2NCA0MzAuODMydi00NTJoMjYwLjg2NHYxMDAuODg4aDEwMS4wNjN2MzUxLjExMnoiLz48cGF0aCBkPSJtMTQ2LjA4OCAxNjAuOTM2aDIxOS44MjR2MzBoLTIxOS44MjR6Ii8+PHBhdGggZD0ibTE0Ni4wODggMjIwLjk4NGgyMTkuODI0djMwaC0yMTkuODI0eiIvPjxwYXRoIGQ9Im0xNDYuMDg4IDI4MS4wMzJoMjE5LjgyNHYzMGgtMjE5LjgyNHoiLz48cGF0aCBkPSJtMTQ2LjA4OCAzNDEuMDhoMjE5LjgyNHYzMGgtMjE5LjgyNHoiLz48L2c+PC9zdmc+);
background-position: center;
background-repeat: no-repeat;
background-size: 18px 22px;
}
a{
color: black;
text-decoration: none;
line-height: 23px;
font-weight: 600;
display: flex;
}
.changelog-link{
margin-left: 20px;
&:before{
content: '';
display: inline-block;
margin-right: 20px;
width: 1px;
height: 10px;
background: black;
position: relative;
top: 7px;
}
}
}
}
@media (min-width: 640px){
.ox-admin__modules {
.ox-admin__module-wrapper{
padding:30px 0;
> div{
padding-left:30px;
padding-right:30px;
}
}
.ox-admin__module{
-ms-flex: 0 0 50%;
flex: 0 0 50%;
max-width: 50%;
}
}
}
@media (min-width: 1025px){
.ox-admin__modules .ox-admin__module{
width: 340px;
-ms-flex: 0 0 340px;
flex: 0 0 340px;
max-width: 340px;
}
}
@media (min-width: 1025px){
.ox-admin__modules .ox-admin__theme{
-ms-flex: 0 0 50%;
flex: 0 0 50%;
max-width: 50%;
.ox-admin__theme-image,
.ox-admin__theme-content{
-ms-flex: 0 0 50%;
flex: 0 0 50%;
max-width: 50%;
}
}
}
@@ -0,0 +1,24 @@
/**
* Olegnax
*
* NOTICE OF LICENSE
*
* This source file is subject to the Olegnax.com license that is
* available through the world-wide-web at this URL:
* https://olegnax.com/license
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2010-2021 Olegnax (http://olegnax.com/)
* @license https://olegnax.com/license
*/
@icons-olegnax__font-name: 'Olegnax Icons';
@icons-olegnax__file-name: 'olegnax-icons';
@icons-olegnax__font-name-path: '@{baseDir}Olegnax_Core/fonts/@{icons-olegnax__file-name}/@{icons-olegnax__file-name}';
@icon-olegnax__content: '\e900';
@@ -0,0 +1,14 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg xmlns="http://www.w3.org/2000/svg">
<metadata>Generated by IcoMoon</metadata>
<defs>
<font id="Olegnax-Icons" horiz-adv-x="1024">
<font-face units-per-em="1024" ascent="960" descent="-64"/>
<missing-glyph horiz-adv-x="1024"/>
<glyph unicode="&#x20;" horiz-adv-x="512" d=""/>
<glyph unicode="&#xe900;" glyph-name="olegnax-logo-icon"
d="M781.964 485.236c4.655-27.927 9.309-51.2 9.309-83.782 0-158.255-130.327-279.273-283.927-279.273-158.255 0-279.273 121.018-279.273 279.273s121.018 283.927 279.273 283.927c27.927 0 55.855-4.655 83.782-13.964 46.545-13.964 102.4 107.055 13.964 139.636-27.927 13.964-65.164 9.309-97.745 9.309-232.727 0-423.564-190.836-423.564-423.564s190.836-418.909 423.564-418.909c232.727 0 423.564 186.182 423.564 418.909 0 46.545 0 88.436-18.618 125.673-37.236 69.818-144.291 32.582-130.327-37.236zM902.982 727.273l69.818 69.818c18.618 18.618 18.618 46.545 0 65.164s-46.545 18.618-65.164 0l-69.818-69.818-69.818 69.818c-18.618 18.618-46.545 13.964-65.164 0-18.618-18.618-18.618-46.545 0-65.164l69.818-69.818-69.818-69.818c-18.618-18.618-13.964-46.545 0-65.164 18.618-18.618 46.545-18.618 65.164 0l69.818 69.818 69.818-69.818c18.618-18.618 46.545-18.618 65.164 0s18.618 46.545 0 65.164l-69.818 69.818z"/>
</font>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 920 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 670 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

@@ -0,0 +1,38 @@
/*
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) $year Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
define([
'Magento_Ui/js/form/element/abstract',
'mageUtils',
'jquery',
'spectrum'
], function (Element, utils, $) {
'use strict';
return Element.extend({
defaults: {
visible: true,
label: '',
error: '',
uid: utils.uniqueid(),
disabled: false,
links: {
value: '${ $.provider }:${ $.dataScope }'
}
},
initialize: function () {
this._super();
},
initColorPickerCallback: function (element) {
$(element).attr("type", "hidden").spectrum({
preferredFormat: "rgb",
allowEmpty: true,
showAlpha: true,
showInput: true,
});
}
});
});
+42
View File
@@ -0,0 +1,42 @@
require(["jquery", 'prototype', 'mage/adminhtml/tools'], function ($) {
"use strict";
$(function () {
window.toggleValueElements_old = window.toggleValueElements;
window.toggleValueElements = function (checkbox, container, excludedElements, checked) {
window.toggleValueElements_old(checkbox, container, excludedElements, checked);
checked = $(checkbox).is(':checked');
// spectrum-colorpicker
var $input = $('input', container);
if ($input.parent().find('.sp-replacer').length) {
$input.prop('disabled', checked).spectrum(checked ? 'disable' : 'enable');
}
// onoff-trigger
$('select, input, textarea, button, img', container).trigger('change');
};
});
});
require(["jquery", "spectrum"], function ($) {
"use strict";
$(function () {
$(".ox-ss-colorpicker, .ox-ss-colorpicker .admin__field-control input[type=text]").spectrum({
preferredFormat: "rgb",
allowEmpty: true,
showAlpha: true,
showInput: true,
move: function (tinycolor) {
$(this).hide();
var value = "";
if (tinycolor && tinycolor.hasOwnProperty("_a")) {
if (1 > tinycolor._a) {
value = tinycolor.toRgbString();
} else {
value = tinycolor.toHexString();
}
$(this).val(value);
}
}
}).attr("type", "hidden");
});
});
@@ -0,0 +1,119 @@
.athleteform-onoff-container {
cursor: pointer;
position: relative;
display: inline-block;
height: 36px;
width: 132px;
margin: 0;
padding: 0;
box-sizing: border-box;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
-webkit-box-shadow: inset 1px 1px 6px 0 rgba(170, 157, 137, .16);
box-shadow: inset 1px 1px 6px 0 rgba(170, 157, 137, .16);
-webkit-transition: all .3s ease-in-out;
-moz-transition: all .3s ease-in-out;
-o-transition: all .3s ease-in-out;
transition: all .3s ease-in-out;
border: 1px solid #d2d2d2;
background: #f8f8f8;
}
.athleteform-onoff-container.disabled.checked {
border-color: rgba(0, 0, 0, 0.4);
background-color: rgba(0, 0, 0, 0.4);
}
.athleteform-onoff-container.disabled .athleteform-onoff-button {
color: rgba(0, 0, 0, 0.4) !important;
}
.athleteform-onoff-container.checked {
background: #96b100;
border-color: #96b100;
}
.athleteform-onoff-container.checked .athleteform-onoff-button {
left: 4px;
color: #96b100;
}
.athleteform-onoff-container .athleteform-onoff-button {
display: inline-block;
box-sizing: border-box;
font: normal normal normal 14px/1 TIFontAwesome;
font-size: inherit;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
position: absolute;
top: 3px;
left: 66px;
width: 59px;
height: 27px;
line-height: 18px;
padding: 4px;
text-align: center;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 2px;
-webkit-box-shadow: 1px 1px 4px 0 rgba(2, 2, 2, .21);
box-shadow: 1px 1px 4px 0 rgba(2, 2, 2, .21);
-webkit-transition: all 350ms cubic-bezier(0, 0.89, 0.44, 1);
-moz-transition: all 350ms cubic-bezier(0, 0.89, 0.44, 1);
-o-transition: all 350ms cubic-bezier(0, 0.89, 0.44, 1);
transition: all 350ms cubic-bezier(0, 0.89, 0.44, 1);
color: #6b625a;
background: #fff;
}
/* Default Unchecked Icon */
.athleteform-onoff-container .athleteform-onoff-button:after,
.athleteform-onoff-container .athleteform-onoff-button:before {
content: "";
width: 10px;
height: 2px;
background: #524a43;
display: block;
position: absolute;
left: 25px;
top: 12px;
}
.athleteform-onoff-container .athleteform-onoff-button:before {
transform: rotateZ(45deg);
}
.athleteform-onoff-container .athleteform-onoff-button:after {
transform: rotateZ(-45deg);
}
/* Checked Icon */
.athleteform-onoff-container.checked .athleteform-onoff-button:before,
.athleteform-onoff-container.checked .athleteform-onoff-button:after {
background: #96b100;
}
.athleteform-onoff-container.checked .athleteform-onoff-button:before {
width: 10px;
left: 26px;
top: 12px;
transform: rotateZ(-45deg);
}
.athleteform-onoff-container.checked .athleteform-onoff-button:after {
width: 5px;
left: 24px;
top: 14px;
transform: rotateZ(45deg);
}
/* Disabled */
.athleteform-onoff-container.disabled {
background-color: rgba(0, 0, 0, 0.4);
}
.athleteform-onoff-container select {
display: none !important;
}
@@ -0,0 +1,60 @@
require(["jquery"], function ($) {
"use strict";
$(function () {
$.fn.athlete_onoff = function (so) {
var sd = {
value: {
on: '',
off: ''
},
class: 'athleteform-onoff',
wrap: 'container',
button: 'button'
},
s = $.extend(true, {}, sd, so);
return $(this).each(function () {
var a = $(this),
d1c = s.class + '-' + s.wrap;
if (!a.is('select') || (!a.children('option[value=0]').length || !a.children('option[value=1]').length) || a.parent('.' + d1c).length) {
return a;
}
var b1 = $('<div>').attr({
class: s.class + '-' + s.button
}),
d1 = $('<div>').attr({
id: a.attr('id') + '_' + s.wrap,
class: d1c
});
d1.attr('class', (d1.attr('class')));
if (a.is(':disabled')) {
d1.toggleClass('disabled', a.is(':disabled'));
}
d1.toggleClass('checked', '0' != a.val());
a.hide().wrap(d1).before(b1);
d1 = a.parent();
a.off('change.onofftrigger').on('change.onofftrigger', function (e) {
d1.toggleClass('disabled', a.is(':disabled'));
if (d1.hasClass('disabled')) {
return e.preventDefault();
}
d1.toggleClass('checked', '0' != a.val());
});
d1.off('click.onofftrigger').on('click.onofftrigger', function (e) {
if (d1.hasClass('disabled')) {
return e.preventDefault();
}
if (a.is(':enabled')) {
var value = ('0' != a.val()) ? '0' : '1';
a.val(value);
a[0].dispatchEvent(new Event('change'));
a.trigger('change');
}
});
return a;
});
};
$('.on-off-trigger').athlete_onoff();
});
});
@@ -0,0 +1,21 @@
<!--
~ @author Olegnax
~ @package Olegnax_Core
~ @copyright Copyright (c) $year Olegnax (http://olegnax.com/). All rights reserved.
~ See COPYING.txt for license details.
-->
<input class="admin__control-text" data-bind="
event: {change: userChanges},
value: value,
hasFocus: focused,
valueUpdate: valueUpdate,
afterRender: initColorPickerCallback,
attr: {
name: inputName,
placeholder: placeholder,
'aria-describedby': noticeId,
id: uid,
disabled: disabled
}"
type="text"/>
+18
View File
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<referenceContainer name="head.additional">
<block name="ox_core_assets" class="Olegnax\Core\Block\SimpleTemplate" template="Olegnax_Core::assets.phtml"/>
</referenceContainer>
<body>
<referenceContainer name="before.body.end">
<block ifconfig="olegnax_core_settings/general/lazyload" class="Olegnax\Core\Block\SimpleTemplate" name="ox_core_lazy" template="Olegnax_Core::lazy_min.phtml"/>
</referenceContainer>
</body>
</page>
+14
View File
@@ -0,0 +1,14 @@
var config = {
paths: {
'owl.carousel': 'Olegnax_Core/owl.carousel/owl.carousel.min',
'OXowlCarousel': 'Olegnax_Core/owl.carousel'
},
shim: {
'owl.carousel': {deps: ['jquery', 'jquery-ui-modules/widget']}
}
};
if(window?.OX_OWL_DISABLE){
delete config.paths['owl.carousel'];
delete config.paths['OXowlCarousel'];
delete config.shim['owl.carousel'];
}
@@ -0,0 +1,5 @@
<?php
if ($this->getConfig('olegnax_core_settings/general/owlcarousel')) { ?>
<link href="<?= $block->getViewFileUrl('Olegnax_Core::owl.carousel/assets/owl.carousel.css'); ?>" rel="stylesheet" media="print" onload="this.media='all'" crossorigin="anonymous">
<?php } ?>
+120
View File
@@ -0,0 +1,120 @@
<script type="text/javascript">
(function () {
function LazyLoad () {
this.settings = {
src: 'data-original',
srcset: 'data-originalset',
selector: '.lazy',
selectorClass: 'lazy',
loadClass: 'lazy-loader',
loadEvent: 'lazyLoaded.oxlazy',
root: null,
rootMargin: '0px',
threshold: 0,
debouncer: 500
}
this.images = document.querySelectorAll(this.settings.selector)
this.observer = null
let self = this
this.load = (event) => {
let image = event.target,
parent = image.parentElement
if (image.src == image.getAttribute(this.settings.src)) {
image.classList.remove(self.settings.selectorClass)
parent.classList.remove(self.settings.loadClass)
let _parent = parent.closest('.product-item-photo')
if (_parent) {
_parent.classList.remove(self.settings.loadClass)
}
image.dispatchEvent(new Event(self.settings.loadEvent))
if (this.observer) {
this.observer.unobserve(image)
}
}
}
this.destroy = () => {
this.observer.disconnect()
}
this.oldLoadImages = () => {
if (!this.settings) {
return
}
let debouncer = function (func, timeout) {
var timeoutID
return function () {
var scope = this,
args = arguments
clearTimeout(timeoutID)
timeoutID = setTimeout(function () {
func.apply(scope, Array.prototype.slice.call(args))
}, timeout)
}
}
window.addEventListener('scroll', debouncer(self.oldInit, self.settings.debouncer))
window.addEventListener('resize', debouncer(self.oldInit, self.settings.debouncer))
self.oldInit()
}
this.oldInit = () => {
let height = window.visualViewport ? window.visualViewport.height : window.innerHeight
Array.prototype.forEach.call(this.images, function (image) {
if (image.classList.contains(self.settings.selectorClass)) {
let bounding = image.getBoundingClientRect()
if (bounding.top != bounding.bottom && 0 < bounding.bottom && height > bounding.top) {
self.applyImage(image)
}
}
})
}
this.applyImage = (image) => {
let src = image.getAttribute(self.settings.src),
srcset = image.getAttribute(self.settings.srcset)
if ('img' === image.tagName.toLowerCase()) {
image.onload = self.load
if (src) {
image.src = src
}
if (srcset) {
image.srcset = srcset
}
} else {
image.style.backgroundImage = 'url(\'' + src + '\')'
}
}
this.init = () => {
if (!window.IntersectionObserver) {
this.oldLoadImages()
return
}
try {
this.observer = new IntersectionObserver(function (entries, observer) {
Array.prototype.forEach.call(entries, function (entry) {
if (entry.isIntersecting) {
self.applyImage(entry.target)
}
})
}, {
rootMargin: this.settings.rootMargin,
threshold: [this.settings.threshold]
})
Array.prototype.forEach.call(this.images, function (image) {
self.observer.observe(image)
})
} catch (e) {
console.info(e)
this.oldLoadImages()
}
}
this.init()
}
window.lazyLoad = function () {
return new LazyLoad()
}
})()
document.addEventListener('DOMContentLoaded', function () {
lazyLoad()
}, false)
require(['jquery'], function ($) {
$(document.body).on('contentUpdated contentUpdated.oxlazy', lazyLoad)
})
</script>
@@ -0,0 +1 @@
<script type="text/javascript">!function(){function a(){this.settings={src:"data-original",srcset:"data-originalset",selector:".lazy",selectorClass:"lazy",loadClass:"lazy-loader",loadEvent:"lazyLoaded.oxlazy",root:null,rootMargin:"0px",threshold:0,debouncer:500},this.images=document.querySelectorAll(this.settings.selector),this.observer=null;let a=this;this.load=e=>{let b=e.target,c=b.parentElement;if(b.src==b.getAttribute(this.settings.src)){b.classList.remove(a.settings.selectorClass),c.classList.remove(a.settings.loadClass);let d=c.closest(".product-item-photo");d&&d.classList.remove(a.settings.loadClass),b.dispatchEvent(new Event(a.settings.loadEvent)),this.observer&&this.observer.unobserve(b)}},this.destroy=()=>{this.observer.disconnect()},this.oldLoadImages=()=>{if(!this.settings)return;let b=function(a,b){var c;return function(){var d=this,e=arguments;clearTimeout(c),c=setTimeout(function(){a.apply(d,Array.prototype.slice.call(e))},b)}};window.addEventListener("scroll",b(a.oldInit,a.settings.debouncer)),window.addEventListener("resize",b(a.oldInit,a.settings.debouncer)),a.oldInit()},this.oldInit=()=>{let b=window.visualViewport?window.visualViewport.height:window.innerHeight;Array.prototype.forEach.call(this.images,function(d){if(d.classList.contains(a.settings.selectorClass)){let c=d.getBoundingClientRect();c.top!=c.bottom&&0<c.bottom&&b>c.top&&a.applyImage(d)}})},this.applyImage=b=>{let c=b.getAttribute(a.settings.src),d=b.getAttribute(a.settings.srcset);"img"===b.tagName.toLowerCase()?(b.onload=a.load,c&&(b.src=c),d&&(b.srcset=d)):b.style.backgroundImage="url('"+c+"')"},this.init=()=>{if(!window.IntersectionObserver){this.oldLoadImages();return}try{this.observer=new IntersectionObserver(function(b,c){Array.prototype.forEach.call(b,function(b){b.isIntersecting&&a.applyImage(b.target)})},{rootMargin:this.settings.rootMargin,threshold:[this.settings.threshold]}),Array.prototype.forEach.call(this.images,function(b){a.observer.observe(b)})}catch(b){console.info(b),this.oldLoadImages()}},this.init()}window.lazyLoad=function(){return new a}}(),document.addEventListener("DOMContentLoaded",function(){lazyLoad()},!1),require(["jquery"],function(a){a(document.body).on("contentUpdated contentUpdated.oxlazy",lazyLoad)})</script>
@@ -0,0 +1,23 @@
<?php
/**
* @author Olegnax
* @package Olegnax_Core
* @copyright Copyright (c) 2023 Olegnax (http://olegnax.com/). All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Framework\View\Element\Template;
use Olegnax\Core\Helper\Helper;
/** @var Template $block */
/** @var Helper $helper */
$helper = $block->getData('helper');
$mobile = $helper->isMobileTheme();
?>
<script>
var OX_MOBILE = <?= $mobile ? 1 : 0 ?>,
OX_PHOTOSWIPE = 1,
OX_CATALOG_AJAX = <?= !$helper->getSystemValue('athlete2_settings/products_listing/catalog_ajax_add_to_cart') ? 1 : 0 ?>,
OX_WAYPOINTS = <?= $helper->getSystemValue('athlete2_settings/general/waypoints') ? 1 : 0 ?>,
OX_OWL_DISABLE = <?= !$helper->getModuleConfig('general/owlcarousel') ? 1 : 0 ?>,
OX_OWL_OBS_DISABLE = false;
</script>
Binary file not shown.

After

Width:  |  Height:  |  Size: 68 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 747 B

@@ -0,0 +1,55 @@
<svg id="athlete_preloader_image" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 44 3">
<defs>
<style type="text/css"><![CDATA[
@keyframes athlete_preloader {
0%{
transform-origin:left;
transform: scale(0, 1);
}
70% {
transform-origin:left;
transform: scale(1, 1);
}
70.01% {
transform-origin:right;
transform: scale(1, 1);
}
100% {
transform-origin:right;
transform: scale(0, 1);
}
}
@-webkit-keyframes athlete_preloader {
0%{
-webkit-transform-origin:left;
-webkit-transform: scale(0, 1);
transform-origin:left;
transform: scale(0, 1);
}
70% {
-webkit-transform-origin:left;
-webkit-transform: scale(1, 1);
transform-origin:left;
transform: scale(1, 1);
}
70.01% {
-webkit-transform-origin:right;
-webkit-transform: scale(1, 1);
transform-origin:right;
transform: scale(1, 1);
}
100% {
-webkit-transform-origin:right;
-webkit-transform: scale(0, 1);
transform-origin:right;
transform: scale(0, 1);
}
}
.athlete_preloader_fill{
transform-origin:left;
animation: athlete_preloader 1s infinite;
}
]]></style>
</defs>
<rect width="44" height="3" class="athlete_preloader_fill"/>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

+146
View File
@@ -0,0 +1,146 @@
define([
'jquery',
'jquery-ui-modules/widget',
'jquery-ui-modules/core',
'owl.carousel',
], function ($) {
'use strict';
$.widget('mage.OXowlCarousel', {
options: {
items: 3,
loop: false,
center: false,
rewind: false,
lazyLoad: true,
checkVisibility: true,
mouseDrag: true,
touchDrag: true,
pullDrag: true,
freeDrag: false,
margin: 0,
stagePadding: 0,
merge: false,
mergeFit: true,
autoWidth: false,
startPosition: 0,
rtl: false,
smartSpeed: 400,
fluidSpeed: false,
dragEndSpeed: false,
responsive: {},
responsiveRefreshRate: 200,
responsiveBaseElement: window,
fallbackEasing: 'swing',
slideTransition: '',
info: false,
nestedItemSelector: false,
itemElement: 'div',
stageElement: 'div',
refreshClass: 'owl-refresh',
loadedClass: 'owl-loaded',
loadingClass: 'owl-loading',
rtlClass: 'owl-rtl',
responsiveClass: 'owl-responsive',
dragClass: 'owl-drag',
itemClass: 'owl-item',
stageClass: 'owl-stage',
stageOuterClass: 'owl-stage-outer',
grabClass: 'owl-grab',
wrapperSelectorClass: '.block.widget',
callbacks: true,
observerLoad: !(window.hasOwnProperty('OX_OWL_OBS_DISABLE') ? OX_OWL_OBS_DISABLE : false)
},
_create: function () {
this.options.onInitialized = this.owlchanged;
this.options.onChanged = this.owlchanged;
this.options.onRefreshed = this.owlchanged;
if (this.options.observerLoad) {
this._loadObserver();
} else {
this._loadOwl();
}
},
_loadObserver: function () {
let _self = this;
if (window.IntersectionObserver) {
let observer = new IntersectionObserver(function (entries, observer) {
Array.prototype.forEach.call(entries, function (entry) {
if (entry.isIntersecting) {
_self._loadOwl.call(_self);
observer.unobserve(entry.target);
}
});
}, {
root: null,
rootMargin: "0px",
threshold: [0]
});
this.element.each(function (i, el) {
observer.observe(el);
});
} else {
let debouncer = function (func) {
var timeoutID;
return function () {
var scope = this,
args = arguments;
clearTimeout(timeoutID);
timeoutID = setTimeout(function () {
func.apply(scope, Array.prototype.slice.call(args));
}, 200);
}
};
$(window).one('scroll resize', debouncer(function () {
let height = window.visualViewport ? window.visualViewport.height : window.innerHeight;
this.element.each(function (i, el) {
let bounding = el.getBoundingClientRect();
if (bounding.top != bounding.bottom && 0 < bounding.bottom && height > bounding.top) {
_self._loadOwl.call(_self);
}
})
}));
}
},
_loadOwl: function () {
this.element.find('picture.owl-lazy').removeClass('owl-lazy');
this.element.owlCarousel(this.options);
this.arrows();
},
owlchanged: function (event) {
var $wraper = this.$element.closest(this.options.wrapperSelectorClass).eq(0);
var current = this.current();
$wraper.find('.ox-owl-nav').toggle(this.settings.items < this.items().length);
var disable_nav_min = current === this.minimum();
var disable_nav_max = current === this.maximum();
if (this.settings.loop) {
disable_nav_min = disable_nav_max = false;
}
$wraper.find('.ox-owl-next').toggleClass('disabled', disable_nav_max);
$wraper.find('.ox-owl-prev').toggleClass('disabled', disable_nav_min);
},
arrows: function () {
var $wraper = this.element.closest(this.options.wrapperSelectorClass).eq(0);
$wraper.on('click', '.ox-owl-next', $.proxy(function () {
this.element.trigger('next.owl.carousel');
}, this));
$wraper.on('click', '.ox-owl-prev', $.proxy(function () {
this.element.trigger('prev.owl.carousel');
}, this));
}
});
return $.mage.OXowlCarousel;
});
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

@@ -0,0 +1,206 @@
/**
* Owl Carousel v2.3.4
* Copyright 2013-2018 David Deutsch
* Licensed under: SEE LICENSE IN https://github.com/OwlCarousel2/OwlCarousel2/blob/master/LICENSE
*/
/*
* Owl Carousel - Core
*/
.owl-carousel {
width: 100%;
-webkit-tap-highlight-color: transparent;
/* position relative and z-index fix webkit rendering fonts issue */
position: relative;
z-index: 1; }
.owl-carousel:not(.owl-loaded){
display: flex!important;
overflow: hidden;
opacity: 0;
visibility: hidden;
}
.owl-carousel:not(.owl-loaded) > *{
display: block!important;
opacity: 0;
visibility: hidden;
}
.owl-carousel .owl-stage {
position: relative;
-ms-touch-action: pan-Y;
touch-action: manipulation;
-moz-backface-visibility: hidden;
/* fix firefox animation glitch */ }
.owl-carousel .owl-stage:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0; }
.owl-carousel .owl-stage-outer {
position: relative;
overflow: hidden;
/* fix for flashing background */
-webkit-transform: translate3d(0px, 0px, 0px); }
.owl-carousel .owl-wrapper,
.owl-carousel .product-item,
.owl-carousel .owl-item {
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-ms-backface-visibility: hidden;
-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
-ms-transform: translate3d(0, 0, 0); }
.owl-carousel .product-item,
.owl-carousel .owl-item {
position: relative;
min-height: 1px;
float: left;
-webkit-backface-visibility: hidden;
-webkit-tap-highlight-color: transparent;
-webkit-touch-callout: none; }
.owl-carousel .product-item img,
.owl-carousel .owl-item img {
display: block;
width: 100%; }
.owl-carousel .owl-nav.disabled,
.owl-carousel .owl-dots.disabled {
display: none; }
.owl-carousel .owl-nav .owl-prev,
.owl-carousel .owl-nav .owl-next,
.owl-carousel .owl-dot {
cursor: pointer;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none; }
.owl-carousel .owl-nav button.owl-prev,
.owl-carousel .owl-nav button.owl-next,
.owl-carousel button.owl-dot {
background: none;
color: inherit;
border: none;
padding: 0 !important;
font: inherit; }
.owl-carousel.owl-loaded {
display: block; }
.owl-carousel.owl-loading {
opacity: 0;
display: block; }
.owl-carousel.owl-hidden {
opacity: 0; }
.owl-carousel.owl-refresh .product-item,
.owl-carousel.owl-refresh .owl-item {
visibility: hidden; }
.owl-carousel.owl-drag .product-item,
.owl-carousel.owl-drag .owl-item {
-ms-touch-action: pan-y;
touch-action: pan-y;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none; }
.owl-carousel.owl-grab {
cursor: move;
cursor: grab; }
.owl-carousel.owl-rtl {
direction: rtl; }
.owl-carousel.owl-rtl .product-item,
.owl-carousel.owl-rtl .owl-item {
float: right; }
/* No Js */
.no-js .owl-carousel {
display: block; }
/*
* Owl Carousel - Animate Plugin
*/
.owl-carousel .animated {
animation-duration: 1000ms;
animation-fill-mode: both; }
.owl-carousel .owl-animated-in {
z-index: 0; }
.owl-carousel .owl-animated-out {
z-index: 1; }
.owl-carousel .fadeOut {
animation-name: fadeOut; }
@keyframes fadeOut {
0% {
opacity: 1; }
100% {
opacity: 0; } }
/*
* Owl Carousel - Auto Height Plugin
*/
.owl-height {
transition: height 500ms ease-in-out; }
/*
* Owl Carousel - Lazy Load Plugin
*/
.owl-carousel .product-item,
.owl-carousel .owl-item {
/**
This is introduced due to a bug in IE11 where lazy loading combined with autoheight plugin causes a wrong
calculation of the height of the owl-item that breaks page layouts
*/ }
.owl-carousel .product-item .owl-lazy,
.owl-carousel .owl-item .owl-lazy {
opacity: 0;
transition: opacity 400ms ease; }
.owl-carousel .product-item .owl-lazy[src^=""], .owl-carousel .product-item .owl-lazy:not([src]),
.owl-carousel .owl-item .owl-lazy[src^=""], .owl-carousel .owl-item .owl-lazy:not([src]) {
max-height: 0; }
.owl-carousel .product-item img.owl-lazy,
.owl-carousel .owl-item img.owl-lazy {
transform-style: preserve-3d; }
/*
* Owl Carousel - Video Plugin
*/
.owl-carousel .owl-video-wrapper {
position: relative;
height: 100%;
background: #000; }
.owl-carousel .owl-video-play-icon {
position: absolute;
height: 80px;
width: 80px;
left: 50%;
top: 50%;
margin-left: -40px;
margin-top: -40px;
background: url("owl.video.play.png") no-repeat;
cursor: pointer;
z-index: 1;
-webkit-backface-visibility: hidden;
transition: transform 100ms ease; }
.owl-carousel .owl-video-play-icon:hover {
-ms-transform: scale(1.3, 1.3);
transform: scale(1.3, 1.3); }
.owl-carousel .owl-video-playing .owl-video-tn,
.owl-carousel .owl-video-playing .owl-video-play-icon {
display: none; }
.owl-carousel .owl-video-tn {
opacity: 0;
height: 100%;
background-position: center center;
background-repeat: no-repeat;
background-size: contain;
transition: opacity 400ms ease; }
.owl-carousel .owl-video-frame {
position: relative;
z-index: 1;
height: 100%;
width: 100%; }
@@ -0,0 +1,6 @@
/**
* Owl Carousel v2.3.4
* Copyright 2013-2018 David Deutsch
* Licensed under: SEE LICENSE IN https://github.com/OwlCarousel2/OwlCarousel2/blob/master/LICENSE
*/
.owl-carousel{width:100%;-webkit-tap-highlight-color:transparent;position:relative;z-index:1}.owl-carousel:not(.owl-loaded){ display: flex!important; overflow: hidden; opacity: 0; visibility: hidden; } .owl-carousel:not(.owl-loaded) > *{ display: block!important; opacity: 0; visibility: hidden; }.owl-carousel .owl-stage{position:relative;-ms-touch-action:pan-Y;touch-action:manipulation;-moz-backface-visibility:hidden}.owl-carousel .owl-stage:after{content:".";display:block;clear:both;visibility:hidden;line-height:0;height:0}.owl-carousel .owl-stage-outer{position:relative;overflow:hidden;-webkit-transform:translate3d(0,0,0)}.owl-carousel .owl-item,.owl-carousel .owl-wrapper,.owl-carousel .product-item{-webkit-backface-visibility:hidden;-moz-backface-visibility:hidden;-ms-backface-visibility:hidden;-webkit-transform:translate3d(0,0,0);-moz-transform:translate3d(0,0,0);-ms-transform:translate3d(0,0,0)}.owl-carousel .owl-item,.owl-carousel .product-item{position:relative;min-height:1px;float:left;-webkit-backface-visibility:hidden;-webkit-tap-highlight-color:transparent;-webkit-touch-callout:none}.owl-carousel .owl-item img,.owl-carousel .product-item img{display:block;width:100%}.owl-carousel .owl-dots.disabled,.owl-carousel .owl-nav.disabled{display:none}.no-js .owl-carousel,.owl-carousel.owl-loaded{display:block}.owl-carousel .owl-dot,.owl-carousel .owl-nav .owl-next,.owl-carousel .owl-nav .owl-prev{cursor:pointer;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.owl-carousel .owl-nav button.owl-next,.owl-carousel .owl-nav button.owl-prev,.owl-carousel button.owl-dot{background:0 0;color:inherit;border:none;padding:0!important;font:inherit}.owl-carousel.owl-loading{opacity:0;display:block}.owl-carousel.owl-hidden{opacity:0}.owl-carousel.owl-refresh .owl-item,.owl-carousel.owl-refresh .product-item{visibility:hidden}.owl-carousel.owl-drag .owl-item,.owl-carousel.owl-drag .product-item{-ms-touch-action:pan-y;touch-action:pan-y;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.owl-carousel.owl-grab{cursor:move;cursor:grab}.owl-carousel.owl-rtl{direction:rtl}.owl-carousel.owl-rtl .owl-item,.owl-carousel.owl-rtl .product-item{float:right}.owl-carousel .animated{animation-duration:1s;animation-fill-mode:both}.owl-carousel .owl-animated-in{z-index:0}.owl-carousel .owl-animated-out{z-index:1}.owl-carousel .fadeOut{animation-name:fadeOut}@keyframes fadeOut{0%{opacity:1}100%{opacity:0}}.owl-height{transition:height .5s ease-in-out}.owl-carousel .owl-item .owl-lazy,.owl-carousel .product-item .owl-lazy{opacity:0;transition:opacity .4s ease}.owl-carousel .owl-item .owl-lazy:not([src]),.owl-carousel .owl-item .owl-lazy[src^=""],.owl-carousel .product-item .owl-lazy:not([src]),.owl-carousel .product-item .owl-lazy[src^=""]{max-height:0}.owl-carousel .owl-item img.owl-lazy,.owl-carousel .product-item img.owl-lazy{transform-style:preserve-3d}.owl-carousel .owl-video-wrapper{position:relative;height:100%;background:#000}.owl-carousel .owl-video-play-icon{position:absolute;height:80px;width:80px;left:50%;top:50%;margin-left:-40px;margin-top:-40px;background:url(owl.video.play.png) no-repeat;cursor:pointer;z-index:1;-webkit-backface-visibility:hidden;transition:transform .1s ease}.owl-carousel .owl-video-play-icon:hover{-ms-transform:scale(1.3,1.3);transform:scale(1.3,1.3)}.owl-carousel .owl-video-playing .owl-video-play-icon,.owl-carousel .owl-video-playing .owl-video-tn{display:none}.owl-carousel .owl-video-tn{opacity:0;height:100%;background-position:center center;background-repeat:no-repeat;background-size:contain;transition:opacity .4s ease}.owl-carousel .owl-video-frame{position:relative;z-index:1;height:100%;width:100%}
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long