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
+32
View File
@@ -0,0 +1,32 @@
<?php
namespace Olegnax\Athlete2\Block\Adminhtml;
use Magento\Backend\Block\Template;
use Magento\Backend\Block\Template\Context;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Filesystem;
class Import extends Template {
protected $_filesystem;
protected $_dir;
public function __construct( Context $context,
Filesystem $filesystem, array $data = []
) {
$this->_filesystem = $filesystem;
parent::__construct( $context, $data );
}
public function getWebsiteId() {
$storeModel = $this->_objectManager->create( 'Magento\Store\Model\Store' );
$store = $storeModel->load( $this->getRequest()->getParam( 'store' ) );
return $store->getWebsiteId();
}
public function getAbsolutePath( $path ) {
return $this->_filesystem->getDirectoryRead( DirectoryList::APP )->getAbsolutePath( $path );
}
}
@@ -0,0 +1,158 @@
<?php
namespace Olegnax\Athlete2\Block\Adminhtml\Import;
use Magento\Backend\Block\Template\Context;
use Magento\Cms\Model\ResourceModel\Page\CollectionFactory;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Filesystem;
use Magento\Store\Model\ScopeInterface;
use Magento\Store\Model\StoreManagerInterface;
use Olegnax\Athlete2\Block\Adminhtml\Import;
use Olegnax\Athlete2\Helper\Helper;
class Exporter extends Import
{
const DEMO_EXPORT_PATH = '*/*/export';
protected $scopeConfig;
protected $blockFactory;
protected $pageFactory;
protected $storeManager;
protected $helper;
/**
* Constructor
*
* @param Context $context
* @param array $data
*/
public function __construct(
Context $context,
Filesystem $filesystem,
ScopeConfigInterface $scopeConfig,
\Magento\Cms\Model\ResourceModel\Block\CollectionFactory $blockFactory,
CollectionFactory $pageFactory,
StoreManagerInterface $storeManager,
Helper $helper,
array $data = []
) {
$this->scopeConfig = $scopeConfig;
$this->blockFactory = $blockFactory;
$this->pageFactory = $pageFactory;
$this->storeManager = $storeManager;
$this->helper = $helper;
parent::__construct($context, $filesystem, $data);
}
public function getConfig()
{
if ($websiteId = $this->getRequest()->getParam('website')) {
return $this->scopeConfig->getValue('', ScopeInterface::SCOPE_WEBSITE, $websiteId);
}
if ($storeId = $this->getRequest()->getParam('store')) {
return $this->scopeConfig->getValue('', ScopeInterface::SCOPE_STORE, $storeId);
}
return $this->scopeConfig->getValue('');
}
public function getBlocks()
{
$storeIds = $this->getStoreIds();
$itemCollection = $this->blockFactory->create();
$items = [];
if (!empty($storeIds)) {
$storeIds[] = 0;
$itemCollection->addFieldToFilter('store_id', ['in' => [$storeIds]]);
}
if (count($itemCollection) > 0) {
foreach ($itemCollection as $item) {
$items[$item->getIdentifier()] = $item->getTitle();
}
}
return $items;
}
protected function getStoreIds()
{
$storeIds = [];
if ($storeId = (int)$this->getRequest()->getParam('store')) {
$storeIds[] = $storeId;
} elseif ($websiteId = (int)$this->getRequest()->getParam('website')) {
$stores = $this->storeManager->getWebsite($websiteId)->getStores();
foreach ($stores as $_store) {
$storeIds[] = $_store->getId();
}
}
return $storeIds;
}
public function getPages()
{
$storeIds = $this->getStoreIds();
$itemCollection = $this->pageFactory->create();
if (!empty($storeIds)) {
$storeIds[] = 0;
$itemCollection->addFieldToFilter('store_id', ['in' => [$storeIds]]);
}
$items = [];
if (count($itemCollection) > 0) {
foreach ($itemCollection as $item) {
$items[$item->getIdentifier()] = $item->getTitle();
}
}
return $items;
}
public function getBannerSlider()
{
$items = [];
if ($this->helper->isActivePlugin('Olegnax_BannerSlider')) {
$group = ObjectManager::getInstance()->get(\Olegnax\BannerSlider\Model\ResourceModel\Group\CollectionFactory::class)->create();
$itemCollection = $group->addFieldToSelect('*');
if (count($itemCollection) > 0) {
foreach ($itemCollection as $item) {
$items[$item->getIdentifier()] = $item->getGroupName();
}
}
}
return $items;
}
public function getCarousel()
{
$items = [];
if ($this->helper->isActivePlugin('Olegnax_Carousel')) {
$group = ObjectManager::getInstance()->get(\Olegnax\Carousel\Model\ResourceModel\Carousel\CollectionFactory::class)->create();
$itemCollection = $group->addFieldToSelect('*');
if (count($itemCollection) > 0) {
foreach ($itemCollection as $item) {
$items[$item->getIdentifier()] = $item->getTitle();
}
}
}
return $items;
}
public function actionExport(array $subArguments = [])
{
$arguments = [];
if ($storeId = $this->getRequest()->getParam('store')) {
$arguments['store'] = $storeId;
} elseif ($websiteId = $this->getRequest()->getParam('website')) {
$arguments['website'] = $websiteId;
}
if (is_array($subArguments)) {
$arguments = array_merge($arguments, $subArguments);
}
$url = $this->getUrl(self::DEMO_EXPORT_PATH, $arguments);
return $url;
}
}
+72
View File
@@ -0,0 +1,72 @@
<?php
namespace Olegnax\Athlete2\Block\Adminhtml\Import;
use Magento\Framework\UrlInterface;
use Olegnax\Athlete2\Controller\Adminhtml\Import\Import;
class Index extends \Olegnax\Athlete2\Block\Adminhtml\Import {
const DEMO_IMPORT_PATH = '*/*/import';
public function getDemo() {
$demoDir = $this->getAbsolutePath( Import::DEMO_DIR );
$demos = array();
if ( is_dir( $demoDir ) ) {
$paths = glob( $demoDir . '/*', GLOB_ONLYDIR );
foreach ( $paths as $path ) {
if ( !is_dir( $path ) ) {
continue;
}
$variations = [];
$demoId = basename( $path );
$vpaths = glob( $path . '/*.xml' );
foreach ( $vpaths as $vpath ) {
$vdemoId = pathinfo( $vpath, PATHINFO_FILENAME );
$variations[] = $vdemoId;
}
if ( !empty( $variations ) ) {
$demos[ $demoId ] = [
'name' => $this->convertString( $demoId ),
'variations' => $variations,
];
}
}
}
return $demos;
}
public function getDemoImage( $demoId ) {
$demoId = str_replace( DIRECTORY_SEPARATOR, '/', $demoId );
return $this->_urlBuilder->getBaseUrl( [ '_type' => UrlInterface::URL_TYPE_MEDIA ] ) . 'athlete2/Demos/' . $demoId . '.jpg';
}
public function getDemoId( $demoId ) {
return str_replace( DIRECTORY_SEPARATOR, '-', $demoId );
}
public function actionImport( $demoId, $vdemoId, array $subArguments = [] ) {
$arguments = [ 'subdir' => $demoId, 'demo' => $vdemoId ];
if ( $storeId = $this->getRequest()->getParam( 'store' ) ) {
$arguments[ 'store' ] = $storeId;
} elseif ( $websiteId = $this->getRequest()->getParam( 'website' ) ) {
$arguments[ 'website' ] = $websiteId;
}
if ( is_array( $subArguments ) ) {
$arguments = array_merge( $arguments, $subArguments );
}
$url = $this->getUrl( self::DEMO_IMPORT_PATH, $arguments );
return $url;
}
public function convertString( $demoId ) {
return ucwords( strtolower( str_replace( [ '-', '_' ], ' ', $demoId ) ) );
}
}
+143
View File
@@ -0,0 +1,143 @@
<?php
namespace Olegnax\Athlete2\Block\Adminhtml;
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\Athlete2\Helper\Helper;
use Olegnax\Core\Helper\ModuleInfo;
class Info extends Fieldset
{
/**
* @var Helper
*/
protected $_helper;
/**
* @var ModuleInfo
*/
private $_moduleInfo;
public function __construct(
Context $context,
Session $authSession,
Js $jsHelper,
ModuleInfo $moduleInfo,
Helper $helper,
array $data = []
) {
$this->_moduleInfo = $moduleInfo;
$this->_helper = $helper;
parent::__construct($context, $authSession, $jsHelper, $data);
}
public function checkModulesVersion( $moduleName ) {
$index = 0;
if ( !empty( $moduleName ) && is_array( $moduleName ) ){
foreach ( $moduleName as $name ) {
$module = $this->_moduleInfo->getModuleInfo( 'Olegnax_' . $name );
if (empty($module)) {
$module = [
'update_status' => false,
'setup_version' => ''
];
}
if ( $module[ 'update_status' ] )
$index++;
}
}
return $index;
}
/**
* Retrieve HTML markup for given form element
*
* @param AbstractElement $element
* @return string
*/
public function render(AbstractElement $element)
{
$modulesList= array('Athlete2','Quickview','MegaMenu','ProductLabel','BrandSlider','BannerSlider','Athlete2Slideshow','ProductSlider','ProductReviewsSummary','Core');
$license = $this->_helper->get();
$code = $this->_helper->getSystemDefaultValue('athlete2_license/general/code');
$status = !empty($license)
&& isset($license->data->the_key)
&& $license->data->the_key == $code
&& $license->data->status == "active";
$devLicense = $status && isset($license->notices->develop);
$supportExpired = $status && $license->data->has_expired;
$notice = [];
$notice[] = '<a href="https://olegnax.com/" target="_blank" class="ox-info-block__logo"></a>';
$notice[] = '<div class="ox-info-block__title">' . __('Athlete2') . '</div>';
if ($devLicense) {
$notice[] = '<div class="ox-info-block__dev">' . __('Dev License Activated. <br>Do not use on live store.') . '</div>';
}
if ($status) {
$module = $this->_moduleInfo->getModuleInfo($this->getModuleName());
$theme = $this->_moduleInfo->getThemeInfo('frontend/Olegnax/athlete2', 'Athlete2');
if (empty($theme)) {
$theme = $this->_moduleInfo->getThemeInfo('frontend/Olegnax/Athlete2', 'Athlete2');
}
if (empty($theme)) {
$theme = [
'update_status' => false,
'setup_version' => ''
];
}
$isExpired = '';
if($theme['update_status']){
$isExpired = ' expired';
}
$notice[] = '<div class="ox-info-block__version'. $isExpired .'">';
// Current Theme version
$notice[] = '<div class="ox-theme-version">Theme v' . $this->escapeHtml($theme['setup_version']);
// Check if Theme is expired
if ($theme['update_status']) {
$notice[] = '<span class="ox-server-version">v'.$this->escapeHtml($theme['server_version']).'</span><a href="' . $this->escapeUrl($theme['url_changelog']) . '">' . __("What's New") . '</a>';
}
$notice[] = '</div>';
// check if Athlete2 Module is expired
/* if ($module['update_status']) {
$notice[] = '<div class="module-expired">Athlete2 Module - v' . $this->escapeHtml($module['setup_version']) . '<span class="server-version">v'.$this->escapeHtml($module['server_version']).'</span>';
if (array_key_exists('url_changelog', $module)) {
$notice[] = '<a href="' . $this->escapeUrl($module['url_changelog']) . '">' . __("What's New") . '</a>';
}
$notice[] = '</div>';
}*/
// check if any of Olegnax Modules are expired
$expiredModules = $this->checkModulesVersion($modulesList);
if($expiredModules > 0){
$notice[] = '<div class="ox-modules-expired"><a href="'. $this->getUrl('olegnax/modules/update') .'">' . $expiredModules . ' of theme modules outdated.</a></div>';
}
//close ox-info-block__version
$notice[] = '</div>';
$notice[] = '<div class="ox-info-block__right">';
$notice[] = '<div class="ox-info-block__docs"><a href="https://athlete2.com/documentation/" target="_blank">' . __('User Guide') . '</a></div>';
$notice[] = '<div class="ox-info-block__support support-' . ($supportExpired ? 'expired' : 'active') . '"><div class="ox-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></div>';
} else {
$notice[] = '<strong style="color:#a4a4a4">Theme is not Activated.</strong>';
}
$html = sprintf(
('<div class="ox-info-block">%s</div>'),
implode('', $notice)
);
if ($element->getIsNested()) {
$html = '<tr class="nested"><td colspan="4">' . $html . '</td></tr>';
}
return $html;
}
}
+43
View File
@@ -0,0 +1,43 @@
<?php
namespace Olegnax\Athlete2\Block\Adminhtml;
use Olegnax\Athlete2\Block\Template;
class Notice extends Template
{
protected function _toHtml()
{
$license = $this->getHelper()->get();
$section = $this->getRequest()->getParam('section');
$notice = '';
if (empty($license)) {
if ('athlete2_settings' == $section || 'athlete2_design' == $section) {
$closeNum = rand(1, 3);
$notice .='<div class="ox-admin__modal ox-admin__modal-license opened"><div class="ox-admin-modal__inner" style="text-align: center;">'
. ' <h2>' . __( 'Athlete 2 Theme is not Activated.' ) . '</h2>'
. '<h3>' . __( 'Please add your purchase code in ') . '<a href="' . $this->getLicenseUrl() . '">' . __('Athlete 2 / Theme License') . '</a></h3>'
. '<hr style=" margin: 30px 0;border: 0; border-bottom: 1px solid #dbdbdb;">'
. '<h3>Press <span style="color:red">'. $closeNum .'</span> to close modal.</h3>'
. '<button style="font-size: 18px; margin: 6px;" class="action-primary '. (($closeNum === 1) ? 'ox-close-modal-license' : '') .'">1</button>'
. '<button style="font-size: 18px; margin: 6px;" class="action-primary '. (($closeNum === 2) ? 'ox-close-modal-license' : '') .'">2</button>'
. '<button style="font-size: 18px; margin: 6px;" class="action-primary '. (($closeNum === 3) ? 'ox-close-modal-license' : '') .'">3</button>'
. '</div></div>';
$notice .='<script>require( [\'jquery\',], function ( $ ) { \'use strict\'; $( \'body\' ).on( \'click\', \'.ox-close-modal-license\', function ( e ) { e.preventDefault(); $( this ).closest( \'.ox-admin__modal-license\' ).removeClass( \'opened\' ); } ); } );</script>';
}
if ('athlete2_license' !== $section) {
$notice .= '<div class="ox-license-status ox-notice-license status-disable"><span class="icon"></span><div class="inner"><h2 class="ox-license-status__title">' . __('Athlete2 Theme ') . '<span class="undelined">' . __('Not Activated!') . '</span><a href="' . $this->getLicenseUrl() . '">' . __('Click here to Activate') . '</a></h2></div></div>';
}
return $notice;
}
return '';
}
protected function getLicenseUrl()
{
return $this->getUrl('*/*/*', ['_current' => true, 'section' => 'athlete2_license']);
}
}
+46
View File
@@ -0,0 +1,46 @@
<?php
namespace Olegnax\Athlete2\Block\Adminhtml;
use Olegnax\Athlete2\Block\Template;
class NoticeLic extends Template
{
protected function _toHtml()
{
if ('athlete2_license' == $this->getRequest()->getParam('section')) {
$license = $this->getHelper()->get();
$code = $this->getHelper()->getSystemDefaultValue('athlete2_license/general/code');
$notice = [];
$status = !empty($license)
&& isset($license->data->the_key)
&& $license->data->the_key == $code
&& $license->data->status == "active";
$supportExpired = $status && $license->data->has_expired;
$devLicense = $status && isset($license->notices->develop) ? ' developer' : '';
$notice[] = '<div class="ox-license-status status-' . ($status ? 'active' : 'disable') . $devLicense .'"><span class="icon"></span><div class="inner"><h2 class="ox-license-status__title">' . __('Theme License ') . '<span class="undelined">' . ($status ? __('Activated') : __('Not Activated!')) . '</span></h2>'. ( $devLicense ? __('<strong class="b-info">' . implode(' ', $license->notices->develop) . '</strong>') : '') . '</div></div>';
if ($supportExpired) {
if ($license->data->has_expired) {
$notice[] = '<div class="ox-license-status support-expired"><span class="icon"></span><div class="inner"><h2 class="ox-license-status__title">' . __('Theme Support has ') . '<span class="undelined">' . __('Expired') . '</span></h2></div><div class="right"><a href="https://themeforest.net/item/athlete2-strong-magento-2-theme/23693737" target="_blank" class="button">' . __('renew') . '</a></div></div>';
} else {
$notice[] = '<div class="ox-license-status support-active"><span class="icon"></span><div class="inner"><h2 class="ox-license-status__title">' . __('Theme Support is ') . '<span class="undelined">' . __('Active') . '</span></h2><strong class="b-info">' . __('Monday - Friday, 10 - 20 GMT +1') . '</strong><div class="support-policy"><a href="https://olegnax.com/support-policy/" class="underline-link">Support Policy</a></div></div><div class="right"><a href="https://olegnax.com/help/" target="_blank" class="button">' . __('get in touch') . '</a></div></div>';
}
/*
foreach ($license->notices as $noticeGroup => $_notice) {
if ('support' !== $noticeGroup) {
$notice[] = '<div class="ox-license-status ' . $noticeGroup . '"><span class="icon"></span><div class="inner"><h2 class="ox-license-status__title">' . implode(' ', $_notice) . '</h2></div></div>';
}
}*/
}
return sprintf(
(1 < count($notice) ? '<div class="two-blocks">%s</div>' : '%s'),
implode('', $notice)
);
}
return '';
}
}
@@ -0,0 +1,41 @@
<?php
namespace Olegnax\Athlete2\Block\Adminhtml\System\Config;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Registry;
use Magento\Backend\Block\Template\Context;
use Magento\Cms\Model\Wysiwyg\Config as WysiwygConfig;
use Magento\Framework\Data\Form\Element\AbstractElement;
class Editor extends Field {
/**
* @var Registry
*/
protected $_coreRegistry;
/**
* @var WysiwygConfig
*/
protected $_wysiwygConfig;
/**
* @param Context $context
* @param WysiwygConfig $wysiwygConfig
* @param array $data
*/
public function __construct(
Context $context, WysiwygConfig $wysiwygConfig, array $data = []
) {
$this->_wysiwygConfig = $wysiwygConfig;
parent::__construct( $context, $data );
}
protected function _getElementHtml( \Magento\Framework\Data\Form\Element\AbstractElement $element ) {
$element->setWysiwyg( true );
$config = $this->_wysiwygConfig->getConfig( $element );
$element->setConfig( $config );
return parent::_getElementHtml( $element );
}
}
+83
View File
@@ -0,0 +1,83 @@
<?php
namespace Olegnax\Athlete2\Block\Blog;
use Magefan\Blog\Model\Config\Source\CommetType;
use Magefan\Blog\Model\Post;
use Magento\Framework\Registry;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
use Magento\Store\Model\ScopeInterface;
class Info extends Template {
protected $_coreRegistry;
public function __construct(
Context $context, Registry $coreRegistry, array $data = []
) {
parent::__construct( $context, $data );
$this->_coreRegistry = $coreRegistry;
}
/**
* Retrieve post instance
*
* @return Post
*/
public function getPost() {
if ( !$this->hasData( 'post' ) ) {
$this->setData(
'post', $this->_coreRegistry->registry( 'current_blog_post' )
);
}
return $this->getData( 'post' );
}
/**
* Block template file
* @var string
*/
protected $_template = 'Magefan_Blog::post/info.phtml';
/**
* DEPRECATED METHOD!!!!
* Retrieve formated posted date
* @var string
* @return string
*/
public function getPostedOn( $format = 'Y-m-d H:i:s' ) {
return $this->getPost()->getPublishDate( $format );
}
/**
* Retrieve 1 if display author information is enabled
* @return int
*/
public function authorEnabled() {
return (int) $this->_scopeConfig->getValue(
'mfblog/author/enabled', \Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
}
/**
* Retrieve 1 if author page is enabled
* @return int
*/
public function authorPageEnabled() {
return (int) $this->_scopeConfig->getValue(
'mfblog/author/page_enabled', \Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
}
/**
* Retrieve true if magefan comments are enabled
* @return bool
*/
public function magefanCommentsEnabled() {
return $this->_scopeConfig->getValue(
'mfblog/post_view/comments/type', \Magento\Store\Model\ScopeInterface::SCOPE_STORE
) == CommetType::MAGEFAN;
}
}
+170
View File
@@ -0,0 +1,170 @@
<?php
/**
* Athlete2 Theme
*
* 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) 2023 Olegnax (http://www.olegnax.com/)
* @license https://www.olegnax.com/license
*/
namespace Olegnax\Athlete2\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);
}
}
+93
View File
@@ -0,0 +1,93 @@
<?php
namespace Olegnax\Athlete2\Block\Frontend;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\View\Element\Template;
use MSP\ReCaptcha\Model\Config;
use MSP\ReCaptcha\Model\LayoutSettings;
use \Magento\Framework\Serialize\Serializer\Json;
class ReCaptcha extends Template
{
/**
* @var array
*/
protected $data;
/**
* @var mixed
*/
protected $layoutSettings;
/**
* @var mixed
*/
protected $config;
/**
* ReCaptcha constructor.
* @param Template\Context $context
* @param array $data
*/
public function __construct(
Template\Context $context,
array $data = []
) {
parent::__construct($context, $data);
$this->data = $data;
if (class_exists(LayoutSettings::class)) {
$this->layoutSettings = ObjectManager::getInstance()->create(LayoutSettings::class);
$this->config = ObjectManager::getInstance()->create(Config::class);
}
$this->json = ObjectManager::getInstance()->get( Json::class);
}
/**
* @inheritdoc
*/
public function getJsLayout()
{
$layout = $this->json->unserialize(parent::getJsLayout());
if ($this->config && $this->config->isEnabledFrontend()) {
// Backward compatibility with fixed scope name
if (isset($layout['components']['msp-recaptcha'])) {
$layout['components'][$this->getRecaptchaId()] = $layout['components']['msp-recaptcha'];
unset($layout['components']['msp-recaptcha']);
}
$recaptchaComponentSettings = [];
if (isset($layout['components'][$this->getRecaptchaId()]['settings'])) {
$recaptchaComponentSettings = $layout['components'][$this->getRecaptchaId()]['settings'];
}
$layout['components'][$this->getRecaptchaId()]['settings'] = array_replace_recursive(
$this->layoutSettings->getCaptchaSettings(),
$recaptchaComponentSettings
);
$layout['components'][$this->getRecaptchaId()]['reCaptchaId'] = $this->getRecaptchaId();
}
return $this->json->serialize($layout);
}
/**
* Get current recaptcha ID
*/
public function getRecaptchaId()
{
return (string)$this->getData('recaptcha_id') ?: 'msp-recaptcha-' . md5($this->getNameInLayout());
}
/**
* @return string
*/
public function toHtml()
{
if (!$this->config || !$this->config->isEnabledFrontend()) {
return '';
}
return parent::toHtml();
}
}
+150
View File
@@ -0,0 +1,150 @@
<?php
/**
* Athlete2 Theme
*
* 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) 2023 Olegnax (http://www.olegnax.com/)
* @license https://www.olegnax.com/license
*/
namespace Olegnax\Athlete2\Block\Html;
use Magento\Backend\Block\Template\Context;
use Magento\Framework\View\Element\Template;
use Olegnax\Athlete2\Helper\Helper;
use Olegnax\Athlete2\Helper\ProductImage as HelperProductImage;
class PrevNextProduct extends Template
{
/**
*
* @var \Olegnax\Athlete2\Helper\PrevNextProduct
*/
protected $prevNextProductHelper;
/**
*
* @var HelperProductImage
*/
protected $imageHelper;
protected $product;
/**
* @var Helper
*/
private $helper;
public function __construct(
Context $context,
\Olegnax\Athlete2\Helper\PrevNextProduct $prevNextProductHelper,
Helper $helper,
HelperProductImage $imageHelper,
array $data = []
) {
$this->prevNextProductHelper = $prevNextProductHelper;
$this->helper = $helper;
$this->imageHelper = $imageHelper;
parent::__construct($context, $data);
}
public function getName()
{
if ($this->isProductExists()) {
return $this->getProduct()->getName();
}
return false;
}
public function isProductExists()
{
return (bool)$this->getProduct();
}
public function getProductUrl()
{
if ($this->isProductExists()) {
return $this->getProduct()->getProductUrl();
}
return false;
}
public function getImage($imageId, $template = HelperProductImage::TEMPLATE, array $attributes = [], $properties = [])
{
if ($this->isProductExists()) {
return $this->imageHelper->getImage($this->getProduct(), $imageId, $template,
$attributes, $properties);
}
return false;
}
public function getImageHover($imageId, $imageId_hover, $template = HelperProductImage::HOVER_TEMPLATE, array $attributes = [], $properties = [])
{
if ($this->isProductExists()) {
return $this->imageHelper->getImageHover($this->getProduct(), $imageId,
$imageId_hover, $template, $attributes, $properties);
}
return false;
}
public function getResizedImage($imageId, $size, $template = HelperProductImage::TEMPLATE, array $attributes = [], $properties = [])
{
if ($this->isProductExists()) {
return $this->imageHelper->getResizedImage($this->getProduct(), $imageId, $size,
$template, $attributes, $properties);
}
return false;
}
public function getResizedImageHover($imageId, $imageId_hover, $size, $template = HelperProductImage::HOVER_TEMPLATE, array $attributes = [], $properties = [])
{
if ($this->isProductExists()) {
return $this->imageHelper->getResizedImageHover($this->getProduct(), $imageId,
$imageId_hover, $size, $template, $attributes, $properties);
}
return false;
}
public function hasHoverImage($imageId, $imageId_hover)
{
if ($this->isProductExists()) {
return $this->imageHelper->hasHoverImage($this->getProduct(), $imageId,
$imageId_hover);
}
return false;
}
protected function _prepareLayout()
{
if ($this->getIsNext()) {
$this->setData('product', $this->prevNextProductHelper->getNextProduct());
} else {
$this->setData('product', $this->prevNextProductHelper->getPreviousProduct());
}
return parent::_prepareLayout();
}
protected function _toHtml()
{
if ($this->helper->isEnabled() &&
$this->helper->getModuleConfig('product/prev_next') &&
$this->isProductExists()) {
return parent::_toHtml();
}
return '';
}
}
+125
View File
@@ -0,0 +1,125 @@
<?php
namespace Olegnax\Athlete2\Block\Product;
use Magento\Cms\Model\BlockFactory;
use Magento\Cms\Model\Template\FilterProvider;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Filter\Template;
use Magento\Store\Model\StoreManagerInterface;
class View extends \Magento\Catalog\Block\Product\View
{
/**
*
* @var ObjectManager
*/
public $objectManager;
protected function _toHtml()
{
if ($this->allowShowTab()) {
$blockId = $this->getData('block');
$attributeCode = $this->getData('attribute');
if (!empty($blockId)) {
return $this->getStaticBlockContent($blockId);
}
if (!empty($attributeCode)) {
return $this->getAttributeContent($attributeCode);
}
}
return '';
}
protected function allowShowTab()
{
$product_skus = $this->getData('product_skus');
$category_ids = $this->getData('category_ids');
if (empty($category_ids) && empty($product_skus)) {
return true;
}
$product = $this->getProduct();
if (!empty($product_skus)) {
$product_skus = array_filter(explode(',', $product_skus));
$sku = $product->getSku();
$id = $product->getId();
if (in_array($sku, $product_skus) || in_array($id, $product_skus)) {
return true;
}
}
if (!empty($category_ids)) {
$category_ids = array_filter(explode(',', $category_ids));
$product_cats = [];
foreach ($product->getCategoryCollection() as $product_cat) {
$product_cats[] = $product_cat->getId();
}
if (0 < count(array_intersect($category_ids, $product_cats))) {
return true;
}
}
return false;
}
protected function getStaticBlockContent($blockId)
{
$store_id = $this->getStoreId();
/** @var BlockFactory $blockFactory */
$blockFactory = $this->_loadObject(BlockFactory::class);
$block = $blockFactory->create()->setStoreId($store_id)->load($blockId);
$content = '';
if ($block) {
$block_content = $block->getContent();
if ($block_content) {
$content = $this->getBlockTemplateProcessor($block_content, $store_id);
}
}
return $content;
}
public function getStoreId()
{
return $this->_loadObject(StoreManagerInterface::class)->getStore()->getId();
}
protected function _loadObject($object)
{
return ObjectManager::getInstance()->get($object);
}
public function getBlockTemplateProcessor($content = '', $store_id = null)
{
if (empty($content) || !is_string($content)) {
$content = '';
}
$content = trim($content);
/** @var Template $filter */
$filter = $this->_loadObject(FilterProvider::class)->getBlockFilter();
if (!empty($store_id)) {
$filter = $filter->setStoreId($store_id);
}
$content = $filter->filter($content);
return $content;
}
protected function getAttributeContent($attributeCode)
{
$product = $this->getProduct();
$attribute = $product->getResource()->getAttribute($attributeCode);
$content = '';
if ($attribute) {
$attr_value = $attribute->getFrontend()->getValue($product);
if ($attr_value) {
$content = $this->getBlockTemplateProcessor($attr_value, $this->getStoreId());
}
}
return $content;
}
}
+65
View File
@@ -0,0 +1,65 @@
<?php
/**
* Athlete2 Theme
*
* 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) 2023 Olegnax (http://www.olegnax.com/)
* @license https://www.olegnax.com/license
*/
namespace Olegnax\Athlete2\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();
}
}
+147
View File
@@ -0,0 +1,147 @@
<?php
/**
* Athlete2 Theme
*
* 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) 2023 Olegnax (http://www.olegnax.com/)
* @license https://www.olegnax.com/license
*/
namespace Olegnax\Athlete2\Block;
use Magento\Customer\Model\Context;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\Store\Model\ScopeInterface;
use Magento\Widget\Block\BlockInterface;
use Magento\Framework\View\Element\Template;
class SocialIcons extends Template implements BlockInterface {
/**
* @var \Magento\Framework\App\Http\Context
*/
protected $httpContext;
/**
* Json Serializer Instance
*
* @var Json
*/
private $json;
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Framework\App\Http\Context $httpContext,
array $data = [],
Json $json = null
) {
$this->httpContext = $httpContext;
$this->json = $json ?: ObjectManager::getInstance()->get( Json::class);
parent::__construct($context, $data);
}
public function getCacheKeyInfo($newval = []) {
return array_merge([
'OLEGNAX_SOCIALICONS_WIDGET',
$this->_storeManager->getStore()->getId(),
$this->_design->getDesignTheme()->getId(),
$this->httpContext->getValue( Context::CONTEXT_GROUP),
$this->json->serialize($this->getRequest()->getParams()),
$this->json->serialize($this->getData()),
], parent::getCacheKeyInfo(), $newval);
}
public function getSocialsId() {
return 'ox_' . $this->getNameInLayout();
}
public function getSocialLinks() {
$social = ['facebook',
'facebook_messenger',
'instagram',
'twitter',
'pinterest',
'skype',
'tumblr',
'youtube',
'amazon',
'amazon_pay',
'kickstarter',
'stripe',
'paypal',
'vimeo',
'vk',
'foursquare',
'flickr',
'linkedin',
'whatsapp',
'telegram_plane',
'snapchat',
'reddit',
'discord',
'slack',
'tripadvisor',
'tiktok',
'business'];
$socialLink = [];
$socialOrder = [];
foreach($social as $_social) {
$link = $this->getData($_social . '_link');
if($link) {
$socialLink[$_social] = $link;
$order = $this->getData($_social . '_sort');
if(empty($order)) {
$order = 0;
}
$socialOrder[$_social] = abs((int)$order);
}
}
asort($socialOrder);
$result = [];
foreach($socialOrder as $_social=>$order) {
$result[$_social] = $socialLink[$_social];
}
return $result;
}
public function prepareStyle(array $style, string $separatorValue = ': ', string $separatorAttribute = ';') {
$style = array_filter($style);
if (empty($style)) {
return '';
}
foreach ($style as $key => &$value) {
$value = $key . $separatorValue . $value;
}
$style = implode($separatorAttribute, $style);
return $style;
}
public function prepareStyleBlock(array $style) {
$result = [];
foreach ($style as $selector=> $_style) {
$result[$selector] = $this->prepareStyle($_style);
}
$result = array_filter($result);
if (!empty($result)) {
foreach ($result as $selector => $_style) {
$result[$selector] = $selector .'{' . $_style .'}';
}
return '<style>' . implode("\n",$result). '</style>';
}
return '';
}
}
@@ -0,0 +1,27 @@
<?php
namespace Olegnax\Athlete2\Block\System\Config\Form\Field;
use Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray;
/**
* Backend system config array field renderer for integration test.
*/
class AttributeArray extends AbstractFieldArray {
/**
* Prepare to render
*
* @return void
*/
protected function _prepareToRender() {
$this->addColumn( 'title', [ 'label' => __( 'Title' ) ] );
$this->addColumn( 'attribute', [ 'label' => __( 'Attribute Code' ) ] );
$this->addColumn( 'category_ids', [ 'label' => __( 'Categories' ) ] );
$this->addColumn( 'product_skus', [ 'label' => __( 'Products' ) ] );
$this->addColumn( 'sort_order', [ 'label' => __( 'Order' ) ] );
$this->_addAfter = false;
$this->_addButtonLabel = __( 'Add Tab' );
}
}
@@ -0,0 +1,27 @@
<?php
namespace Olegnax\Athlete2\Block\System\Config\Form\Field;
use Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray;
/**
* Backend system config array field renderer for integration test.
*/
class BlockArray extends AbstractFieldArray {
/**
* Prepare to render
*
* @return void
*/
protected function _prepareToRender() {
$this->addColumn( 'title', [ 'label' => __( 'Title' ) ] );
$this->addColumn( 'block', [ 'label' => __( 'Block' ) ] );
$this->addColumn( 'category_ids', [ 'label' => __( 'Categories' ) ] );
$this->addColumn( 'product_skus', [ 'label' => __( 'Products' ) ] );
$this->addColumn( 'sort_order', [ 'label' => __( 'Order' ) ] );
$this->_addAfter = false;
$this->_addButtonLabel = __( 'Add Tab' );
}
}
@@ -0,0 +1,21 @@
<?php
namespace Olegnax\Athlete2\Block\System\Config\Form\Field;
use Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray;
/**
* Backend system config array field renderer for integration test.
*/
class DeferActionArray extends AbstractFieldArray {
/**
* Prepare to render
*
* @return void
*/
protected function _prepareToRender() {
$this->addColumn( 'condition', [ 'label' => __( 'Matched Expression' ) ] );
}
}
+164
View File
@@ -0,0 +1,164 @@
<?php
/**
* Athlete2 Theme
*
* 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) 2023 Olegnax (http://www.olegnax.com/)
* @license https://www.olegnax.com/license
*/
namespace Olegnax\Athlete2\Block;
use Magento\Customer\Model\Form;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\App\Request\Http;
use Magento\Store\Model\ScopeInterface;
use Olegnax\Athlete2\Helper\Helper as HelperHelper;
use Olegnax\Athlete2\Helper\ProductImage as HelperProductImage;
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();
}
/**
* @return HelperHelper
*/
public function getHelper()
{
return $this->_loadObject(HelperHelper::class);
}
public function getWishlistCount()
{
return $this->getHelper()->getWishlistCount();
}
// Helper Helper //
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 getSystemValue($path, $storeCode = null)
{
$value = $this->_scopeConfig->getValue($path, ScopeInterface::SCOPE_STORE, $storeCode);
if (is_null($value)) {
$value = '';
}
return $value;
}
public function getBlockTemplateProcessor($content = '')
{
if (empty($content) || !is_string($content)) {
$content = '';
}
return $this->getHelper()->getBlockTemplateProcessor($content);
}
public function getConfig($path, $storeCode = null)
{
return $this->getSystemValue($path, $storeCode);
}
public function isCurrentPage($pageFullActionName)
{
if (empty($pageFullActionName)) {
return true;
}
if (is_string($pageFullActionName)) {
$pageFullActionName = explode(',', $pageFullActionName);
}
$pageFullActionName = array_filter($pageFullActionName);
if (empty($pageFullActionName)) {
return true;
}
return in_array($this->getFullActionName(), $pageFullActionName);
}
public function getFullActionName()
{
return $this->_getRequest()->getFullActionName();
}
protected function _getRequest()
{
return $this->_loadObject(Http::class);
}
}
+82
View File
@@ -0,0 +1,82 @@
<?php
/**
* Athlete2 Theme
*
* 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) 2023 Olegnax (http://www.olegnax.com/)
* @license https://www.olegnax.com/license
*/
namespace Olegnax\Athlete2\Block;
use Magento\Customer\Model\Context;
use Magento\Customer\Model\Url;
use Olegnax\Athlete2\Helper\Helper as HelperHelper;
class TopLinks extends SimpleTemplate
{
/**
* @var \Magento\Framework\App\Http\Context
*/
protected $httpContext;
/**
* @var Url
*/
protected $_customerUrl;
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Framework\App\Http\Context $httpContext,
Url $customerUrl,
array $data = []
) {
$this->httpContext = $httpContext;
$this->_customerUrl = $customerUrl;
parent::__construct($context, $data);
}
public function getCompareListUrl()
{
return $this->_loadObject(HelperHelper::class)->getCompareListUrl();
}
/**
* @return string
*/
public function getLoginUrl()
{
return $this->_customerUrl->getLoginUrl();
}
/**
* @return string
*/
public function getLogoutUrl()
{
return $this->_customerUrl->getLogoutUrl();
}
/**
* Is logged in
*
* @return bool
*/
public function isLoggedIn()
{
return $this->httpContext->getValue(Context::CONTEXT_AUTH);
}
}