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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?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\Controller\Adminhtml;
|
||||
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Backend\Model\View\Result\Page;
|
||||
use Magento\Framework\Registry;
|
||||
|
||||
abstract class Group extends Action {
|
||||
|
||||
protected $_coreRegistry;
|
||||
protected $_slidesFactory;
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param Registry $coreRegistry
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context, Registry $coreRegistry
|
||||
) {
|
||||
$this->_coreRegistry = $coreRegistry;
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Init page
|
||||
*
|
||||
* @param Page $resultPage
|
||||
* @return Page
|
||||
*/
|
||||
public function initPage($resultPage) {
|
||||
$resultPage->setActiveMenu('Olegnax_Core::Olegnax_Core')
|
||||
->addBreadcrumb(__('Banners'), __('Banners'))
|
||||
->addBreadcrumb(__('Banner Group'), __('Banner Group'));
|
||||
return $resultPage;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?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\Controller\Adminhtml\Group;
|
||||
|
||||
use Exception;
|
||||
use Magento\Backend\Model\View\Result\Redirect;
|
||||
use Magento\Framework\Controller\ResultInterface;
|
||||
use Olegnax\BannerSlider\Model\Group;
|
||||
|
||||
class Delete extends \Olegnax\BannerSlider\Controller\Adminhtml\Group {
|
||||
|
||||
const ADMIN_RESOURCE = 'Olegnax_BannerSlider::Group_Delete';
|
||||
/**
|
||||
* Delete action
|
||||
*
|
||||
* @return ResultInterface
|
||||
*/
|
||||
public function execute() {
|
||||
/** @var Redirect $resultRedirect */
|
||||
$resultRedirect = $this->resultRedirectFactory->create();
|
||||
// check if we know what should be deleted
|
||||
$id = $this->getRequest()->getParam('id');
|
||||
if ($id) {
|
||||
try {
|
||||
// init model and delete
|
||||
$model = $this->_objectManager->create( Group::class);
|
||||
$model->load($id);
|
||||
$model->delete();
|
||||
// display success message
|
||||
$this->messageManager->addSuccessMessage(__('Banner group has been deleted.'));
|
||||
$this->messageManager->addWarningMessage(__('Banner group has beed changed. Please go to Cache Management and Flush Magento Cache.'));
|
||||
// go to grid
|
||||
return $resultRedirect->setPath('*/*/');
|
||||
} catch ( Exception $e) {
|
||||
// display error message
|
||||
$this->messageManager->addErrorMessage($e->getMessage());
|
||||
// go back to edit form
|
||||
return $resultRedirect->setPath('*/*/edit', ['id' => $id]);
|
||||
}
|
||||
}
|
||||
// display error message
|
||||
$this->messageManager->addErrorMessage(__('We can\'t find a Group to delete.'));
|
||||
// go to grid
|
||||
return $resultRedirect->setPath('*/*/');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?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\Controller\Adminhtml\Group;
|
||||
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\Controller\ResultInterface;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
use Olegnax\BannerSlider\Model\Group;
|
||||
|
||||
class Edit extends \Olegnax\BannerSlider\Controller\Adminhtml\Group {
|
||||
|
||||
const ADMIN_RESOURCE = 'Olegnax_BannerSlider::Group_Edit';
|
||||
|
||||
protected $resultPageFactory;
|
||||
|
||||
public function __construct(
|
||||
Context $context, Registry $coreRegistry, PageFactory $resultPageFactory
|
||||
) {
|
||||
$this->resultPageFactory = $resultPageFactory;
|
||||
parent::__construct($context, $coreRegistry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit action
|
||||
*
|
||||
* @return ResultInterface
|
||||
*/
|
||||
public function execute() {
|
||||
$id = $this->getRequest()->getParam('id');
|
||||
$model = $this->_objectManager->create( Group::class);
|
||||
|
||||
if ($id) {
|
||||
$model->load($id);
|
||||
if (!$model->getId()) {
|
||||
$this->messageManager->addErrorMessage(__('This Group no longer exists.'));
|
||||
$resultRedirect = $this->resultRedirectFactory->create();
|
||||
return $resultRedirect->setPath('*/*/');
|
||||
}
|
||||
}
|
||||
|
||||
$this->_coreRegistry->register('olegnax_bannerslider_group', $model);
|
||||
|
||||
$resultPage = $this->resultPageFactory->create();
|
||||
$this->initPage($resultPage)->addBreadcrumb(
|
||||
$id ? __('Edit Group') : __('New Group'),
|
||||
$id ? __('Edit Group') : __('New Group')
|
||||
);
|
||||
$resultPage->getConfig()->getTitle()->prepend(__('Group'));
|
||||
$resultPage->getConfig()->getTitle()->prepend($model->getId() ? __('Edit Group %1',
|
||||
$model->getId()) : __('New Group') );
|
||||
return $resultPage;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?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\Controller\Adminhtml\Group;
|
||||
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
|
||||
class Index extends Action {
|
||||
|
||||
const ADMIN_RESOURCE = 'Olegnax_BannerSlider::Group_Index';
|
||||
|
||||
protected $_pageFactory;
|
||||
|
||||
public function __construct(
|
||||
Context $context, PageFactory $pageFactory) {
|
||||
$this->_pageFactory = $pageFactory;
|
||||
return parent::__construct($context);
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
$resultPage = $this->_pageFactory->create();
|
||||
$resultPage->getConfig()->getTitle()->prepend((__('Banner Group Manager')));
|
||||
|
||||
return $resultPage;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?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\Controller\Adminhtml\Group;
|
||||
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Backend\Model\View\Result\ForwardFactory;
|
||||
use Magento\Framework\Controller\Result\Forward;
|
||||
use Magento\Framework\Controller\ResultInterface;
|
||||
use Magento\Framework\Registry;
|
||||
use Olegnax\BannerSlider\Controller\Adminhtml\Group;
|
||||
|
||||
class NewAction extends Group {
|
||||
|
||||
const ADMIN_RESOURCE = 'Olegnax_BannerSlider::Group_New';
|
||||
|
||||
protected $resultForwardFactory;
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param Registry $coreRegistry
|
||||
* @param ForwardFactory $resultForwardFactory
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context, Registry $coreRegistry, ForwardFactory $resultForwardFactory
|
||||
) {
|
||||
$this->resultForwardFactory = $resultForwardFactory;
|
||||
parent::__construct($context, $coreRegistry);
|
||||
}
|
||||
|
||||
/**
|
||||
* New action
|
||||
*
|
||||
* @return ResultInterface
|
||||
*/
|
||||
public function execute() {
|
||||
/** @var Forward $resultForward */
|
||||
$resultForward = $this->resultForwardFactory->create();
|
||||
return $resultForward->forward('edit');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
<?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\Controller\Adminhtml\Group;
|
||||
|
||||
use Exception;
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\App\ObjectManager;
|
||||
use Magento\Framework\Controller\ResultInterface;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
use Olegnax\BannerSlider\Model\Group;
|
||||
|
||||
class Save extends Action {
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param PageFactory $resultPageFactory
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context, PageFactory $resultPageFactory
|
||||
) {
|
||||
parent::__construct( $context );
|
||||
}
|
||||
|
||||
protected function _isAllowed() {
|
||||
return $this->_authorization->isAllowed('Olegnax_BannerSlider::Group_New') || $this->_authorization->isAllowed('Olegnax_BannerSlider::Group_Edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Save action
|
||||
*
|
||||
* @return ResultInterface
|
||||
*/
|
||||
public function execute() {
|
||||
$data = $this->getRequest()->getPostValue();
|
||||
$resultRedirect = $this->resultRedirectFactory->create();
|
||||
$id = $this->getRequest()->getParam( 'group_id' );
|
||||
$model = $this->_objectManager->create( Group::class );
|
||||
$identifier = (string)$data[ 'identifier' ];
|
||||
if ( empty( $identifier ) ) {
|
||||
$identifier = $data[ 'group_name' ];
|
||||
}
|
||||
$_identifier = $identifier = str_replace( ' ', '-', strtolower( trim( $identifier ) ) );
|
||||
$suffix = '';
|
||||
$index = 0;
|
||||
do {
|
||||
$identifier = $_identifier . $suffix;
|
||||
$index++;
|
||||
$suffix = '-' . $index;
|
||||
} while ( !$this->isUniqueIdentifier( $identifier, $id ) );
|
||||
$data[ 'identifier' ] = $identifier;
|
||||
|
||||
$model->setData( $data );
|
||||
|
||||
try {
|
||||
$model->save();
|
||||
|
||||
$this->messageManager->addSuccess( __( 'Banner group has been saved.' ) );
|
||||
$this->messageManager->addWarningMessage( __( 'Banner group has been changed. Please go to Cache Management and Flush Magento Cache.' ) );
|
||||
if ( $this->getRequest()->getParam( 'back' ) ) {
|
||||
return $resultRedirect->setPath( '*/*/edit', [
|
||||
'id' => $model->getId(),
|
||||
'_current' => true ] );
|
||||
}
|
||||
$this->_objectManager->get( 'Magento\Backend\Model\Session' )->setFormData( false );
|
||||
return $resultRedirect->setPath( '*/*/' );
|
||||
} catch ( Exception $e ) {
|
||||
throw new \Magento\Framework\Exception\LocalizedException( __( '%1', $e->getMessage() ) );
|
||||
$this->messageManager->addException( $e, __( 'Something went wrong.' ) );
|
||||
}
|
||||
$this->_getSession()->setFormData( $data );
|
||||
return $resultRedirect->setPath( '*/*/edit', [
|
||||
'id' => $id ] );
|
||||
}
|
||||
|
||||
protected function isUniqueIdentifier( $identifier, $id = 0 ) {
|
||||
if ( empty( $identifier ) ) {
|
||||
return false;
|
||||
}
|
||||
$itemCollection = ObjectManager::getInstance()->get( '\Olegnax\BannerSlider\Model\ResourceModel\Group\CollectionFactory' )->create()
|
||||
->addFieldToFilter( 'identifier', $identifier )
|
||||
->addFieldToFilter( 'group_id', [ 'neq' => $id ] );
|
||||
return count( $itemCollection ) == 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?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\Controller\Adminhtml;
|
||||
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Backend\Model\View\Result\Page;
|
||||
use Magento\Framework\Registry;
|
||||
|
||||
abstract class Slides extends Action {
|
||||
|
||||
protected $_coreRegistry;
|
||||
protected $_slidesFactory;
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param Registry $coreRegistry
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context, Registry $coreRegistry
|
||||
) {
|
||||
$this->_coreRegistry = $coreRegistry;
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Init page
|
||||
*
|
||||
* @param Page $resultPage
|
||||
* @return Page
|
||||
*/
|
||||
public function initPage($resultPage) {
|
||||
$resultPage->setActiveMenu('Olegnax_Core::Olegnax_Core')
|
||||
->addBreadcrumb(__('Banners'), __('Banners'))
|
||||
->addBreadcrumb(__('Banner Slides'), __('Banner Slides'));
|
||||
return $resultPage;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?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\Controller\Adminhtml\Slides;
|
||||
|
||||
use Exception;
|
||||
use Magento\Backend\Model\View\Result\Redirect;
|
||||
use Magento\Framework\Controller\ResultInterface;
|
||||
use Olegnax\BannerSlider\Model\Slides;
|
||||
|
||||
class Delete extends \Olegnax\BannerSlider\Controller\Adminhtml\Slides {
|
||||
const ADMIN_RESOURCE = 'Olegnax_BannerSlider::Slide_Delete';
|
||||
/**
|
||||
* Delete action
|
||||
*
|
||||
* @return ResultInterface
|
||||
*/
|
||||
public function execute() {
|
||||
/** @var Redirect $resultRedirect */
|
||||
$resultRedirect = $this->resultRedirectFactory->create();
|
||||
// check if we know what should be deleted
|
||||
$id = $this->getRequest()->getParam('id');
|
||||
if ($id) {
|
||||
try {
|
||||
// init model and delete
|
||||
$model = $this->_objectManager->create( Slides::class);
|
||||
$model->load($id);
|
||||
$model->delete();
|
||||
// display success message
|
||||
$this->messageManager->addSuccessMessage(__('Slide has been deleted.'));
|
||||
$this->messageManager->addWarningMessage(__('Banner slide has been changed. Please go to Cache Management and Flush Magento Cache.'));
|
||||
// go to grid
|
||||
return $resultRedirect->setPath('*/*/');
|
||||
} catch ( Exception $e) {
|
||||
// display error message
|
||||
$this->messageManager->addErrorMessage($e->getMessage());
|
||||
// go back to edit form
|
||||
return $resultRedirect->setPath('*/*/edit', ['id' => $id]);
|
||||
}
|
||||
}
|
||||
// display error message
|
||||
$this->messageManager->addErrorMessage(__('We can\'t find a Slide to delete.'));
|
||||
// go to grid
|
||||
return $resultRedirect->setPath('*/*/');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?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\Controller\Adminhtml\Slides;
|
||||
|
||||
use Exception;
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\Controller\ResultFactory;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Ui\Component\MassAction\Filter;
|
||||
use Olegnax\BannerSlider\Model\ResourceModel\Slides\CollectionFactory;
|
||||
|
||||
class Disable extends Action {
|
||||
const ADMIN_RESOURCE = 'Olegnax_BannerSlider::Slide_Edit';
|
||||
protected $_filter;
|
||||
protected $_collectionFactory;
|
||||
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Filter $filter,
|
||||
CollectionFactory $collectionFactory
|
||||
) {
|
||||
$this->_filter = $filter;
|
||||
$this->_collectionFactory = $collectionFactory;
|
||||
|
||||
parent::__construct( $context );
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
$collection = $this->_filter->getCollection( $this->_collectionFactory->create() );
|
||||
$sliderUpdated = 0;
|
||||
foreach ( $collection as $slider ) {
|
||||
try {
|
||||
$slider->setStatus( 0 )->save();
|
||||
|
||||
$sliderUpdated++;
|
||||
} catch ( LocalizedException $e ) {
|
||||
$this->messageManager->addErrorMessage( $e->getMessage() );
|
||||
} catch ( Exception $e ) {
|
||||
$this->messageManager->addErrorMessage( __( 'Something went wrong while updating status for %1.', $slider->getName() ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $sliderUpdated ) {
|
||||
$this->messageManager->addSuccessMessage( __( 'A total of %1 record(s) have been updated.', $sliderUpdated ) );
|
||||
}
|
||||
|
||||
$resultRedirect = $this->resultFactory->create( ResultFactory::TYPE_REDIRECT);
|
||||
|
||||
return $resultRedirect->setPath('*/*/');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?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\Controller\Adminhtml\Slides;
|
||||
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\Controller\ResultInterface;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
use Olegnax\BannerSlider\Model\Slides;
|
||||
|
||||
class Edit extends \Olegnax\BannerSlider\Controller\Adminhtml\Slides {
|
||||
const ADMIN_RESOURCE = 'Olegnax_BannerSlider::Slide_Edit';
|
||||
protected $resultPageFactory;
|
||||
|
||||
public function __construct(
|
||||
Context $context, Registry $coreRegistry, PageFactory $resultPageFactory
|
||||
) {
|
||||
$this->resultPageFactory = $resultPageFactory;
|
||||
parent::__construct($context, $coreRegistry);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Edit action
|
||||
*
|
||||
* @return ResultInterface
|
||||
*/
|
||||
public function execute() {
|
||||
$id = $this->getRequest()->getParam('id');
|
||||
$model = $this->_objectManager->create( Slides::class);
|
||||
|
||||
if ($id) {
|
||||
$model->load($id);
|
||||
if (!$model->getId()) {
|
||||
$this->messageManager->addErrorMessage(__('This Slide no longer exists.'));
|
||||
$resultRedirect = $this->resultRedirectFactory->create();
|
||||
return $resultRedirect->setPath('*/*/');
|
||||
}
|
||||
}
|
||||
|
||||
$this->_coreRegistry->register('olegnax_bannerslider_slide', $model);
|
||||
|
||||
$resultPage = $this->resultPageFactory->create();
|
||||
$this->initPage($resultPage)->addBreadcrumb(
|
||||
$id ? __('Edit Slide') : __('New Slide'),
|
||||
$id ? __('Edit Slide') : __('New Slide')
|
||||
);
|
||||
$resultPage->getConfig()->getTitle()->prepend(__('Slide'));
|
||||
$resultPage->getConfig()->getTitle()->prepend($model->getId() ? __('Edit Slide %1',
|
||||
$model->getId()) : __('New Slide') );
|
||||
return $resultPage;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?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\Controller\Adminhtml\Slides;
|
||||
|
||||
use Exception;
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\Controller\ResultFactory;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Ui\Component\MassAction\Filter;
|
||||
use Olegnax\BannerSlider\Model\ResourceModel\Slides\CollectionFactory;
|
||||
|
||||
class Enable extends Action {
|
||||
const ADMIN_RESOURCE = 'Olegnax_BannerSlider::Slide_Edit';
|
||||
protected $_filter;
|
||||
protected $_collectionFactory;
|
||||
|
||||
public function __construct(
|
||||
Context $context, Filter $filter,
|
||||
CollectionFactory $collectionFactory
|
||||
) {
|
||||
$this->_filter = $filter;
|
||||
$this->_collectionFactory = $collectionFactory;
|
||||
|
||||
parent::__construct( $context );
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
$collection = $this->_filter->getCollection( $this->_collectionFactory->create() );
|
||||
$sliderUpdated = 0;
|
||||
foreach ( $collection as $slider ) {
|
||||
try {
|
||||
$slider->setStatus( 1 )->save();
|
||||
|
||||
$sliderUpdated++;
|
||||
} catch ( LocalizedException $e ) {
|
||||
$this->messageManager->addErrorMessage( $e->getMessage() );
|
||||
} catch ( Exception $e ) {
|
||||
$this->messageManager->addErrorMessage( __( 'Something went wrong while updating status for %1.', $slider->getName() ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $sliderUpdated ) {
|
||||
$this->messageManager->addSuccessMessage( __( 'A total of %1 record(s) have been updated.', $sliderUpdated ) );
|
||||
}
|
||||
|
||||
$resultRedirect = $this->resultFactory->create( ResultFactory::TYPE_REDIRECT );
|
||||
|
||||
return $resultRedirect->setPath( '*/*/' );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?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\Controller\Adminhtml\Slides;
|
||||
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
|
||||
class Index extends Action {
|
||||
|
||||
const ADMIN_RESOURCE = 'Olegnax_BannerSlider::Slide_Index';
|
||||
|
||||
protected $_pageFactory;
|
||||
|
||||
public function __construct(
|
||||
Context $context, PageFactory $pageFactory) {
|
||||
$this->_pageFactory = $pageFactory;
|
||||
return parent::__construct($context);
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
$resultPage = $this->_pageFactory->create();
|
||||
$resultPage->getConfig()->getTitle()->prepend((__('Banner Slide Manager')));
|
||||
|
||||
return $resultPage;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?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\Controller\Adminhtml\Slides;
|
||||
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\Controller\ResultFactory;
|
||||
use Magento\Ui\Component\MassAction\Filter;
|
||||
use Olegnax\BannerSlider\Model\ResourceModel\Slides\CollectionFactory;
|
||||
|
||||
class MassDelete extends Action {
|
||||
const ADMIN_RESOURCE = 'Olegnax_BannerSlider::Slide_Delete';
|
||||
protected $_filter;
|
||||
protected $_collectionFactory;
|
||||
|
||||
public function __construct(
|
||||
Context $context, Filter $filter,
|
||||
CollectionFactory $collectionFactory
|
||||
) {
|
||||
$this->_filter = $filter;
|
||||
$this->_collectionFactory = $collectionFactory;
|
||||
|
||||
parent::__construct( $context );
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
$collection = $this->_filter->getCollection( $this->_collectionFactory->create() );
|
||||
$delete = 0;
|
||||
if ( !empty( $collection ) ) {
|
||||
foreach ( $collection as $item ) {
|
||||
$item->delete();
|
||||
$delete++;
|
||||
}
|
||||
$this->messageManager->addSuccessMessage( __( 'A total of %1 record(s) have been deleted.', $delete ) );
|
||||
} else {
|
||||
$this->messageManager->addException( __( 'Nothing selected!' ) );
|
||||
}
|
||||
|
||||
|
||||
$resultRedirect = $this->resultFactory->create( ResultFactory::TYPE_REDIRECT );
|
||||
|
||||
return $resultRedirect->setPath( '*/*/' );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?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\Controller\Adminhtml\Slides;
|
||||
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Backend\Model\View\Result\ForwardFactory;
|
||||
use Magento\Framework\Controller\Result\Forward;
|
||||
use Magento\Framework\Controller\ResultInterface;
|
||||
use Magento\Framework\Registry;
|
||||
use Olegnax\BannerSlider\Controller\Adminhtml\Slides;
|
||||
|
||||
class NewAction extends Slides {
|
||||
const ADMIN_RESOURCE = 'Olegnax_BannerSlider::Slide_New';
|
||||
protected $resultForwardFactory;
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param Registry $coreRegistry
|
||||
* @param ForwardFactory $resultForwardFactory
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context, Registry $coreRegistry, ForwardFactory $resultForwardFactory
|
||||
) {
|
||||
$this->resultForwardFactory = $resultForwardFactory;
|
||||
parent::__construct($context, $coreRegistry);
|
||||
}
|
||||
|
||||
/**
|
||||
* New action
|
||||
*
|
||||
* @return ResultInterface
|
||||
*/
|
||||
public function execute() {
|
||||
/** @var Forward $resultForward */
|
||||
$resultForward = $this->resultForwardFactory->create();
|
||||
return $resultForward->forward('edit');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
<?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\Controller\Adminhtml\Slides;
|
||||
|
||||
use Exception;
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\Controller\ResultInterface;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\File\Uploader;
|
||||
use Magento\Framework\View\Result\PageFactory;
|
||||
use Olegnax\BannerSlider\Helper\Image;
|
||||
use Olegnax\BannerSlider\Model\Slides;
|
||||
|
||||
class Save extends Action {
|
||||
const ADMIN_RESOURCE = 'Olegnax_BannerSlider::Slide_Index';
|
||||
const IMAGE_FOLDER = 'bannerslider/';
|
||||
|
||||
protected $directory;
|
||||
protected $helperImage;
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param PageFactory $resultPageFactory
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context, PageFactory $resultPageFactory,
|
||||
Image $helperImage
|
||||
) {
|
||||
$this->helperImage = $helperImage;
|
||||
parent::__construct( $context );
|
||||
}
|
||||
|
||||
/**
|
||||
* Save action
|
||||
*
|
||||
* @return ResultInterface
|
||||
*/
|
||||
public function execute() {
|
||||
$data = $this->getRequest()->getPostValue();
|
||||
$resultRedirect = $this->resultRedirectFactory->create();
|
||||
$id = $this->getRequest()->getParam( 'slider_id' );
|
||||
$model = $this->_objectManager->create( Slides::class );
|
||||
$image_fields = [
|
||||
'image',
|
||||
'imageX2',
|
||||
];
|
||||
$need_delete = [
|
||||
];
|
||||
foreach ( $image_fields as $fields ) {
|
||||
if ( array_key_exists( $fields, $data ) && is_array( $data[ $fields ] ) ) {
|
||||
if ( isset( $data[ $fields ][ 'delete' ] ) ) {
|
||||
$need_delete[ $fields ] = $data[ $fields ][ 'value' ];
|
||||
}
|
||||
$data[ $fields ] = $data[ $fields ][ 'value' ];
|
||||
} else {
|
||||
$data[ $fields ] = '';
|
||||
}
|
||||
}
|
||||
$model->setData( $data );
|
||||
$model->save();
|
||||
try {
|
||||
foreach ( $image_fields as $fields ) {
|
||||
if ( array_key_exists( $fields, $need_delete ) ) {
|
||||
$this->removeImages( $fields, $model );
|
||||
} else {
|
||||
$this->saveImages( $fields, $model, $data[ $fields ] );
|
||||
}
|
||||
}
|
||||
$model->save();
|
||||
|
||||
$this->messageManager->addSuccess( __( 'Banner slide has been saved.' ) );
|
||||
$this->messageManager->addWarningMessage( __( 'Banner slide has been changed. Please go to Cache Management and Flush Magento Cache.' ) );
|
||||
if ( $this->getRequest()->getParam( 'back' ) ) {
|
||||
return $resultRedirect->setPath( '*/*/edit', [
|
||||
'id' => $model->getId(),
|
||||
'_current' => true ] );
|
||||
}
|
||||
$this->_objectManager->get( 'Magento\Backend\Model\Session' )->setFormData( false );
|
||||
return $resultRedirect->setPath( '*/*/' );
|
||||
} catch ( Exception $e ) {
|
||||
throw new \Magento\Framework\Exception\LocalizedException( __( '%1', $e->getMessage() ) );
|
||||
$this->messageManager->addException( $e, __( 'Something went wrong.' ) );
|
||||
}
|
||||
$this->_getSession()->setFormData( $data );
|
||||
return $resultRedirect->setPath( '*/*/edit', [
|
||||
'id' => $id ] );
|
||||
}
|
||||
|
||||
protected function imagePath( $subFolder = '', $prefixFolder = '' ) {
|
||||
$path = self::IMAGE_FOLDER;
|
||||
if ( !empty( $subFolder ) ) {
|
||||
$path .= $subFolder . '/';
|
||||
}
|
||||
if ( !empty( $prefixFolder ) ) {
|
||||
$path = $prefixFolder . $path;
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
|
||||
protected function mediaPath() {
|
||||
if ( !$this->directory ) {
|
||||
$this->directory = $this->_objectManager->get( '\Magento\Framework\Filesystem\DirectoryList' );
|
||||
}
|
||||
return $this->directory->getRoot() . '/pub/media/';
|
||||
}
|
||||
|
||||
protected function saveImages( string $fieldId, $model, $currentValue = '' ) {
|
||||
$saveDirectory = $this->imagePath( $model->getId(), $this->mediaPath() );
|
||||
$result = null;
|
||||
$filename = '';
|
||||
try {
|
||||
$uploader = new \Magento\MediaStorage\Model\File\Uploader(
|
||||
$fieldId, $this->_objectManager->create( 'Magento\MediaStorage\Helper\File\Storage\Database' ), $this->_objectManager->create( 'Magento\MediaStorage\Helper\File\Storage' ), $this->_objectManager->create( 'Magento\MediaStorage\Model\File\Validator\NotProtectedExtension' )
|
||||
);
|
||||
$uploader->setAllowCreateFolders( true );
|
||||
$uploader->setAllowRenameFiles( true );
|
||||
$uploader->setAllowedExtensions( [
|
||||
'jpeg',
|
||||
'jpg',
|
||||
'png' ] );
|
||||
$this->removeImages( $fieldId, $model );
|
||||
$result = $uploader->save( $saveDirectory );
|
||||
$filename = $uploader->getUploadedFileName();
|
||||
} catch ( Exception $e ) {
|
||||
if ( in_array( $fieldId, [
|
||||
'image' ] ) && $e->getCode() != Uploader::TMP_NAME_EMPTY ) {
|
||||
$this->messageManager->addException( $e, $e->getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $result ) {
|
||||
$model->setData( $fieldId, $this->imagePath( $model->getId() ) . $filename );
|
||||
} else {
|
||||
$model->setData( $fieldId, $currentValue );
|
||||
}
|
||||
}
|
||||
|
||||
protected function removeImages( string $fieldId, $model, $currentValue = '' ) {
|
||||
$image = $model->getData( $fieldId );
|
||||
if ( !empty( $image ) ) {
|
||||
$this->helperImage->removeResized( $image );
|
||||
$path = $this->mediaPath() . $image;
|
||||
if ( file_exists( $path ) && is_file( $path ) ) {
|
||||
@unlink( $path );
|
||||
$model->setData( $fieldId, $currentValue );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function _isAllowed() {
|
||||
return $this->_authorization->isAllowed('Olegnax_BannerSlider::Slide_New') || $this->_authorization->isAllowed('Olegnax_BannerSlider::Slide_Edit');
|
||||
}
|
||||
|
||||
}
|
||||
+610
@@ -0,0 +1,610 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Image helper
|
||||
*
|
||||
* Copyright © 2015 Magento. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
namespace Olegnax\BannerSlider\Helper;
|
||||
|
||||
use Exception;
|
||||
use Magento\Framework\App\Filesystem\DirectoryList;
|
||||
use Magento\Framework\App\Helper\AbstractHelper;
|
||||
use Magento\Framework\Filesystem;
|
||||
use Magento\Framework\Filesystem\Directory\WriteInterface;
|
||||
use Magento\Framework\Image as MagentoImage;
|
||||
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
|
||||
{
|
||||
|
||||
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;
|
||||
/**
|
||||
* @var int[]
|
||||
*/
|
||||
protected $_backgroundColor = [255, 255, 255];
|
||||
/**
|
||||
* @var MagentoImage
|
||||
*/
|
||||
protected $_processor;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_destinationSubdir;
|
||||
/**
|
||||
* @var WriteInterface
|
||||
*/
|
||||
protected $_mediaDirectory;
|
||||
/**
|
||||
* @var Factory
|
||||
*/
|
||||
protected $_imageFactory;
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $attributes;
|
||||
/**
|
||||
* @var AdapterFactory
|
||||
*/
|
||||
protected $adapterFactory;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $cachePrefix = 'IMG_INFO';
|
||||
/**
|
||||
* Store Manager
|
||||
*
|
||||
* @var StoreManagerInterface
|
||||
*/
|
||||
private $_storeManager;
|
||||
|
||||
public function __construct(
|
||||
Filesystem $filesystem,
|
||||
Factory $imageFactory,
|
||||
StoreManagerInterface $storeManager,
|
||||
AdapterFactory $adapterFactory
|
||||
) {
|
||||
$this->_mediaDirectory = $filesystem->getDirectoryRead(DirectoryList::MEDIA);
|
||||
$this->_imageFactory = $imageFactory;
|
||||
$this->_storeManager = $storeManager;
|
||||
$this->adapterFactory = $adapterFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function checkDependencies() {
|
||||
try {
|
||||
$this->adapterFactory->create();
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
$this->_logger->critical($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function adaptiveResize($file, $size, $attributes = [])
|
||||
{
|
||||
if ($this->checkDependencies()) {
|
||||
$this->init($file, $attributes);
|
||||
[$width, $height] = $this->prepareSize($size);
|
||||
$this->setWidth($width);
|
||||
$this->setHeight($height);
|
||||
if ($this->_keepAspectRatio && $this->_cropOnly) {
|
||||
$this->crop();
|
||||
}
|
||||
$this->resize();
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function init($file, $attributes = [])
|
||||
{
|
||||
$this->_processor = null;
|
||||
|
||||
$this->setBaseFile($file);
|
||||
|
||||
$this->attributes = $attributes;
|
||||
$this->setImageProperties();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set image properties
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
protected function setImageProperties()
|
||||
{
|
||||
$this->setDestinationSubdir('resized');
|
||||
|
||||
|
||||
// Set 'keep frame' flag
|
||||
$frame = $this->getAttribute('frame');
|
||||
if (!empty($frame)) {
|
||||
$this->setKeepFrame($frame);
|
||||
}
|
||||
|
||||
// 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 = $this->getAttribute('background');
|
||||
if (!empty($background)) {
|
||||
$this->setBackgroundColor($background);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve image attribute
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getAttribute($name)
|
||||
{
|
||||
return $this->attributes[$name] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $keep
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setKeepFrame($keep)
|
||||
{
|
||||
$this->_keepFrame = $keep && $keep !== 'false';
|
||||
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 $flag
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function seCropOnly($flag)
|
||||
{
|
||||
$this->_cropOnly = $flag && $flag !== 'false';
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $keep
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setKeepTransparency($keep)
|
||||
{
|
||||
$this->_keepTransparency = $keep && $keep !== 'false';
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int[] $rgbArray
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setBackgroundColor(array $rgbArray)
|
||||
{
|
||||
$this->_backgroundColor = $rgbArray;
|
||||
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->getWidth() === null && $this->getHeight() === null) || !$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 int
|
||||
*/
|
||||
public function getWidth()
|
||||
{
|
||||
return $this->_width;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $width
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setWidth($width)
|
||||
{
|
||||
$this->_width = $width;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getHeight()
|
||||
{
|
||||
return $this->_height;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $height
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setHeight($height)
|
||||
{
|
||||
$this->_height = $height;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBaseFile()
|
||||
{
|
||||
return $this->_baseFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set filenames for base file and new file
|
||||
*
|
||||
* @param string $file
|
||||
*
|
||||
* @return $this
|
||||
* @throws Exception
|
||||
*/
|
||||
public function setBaseFile($file)
|
||||
{
|
||||
if ($this->_fileExists($file)) {
|
||||
$this->_baseFile = $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 file_exists($this->_mediaDirectory->getAbsolutePath($filename));
|
||||
}
|
||||
|
||||
private function getResizedFile()
|
||||
{
|
||||
$new_filename = pathinfo($this->getBaseFile());
|
||||
if (is_array($new_filename) && !empty($new_filename)) {
|
||||
$new_filename['filename'] = implode('_', [
|
||||
$new_filename['filename'],
|
||||
$this->getWidth(),
|
||||
$this->getHeight()
|
||||
]) . '.' . $new_filename['extension'];
|
||||
return implode('/', [$this->getDestinationSubdir(), $new_filename['dirname'], $new_filename['filename']]);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDestinationSubdir()
|
||||
{
|
||||
return $this->_destinationSubdir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $dir
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDestinationSubdir($dir)
|
||||
{
|
||||
$this->_destinationSubdir = $dir;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MagentoImage
|
||||
*/
|
||||
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 $this
|
||||
* @see \Magento\Framework\Image\Adapter\AbstractAdapter
|
||||
*/
|
||||
public function resize()
|
||||
{
|
||||
if ($this->getWidth() === null && $this->getHeight() === null
|
||||
|| !$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 MagentoImage $processor
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setImageProcessor($processor)
|
||||
{
|
||||
$this->_processor = $processor;
|
||||
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)
|
||||
{
|
||||
$this->_quality = $quality;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUrl()
|
||||
{
|
||||
$media_url = $this->_storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_MEDIA);
|
||||
if ($this->getBaseFile()) {
|
||||
return $media_url . $this->getResizedFile();
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
||||
public function removeResized($file)
|
||||
{
|
||||
if (!empty($file)) {
|
||||
$this->init($file);
|
||||
}
|
||||
$file = $this->getBaseFile();
|
||||
|
||||
if (!empty($file)) {
|
||||
$new_filename = pathinfo($file);
|
||||
$new_filename['filename'] = implode('_',
|
||||
[$new_filename['filename'], '*']) . '.' . $new_filename['extension'];
|
||||
$pattern = implode('/',
|
||||
[$this->getDestinationSubdir(), $new_filename['dirname'], $new_filename['filename']]);
|
||||
$pattern = $this->_mediaDirectory->getAbsolutePath($pattern);
|
||||
$files = (array)@glob($pattern);
|
||||
if (!empty($files)) {
|
||||
foreach ($files as $_file) {
|
||||
if (file_exists($_file)) {
|
||||
@unlink($_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image size
|
||||
*
|
||||
* @param string $imagePath
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getImageSize($imagePath)
|
||||
{
|
||||
$imageSize = getimagesize($imagePath);
|
||||
return $imageSize;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Olegnax\BannerSlider\Model\Config\Source;
|
||||
|
||||
use Magento\Framework\App\ObjectManager;
|
||||
use Magento\Framework\Option\ArrayInterface;
|
||||
use Olegnax\Athlete2Slideshow\Helper\Helper;
|
||||
use Olegnax\BannerSlider\Model\ResourceModel\Group\CollectionFactory;
|
||||
|
||||
class GroupName implements ArrayInterface {
|
||||
|
||||
/**
|
||||
*
|
||||
* @var CollectionFactory
|
||||
*/
|
||||
protected $group;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var ObjectManager
|
||||
*/
|
||||
public $_objectManager;
|
||||
|
||||
public function __construct( Helper $helper) {
|
||||
$this->_objectManager = ObjectManager::getInstance();
|
||||
}
|
||||
|
||||
public function toOptionArray() {
|
||||
$options = [];
|
||||
if (!$this->group) {
|
||||
$this->group = $this->_objectManager->get('\Olegnax\BannerSlider\Model\ResourceModel\Group\CollectionFactory')->create();
|
||||
}
|
||||
if ($this->group && $this->group->getSize()) {
|
||||
$groups = $this->group->addFieldToSelect('*')->setOrder('group_name', 'asc');
|
||||
foreach ($groups as $group) {
|
||||
$options[] = [
|
||||
'value' => $group->getId(),
|
||||
'label' => $group->getGroupName()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Olegnax\BannerSlider\Model\Config\Source;
|
||||
|
||||
use Magento\Framework\App\ObjectManager;
|
||||
use Magento\Framework\Option\ArrayInterface;
|
||||
use Olegnax\Athlete2Slideshow\Helper\Helper;
|
||||
use Olegnax\BannerSlider\Model\ResourceModel\Group\CollectionFactory;
|
||||
|
||||
class GroupNameWidget implements ArrayInterface {
|
||||
|
||||
/**
|
||||
*
|
||||
* @var CollectionFactory
|
||||
*/
|
||||
protected $group;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var ObjectManager
|
||||
*/
|
||||
public $_objectManager;
|
||||
|
||||
public function __construct( Helper $helper) {
|
||||
$this->_objectManager = ObjectManager::getInstance();
|
||||
}
|
||||
|
||||
public function toOptionArray() {
|
||||
$options = [];
|
||||
if (!$this->group) {
|
||||
$this->group = $this->_objectManager->get('\Olegnax\BannerSlider\Model\ResourceModel\Group\CollectionFactory')->create();
|
||||
}
|
||||
if ($this->group && $this->group->getSize()) {
|
||||
$groups = $this->group->addFieldToSelect('*')->setOrder('group_name', 'asc');
|
||||
foreach ($groups as $group) {
|
||||
$options[] = [
|
||||
'value' => $group->getIdentifier(),
|
||||
'label' => $group->getGroupName()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Olegnax\BannerSlider\Model\Config\Source;
|
||||
|
||||
use Magento\Framework\Option\ArrayInterface;
|
||||
|
||||
class Position implements ArrayInterface {
|
||||
|
||||
public function toOptionArray() {
|
||||
return [
|
||||
[
|
||||
'value' => 'top-left',
|
||||
'label' => __('Top Left')
|
||||
],
|
||||
[
|
||||
'value' => 'top-right',
|
||||
'label' => __('Top Right')
|
||||
],
|
||||
[
|
||||
'value' => 'bottom-left',
|
||||
'label' => __('Bottom Left')
|
||||
],
|
||||
[
|
||||
'value' => 'bottom-right',
|
||||
'label' => __('Bottom Right')
|
||||
],
|
||||
[
|
||||
'value' => 'center',
|
||||
'label' => __('Center')
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
<?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\Model;
|
||||
|
||||
use Magento\Framework\Filesystem\DirectoryList;
|
||||
use Magento\Framework\Filesystem\Io\File;
|
||||
use Magento\Framework\Model\AbstractModel;
|
||||
use Magento\Framework\Model\Context;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
|
||||
class Group extends AbstractModel {
|
||||
|
||||
protected $directoryList;
|
||||
protected $io;
|
||||
protected $_storeManager;
|
||||
protected $_eventPrefix = 'olegnax_bannerslider_group';
|
||||
|
||||
public function __construct(
|
||||
Context $context, Registry $registry,
|
||||
StoreManagerInterface $storeManager, DirectoryList $directoryList,
|
||||
File $io
|
||||
) {
|
||||
$this->_storeManager = $storeManager;
|
||||
$this->directoryList = $directoryList;
|
||||
$this->io = $io;
|
||||
parent::__construct( $context, $registry );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct() {
|
||||
$this->_init( \Olegnax\BannerSlider\Model\ResourceModel\Group::class );
|
||||
}
|
||||
|
||||
public function getIdentities() {
|
||||
return [ $this->_eventPrefix . '_' . $this->getId() ];
|
||||
}
|
||||
|
||||
public function getIdentifier() {
|
||||
return $this->getData( 'identifier' );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<?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\Model\Group;
|
||||
|
||||
use Magento\Framework\App\Request\DataPersistorInterface;
|
||||
use Magento\Ui\DataProvider\AbstractDataProvider;
|
||||
use Olegnax\BannerSlider\Model\ResourceModel\Group\CollectionFactory;
|
||||
|
||||
class DataProvider extends AbstractDataProvider {
|
||||
|
||||
protected $collection;
|
||||
protected $dataPersistor;
|
||||
protected $loadedData;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $primaryFieldName
|
||||
* @param string $requestFieldName
|
||||
* @param CollectionFactory $collectionFactory
|
||||
* @param DataPersistorInterface $dataPersistor
|
||||
* @param array $meta
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
$name, $primaryFieldName, $requestFieldName, CollectionFactory $collectionFactory, DataPersistorInterface $dataPersistor, array $meta = [], array $data = []
|
||||
) {
|
||||
$this->collection = $collectionFactory->create();
|
||||
$this->dataPersistor = $dataPersistor;
|
||||
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getData() {
|
||||
if (isset($this->loadedData)) {
|
||||
return $this->loadedData;
|
||||
}
|
||||
$items = $this->collection->getItems();
|
||||
foreach ($items as $model) {
|
||||
$this->loadedData[$model->getId()] = $model->getData();
|
||||
}
|
||||
$data = $this->dataPersistor->get('olegnax_bannerslider_group');
|
||||
|
||||
if (!empty($data)) {
|
||||
$model = $this->collection->getNewEmptyItem();
|
||||
$model->setData($data);
|
||||
$this->loadedData[$model->getId()] = $model->getData();
|
||||
$this->dataPersistor->clear('olegnax_bannerslider_group');
|
||||
}
|
||||
|
||||
return $this->loadedData;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?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\Model\ResourceModel;
|
||||
|
||||
use Magento\Framework\Model\AbstractModel;
|
||||
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
|
||||
|
||||
class Group extends AbstractDb {
|
||||
|
||||
/**
|
||||
* Define resource model
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct() {
|
||||
$this->_init('olegnax_bannerslider_group', 'group_id');
|
||||
}
|
||||
|
||||
protected function _beforeSave( AbstractModel $object) {
|
||||
$storeId = $object->getStoreId();
|
||||
if (is_array($storeId)) {
|
||||
$object->setStoreId(implode(',', $storeId));
|
||||
}
|
||||
|
||||
return parent::_beforeSave($object);
|
||||
}
|
||||
|
||||
protected function _afterLoad( AbstractModel $object) {
|
||||
$storeId = $object->getStoreId();
|
||||
if (!is_array($storeId)) {
|
||||
$storeId = $storeId ? explode(',', $storeId) : 0;
|
||||
$object->setStoreId($storeId);
|
||||
}
|
||||
|
||||
return parent::_afterLoad($object);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
<?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\Model\ResourceModel\Group;
|
||||
|
||||
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface;
|
||||
use Magento\Framework\Data\Collection\EntityFactoryInterface;
|
||||
use Magento\Framework\DB\Adapter\AdapterInterface;
|
||||
use Magento\Framework\Event\ManagerInterface;
|
||||
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
|
||||
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
|
||||
use Magento\Store\Api\Data\StoreInterface;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
use Olegnax\BannerSlider\Model\ResourceModel\Group;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Collection extends AbstractCollection {
|
||||
|
||||
/**
|
||||
* ID Field Name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_idFieldName = 'group_id';
|
||||
|
||||
/**
|
||||
* Current scope (store Id)
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_storeId;
|
||||
|
||||
/**
|
||||
* Store manager
|
||||
*
|
||||
* @var StoreManagerInterface
|
||||
*/
|
||||
protected $_storeManager;
|
||||
|
||||
public function __construct(
|
||||
EntityFactoryInterface $entityFactory, LoggerInterface $logger,
|
||||
FetchStrategyInterface $fetchStrategy,
|
||||
ManagerInterface $eventManager, StoreManagerInterface $storeManager,
|
||||
AdapterInterface $connection = null,
|
||||
AbstractDb $resource = null
|
||||
) {
|
||||
$this->_storeManager = $storeManager;
|
||||
parent::__construct( $entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define resource model
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct() {
|
||||
$this->_init(
|
||||
\Olegnax\BannerSlider\Model\Group::class, Group::class
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set store scope
|
||||
*
|
||||
* @param int|string|StoreInterface $storeId
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setStoreId( $storeId ) {
|
||||
if ( $storeId instanceof StoreInterface ) {
|
||||
$storeId = $storeId->getId();
|
||||
}
|
||||
$this->_storeId = (int) $storeId;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return current store id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getStoreId() {
|
||||
if ( $this->_storeId === null ) {
|
||||
$this->setStoreId( $this->_storeManager->getStore()->getId() );
|
||||
}
|
||||
return $this->_storeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add store availability filter. Include availability product
|
||||
* for store website
|
||||
*
|
||||
* @param null|string|bool|int $store
|
||||
* @return $this
|
||||
*/
|
||||
public function addStoreFilter( $store = null ) {
|
||||
if ( $store === null ) {
|
||||
$store = $this->getStoreId();
|
||||
}
|
||||
$store = $this->_storeManager->getStore( $store );
|
||||
|
||||
$this->getSelect()->where( "(`store_id` = 0 OR `store_id` LIKE '?,%' OR `store_id` = ? OR `store_id` LIKE '%,?' OR `store_id` LIKE '%,?,%')", $store->getId(), 'int' );
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?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\Model\ResourceModel;
|
||||
|
||||
use Magento\Framework\Model\AbstractModel;
|
||||
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
|
||||
|
||||
class Slides extends AbstractDb {
|
||||
|
||||
/**
|
||||
* Define resource model
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct() {
|
||||
$this->_init('olegnax_bannerslider_slides', 'slider_id');
|
||||
}
|
||||
|
||||
protected function _beforeSave( AbstractModel $object) {
|
||||
$storeId = $object->getStoreId();
|
||||
if (is_array($storeId)) {
|
||||
$object->setStoreId(implode(',', $storeId));
|
||||
}
|
||||
|
||||
return parent::_beforeSave($object);
|
||||
}
|
||||
|
||||
protected function _afterLoad( AbstractModel $object) {
|
||||
$storeId = $object->getStoreId();
|
||||
if (!is_array($storeId)) {
|
||||
$storeId = explode(',', $storeId);
|
||||
$object->setStoreId($storeId);
|
||||
}
|
||||
|
||||
return parent::_afterLoad($object);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
<?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\Model\ResourceModel\Slides;
|
||||
|
||||
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface;
|
||||
use Magento\Framework\Data\Collection\EntityFactoryInterface;
|
||||
use Magento\Framework\DB\Adapter\AdapterInterface;
|
||||
use Magento\Framework\Event\ManagerInterface;
|
||||
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
|
||||
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
|
||||
use Magento\Store\Api\Data\StoreInterface;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
use Olegnax\BannerSlider\Model\ResourceModel\Slides;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Collection extends AbstractCollection {
|
||||
|
||||
/**
|
||||
* ID Field Name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_idFieldName = 'slider_id';
|
||||
|
||||
/**
|
||||
* Current scope (store Id)
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_storeId;
|
||||
|
||||
/**
|
||||
* Store manager
|
||||
*
|
||||
* @var StoreManagerInterface
|
||||
*/
|
||||
protected $_storeManager;
|
||||
|
||||
public function __construct(
|
||||
EntityFactoryInterface $entityFactory, LoggerInterface $logger,
|
||||
FetchStrategyInterface $fetchStrategy,
|
||||
ManagerInterface $eventManager, StoreManagerInterface $storeManager,
|
||||
AdapterInterface $connection = null,
|
||||
AbstractDb $resource = null
|
||||
) {
|
||||
$this->_storeManager = $storeManager;
|
||||
parent::__construct( $entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define resource model
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct() {
|
||||
$this->_init(
|
||||
\Olegnax\BannerSlider\Model\Slides::class, Slides::class
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set store scope
|
||||
*
|
||||
* @param int|string|StoreInterface $storeId
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setStoreId( $storeId ) {
|
||||
if ( $storeId instanceof StoreInterface ) {
|
||||
$storeId = $storeId->getId();
|
||||
}
|
||||
$this->_storeId = (int) $storeId;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return current store id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getStoreId() {
|
||||
if ( $this->_storeId === null ) {
|
||||
$this->setStoreId( $this->_storeManager->getStore()->getId() );
|
||||
}
|
||||
return $this->_storeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add store availability filter. Include availability product
|
||||
* for store website
|
||||
*
|
||||
* @param null|string|bool|int $store
|
||||
* @return $this
|
||||
*/
|
||||
public function addStoreFilter( $store = null ) {
|
||||
if ( $store === null ) {
|
||||
$store = $this->getStoreId();
|
||||
}
|
||||
$store = $this->_storeManager->getStore( $store );
|
||||
|
||||
$this->getSelect()->where( "(`store_id` = 0 OR `store_id` LIKE '?,%' OR `store_id` = ? OR `store_id` LIKE '%,?' OR `store_id` LIKE '%,?,%')", $store->getId(), 'int' );
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
<?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\Model;
|
||||
|
||||
use Magento\Framework\Filesystem\DirectoryList;
|
||||
use Magento\Framework\Filesystem\Io\File;
|
||||
use Magento\Framework\Model\AbstractModel;
|
||||
use Magento\Framework\Model\Context;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Framework\UrlInterface;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
|
||||
class Slides extends AbstractModel {
|
||||
|
||||
protected $directoryList;
|
||||
protected $io;
|
||||
protected $_storeManager;
|
||||
protected $_eventPrefix = 'olegnax_bannerslider_slides';
|
||||
|
||||
public function __construct(
|
||||
Context $context, Registry $registry, StoreManagerInterface $storeManager, DirectoryList $directoryList, File $io
|
||||
) {
|
||||
$this->_storeManager = $storeManager;
|
||||
$this->directoryList = $directoryList;
|
||||
$this->io = $io;
|
||||
parent::__construct($context, $registry);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct() {
|
||||
$this->_init(\Olegnax\BannerSlider\Model\ResourceModel\Slides::class);
|
||||
}
|
||||
|
||||
public function getIdentities() {
|
||||
return [$this->_eventPrefix . '_' . $this->getId()];
|
||||
}
|
||||
|
||||
private function getPrefixedPath($path, $prefix = '') {
|
||||
$fullPath = '';
|
||||
$path = ltrim($path, '/');
|
||||
if (!empty($path)) {
|
||||
$fullPath = $prefix . $path;
|
||||
}
|
||||
|
||||
return $fullPath;
|
||||
}
|
||||
|
||||
public function getImageUrl($fieldId = 'image') {
|
||||
return $this->getPrefixedPath($this->getData($fieldId),
|
||||
rtrim((string)$this->_storeManager->getStore()->getBaseUrl( UrlInterface::URL_TYPE_MEDIA),
|
||||
'/') . '/');
|
||||
}
|
||||
|
||||
public function getImagePath($fieldId = 'image') {
|
||||
return $this->getPrefixedPath($this->getData($fieldId),
|
||||
$this->directoryList->getRoot() . '/pub/media/');
|
||||
}
|
||||
|
||||
public function existsImage($fieldId = 'image') {
|
||||
return is_file($this->getImagePath($fieldId));
|
||||
}
|
||||
|
||||
public function hasImage($fieldId = 'image') {
|
||||
|
||||
return ((bool) $this->getData($fieldId) !== false && $this->existsImage());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<?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\Model\Slides;
|
||||
|
||||
use Magento\Framework\App\Request\DataPersistorInterface;
|
||||
use Magento\Ui\DataProvider\AbstractDataProvider;
|
||||
use Olegnax\BannerSlider\Model\ResourceModel\Slides\CollectionFactory;
|
||||
|
||||
class DataProvider extends AbstractDataProvider {
|
||||
|
||||
protected $collection;
|
||||
protected $dataPersistor;
|
||||
protected $loadedData;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $primaryFieldName
|
||||
* @param string $requestFieldName
|
||||
* @param CollectionFactory $collectionFactory
|
||||
* @param DataPersistorInterface $dataPersistor
|
||||
* @param array $meta
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
$name, $primaryFieldName, $requestFieldName, CollectionFactory $collectionFactory, DataPersistorInterface $dataPersistor, array $meta = [], array $data = []
|
||||
) {
|
||||
$this->collection = $collectionFactory->create();
|
||||
$this->dataPersistor = $dataPersistor;
|
||||
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getData() {
|
||||
if (isset($this->loadedData)) {
|
||||
return $this->loadedData;
|
||||
}
|
||||
$items = $this->collection->getItems();
|
||||
foreach ($items as $model) {
|
||||
$this->loadedData[$model->getId()] = $model->getData();
|
||||
}
|
||||
$data = $this->dataPersistor->get('olegnax_bannerslider_slides');
|
||||
|
||||
if (!empty($data)) {
|
||||
$model = $this->collection->getNewEmptyItem();
|
||||
$model->setData($data);
|
||||
$this->loadedData[$model->getId()] = $model->getData();
|
||||
$this->dataPersistor->clear('olegnax_bannerslider_slides');
|
||||
}
|
||||
|
||||
return $this->loadedData;
|
||||
}
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?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\Setup;
|
||||
|
||||
use Magento\Framework\Setup\InstallDataInterface;
|
||||
use Magento\Framework\Setup\ModuleContextInterface;
|
||||
use Magento\Framework\Setup\ModuleDataSetupInterface;
|
||||
|
||||
class InstallData implements InstallDataInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function install(
|
||||
ModuleDataSetupInterface $setup, ModuleContextInterface $context
|
||||
) {
|
||||
//Your install script
|
||||
}
|
||||
|
||||
}
|
||||
+163
@@ -0,0 +1,163 @@
|
||||
<?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\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 {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function install( SchemaSetupInterface $setup, ModuleContextInterface $context ) {
|
||||
$setup->startSetup();
|
||||
$this->_install( $setup );
|
||||
$setup->endSetup();
|
||||
}
|
||||
|
||||
private function tables() {
|
||||
$varchar = [
|
||||
'type' => Table::TYPE_TEXT,
|
||||
'size' => 255,
|
||||
'options' => [
|
||||
'nullable' => false,
|
||||
'default' => '',
|
||||
],
|
||||
];
|
||||
return [
|
||||
'olegnax_bannerslider_group' => [
|
||||
'group_id' => [
|
||||
'options' => [
|
||||
'identity' => true,
|
||||
'nullable' => false,
|
||||
'primary' => true,
|
||||
'unsigned' => true,
|
||||
],
|
||||
],
|
||||
'group_name' => $varchar,
|
||||
'identifier' => $varchar,
|
||||
'slide_width' => [
|
||||
'type' => Table::TYPE_SMALLINT,
|
||||
'size' => 6,
|
||||
'options' => [
|
||||
'nullable' => false,
|
||||
],
|
||||
],
|
||||
'slide_height' => [
|
||||
'type' => Table::TYPE_SMALLINT,
|
||||
'size' => 6,
|
||||
'options' => [
|
||||
'nullable' => false,
|
||||
],
|
||||
],
|
||||
'created_time' => [
|
||||
'type' => Table::TYPE_DATETIME,
|
||||
],
|
||||
'update_time' => [
|
||||
'type' => Table::TYPE_DATETIME,
|
||||
],
|
||||
],
|
||||
'olegnax_bannerslider_slides' => [
|
||||
'slider_id' => [
|
||||
'options' => [
|
||||
'identity' => true,
|
||||
'nullable' => false,
|
||||
'primary' => true,
|
||||
'unsigned' => true,
|
||||
],
|
||||
],
|
||||
'slide_group' => [
|
||||
'unsigned' => true,
|
||||
],
|
||||
'store_id' => $varchar,
|
||||
'slide_bg' => $varchar,
|
||||
'image' => $varchar,
|
||||
'imageX2' => $varchar,
|
||||
'title_color' => $varchar,
|
||||
'title_bg' => $varchar,
|
||||
'title_hover_color' => $varchar,
|
||||
'title_hover_bg' => $varchar,
|
||||
'title_position' => $varchar,
|
||||
'title' => $varchar,
|
||||
'link_color' => $varchar,
|
||||
'link_bg' => $varchar,
|
||||
'link_text' => $varchar,
|
||||
'link_href' => $varchar,
|
||||
'status' => [
|
||||
'type' => Table::TYPE_SMALLINT,
|
||||
'size' => 6,
|
||||
'options' => [
|
||||
'nullable' => false,
|
||||
'default' => '0',
|
||||
],
|
||||
],
|
||||
'sort_order' => [
|
||||
'type' => Table::TYPE_SMALLINT,
|
||||
'size' => 6,
|
||||
'options' => [
|
||||
'nullable' => false,
|
||||
'default' => '0',
|
||||
],
|
||||
],
|
||||
'created_time' => [
|
||||
'type' => Table::TYPE_DATETIME,
|
||||
],
|
||||
'update_time' => [
|
||||
'type' => Table::TYPE_DATETIME,
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
private function _install( SchemaSetupInterface $setup ) {
|
||||
$tables = $this->tables();
|
||||
foreach ( $tables as $table_name => $table ) {
|
||||
if ( $setup->tableExists( $table_name ) ) {
|
||||
continue;
|
||||
}
|
||||
$_table = $setup->getConnection()->newTable( $setup->getTable( $table_name ) );
|
||||
foreach ( $table as $field_name => $field ) {
|
||||
if ( !array_key_exists( 'type', $field ) ) {
|
||||
$field[ 'type' ] = Table::TYPE_INTEGER;
|
||||
}
|
||||
if ( !array_key_exists( 'size', $field ) ) {
|
||||
$field[ 'size' ] = null;
|
||||
}
|
||||
if ( !array_key_exists( 'options', $field ) || empty( $field[ 'options' ] ) ) {
|
||||
$field[ 'options' ] = [
|
||||
];
|
||||
}
|
||||
if ( !array_key_exists( 'comment', $field ) ) {
|
||||
$field[ 'comment' ] = null;
|
||||
}
|
||||
|
||||
$_table->addColumn( $field_name, $field[ 'type' ], $field[ 'size' ], $field[ 'options' ], $field[ 'comment' ] );
|
||||
}
|
||||
$setup->getConnection()->createTable( $_table );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
<?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\Setup;
|
||||
|
||||
use Magento\Framework\Setup\UpgradeDataInterface;
|
||||
use Magento\Framework\Setup\ModuleContextInterface;
|
||||
use Magento\Framework\Setup\ModuleDataSetupInterface;
|
||||
|
||||
class UpgradeData implements UpgradeDataInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function upgrade(
|
||||
ModuleDataSetupInterface $setup, ModuleContextInterface $context
|
||||
) {
|
||||
$setup->startSetup();
|
||||
|
||||
$this->applyUpgradeFunctions( $setup, $context );
|
||||
$setup->endSetup();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
private function applyUpgradeFunctions( ModuleDataSetupInterface $setup, ModuleContextInterface $context ) {
|
||||
$methods = $this->getUpgradeFunctions( $context->getVersion() );
|
||||
foreach ( $methods as $method ) {
|
||||
call_user_func_array( [ $this, $method ], [ $setup, $context ] );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
<?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\Setup;
|
||||
|
||||
use Magento\Framework\DB\Ddl\Table;
|
||||
use Magento\Framework\Setup\UpgradeSchemaInterface;
|
||||
use Magento\Framework\Setup\ModuleContextInterface;
|
||||
use Magento\Framework\Setup\SchemaSetupInterface;
|
||||
|
||||
class UpgradeSchema implements UpgradeSchemaInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function upgrade(
|
||||
SchemaSetupInterface $setup, ModuleContextInterface $context
|
||||
) {
|
||||
$setup->startSetup();
|
||||
|
||||
$this->applyUpgradeFunctions( $setup, $context );
|
||||
$setup->endSetup();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
private function applyUpgradeFunctions( SchemaSetupInterface $setup, ModuleContextInterface $context ) {
|
||||
$methods = $this->getUpgradeFunctions( $context->getVersion() );
|
||||
foreach ( $methods as $method ) {
|
||||
call_user_func_array( [ $this, $method ], [ $setup, $context ] );
|
||||
}
|
||||
}
|
||||
|
||||
public function upgrade_1_0_1( SchemaSetupInterface $setup, ModuleContextInterface $context ) {
|
||||
$tables = [
|
||||
'olegnax_bannerslider_group' => [
|
||||
'identifier' => [
|
||||
'type' => Table::TYPE_TEXT,
|
||||
'size' => 255,
|
||||
'nullable' => false,
|
||||
'default' => '',
|
||||
'comment' => 'Identifier from v1.0.1'
|
||||
],
|
||||
],
|
||||
];
|
||||
$connection = $setup->getConnection();
|
||||
foreach ( $tables as $table_name => $table ) {
|
||||
$_table = $setup->getTable( $table_name );
|
||||
foreach ( $table as $field_name => $field ) {
|
||||
foreach ( [
|
||||
'type' => Table::TYPE_INTEGER,
|
||||
'size' => null,
|
||||
'comment' => '',
|
||||
] as $attr_name => $attr ) {
|
||||
if ( !array_key_exists( $attr_name, $field ) ) {
|
||||
$field[ $attr_name ] = $attr;
|
||||
}
|
||||
}
|
||||
|
||||
$connection->addColumn( $_table, $field_name, $field );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Olegnax\BannerSlider\Ui\Component\Listing\Column;
|
||||
|
||||
use Magento\Framework\App\ObjectManager;
|
||||
use Magento\Framework\View\Element\UiComponent\ContextInterface;
|
||||
use Magento\Framework\View\Element\UiComponentFactory;
|
||||
use Magento\Ui\Component\Listing\Columns\Column;
|
||||
|
||||
class Group extends Column {
|
||||
|
||||
protected $_objectManager;
|
||||
protected $groups;
|
||||
|
||||
public function __construct(
|
||||
ContextInterface $context, UiComponentFactory $uiComponentFactory, array $components = [], array $data = []
|
||||
) {
|
||||
$this->_objectManager = ObjectManager::getInstance();
|
||||
parent::__construct($context, $uiComponentFactory, $components, $data);
|
||||
$this->setGroup();
|
||||
}
|
||||
|
||||
private function setGroup() {
|
||||
if (empty($this->groups)) {
|
||||
$this->groups = [];
|
||||
$group_model = $this->_objectManager->get('\Olegnax\BannerSlider\Model\ResourceModel\Group\CollectionFactory')->create();
|
||||
if ($group_model && $group_model->getSize()) {
|
||||
$groups = $group_model->addFieldToSelect('*')->setOrder('group_name', 'asc');
|
||||
foreach ($groups as $group) {
|
||||
$this->groups[$group->getId()] = $group->getGroupName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getGroup($id) {
|
||||
if (array_key_exists($id, $this->groups)) {
|
||||
return $this->groups[$id];
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
public function prepareDataSource(array $dataSource) {
|
||||
if (isset($dataSource['data']['items'])) {
|
||||
foreach ($dataSource['data']['items'] as &$item) {
|
||||
$item['slide_group'] = $this->getGroup($item['slide_group']);
|
||||
}
|
||||
}
|
||||
return $dataSource;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
<?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\Ui\Component\Listing\Column;
|
||||
|
||||
use Magento\Framework\UrlInterface;
|
||||
use Magento\Framework\View\Element\UiComponent\ContextInterface;
|
||||
use Magento\Framework\View\Element\UiComponentFactory;
|
||||
use Magento\Ui\Component\Listing\Columns\Column;
|
||||
|
||||
class GroupActions extends Column {
|
||||
|
||||
const URL_PATH_DELETE = 'bannerslider/group/delete';
|
||||
|
||||
protected $urlBuilder;
|
||||
|
||||
const URL_PATH_EDIT = 'bannerslider/group/edit';
|
||||
|
||||
/**
|
||||
* @param ContextInterface $context
|
||||
* @param UiComponentFactory $uiComponentFactory
|
||||
* @param UrlInterface $urlBuilder
|
||||
* @param array $components
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
ContextInterface $context, UiComponentFactory $uiComponentFactory, UrlInterface $urlBuilder, array $components = [], array $data = []
|
||||
) {
|
||||
$this->urlBuilder = $urlBuilder;
|
||||
parent::__construct($context, $uiComponentFactory, $components, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare Data Source
|
||||
*
|
||||
* @param array $dataSource
|
||||
* @return array
|
||||
*/
|
||||
public function prepareDataSource(array $dataSource) {
|
||||
if (isset($dataSource['data']['items'])) {
|
||||
foreach ($dataSource['data']['items'] as & $item) {
|
||||
if (isset($item['group_id'])) {
|
||||
$item[$this->getData('name')] = [
|
||||
'edit' => [
|
||||
'href' => $this->urlBuilder->getUrl(
|
||||
static::URL_PATH_EDIT, [
|
||||
'id' => $item['group_id']
|
||||
]
|
||||
),
|
||||
'label' => __('Edit')
|
||||
],
|
||||
'delete' => [
|
||||
'href' => $this->urlBuilder->getUrl(
|
||||
static::URL_PATH_DELETE, [
|
||||
'id' => $item['group_id']
|
||||
]
|
||||
),
|
||||
'label' => __('Delete'),
|
||||
'confirm' => [
|
||||
'title' => __('Delete "%1"', $item['group_name']),
|
||||
'message' => __('Are you sure you wan\'t to delete a "%1" record?', $item['group_name'])
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $dataSource;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Olegnax\BannerSlider\Ui\Component\Listing\Column;
|
||||
|
||||
use Magento\Framework\View\Element\UiComponent\ContextInterface;
|
||||
use Magento\Framework\View\Element\UiComponentFactory;
|
||||
use Magento\Ui\Component\Listing\Columns\Column;
|
||||
use Olegnax\BannerSlider\Model\SlidesFactory;
|
||||
|
||||
class Image extends Column {
|
||||
|
||||
protected $_slidesFactory;
|
||||
|
||||
public function __construct(
|
||||
ContextInterface $context, UiComponentFactory $uiComponentFactory, SlidesFactory $slidesFactory, array $components = [], array $data = []
|
||||
) {
|
||||
$this->_slidesFactory = $slidesFactory;
|
||||
parent::__construct($context, $uiComponentFactory, $components, $data);
|
||||
}
|
||||
|
||||
public function prepareDataSource(array $dataSource) {
|
||||
if (isset($dataSource['data']['items'])) {
|
||||
foreach ($dataSource['data']['items'] as &$item) {
|
||||
if ($item) {
|
||||
if (isset($item['slider_id'])) {
|
||||
|
||||
$_item = $this->_slidesFactory->create()->load($item['slider_id']);
|
||||
if ($_item->hasImage()) {
|
||||
$item['image_src'] = $_item->getImageUrl();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $dataSource;
|
||||
}
|
||||
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
<?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\Ui\Component\Listing\Column;
|
||||
|
||||
use Magento\Framework\UrlInterface;
|
||||
use Magento\Framework\View\Element\UiComponent\ContextInterface;
|
||||
use Magento\Framework\View\Element\UiComponentFactory;
|
||||
use Magento\Ui\Component\Listing\Columns\Column;
|
||||
|
||||
class SlidesActions extends Column {
|
||||
|
||||
const URL_PATH_DELETE = 'bannerslider/slides/delete';
|
||||
|
||||
protected $urlBuilder;
|
||||
|
||||
const URL_PATH_EDIT = 'bannerslider/slides/edit';
|
||||
|
||||
/**
|
||||
* @param ContextInterface $context
|
||||
* @param UiComponentFactory $uiComponentFactory
|
||||
* @param UrlInterface $urlBuilder
|
||||
* @param array $components
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
ContextInterface $context, UiComponentFactory $uiComponentFactory, UrlInterface $urlBuilder, array $components = [], array $data = []
|
||||
) {
|
||||
$this->urlBuilder = $urlBuilder;
|
||||
parent::__construct($context, $uiComponentFactory, $components, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare Data Source
|
||||
*
|
||||
* @param array $dataSource
|
||||
* @return array
|
||||
*/
|
||||
public function prepareDataSource(array $dataSource) {
|
||||
if (isset($dataSource['data']['items'])) {
|
||||
foreach ($dataSource['data']['items'] as & $item) {
|
||||
if (isset($item['slider_id'])) {
|
||||
$item[$this->getData('name')] = [
|
||||
'edit' => [
|
||||
'href' => $this->urlBuilder->getUrl(
|
||||
static::URL_PATH_EDIT, [
|
||||
'id' => $item['slider_id']
|
||||
]
|
||||
),
|
||||
'label' => __('Edit')
|
||||
],
|
||||
'delete' => [
|
||||
'href' => $this->urlBuilder->getUrl(
|
||||
static::URL_PATH_DELETE, [
|
||||
'id' => $item['slider_id']
|
||||
]
|
||||
),
|
||||
'label' => __('Delete'),
|
||||
'confirm' => [
|
||||
'title' => __('Delete "%1"', $item['slider_id']),
|
||||
'message' => __('Are you sure you wan\'t to delete a "%1" record?', $item['slider_id'])
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $dataSource;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Olegnax\BannerSlider\Ui\Component\Listing\Column;
|
||||
|
||||
use Magento\Ui\Component\Listing\Columns\Column;
|
||||
|
||||
class Status extends Column {
|
||||
|
||||
public function prepareDataSource(array $dataSource) {
|
||||
if (isset($dataSource['data']['items'])) {
|
||||
foreach ($dataSource['data']['items'] as &$item) {
|
||||
if ($item) {
|
||||
$item['status'] = ($item['status'] == 1 ? __('Enable') : __('Disable'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $dataSource;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?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\Ui\Component\Listing\Column;
|
||||
|
||||
class Store extends \Magento\Store\Ui\Component\Listing\Column\Store {
|
||||
|
||||
protected function prepareItem(array $item) {
|
||||
$content = '';
|
||||
if (!empty($item[$this->storeKey])) {
|
||||
$origStores = $item[$this->storeKey];
|
||||
} else {
|
||||
$origStores = '0';
|
||||
}
|
||||
|
||||
if (!is_array($origStores)) {
|
||||
$origStores = explode(',', $origStores);
|
||||
}
|
||||
if (in_array(0, $origStores) && count($origStores) == 1) {
|
||||
return __('All Store Views');
|
||||
}
|
||||
|
||||
$data = $this->systemStore->getStoresStructure(false, $origStores);
|
||||
|
||||
foreach ($data as $website) {
|
||||
$content .= $website['label'] . "<br/>";
|
||||
foreach ($website['children'] as $group) {
|
||||
$content .= str_repeat(' ', 3) . $this->escaper->escapeHtml($group['label']) . "<br/>";
|
||||
foreach ($group['children'] as $store) {
|
||||
$content .= str_repeat(' ', 6) . $this->escaper->escapeHtml($store['label']) . "<br/>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
<?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">
|
||||
<resource id="Olegnax_BannerSlider::bannerslider" sortOrder="10" title="Banners">
|
||||
<resource id="Olegnax_BannerSlider::Group_Index" sortOrder="10" title="Groups">
|
||||
<resource id="Olegnax_BannerSlider::Group_New" sortOrder="10" title="Create New Group"/>
|
||||
<resource id="Olegnax_BannerSlider::Group_Edit" sortOrder="20" title="Edit Group"/>
|
||||
<resource id="Olegnax_BannerSlider::Group_Delete" sortOrder="40" title="Delete Group"/>
|
||||
</resource>
|
||||
<resource id="Olegnax_BannerSlider::Slide_Index" sortOrder="20" title="Slides">
|
||||
<resource id="Olegnax_BannerSlider::Slide_New" sortOrder="10" title="Create New Slide"/>
|
||||
<resource id="Olegnax_BannerSlider::Slide_Edit" sortOrder="20" title="Edit Slide"/>
|
||||
<resource id="Olegnax_BannerSlider::Slide_Delete" sortOrder="40" title="Delete Slide"/>
|
||||
</resource>
|
||||
</resource>
|
||||
</resource>
|
||||
</resource>
|
||||
</resources>
|
||||
</acl>
|
||||
</config>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?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_BannerSlider::bannerslider" title="Banners" translate="title" module="Olegnax_BannerSlider" sortOrder="999" parent="Olegnax_Core::Olegnax_Core" resource="Olegnax_BannerSlider::bannerslider"/>
|
||||
<add id="Olegnax_BannerSlider::group" title="Groups" translate="title" module="Olegnax_BannerSlider" sortOrder="10" action="bannerslider/group/index" parent="Olegnax_BannerSlider::bannerslider" resource="Olegnax_BannerSlider::Group_Index"/>
|
||||
<add id="Olegnax_BannerSlider::slides" title="Slides" translate="title" module="Olegnax_BannerSlider" sortOrder="20" action="bannerslider/slides/index" parent="Olegnax_BannerSlider::bannerslider" resource="Olegnax_BannerSlider::Slide_Index"/>
|
||||
</menu>
|
||||
</config>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?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="bannerslider" id="bannerslider">
|
||||
<module before="Magento_Backend" name="Olegnax_BannerSlider"/>
|
||||
</route>
|
||||
</router>
|
||||
</config>
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" ?>
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
|
||||
<virtualType name="Olegnax\BannerSlider\Model\ResourceModel\Slides\Grid\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
|
||||
<arguments>
|
||||
<argument name="mainTable" xsi:type="string">olegnax_bannerslider_slides</argument>
|
||||
<argument name="resourceModel" xsi:type="string">Olegnax\BannerSlider\Model\ResourceModel\Slides\Collection</argument>
|
||||
</arguments>
|
||||
</virtualType>
|
||||
<virtualType name="Olegnax\BannerSlider\Model\ResourceModel\Group\Grid\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
|
||||
<arguments>
|
||||
<argument name="mainTable" xsi:type="string">olegnax_bannerslider_group</argument>
|
||||
<argument name="resourceModel" xsi:type="string">Olegnax\BannerSlider\Model\ResourceModel\Group\Collection</argument>
|
||||
</arguments>
|
||||
</virtualType>
|
||||
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
|
||||
<arguments>
|
||||
<argument name="collections" xsi:type="array">
|
||||
<item name="olegnax_bannerslider_slides_listing_data_source" xsi:type="string">Olegnax\BannerSlider\Model\ResourceModel\Slides\Grid\Collection</item>
|
||||
<item name="olegnax_bannerslider_group_listing_data_source" xsi:type="string">Olegnax\BannerSlider\Model\ResourceModel\Group\Grid\Collection</item>
|
||||
</argument>
|
||||
</arguments>
|
||||
</type>
|
||||
</config>
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" ?>
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
|
||||
<module name="Olegnax_BannerSlider" setup_version="1.0.13">
|
||||
<sequence>
|
||||
<module name="Magento_Catalog"/>
|
||||
</sequence>
|
||||
</module>
|
||||
</config>
|
||||
Executable
+104
@@ -0,0 +1,104 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<widgets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Widget:etc/widget.xsd">
|
||||
<widget id="banner_slider" class="Olegnax\BannerSlider\Block\BannerSlider" is_email_compatible="true"
|
||||
placeholder_image="Olegnax_BannerSlider::images/products_list.png" ttl="86400">
|
||||
<label translate="true">Olegnax - Banner Slider</label>
|
||||
<description translate="true"></description>
|
||||
<parameters>
|
||||
<parameter name="slide_group" xsi:type="select" visible="true" source_model="Olegnax\BannerSlider\Model\Config\Source\GroupNameWidget">
|
||||
<label translate="true">Group</label>
|
||||
</parameter>
|
||||
<parameter name="size_big" xsi:type="select" visible="true" source_model="Olegnax\Core\Model\Config\Source\Noyes">
|
||||
<label translate="true">Big Size</label>
|
||||
<description translate="true">Make text and button bigger.</description>
|
||||
</parameter>
|
||||
<parameter name="auto_scroll" xsi:type="text" visible="true">
|
||||
<label translate="true">Autoscroll</label>
|
||||
<description translate="true"><![CDATA[Set to 0 to disable autoscroll</br>Set to 1-10 to enable autoscroll ( scroll timeout - autoscroll * 1000ms ) ]]></description>
|
||||
</parameter>
|
||||
<parameter name="scroll_items" xsi:type="select" visible="true">
|
||||
<label translate="true">Items to scroll</label>
|
||||
<options>
|
||||
<option name="item" value="1" selected="true">
|
||||
<label translate="true">Scroll per item</label>
|
||||
</option>
|
||||
<option name="page" value="page">
|
||||
<label translate="true">Scroll per page</label>
|
||||
</option>
|
||||
</options>
|
||||
</parameter>
|
||||
<parameter name="rewind" xsi:type="select" visible="true" source_model="Olegnax\Core\Model\Config\Source\Noyes">
|
||||
<label translate="true">Rewind Carousel</label>
|
||||
<description translate="true">Slide to first item or stop at last item</description>
|
||||
</parameter>
|
||||
<parameter name="dots" xsi:type="select" visible="true" source_model="Olegnax\Core\Model\Config\Source\Noyes">
|
||||
<label translate="true">Show Dots</label>
|
||||
</parameter>
|
||||
<parameter name="dots_align" xsi:type="select" visible="true">
|
||||
<label translate="true">Navigation Dots Align</label>
|
||||
<depends>
|
||||
<parameter name="dots" value="1"/>
|
||||
</depends>
|
||||
<options>
|
||||
<option name="left" value="left" selected="true">
|
||||
<label translate="true">Left</label>
|
||||
</option>
|
||||
<option name="center" value="center">
|
||||
<label translate="true">Center</label>
|
||||
</option>
|
||||
</options>
|
||||
</parameter>
|
||||
<parameter name="arrows" xsi:type="select" visible="true">
|
||||
<label translate="true">Show Arrows</label>
|
||||
<options>
|
||||
<option name="show" value="show" selected="true">
|
||||
<label translate="true">Yes</label>
|
||||
</option>
|
||||
<option name="hide" value="hide">
|
||||
<label translate="true">No</label>
|
||||
</option>
|
||||
</options>
|
||||
</parameter>
|
||||
<parameter name="arrows_show_always" xsi:type="select" visible="true" source_model="Olegnax\Core\Model\Config\Source\Noyes">
|
||||
<label translate="true">Always show Arrows</label>
|
||||
<depends>
|
||||
<parameter name="arrows" value="true"/>
|
||||
</depends>
|
||||
</parameter>
|
||||
<parameter name="image_hover" xsi:type="select" visible="true">
|
||||
<label translate="true">Image Hover</label>
|
||||
<options>
|
||||
<option name="zoom" value="zoom" selected="true">
|
||||
<label translate="true">Zoom</label>
|
||||
</option>
|
||||
<option name="none" value="none">
|
||||
<label translate="true">Disable</label>
|
||||
</option>
|
||||
</options>
|
||||
</parameter>
|
||||
<parameter name="lazy_load" xsi:type="select" visible="true">
|
||||
<label translate="true">Disable Lazy Load</label>
|
||||
<description translate="true">Disable carousel lazy load feature for images</description>
|
||||
<options>
|
||||
<option name="noexclude" value="noexclude" selected="true">
|
||||
<label translate="true">No</label>
|
||||
</option>
|
||||
<option name="exclude" value="exclude">
|
||||
<label translate="true">Yes</label>
|
||||
</option>
|
||||
</options>
|
||||
</parameter>
|
||||
<parameter name="cache_lifetime" xsi:type="text" visible="true">
|
||||
<label translate="true">Cache Lifetime (Seconds)</label>
|
||||
<description translate="true">86400 by default, if not set. To refresh instantly, clear the Blocks HTML Output cache.</description>
|
||||
</parameter>
|
||||
</parameters>
|
||||
</widget>
|
||||
|
||||
</widgets>
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
use Magento\Framework\Component\ComponentRegistrar;
|
||||
|
||||
ComponentRegistrar::register(
|
||||
ComponentRegistrar::MODULE,
|
||||
'Olegnax_BannerSlider', __DIR__
|
||||
);
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?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" layout="admin-2columns-left">
|
||||
<body>
|
||||
<referenceContainer name="content">
|
||||
<block class="Olegnax\BannerSlider\Block\Adminhtml\Group\Edit" name="olegnax_bannerslider_group_edit"/>
|
||||
</referenceContainer>
|
||||
<referenceContainer name="left">
|
||||
<block class="Olegnax\BannerSlider\Block\Adminhtml\Group\Edit\Tabs" name="olegnax_bannerslider_group_tabs">
|
||||
<block class="Olegnax\BannerSlider\Block\Adminhtml\Group\Edit\Tab\General" name="olegnax_bannerslider_group_tab_general"/>
|
||||
<action method="addTab">
|
||||
<argument name="name" xsi:type="string">general</argument>
|
||||
<argument name="block" xsi:type="string">olegnax_bannerslider_group_tab_general</argument>
|
||||
</action>
|
||||
</block>
|
||||
</referenceContainer>
|
||||
</body>
|
||||
</page>
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
<?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">
|
||||
<update handle="styles"/>
|
||||
<body>
|
||||
<referenceContainer name="content">
|
||||
<uiComponent name="olegnax_bannerslider_group_listing"/>
|
||||
</referenceContainer>
|
||||
</body>
|
||||
</page>
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
<?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">
|
||||
<update handle="bannerslider_group_edit"/>
|
||||
</page>
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?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" layout="admin-2columns-left">
|
||||
<body>
|
||||
<referenceContainer name="content">
|
||||
<block class="Olegnax\BannerSlider\Block\Adminhtml\Slides\Edit" name="olegnax_bannerslider_slides_edit"/>
|
||||
</referenceContainer>
|
||||
<referenceContainer name="left">
|
||||
<block class="Olegnax\BannerSlider\Block\Adminhtml\Slides\Edit\Tabs" name="olegnax_bannerslider_slides_tabs">
|
||||
<block class="Olegnax\BannerSlider\Block\Adminhtml\Slides\Edit\Tab\General" name="olegnax_bannerslider_slides_tab_general"/>
|
||||
<action method="addTab">
|
||||
<argument name="name" xsi:type="string">general</argument>
|
||||
<argument name="block" xsi:type="string">olegnax_bannerslider_slides_tab_general</argument>
|
||||
</action>
|
||||
</block>
|
||||
</referenceContainer>
|
||||
</body>
|
||||
</page>
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
<?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">
|
||||
<update handle="styles"/>
|
||||
<body>
|
||||
<referenceContainer name="content">
|
||||
<uiComponent name="olegnax_bannerslider_slides_listing"/>
|
||||
</referenceContainer>
|
||||
</body>
|
||||
</page>
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
<?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">
|
||||
<update handle="bannerslider_slides_edit"/>
|
||||
</page>
|
||||
Executable
+89
@@ -0,0 +1,89 @@
|
||||
<?xml version="1.0" ?>
|
||||
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="js_config" xsi:type="array">
|
||||
<item name="provider" xsi:type="string">olegnax_bannerslider_group_listing.olegnax_bannerslider_group_listing_data_source</item>
|
||||
<item name="deps" xsi:type="string">olegnax_bannerslider_group_listing.olegnax_bannerslider_group_listing_data_source</item>
|
||||
</item>
|
||||
<item name="spinner" xsi:type="string">olegnax_bannerslider_group_columns</item>
|
||||
<item name="buttons" xsi:type="array">
|
||||
<item name="add" xsi:type="array">
|
||||
<item name="name" xsi:type="string">add</item>
|
||||
<item name="label" xsi:type="string" translate="true">Add new Group</item>
|
||||
<item name="class" xsi:type="string">primary</item>
|
||||
<item name="url" xsi:type="string">*/*/new</item>
|
||||
</item>
|
||||
</item>
|
||||
</argument>
|
||||
<dataSource name="olegnax_bannerslider_group_listing_data_source">
|
||||
<argument name="dataProvider" xsi:type="configurableObject">
|
||||
<argument name="class" xsi:type="string">Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider</argument>
|
||||
<argument name="name" xsi:type="string">olegnax_bannerslider_group_listing_data_source</argument>
|
||||
<argument name="primaryFieldName" xsi:type="string">group_id</argument>
|
||||
<argument name="requestFieldName" xsi:type="string">id</argument>
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="component" xsi:type="string">Magento_Ui/js/grid/provider</item>
|
||||
<item name="update_url" xsi:type="url" path="mui/index/render"/>
|
||||
<item name="storageConfig" xsi:type="array">
|
||||
<item name="indexField" xsi:type="string">group_id</item>
|
||||
</item>
|
||||
</item>
|
||||
</argument>
|
||||
</argument>
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="js_config" xsi:type="array">
|
||||
<item name="component" xsi:type="string">Magento_Ui/js/grid/provider</item>
|
||||
</item>
|
||||
</argument>
|
||||
</dataSource>
|
||||
<listingToolbar name="listing_top">
|
||||
<settings>
|
||||
<sticky>true</sticky>
|
||||
</settings>
|
||||
<bookmark name="bookmarks"/>
|
||||
<columnsControls name="columns_controls"/>
|
||||
<filters name="listing_filters"/>
|
||||
<paging name="listing_paging"/>
|
||||
</listingToolbar>
|
||||
<columns name="olegnax_bannerslider_group_columns">
|
||||
<column name="group_id">
|
||||
<settings>
|
||||
<filter>text</filter>
|
||||
<sorting>asc</sorting>
|
||||
<label translate="true">ID</label>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="group_name">
|
||||
<settings>
|
||||
<label translate="true">Name</label>
|
||||
<sortable>true</sortable>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="identifier">
|
||||
<settings>
|
||||
<label translate="true">Identifier</label>
|
||||
<sortable>true</sortable>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="slide_width">
|
||||
<settings>
|
||||
<label translate="true">Slide width</label>
|
||||
<sortable>true</sortable>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="slide_height">
|
||||
<settings>
|
||||
<label translate="true">Slide height</label>
|
||||
<sortable>true</sortable>
|
||||
</settings>
|
||||
</column>
|
||||
<actionsColumn class="Olegnax\BannerSlider\Ui\Component\Listing\Column\GroupActions" name="actions">
|
||||
<settings>
|
||||
<indexField>group_id</indexField>
|
||||
<resizeEnabled>false</resizeEnabled>
|
||||
<resizeDefaultWidth>107</resizeDefaultWidth>
|
||||
</settings>
|
||||
</actionsColumn>
|
||||
</columns>
|
||||
</listing>
|
||||
Executable
+151
@@ -0,0 +1,151 @@
|
||||
<?xml version="1.0" ?>
|
||||
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="js_config" xsi:type="array">
|
||||
<item name="provider" xsi:type="string">olegnax_bannerslider_slides_listing.olegnax_bannerslider_slides_listing_data_source</item>
|
||||
<item name="deps" xsi:type="string">olegnax_bannerslider_slides_listing.olegnax_bannerslider_slides_listing_data_source</item>
|
||||
</item>
|
||||
<item name="spinner" xsi:type="string">olegnax_bannerslider_slides_columns</item>
|
||||
<item name="buttons" xsi:type="array">
|
||||
<item name="add" xsi:type="array">
|
||||
<item name="name" xsi:type="string">add</item>
|
||||
<item name="label" xsi:type="string" translate="true">Add new Slide</item>
|
||||
<item name="class" xsi:type="string">primary</item>
|
||||
<item name="url" xsi:type="string">*/*/new</item>
|
||||
</item>
|
||||
</item>
|
||||
</argument>
|
||||
<dataSource name="olegnax_bannerslider_slides_listing_data_source">
|
||||
<argument name="dataProvider" xsi:type="configurableObject">
|
||||
<argument name="class" xsi:type="string">Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider</argument>
|
||||
<argument name="name" xsi:type="string">olegnax_bannerslider_slides_listing_data_source</argument>
|
||||
<argument name="primaryFieldName" xsi:type="string">slider_id</argument>
|
||||
<argument name="requestFieldName" xsi:type="string">id</argument>
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="component" xsi:type="string">Magento_Ui/js/grid/provider</item>
|
||||
<item name="update_url" xsi:type="url" path="mui/index/render"/>
|
||||
<item name="storageConfig" xsi:type="array">
|
||||
<item name="indexField" xsi:type="string">slider_id</item>
|
||||
</item>
|
||||
</item>
|
||||
</argument>
|
||||
</argument>
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="js_config" xsi:type="array">
|
||||
<item name="component" xsi:type="string">Magento_Ui/js/grid/provider</item>
|
||||
</item>
|
||||
</argument>
|
||||
</dataSource>
|
||||
<listingToolbar name="listing_top">
|
||||
<settings>
|
||||
<sticky>true</sticky>
|
||||
</settings>
|
||||
<bookmark name="bookmarks"/>
|
||||
<columnsControls name="columns_controls"/>
|
||||
<filters name="listing_filters"/>
|
||||
<massaction name="listing_massaction">
|
||||
<action name="delete">
|
||||
<settings>
|
||||
<confirm>
|
||||
<message translate="true">Are you sure you want to delete selected items?</message>
|
||||
<title translate="true">Delete items</title>
|
||||
</confirm>
|
||||
<url path="bannerslider/slides/massDelete"/>
|
||||
<type>delete</type>
|
||||
<label translate="true">Delete</label>
|
||||
</settings>
|
||||
</action>
|
||||
<action name="disable">
|
||||
<settings>
|
||||
<url path="bannerslider/slides/disable"/>
|
||||
<type>disable</type>
|
||||
<label translate="true">Disable</label>
|
||||
</settings>
|
||||
</action>
|
||||
<action name="enable">
|
||||
<settings>
|
||||
<url path="bannerslider/slides/enable"/>
|
||||
<type>enable</type>
|
||||
<label translate="true">Enable</label>
|
||||
</settings>
|
||||
</action>
|
||||
</massaction>
|
||||
<paging name="listing_paging"/>
|
||||
</listingToolbar>
|
||||
<columns name="olegnax_bannerslider_slides_columns">
|
||||
<settings>
|
||||
<childDefaults>
|
||||
<param name="fieldAction" xsi:type="array">
|
||||
<item name="provider" xsi:type="string">olegnax_bannerslider_slides_listing.olegnax_bannerslider_slides_listing.olegnax_bannerslider_slides_columns.actions</item>
|
||||
<item name="target" xsi:type="string">applyAction</item>
|
||||
<item name="params" xsi:type="array">
|
||||
<item name="0" xsi:type="string">${ $.$data.rowIndex }</item>
|
||||
<item name="1" xsi:type="boolean">true</item>
|
||||
</item>
|
||||
</param>
|
||||
</childDefaults>
|
||||
</settings>
|
||||
<selectionsColumn name="ids">
|
||||
<settings>
|
||||
<indexField>slider_id</indexField>
|
||||
</settings>
|
||||
</selectionsColumn>
|
||||
<column name="slider_id">
|
||||
<settings>
|
||||
<filter>text</filter>
|
||||
<label translate="true">ID</label>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="slide_group" class="Olegnax\BannerSlider\Ui\Component\Listing\Column\Group">
|
||||
<settings>
|
||||
<label translate="true">Group</label>
|
||||
<sorting>asc</sorting>
|
||||
</settings>
|
||||
</column>
|
||||
|
||||
<column name="store_id" class="Olegnax\BannerSlider\Ui\Component\Listing\Column\Store">
|
||||
<settings>
|
||||
<label translate="true">Store View</label>
|
||||
<bodyTmpl>ui/grid/cells/html</bodyTmpl>
|
||||
<sortable>false</sortable>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="image" class="Olegnax\BannerSlider\Ui\Component\Listing\Column\Image">
|
||||
<argument name="data" xsi:type="array">
|
||||
<item name="config" xsi:type="array">
|
||||
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/thumbnail</item>
|
||||
<item name="sortable" xsi:type="boolean">false</item>
|
||||
<item name="has_preview" xsi:type="string">1</item>
|
||||
<item name="label" xsi:type="string" translate="true">Image</item>
|
||||
</item>
|
||||
</argument>
|
||||
</column>
|
||||
<column name="status" class="Olegnax\BannerSlider\Ui\Component\Listing\Column\Status">
|
||||
<settings>
|
||||
<filter>text</filter>
|
||||
<label translate="true">Status</label>
|
||||
</settings>
|
||||
</column>
|
||||
<column name="sort_order">
|
||||
<settings>
|
||||
<filter>text</filter>
|
||||
<label translate="true">Sort Order</label>
|
||||
<sorting>asc</sorting>
|
||||
<editor>
|
||||
<editorType>text</editorType>
|
||||
<validation>
|
||||
<rule name="required-entry" xsi:type="boolean">true</rule>
|
||||
</validation>
|
||||
</editor>
|
||||
</settings>
|
||||
</column>
|
||||
<actionsColumn class="Olegnax\BannerSlider\Ui\Component\Listing\Column\SlidesActions" name="actions">
|
||||
<settings>
|
||||
<indexField>slider_id</indexField>
|
||||
<resizeEnabled>false</resizeEnabled>
|
||||
<resizeDefaultWidth>107</resizeDefaultWidth>
|
||||
</settings>
|
||||
</actionsColumn>
|
||||
</columns>
|
||||
</listing>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
@@ -0,0 +1,5 @@
|
||||
var config = {
|
||||
paths: {
|
||||
'OXBannerSlider': 'Olegnax_BannerSlider/bannerslider'
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,142 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
/** @var BannerSlider $block */
|
||||
|
||||
use Olegnax\Athlete2\Helper\LazyLoad;
|
||||
use Olegnax\BannerSlider\Block\BannerSlider;
|
||||
|
||||
$slider_id = $block->getSliderId();
|
||||
$slides = $block->getSlides();
|
||||
$slideGroup = $block->getGroup();
|
||||
if ($slideGroup) :
|
||||
$athleteImgHelper = $this->helper('Olegnax\BannerSlider\Helper\Image');
|
||||
$customArrows = true;
|
||||
if($block->getArrows() == 'hide') {
|
||||
$customArrows = false;
|
||||
}
|
||||
$nolazy = ($block->getLazyLoad() === 'exclude') ?: 0;
|
||||
$classes = [];
|
||||
if($block->getDots()){
|
||||
$classes[] = 'owl-dots--align-' . $block->getDotsAlign();
|
||||
}
|
||||
if($block->getArrowsShowAlways()){
|
||||
$classes[] = 'ox-banner__nav-always';
|
||||
}
|
||||
$imageZoom = $block->getImageHover() ?: 'zoom';
|
||||
$classes[] = 'ox-banner__hover-' . $imageZoom;
|
||||
|
||||
if($block->getSizeBig()){
|
||||
$classes[] = 'ox-banner-medium';
|
||||
}
|
||||
$slideHeight = $slideGroup->getSlideHeight();
|
||||
if($slideHeight){
|
||||
$slideHeight = 'style="height:' . $slideHeight . 'px"';
|
||||
}
|
||||
if ( 0 < count( $slides ) ) :
|
||||
?>
|
||||
<div id="<?= $slider_id ?>" class="block widget ox-banners-slider__container <?= implode(' ', $classes ) ?>" <?= $slideHeight ?>>
|
||||
<?php if( $customArrows ) { ?>
|
||||
<div id="<?= $slider_id ?>_list_nav" class="owl-nav ox-owl-nav">
|
||||
<button class="owl-prev ox-owl-prev" role="presentation"><span aria-label="Previous">></span></button>
|
||||
<button class="owl-next ox-owl-next" role="presentation"><span aria-label="Next">></span></button>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div id="<?= $slider_id ?>_list" class="ox-banner__banners owl-carousel" data-mage-init='{"OXBannerSlider":<?= json_encode([
|
||||
'autoScroll' => $block->getAutoScroll(),
|
||||
'slideBy' => $block->getScrollItems(),
|
||||
'rewind' => (bool) $block->getRewind(),
|
||||
'lazyLoad' => !(bool) $nolazy,
|
||||
'responsive' => $block->getResponsive( false ),
|
||||
'slideWidth' => $slideGroup->getSlideWidth(),
|
||||
'slideHeight' => $slideGroup->getSlideHeight(),
|
||||
'dots' => (bool)$block->getDots(),
|
||||
'customNav' => $customArrows,
|
||||
]); ?>}'>
|
||||
<?php foreach ($slides as $slide) : ?>
|
||||
<div class="ox-banner__slide slide<?= $slide->getData('slider_id'); ?>" style="<?= $block->prepareStyle(['background-color' => $slide->getData('slide_bg')]) ?>">
|
||||
<?php
|
||||
$styles = array();
|
||||
if (!empty($slide->getData('title_color'))) { $styles[] = '#' . $slider_id. ' .slide' . $slide->getData('slider_id') .' .ox-banner__text-container .text{ color:' . $slide->getData('title_color') . '}'; }
|
||||
if (!empty($slide->getData('title_hover_color'))) { $styles[] = '#' . $slider_id. ' .slide' . $slide->getData('slider_id') .' .ox-banner__text-container .animate-me .text{ color:' . $slide->getData('title_hover_color') . '}'; }
|
||||
if (!empty($slide->getData('title_bg'))) { $styles[] = '#' . $slider_id. ' .slide' . $slide->getData('slider_id') .' .ox-banner__text-container .text{ background-color:' . $slide->getData('title_bg') . '}'; }
|
||||
if (!empty($slide->getData('title_hover_bg'))) { $styles[] = ' #' . $slider_id. ' .slide' . $slide->getData('slider_id') .' .ox-banner__text-container .text:after{ background-color:' . $slide->getData('title_hover_bg') . '}'; }
|
||||
if ( !empty($styles) ){
|
||||
echo '<style>' . implode(' ', $styles) . '</style>';
|
||||
}
|
||||
unset($styles);
|
||||
?>
|
||||
<a href="<?= $slide->getData('link_href'); ?>" class="ox-banner__link-wrapper">
|
||||
<span class="ox-banner__text-container <?= $slide->getData('title_position'); ?>">
|
||||
<?php
|
||||
$title = $slide->getData('title');
|
||||
if (!empty($title)) {
|
||||
$_title = explode("\n", $title);
|
||||
|
||||
echo '<span class="text">' . implode('</span><br/><span class="text">', $_title) . '</span><br/>';
|
||||
}
|
||||
|
||||
$link_text = $slide->getData('link_text');
|
||||
if (!empty($link_text)) {
|
||||
$_style = $block->prepareStyle([
|
||||
'color' => $slide->getData('link_color'),
|
||||
'background-color' => $slide->getData('link_bg')
|
||||
]);
|
||||
echo '<em class="link" style="' . $_style . '">' . $link_text . '</em>';
|
||||
}
|
||||
?>
|
||||
</span>
|
||||
|
||||
<?php
|
||||
if (!empty($slide['image'])) :
|
||||
$size = [$slideGroup->getSlideWidth(), $slideGroup->getSlideHeight()];
|
||||
$url = $escaper->escapeUrl($athleteImgHelper->adaptiveResize($slide['image'], $size)->getUrl());
|
||||
$urlX2 = '';
|
||||
if (!empty($slide['imageX2'])) {
|
||||
foreach ($size as &$_size) {
|
||||
$_size *= 2;
|
||||
}
|
||||
$urlX2 = $escaper->escapeUrl($athleteImgHelper->adaptiveResize($slide['imageX2'], $size)->getUrl());
|
||||
}
|
||||
if($nolazy):
|
||||
?>
|
||||
<img src="<?= $url; ?>" alt="" <?= ($urlX2 ? 'data-srcX2="' . $urlX2 . '"' : '' ); ?>
|
||||
width="<?= $escaper->escapeHtmlAttr($slideGroup->getSlideWidth()) ?>" height="<?=
|
||||
$escaper->escapeHtmlAttr($slideGroup->getSlideHeight()) ?>" class="ox-banner-slider__image no-lazy" data-ox="slider" alt="<?= $escaper->escapeHtmlAttr($title) ?>"/>
|
||||
<?php else:
|
||||
/** @var LazyLoad $athleteLazyLoadHelper */
|
||||
$athleteLazyLoadHelper = $this->helper( LazyLoad::class);
|
||||
?>
|
||||
<img src="<?= $athleteLazyLoadHelper->getPlaceHolder($url); ?>" data-src="<?= $url; ?>"
|
||||
alt=""
|
||||
<?= ($urlX2 ? 'data-srcX2="' . $urlX2 . '"' : '' ); ?> width="<?=
|
||||
$escaper->escapeHtmlAttr($slideGroup->getSlideWidth()) ?>" height="<?= $escaper->escapeHtmlAttr($slideGroup->getSlideHeight()) ?>"
|
||||
class="owl-lazy ox-banner-slider__image" data-ox="slider" alt="<?= $escaper->escapeHtmlAttr($title) ?>"/>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,253 @@
|
||||
define([
|
||||
'jquery',
|
||||
'jquery-ui-modules/widget',
|
||||
'jquery-ui-modules/core',
|
||||
'jquery-ui-modules/effect',
|
||||
'owl.carousel',
|
||||
], function ($) {
|
||||
'use strict';
|
||||
|
||||
var animation_text_space = 0;
|
||||
|
||||
$.widget('mage.OxBannerSlider', {
|
||||
options: {
|
||||
// OxBannerSlider
|
||||
autoScroll: 0,
|
||||
slideWidth: 0,
|
||||
slideHeight: 0,
|
||||
customNav: true,
|
||||
// Owl.carousel
|
||||
dots: false,
|
||||
rewind: false,
|
||||
items: 1,
|
||||
slideBy: 1,
|
||||
lazyLoad: true,
|
||||
responsive: {
|
||||
0: {
|
||||
items: 1,
|
||||
},
|
||||
},
|
||||
nav: false,
|
||||
observerLoad: !(window.hasOwnProperty('OX_OWL_OBS_DISABLE') ? OX_OWL_OBS_DISABLE : false)
|
||||
},
|
||||
_create: function () {
|
||||
this.options.responsiveBaseElement = this.element.parent();
|
||||
this.options.autoplayTimeout = parseInt(this.options.autoScroll) * 1000;
|
||||
this.options.autoplay = 0 < this.options.autoplayTimeout;
|
||||
this.options.autoplayHoverPause = this.options.autoplay;
|
||||
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 () {
|
||||
var options = this._createOptions();
|
||||
this.element.owlCarousel(options);
|
||||
this.arrows();
|
||||
},
|
||||
_createOptions: function () {
|
||||
var _self = this;
|
||||
var options = {
|
||||
onInitialize: function () {
|
||||
var $carousel = this.$element,
|
||||
$items = $carousel.find('.ox-banner__slide'),
|
||||
$text_container = $carousel.find('.ox-banner__text-container'),
|
||||
$text = $text_container.find('.text'),
|
||||
$link = $text_container.find('.link');
|
||||
this.$element.data('textSize', parseInt($text.css('font-size'), 10));
|
||||
this.$element.data('textLineHeight', parseInt($text.css('line-height'), 10));
|
||||
this.$element.data('linkSize', parseInt($link.css('font-size'), 12));
|
||||
|
||||
$text_container.show();
|
||||
$text.wrap('<div class="animation-wrapper animation-text" />');
|
||||
$link.wrap('<div class="animation-wrapper animation-link" />');
|
||||
$carousel.find('.ox-banner__text-container br').hide();
|
||||
|
||||
$carousel.find('.ox-banner__text-container.center').each(function () {
|
||||
$(this).attr('data-margin', $(this).css('margin'));
|
||||
});
|
||||
|
||||
_self._initBannerText($carousel);
|
||||
|
||||
//banner hover
|
||||
$items.on('mouseenter',
|
||||
function () {
|
||||
$('.ox-banner__text-container .animation-wrapper', this).each(function (i) {
|
||||
$(this)
|
||||
.delay(64 * (i))
|
||||
.queue(function (next) {
|
||||
$(this).addClass('animate-me');
|
||||
next();
|
||||
});
|
||||
});
|
||||
}).on('mouseleave',
|
||||
function () {
|
||||
$('.ox-banner__text-container .animation-wrapper', this).each(function (i) {
|
||||
$(this)
|
||||
.delay(64 * i)
|
||||
.queue(function (next) {
|
||||
$(this).removeClass('animate-me');
|
||||
next();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
},
|
||||
onInitialized: function () {
|
||||
this.$element.closest('.ox-banners-slider__container').eq(0).css('height', '');
|
||||
|
||||
_self._resizeSlides(this.$element, this);
|
||||
_self.__initBannerText(this.$element);
|
||||
_self._afterMove(this.$element);
|
||||
|
||||
},
|
||||
onRefresh: function () {
|
||||
this.$element.find('.ox-banner__text-container .animation-wrapper').css('width', '0px');
|
||||
},
|
||||
onRefreshed: function () {
|
||||
_self._resizeSlides(this.$element, this);
|
||||
_self.__initBannerText(this.$element);
|
||||
_self._afterMove(this.$element);
|
||||
},
|
||||
onChanged: function () {
|
||||
var carouselId = this.$element.attr('id');
|
||||
var $wraper = this.$element.closest('.ox-banners-slider__container').eq(0);
|
||||
var current = this.current();
|
||||
var $nav = $wraper.find('#' + carouselId + '_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;
|
||||
}
|
||||
$nav.find('.ox-owl-next').toggleClass('disabled', disable_nav_max);
|
||||
$nav.find('.ox-owl-prev').toggleClass('disabled', disable_nav_min);
|
||||
_self._afterMove(this);
|
||||
}
|
||||
};
|
||||
|
||||
return $.extend({}, options, this.options);
|
||||
|
||||
},
|
||||
__initBannerText: function ($this) {
|
||||
var _self = this;
|
||||
setTimeout(function () {
|
||||
_self._initBannerText($this);
|
||||
}, 200);
|
||||
},
|
||||
_initBannerText: function ($this) {
|
||||
var carouselHeight = $this.find('.ox-banner__slide .ox-banner__link-wrapper').height();
|
||||
|
||||
$('.animation-wrapper', $this).removeAttr('style').attr({'data-width': '', 'data-height': ''});
|
||||
$('.ox-banner__text-container .text, .ox-banner__text-container .link', $this).each(function () {
|
||||
var w = $(this).outerWidth(!0) + animation_text_space,
|
||||
h = $(this).outerHeight();
|
||||
|
||||
$(this).parent()
|
||||
.attr('data-width', w)
|
||||
.attr('data-height', h)
|
||||
.width(0)
|
||||
.height(h);
|
||||
});
|
||||
$('.ox-banner__text-container.center', $this).each(function () {
|
||||
$(this)
|
||||
.css('margin', $(this).attr('data-margin'))
|
||||
.css('margin-top', parseInt((carouselHeight - $(this).height()) / 2) + 'px');
|
||||
});
|
||||
},
|
||||
_afterMove: function ($this) {
|
||||
var animationDelay = this.options.animationDelay;
|
||||
var animationTimeout = this.options.animationTimeout;
|
||||
setTimeout(function () {
|
||||
$.each($this._items, function (index, item) {
|
||||
var text_animation = $('.ox-banner__text-container .animation-wrapper', item);
|
||||
if (item.hasClass('active')) {
|
||||
text_animation.each(function (i) {
|
||||
$(this).delay(animationTimeout * i).animate({width: $(this).attr('data-width')}, animationDelay, 'easeOutExpo');
|
||||
});
|
||||
} else {
|
||||
text_animation.css('width', 0);
|
||||
}
|
||||
|
||||
});
|
||||
}, 400);
|
||||
},
|
||||
|
||||
_resizeSlides: function ($this, owl) {
|
||||
var carousel = owl.$element;
|
||||
var newWidth = $(owl._items[0]).width(),
|
||||
newHeight = Math.round(newWidth * this.options.slideHeight / this.options.slideWidth),
|
||||
ratio = $(owl._items[0]).width() / this.options.slideWidth,
|
||||
newTextSize = Math.ceil($(carousel).data('textSize') * ratio),
|
||||
newTextLineHeight = Math.ceil($(carousel).data('textLineHeight') * ratio) + 1,
|
||||
newLinkSize = Math.ceil($(carousel).data('linkSize') * ratio);
|
||||
|
||||
$('.ox-banner__slide .ox-banner__link-wrapper', carousel).width(newWidth).height(newHeight);
|
||||
$('.ox-banner__slide .ox-banner-slider__image', carousel).css({
|
||||
'transform': 'scale(' + ratio + ')',
|
||||
'-ms-transform': 'scale(' + ratio + ')',
|
||||
'-webkit-transform': 'scale(' + ratio + ')'
|
||||
});
|
||||
|
||||
$('.ox-banner__slide .ox-banner__text-container .text', carousel).css('font-size', newTextSize + 'px');
|
||||
$('.ox-banner__slide .ox-banner__text-container .text', carousel).css('line-height', newTextLineHeight + 'px');
|
||||
$('.ox-banner__slide .ox-banner__text-container .link', carousel).css('font-size', newLinkSize + 'px');
|
||||
|
||||
$(carousel).animate({height: newHeight + 'px'}, 1000, 'easeOutExpo');
|
||||
},
|
||||
arrows: function () {
|
||||
if (this.options.customNav) {
|
||||
var $wraper = this.element.closest('.ox-banners-slider__container').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.OxBannerSlider;
|
||||
});
|
||||
@@ -0,0 +1,355 @@
|
||||
@athlete-banner-slider__main-color: #ffe51e;
|
||||
@font-weight__black: 800;
|
||||
|
||||
& when (@media-common = true) {
|
||||
|
||||
.animation-link {
|
||||
.lib-css(transition, ~"transform 256ms cubic-bezier(0.330, 0.975, 0.245, 0.910)", @_prefix: 1);
|
||||
}
|
||||
/* @TODO banners slider sidebar */
|
||||
.sidebar .banners-slider-container { margin: 0 auto 15px; }
|
||||
.sidebar .banners-slider-container .text-container .text { font-size: 28px; }
|
||||
.col3-layout .sidebar .banners-slider-container .text-container .text { font-size: 22px; }
|
||||
/*.col3-layout .sidebar .banners-slider-container .text-container .link { font-size: 10px; }*/
|
||||
/*.col2-left-layout .col-main .banners-slider-container,
|
||||
.col2-right-layout .col-main .banners-slider-container {width:640px;}
|
||||
.col3-layout .col-main .banners-slider-container {width:320px;} */
|
||||
|
||||
//
|
||||
// Banner Slider
|
||||
// _____________________________________________
|
||||
|
||||
.ox-banners-slider__container{
|
||||
position: relative;
|
||||
margin: 0 auto;
|
||||
-webkit-transform: translateZ(0);
|
||||
.owl-carousel .owl-item .owl-lazy.ox-banner-slider__image,
|
||||
.ox-banner-slider__image{
|
||||
.lib-css(transition, ~"all 400ms ease-in-out", @_prefix: 1);
|
||||
-webkit-transform:scale(1) !important;
|
||||
-moz-transform:scale(1) !important;
|
||||
-o-transform:scale(1) !important;
|
||||
transform:scale(1) !important;
|
||||
}
|
||||
|
||||
.ox-banner__banners{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
/*overflow: hidden; */
|
||||
list-style: none;
|
||||
-webkit-backface-visibility: hidden;
|
||||
-webkit-transform: translateZ(0);
|
||||
.ox-banner__slide{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
float: left;
|
||||
.ox-banner__link-wrapper{
|
||||
display: block;
|
||||
padding:0;
|
||||
margin: 0;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
-webkit-backface-visibility: hidden;
|
||||
-webkit-transform: translateZ(0);
|
||||
.ox-banner-slider__image{
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
display: block;
|
||||
position: absolute;
|
||||
top:0;
|
||||
left: 0;
|
||||
-webkit-backface-visibility: hidden;
|
||||
-webkit-transform: translateZ(0) !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.bottom-left,
|
||||
.top-left {
|
||||
left: 0;
|
||||
.animation-link.animate-me{
|
||||
transform:translateX(10px);
|
||||
}
|
||||
}
|
||||
.top-left {
|
||||
top: 0;
|
||||
}
|
||||
.bottom-left {
|
||||
bottom: 0;
|
||||
}
|
||||
.bottom-right,
|
||||
.top-right {
|
||||
right: 0;
|
||||
text-align: right;
|
||||
.animation-wrapper {
|
||||
margin-left: auto;
|
||||
}
|
||||
.animation-link.animate-me{
|
||||
transform:translateX(-10px);
|
||||
}
|
||||
}
|
||||
.top-right {
|
||||
top: 0;
|
||||
}
|
||||
.bottom-right {
|
||||
bottom: 0;
|
||||
}
|
||||
.center {
|
||||
left: 0;
|
||||
right: 0;
|
||||
margin: 0 auto;
|
||||
text-align: center;
|
||||
.animation-wrapper {
|
||||
margin: 0 auto;
|
||||
&.animation-text{
|
||||
margin-top: -8px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.owl-nav{
|
||||
button{
|
||||
visibility:hidden;
|
||||
opacity:0;
|
||||
.lib-css(transition, ~"all 200ms ease", @_prefix: 1);
|
||||
&.owl-next,
|
||||
&.owl-prev{
|
||||
z-index: 2;
|
||||
width: 49px;
|
||||
height: 74px;
|
||||
margin: -37px 0 0;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
background:#000000;
|
||||
&.disabled{
|
||||
opacity: 0.2;
|
||||
cursor: default;
|
||||
pointer-events: none;
|
||||
}
|
||||
span{
|
||||
line-height: 30px;
|
||||
height: 30px;
|
||||
width: 16px;
|
||||
&:after,
|
||||
&:before{
|
||||
height: 20px;
|
||||
left: 7px;
|
||||
top: -2px;
|
||||
}
|
||||
&:after{
|
||||
top: 12px;
|
||||
}
|
||||
}
|
||||
}
|
||||
&.owl-prev{
|
||||
transform: translateX(-20px);
|
||||
left: -10px;
|
||||
}
|
||||
&.owl-next{
|
||||
transform: translateX(20px);
|
||||
right:-10px;
|
||||
span{
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
&.ox-banner__nav-always,
|
||||
&:hover{
|
||||
.owl-nav{
|
||||
button{
|
||||
visibility:visible;
|
||||
opacity:1;
|
||||
&.owl-prev,
|
||||
&.owl-next{
|
||||
transform:translateX(0px);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Banner Title and Links
|
||||
// _____________________________________________
|
||||
|
||||
.ox-banner__text-container {
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
margin: 17px 14px;
|
||||
display: none;
|
||||
br {
|
||||
clear:both;
|
||||
height:0;
|
||||
line-height: 0;
|
||||
font-size: 0;
|
||||
}
|
||||
|
||||
.text {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
display: inline-block;
|
||||
overflow: hidden;
|
||||
line-height:28px;
|
||||
padding:4px 8px 6px;
|
||||
margin: -8px 0 0;
|
||||
color:#fff;
|
||||
background-color:#000000;
|
||||
font-size:31px;
|
||||
font-weight:800;
|
||||
text-transform:uppercase;
|
||||
white-space: nowrap;
|
||||
-webkit-transform: translateZ(0);
|
||||
.lib-css(transition, ~"all 256ms cubic-bezier(0.330, 0.975, 0.245, 0.910)", @_prefix: 1);
|
||||
|
||||
&:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
&:before,
|
||||
&:after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 0;
|
||||
height: 100%;
|
||||
z-index: -1;
|
||||
}
|
||||
:before {
|
||||
width: 100%;
|
||||
}
|
||||
&:after{
|
||||
background-color:@athlete-banner-slider__main-color;
|
||||
.lib-css(transition, ~"all 256ms cubic-bezier(0.330, 0.975, 0.245, 0.910)", @_prefix: 1);
|
||||
}
|
||||
}
|
||||
.link {
|
||||
display: inline-block;
|
||||
overflow: hidden;
|
||||
padding: 6px 8px;
|
||||
margin:0 3px 0 6px;
|
||||
font-style: normal;
|
||||
line-height:1;
|
||||
white-space: nowrap;
|
||||
-webkit-transform: translateZ(0);
|
||||
font-weight: @font-weight__bold;
|
||||
font-size: 12px!important;
|
||||
color:#000000;
|
||||
background-color:@athlete-banner-slider__main-color;
|
||||
}
|
||||
.animation-wrapper {
|
||||
position: relative;
|
||||
z-index: 3;
|
||||
overflow: hidden;
|
||||
margin: -8px 0 0;
|
||||
&:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
.animation-link {
|
||||
margin-top: 0;
|
||||
}
|
||||
.animate-me .text{
|
||||
color:#000000;
|
||||
&:after {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
.ox-banner-medium{
|
||||
.ox-banner__text-container{
|
||||
margin: 40px;
|
||||
.link{
|
||||
padding: 8px 11px;
|
||||
font-weight: @font-weight__black;
|
||||
font-size: 14px!important;
|
||||
margin-left: 12px;
|
||||
}
|
||||
.text {
|
||||
padding:10px 12px;
|
||||
font-size:36px;
|
||||
line-height:34px;
|
||||
}
|
||||
.animation-wrapper {
|
||||
margin-top: -10px;
|
||||
&:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
&.animation-link{
|
||||
margin-top: 8px;
|
||||
}
|
||||
}
|
||||
}
|
||||
.ox-banners-slider__container{
|
||||
.center {
|
||||
.ox-banner__text-container{
|
||||
.link{
|
||||
margin-left:0;
|
||||
margin-right:0;
|
||||
}
|
||||
}
|
||||
.animation-wrapper {
|
||||
&.animation-text{
|
||||
margin-top: -12px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//
|
||||
// Banner Hovers
|
||||
// _____________________________________________
|
||||
|
||||
@media only screen and (min-width: 1025px) {
|
||||
.ox-banners-slider__container{
|
||||
.ox-banner__banners{
|
||||
.ox-banner__slide{
|
||||
.ox-banner__link-wrapper{
|
||||
&:hover{
|
||||
background: transparent;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
&.ox-banner__hover-zoom{
|
||||
.ox-banner__banners{
|
||||
.ox-banner__slide{
|
||||
&:hover{
|
||||
.ox-banner-slider__image{
|
||||
-webkit-transform:scale(1.1) !important;
|
||||
-moz-transform:scale(1.1) !important;
|
||||
-o-transform:scale(1.1) !important;
|
||||
transform:scale(1.1) !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
&.ox-banner-medium{
|
||||
&.ox-banner__hover-zoom{
|
||||
.ox-banner__banners{
|
||||
.ox-banner__slide{
|
||||
&:hover{
|
||||
.ox-banner-slider__image{
|
||||
-webkit-transform:scale(1.05) !important;
|
||||
-moz-transform:scale(1.05) !important;
|
||||
-o-transform:scale(1.05) !important;
|
||||
transform:scale(1.05) !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__m) {
|
||||
.ox-banner__text-container {
|
||||
.link {
|
||||
letter-spacing: -0.03em;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user