ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace Olegnax\BannerSlider\Block\Adminhtml\Group;
|
||||
|
||||
use Magento\Backend\Block\Widget\Context;
|
||||
use Magento\Backend\Block\Widget\Form\Container;
|
||||
use Magento\Framework\Phrase;
|
||||
use Magento\Framework\Registry;
|
||||
|
||||
class Edit extends Container
|
||||
{
|
||||
|
||||
protected $_coreRegistry = null;
|
||||
|
||||
/**
|
||||
* Edit constructor.
|
||||
* @param Registry $registry
|
||||
* @param Context $context
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Registry $registry,
|
||||
Context $context,
|
||||
array $data = []
|
||||
) {
|
||||
$this->_coreRegistry = $registry;
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Phrase|string
|
||||
*/
|
||||
public function getHeaderText()
|
||||
{
|
||||
$id = $this->_coreRegistry->registry('olegnax_bannerslider_group')->getId();
|
||||
if ($id) {
|
||||
return __("Edit Group '%1'", $this->escapeHtml($id));
|
||||
} else {
|
||||
return __('New Group');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_blockGroup = 'Olegnax_BannerSlider';
|
||||
$this->_controller = 'adminhtml_group';
|
||||
parent::_construct();
|
||||
if ($this->_isAllowedAction('Olegnax_BannerSlider::Group_New')
|
||||
|| $this->_isAllowedAction('Olegnax_BannerSlider::Group_Edit')) {
|
||||
$this->buttonList->remove('reset');
|
||||
$this->buttonList->update('save', 'label', __('Save Group'));
|
||||
$this->buttonList->add(
|
||||
'saveandcontinue',
|
||||
[
|
||||
'label' => __('Save and Continue Edit'),
|
||||
'class' => 'save',
|
||||
'data_attribute' => [
|
||||
'mage-init' => [
|
||||
'button' => ['event' => 'saveAndContinueEdit', 'target' => '#edit_form'],
|
||||
],
|
||||
],
|
||||
],
|
||||
-100
|
||||
);
|
||||
$this->buttonList->update('delete', 'label', __('Delete Group'));
|
||||
} else {
|
||||
$this->buttonList->remove('save');
|
||||
$this->buttonList->remove('delete');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $resourceId
|
||||
* @return bool
|
||||
*/
|
||||
protected function _isAllowedAction($resourceId)
|
||||
{
|
||||
return $this->_authorization->isAllowed($resourceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function _toHtml()
|
||||
{
|
||||
$this->_eventManager->dispatch(
|
||||
'adminhtml_block_html_before',
|
||||
['block' => $this]
|
||||
);
|
||||
return parent::_toHtml();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Olegnax\BannerSlider\Block\Adminhtml\Group\Edit;
|
||||
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Backend\Block\Widget\Form\Generic;
|
||||
use Magento\Framework\Data\FormFactory;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Store\Model\System\Store;
|
||||
|
||||
class Form extends Generic {
|
||||
|
||||
protected $_systemStore;
|
||||
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Registry $registry,
|
||||
FormFactory $formFactory,
|
||||
Store $systemStore,
|
||||
array $data = [ ]
|
||||
) {
|
||||
$this->_systemStore = $systemStore;
|
||||
parent::__construct( $context, $registry, $formFactory, $data );
|
||||
}
|
||||
|
||||
protected function _construct() {
|
||||
parent::_construct();
|
||||
$this->setId( 'group_form' );
|
||||
$this->setTitle( __( 'Group' ) );
|
||||
}
|
||||
|
||||
protected function _prepareForm() {
|
||||
$form = $this->_formFactory->create(
|
||||
[
|
||||
'data' => [
|
||||
'id' => 'edit_form',
|
||||
'action' => $this->getData( 'action' ),
|
||||
'enctype'=>'multipart/form-data',
|
||||
'method' => 'post',
|
||||
|
||||
]
|
||||
]
|
||||
);
|
||||
$form->setUseContainer( true );
|
||||
$this->setForm( $form );
|
||||
|
||||
return parent::_prepareForm();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace Olegnax\BannerSlider\Block\Adminhtml\Group\Edit\Tab;
|
||||
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Backend\Block\Widget\Form\Generic;
|
||||
use Magento\Backend\Block\Widget\Tab\TabInterface;
|
||||
use Magento\Framework\Data\FormFactory;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Store\Model\System\Store;
|
||||
|
||||
class General extends Generic implements TabInterface {
|
||||
|
||||
/**
|
||||
* @var Store
|
||||
*/
|
||||
protected $_systemStore;
|
||||
|
||||
public function __construct(
|
||||
Store $systemStore,
|
||||
Context $context,
|
||||
Registry $registry,
|
||||
FormFactory $formFactory,
|
||||
array $data = []
|
||||
) {
|
||||
$this->_systemStore = $systemStore;
|
||||
parent::__construct($context, $registry, $formFactory, $data);
|
||||
}
|
||||
|
||||
protected function _prepareForm() {
|
||||
$model = $this->_coreRegistry->registry('olegnax_bannerslider_group');
|
||||
$form = $this->_formFactory->create();
|
||||
$fieldset = $form->addFieldset(
|
||||
'base_fieldset', ['legend' => __('General')]
|
||||
);
|
||||
|
||||
if ($model->getId()) {
|
||||
$fieldset->addField(
|
||||
'group_id', 'hidden', ['name' => 'group_id']
|
||||
);
|
||||
}
|
||||
|
||||
$fieldset->addField('group_name', 'text', array(
|
||||
'label' => __('Group name'),
|
||||
'name' => 'group_name',
|
||||
'required' => true
|
||||
));
|
||||
$fieldset->addField('identifier', 'text', array(
|
||||
'label' => __('Identifier'),
|
||||
'name' => 'identifier',
|
||||
'required' => true
|
||||
));
|
||||
$fieldset->addField('slide_width', 'text', array(
|
||||
'label' => __('Slide width'),
|
||||
'name' => 'slide_width',
|
||||
'required' => true
|
||||
));
|
||||
$fieldset->addField('slide_height', 'text', array(
|
||||
'label' => __('Slide height'),
|
||||
'name' => 'slide_height',
|
||||
'required' => true
|
||||
));
|
||||
|
||||
$data = $model->getData();
|
||||
$form->setValues($data);
|
||||
$this->setForm($form);
|
||||
|
||||
return parent::_prepareForm();
|
||||
}
|
||||
|
||||
public function getTabLabel() {
|
||||
return __('General');
|
||||
}
|
||||
|
||||
public function getTabTitle() {
|
||||
return __('General');
|
||||
}
|
||||
|
||||
public function canShowTab() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isHidden() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Olegnax\BannerSlider\Block\Adminhtml\Group\Edit;
|
||||
|
||||
class Tabs extends \Magento\Backend\Block\Widget\Tabs {
|
||||
|
||||
protected function _construct() {
|
||||
parent::_construct();
|
||||
$this->setId( 'group_edit_tabs' );
|
||||
$this->setDestElementId( 'edit_form' );
|
||||
$this->setTitle( __( 'Group' ) );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace Olegnax\BannerSlider\Block\Adminhtml\Slides;
|
||||
|
||||
use Magento\Backend\Block\Widget\Context;
|
||||
use Magento\Backend\Block\Widget\Form\Container;
|
||||
use Magento\Framework\Phrase;
|
||||
use Magento\Framework\Registry;
|
||||
|
||||
class Edit extends Container
|
||||
{
|
||||
|
||||
protected $_coreRegistry = null;
|
||||
|
||||
/**
|
||||
* Edit constructor.
|
||||
* @param Registry $registry
|
||||
* @param Context $context
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Registry $registry,
|
||||
Context $context,
|
||||
array $data = []
|
||||
) {
|
||||
$this->_coreRegistry = $registry;
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Phrase|string
|
||||
*/
|
||||
public function getHeaderText()
|
||||
{
|
||||
$id = $this->_coreRegistry->registry('olegnax_bannerslider_slide')->getId();
|
||||
if ($id) {
|
||||
return __("Edit Slide '%1'", $this->escapeHtml($id));
|
||||
} else {
|
||||
return __('New Slide');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_blockGroup = 'Olegnax_BannerSlider';
|
||||
$this->_controller = 'adminhtml_slides';
|
||||
parent::_construct();
|
||||
if ($this->_isAllowedAction('Olegnax_BannerSlider::Slide_Edit')
|
||||
|| $this->_isAllowedAction('Olegnax_BannerSlider::Slide_New')
|
||||
) {
|
||||
$this->buttonList->remove('reset');
|
||||
$this->buttonList->update('save', 'label', __('Save Slide'));
|
||||
$this->buttonList->add(
|
||||
'saveandcontinue',
|
||||
[
|
||||
'label' => __('Save and Continue Edit'),
|
||||
'class' => 'save',
|
||||
'data_attribute' => [
|
||||
'mage-init' => [
|
||||
'button' => ['event' => 'saveAndContinueEdit', 'target' => '#edit_form'],
|
||||
],
|
||||
],
|
||||
],
|
||||
-100
|
||||
);
|
||||
$this->buttonList->update('delete', 'label', __('Delete Slide'));
|
||||
} else {
|
||||
$this->buttonList->remove('save');
|
||||
$this->buttonList->remove('delete');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $resourceId
|
||||
* @return bool
|
||||
*/
|
||||
protected function _isAllowedAction($resourceId)
|
||||
{
|
||||
return $this->_authorization->isAllowed($resourceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function _toHtml()
|
||||
{
|
||||
$this->_eventManager->dispatch(
|
||||
'adminhtml_block_html_before',
|
||||
['block' => $this]
|
||||
);
|
||||
return parent::_toHtml();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Olegnax\BannerSlider\Block\Adminhtml\Slides\Edit;
|
||||
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Backend\Block\Widget\Form\Generic;
|
||||
use Magento\Framework\Data\FormFactory;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Store\Model\System\Store;
|
||||
|
||||
class Form extends Generic {
|
||||
|
||||
protected $_systemStore;
|
||||
|
||||
public function __construct(
|
||||
Context $context, Registry $registry, FormFactory $formFactory, Store $systemStore, array $data = []
|
||||
) {
|
||||
$this->_systemStore = $systemStore;
|
||||
parent::__construct($context, $registry, $formFactory, $data);
|
||||
}
|
||||
|
||||
protected function _construct() {
|
||||
parent::_construct();
|
||||
$this->setId('slides_form');
|
||||
$this->setTitle(__('Slide'));
|
||||
}
|
||||
|
||||
protected function _prepareForm() {
|
||||
$form = $this->_formFactory->create(
|
||||
[
|
||||
'data' => [
|
||||
'id' => 'edit_form',
|
||||
'action' => $this->getData('action'),
|
||||
'enctype' => 'multipart/form-data',
|
||||
'method' => 'post',
|
||||
]
|
||||
]
|
||||
);
|
||||
$form->setUseContainer(true);
|
||||
$this->setForm($form);
|
||||
|
||||
return parent::_prepareForm();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
|
||||
namespace Olegnax\BannerSlider\Block\Adminhtml\Slides\Edit\Tab;
|
||||
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Backend\Block\Widget\Form\Generic;
|
||||
use Magento\Backend\Block\Widget\Tab\TabInterface;
|
||||
use Magento\Framework\App\ObjectManager;
|
||||
use Magento\Framework\Data\FormFactory;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Store\Model\System\Store;
|
||||
|
||||
class General extends Generic implements TabInterface {
|
||||
|
||||
/**
|
||||
* @var Store
|
||||
*/
|
||||
protected $_systemStore;
|
||||
protected $objectManager;
|
||||
|
||||
public function __construct(
|
||||
Store $systemStore, Context $context,
|
||||
Registry $registry, FormFactory $formFactory, array $data = []
|
||||
) {
|
||||
$this->_systemStore = $systemStore;
|
||||
$this->objectManager = ObjectManager::getInstance();
|
||||
parent::__construct( $context, $registry, $formFactory, $data );
|
||||
}
|
||||
|
||||
protected function _prepareForm() {
|
||||
$model = $this->_coreRegistry->registry( 'olegnax_bannerslider_slide' );
|
||||
$form = $this->_formFactory->create();
|
||||
$fieldset = $form->addFieldset(
|
||||
'base_fieldset', [ 'legend' => __( 'General' ) ]
|
||||
);
|
||||
|
||||
if ( $model->getId() ) {
|
||||
$fieldset->addField(
|
||||
'slider_id', 'hidden', [ 'name' => 'slider_id' ]
|
||||
);
|
||||
}
|
||||
|
||||
$fieldset->addField( 'slide_group', 'select', array(
|
||||
'label' => __( 'Slide group' ),
|
||||
'name' => 'slide_group',
|
||||
'values' => $this->getOptionArray( '\Olegnax\BannerSlider\Model\Config\Source\GroupName' ),
|
||||
) );
|
||||
|
||||
if ( !$this->_storeManager->isSingleStoreMode() ) {
|
||||
$rendererBlock = $this->getLayout()->createBlock( 'Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element' );
|
||||
$fieldset->addField( 'store_id', 'multiselect', [
|
||||
'name' => 'store_id',
|
||||
'label' => __( 'Store Views' ),
|
||||
'title' => __( 'Store Views' ),
|
||||
'required' => true,
|
||||
'values' => $this->_systemStore->getStoreValuesForForm( false, true )
|
||||
] )->setRenderer( $rendererBlock );
|
||||
} else {
|
||||
$fieldset->addField( 'store_id', 'hidden', [
|
||||
'name' => 'store_id',
|
||||
'value' => $this->_storeManager->getStore()->getId()
|
||||
] );
|
||||
}
|
||||
$fieldset->addField( 'slide_bg', 'text', array(
|
||||
'label' => __( 'Slide background' ),
|
||||
'name' => 'slide_bg',
|
||||
'note' => 'Leave empty to use default colors',
|
||||
'class' => 'ox-ss-colorpicker',
|
||||
) );
|
||||
$fieldset->addField( 'image', 'image', array(
|
||||
'label' => __( 'Background Image' ),
|
||||
'required' => true,
|
||||
'name' => 'image',
|
||||
) );
|
||||
$fieldset->addField( 'imageX2', 'image', array(
|
||||
'label' => __( 'Background Image for Retina' ),
|
||||
'required' => true,
|
||||
'name' => 'imageX2',
|
||||
) );
|
||||
$fieldset->addField( 'title_color', 'text', array(
|
||||
'label' => __( 'Title color' ),
|
||||
'name' => 'title_color',
|
||||
'note' => 'Leave empty to use default colors',
|
||||
'class' => 'ox-ss-colorpicker',
|
||||
) );
|
||||
$fieldset->addField( 'title_bg', 'text', array(
|
||||
'label' => __( 'Title background' ),
|
||||
'name' => 'title_bg',
|
||||
'note' => 'Leave empty to use default colors',
|
||||
'class' => 'ox-ss-colorpicker',
|
||||
) );
|
||||
$fieldset->addField( 'title_hover_color', 'text', array(
|
||||
'label' => __( 'Title Hover color' ),
|
||||
'name' => 'title_hover_color',
|
||||
'note' => 'Leave empty to use default colors',
|
||||
'class' => 'ox-ss-colorpicker',
|
||||
) );
|
||||
$fieldset->addField( 'title_hover_bg', 'text', array(
|
||||
'label' => __( 'Title hover background' ),
|
||||
'name' => 'title_hover_bg',
|
||||
'note' => 'Leave empty to use default colors',
|
||||
'class' => 'ox-ss-colorpicker',
|
||||
) );
|
||||
$fieldset->addField( 'title_position', 'select', [
|
||||
'name' => 'title_position',
|
||||
'label' => __( 'Title position' ),
|
||||
'values' => $this->getOptionArray( '\Olegnax\BannerSlider\Model\Config\Source\Position' ),
|
||||
] );
|
||||
|
||||
$fieldset->addField( 'title', 'textarea', [
|
||||
'name' => 'title',
|
||||
'label' => __( 'Title' ),
|
||||
'required' => false
|
||||
] );
|
||||
$fieldset->addField( 'link_color', 'text', array(
|
||||
'label' => __( 'Link color' ),
|
||||
'name' => 'link_color',
|
||||
'note' => 'Leave empty to use default colors',
|
||||
'class' => 'ox-ss-colorpicker',
|
||||
) );
|
||||
$fieldset->addField( 'link_bg', 'text', array(
|
||||
'label' => __( 'Link background' ),
|
||||
'name' => 'link_bg',
|
||||
'note' => 'Leave empty to use default colors',
|
||||
'class' => 'ox-ss-colorpicker',
|
||||
) );
|
||||
$fieldset->addField( 'link_text', 'text', array(
|
||||
'label' => __( 'Link text' ),
|
||||
'required' => false,
|
||||
'name' => 'link_text',
|
||||
) );
|
||||
$fieldset->addField( 'link_href', 'text', array(
|
||||
'label' => __( 'Link Url' ),
|
||||
'required' => false,
|
||||
'name' => 'link_href',
|
||||
) );
|
||||
$fieldset->addField( 'status', 'select', [
|
||||
'name' => 'status',
|
||||
'label' => __( 'Status' ),
|
||||
'title' => __( 'Status' ),
|
||||
'required' => true,
|
||||
'options' => [
|
||||
'1' => __( 'Enable' ),
|
||||
'0' => __( 'Disable' )
|
||||
]
|
||||
] );
|
||||
$fieldset->addField( 'sort_order', 'text', array(
|
||||
'label' => __( 'Sort Order' ),
|
||||
'required' => false,
|
||||
'name' => 'sort_order',
|
||||
) );
|
||||
|
||||
if ( !$model->getId() ) {
|
||||
$model->setData( 'store_id', '0' );
|
||||
$model->setData( 'status', '1' );
|
||||
$model->setData( 'sort_order', '10' );
|
||||
}
|
||||
|
||||
|
||||
|
||||
$data = $model->getData();
|
||||
$form->setValues( $data );
|
||||
$this->setForm( $form );
|
||||
|
||||
return parent::_prepareForm();
|
||||
}
|
||||
|
||||
public function getTabLabel() {
|
||||
return __( 'General' );
|
||||
}
|
||||
|
||||
public function getTabTitle() {
|
||||
return __( 'General' );
|
||||
}
|
||||
|
||||
public function canShowTab() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isHidden() {
|
||||
return false;
|
||||
}
|
||||
|
||||
private function getOptionArray( $model_name ) {
|
||||
return $this->objectManager->create( $model_name )->toOptionArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Olegnax\BannerSlider\Block\Adminhtml\Slides\Edit;
|
||||
|
||||
class Tabs extends \Magento\Backend\Block\Widget\Tabs {
|
||||
|
||||
protected function _construct() {
|
||||
parent::_construct();
|
||||
$this->setId('slides_edit_tabs');
|
||||
$this->setDestElementId('edit_form');
|
||||
$this->setTitle(__('Slide'));
|
||||
}
|
||||
|
||||
}
|
||||
+173
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Olegnax BannerSlider
|
||||
*
|
||||
* 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_BannerSlider
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
*/
|
||||
|
||||
namespace Olegnax\BannerSlider\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;
|
||||
use Olegnax\BannerSlider\Model\ResourceModel\Group\CollectionFactory;
|
||||
|
||||
class BannerSlider extends Template implements BlockInterface {
|
||||
|
||||
protected $_slidesSollection;
|
||||
protected $_groupSollection;
|
||||
|
||||
/**
|
||||
* @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,
|
||||
\Olegnax\BannerSlider\Model\ResourceModel\Slides\CollectionFactory $slidesCollectionFactory,
|
||||
CollectionFactory $groupCollectionFactory,
|
||||
\Magento\Framework\App\Http\Context $httpContext, array $data = [],
|
||||
Json $json = null
|
||||
) {
|
||||
$this->_slidesSollection = $slidesCollectionFactory->create();
|
||||
$this->_groupSollection = $groupCollectionFactory->create();
|
||||
|
||||
$this->httpContext = $httpContext;
|
||||
$this->json = $json ?: ObjectManager::getInstance()->get( Json::class );
|
||||
parent::__construct( $context, $data );
|
||||
}
|
||||
|
||||
protected function _construct() {
|
||||
$this->addData( [
|
||||
'cache_lifetime' => 86400,
|
||||
] );
|
||||
if ( !$this->hasData( 'template' ) && !$this->getTemplate() ) {
|
||||
$this->setTemplate( 'Olegnax_BannerSlider::bannerslider.phtml' );
|
||||
}
|
||||
parent::_construct();
|
||||
}
|
||||
|
||||
public function getCacheKeyInfo( $newval = [] ) {
|
||||
return array_merge( [
|
||||
'OLEGNAX_BANNERSLIDER_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 getConfig( $path, $storeCode = null ) {
|
||||
$value = $this->_scopeConfig->getValue( $path, ScopeInterface::SCOPE_STORE, $storeCode );
|
||||
if (is_null($value)) {
|
||||
$value = '';
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function getSlides() {
|
||||
$group = $this->getGroup();
|
||||
if ( !empty( $group ) ) {
|
||||
return $this->_slidesSollection
|
||||
->addFieldToSelect( '*' )
|
||||
->addStoreFilter( $this->_storeManager->getStore() )
|
||||
->addFieldToFilter( 'slide_group', $group[ 'group_id' ] )
|
||||
->addFieldToFilter( 'status', 1 )
|
||||
->setOrder( 'sort_order', 'asc' );
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getGroup() {
|
||||
$group = $this->getData( 'current_group' );
|
||||
if ( empty( $group ) ) {
|
||||
$groups = $this->_groupSollection
|
||||
->addFieldToSelect( '*' )
|
||||
->addFieldToFilter( 'identifier', $this->getSlideGroup() );
|
||||
if ( $groups->getSize() ) {
|
||||
foreach ( $groups as $group ) {
|
||||
$this->setData( 'current_group', $group );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $group;
|
||||
}
|
||||
|
||||
public function getSliderId() {
|
||||
return 'ox_' . $this->getNameInLayout() . substr( md5( microtime() ), -5 );;
|
||||
}
|
||||
|
||||
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 getResponsive( $to_string = true ) {
|
||||
$width = $this->getGroup()->getSlideWidth();
|
||||
$responsive = [
|
||||
0 => [
|
||||
'items' => 1,
|
||||
],
|
||||
];
|
||||
$j = 1;
|
||||
for ( $i = $width + 1; $i < 3000; $i += $width ) {
|
||||
$j++;
|
||||
$responsive[ $i ] = [
|
||||
'items' => $j,
|
||||
];
|
||||
}
|
||||
|
||||
if ( $to_string ) {
|
||||
return json_encode( $responsive );
|
||||
}
|
||||
|
||||
return $responsive;
|
||||
}
|
||||
|
||||
public function getAutoScroll() {
|
||||
$auto_scroll = $this->getData( 'auto_scroll' );
|
||||
if ( empty( $auto_scroll ) ) {
|
||||
$auto_scroll = 0;
|
||||
}
|
||||
|
||||
return $auto_scroll;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user