Skip to content

Commit

Permalink
Merge pull request #72 from mageplaza/2.4-develop
Browse files Browse the repository at this point in the history
2.4 develop
  • Loading branch information
haitv282 authored Nov 9, 2020
2 parents 1022bac + 4ee62da commit f47ba4f
Show file tree
Hide file tree
Showing 54 changed files with 607 additions and 499 deletions.
6 changes: 3 additions & 3 deletions Block/Adminhtml/Banner.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ class Banner extends Container
*/
protected function _construct()
{
$this->_controller = 'adminhtml_banner';
$this->_blockGroup = 'Mageplaza_BannerSlider';
$this->_headerText = __('Banners');
$this->_controller = 'adminhtml_banner';
$this->_blockGroup = 'Mageplaza_BannerSlider';
$this->_headerText = __('Banners');
$this->_addButtonLabel = __('Create New Banner');

parent::_construct();
Expand Down
8 changes: 4 additions & 4 deletions Block/Adminhtml/Banner/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,20 @@ public function __construct(
*/
protected function _construct()
{
$this->_objectId = 'banner_id';
$this->_objectId = 'banner_id';
$this->_blockGroup = 'Mageplaza_BannerSlider';
$this->_controller = 'adminhtml_banner';
parent::_construct();
$this->buttonList->update('save', 'label', __('Save Banner'));
$this->buttonList->add(
'save-and-continue',
[
'label' => __('Save and Continue Edit'),
'class' => 'save',
'label' => __('Save and Continue Edit'),
'class' => 'save',
'data_attribute' => [
'mage-init' => [
'button' => [
'event' => 'saveAndContinueEdit',
'event' => 'saveAndContinueEdit',
'target' => '#edit_form'
]
]
Expand Down
6 changes: 3 additions & 3 deletions Block/Adminhtml/Banner/Edit/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ protected function _prepareForm()
$form = $this->_formFactory->create(
[
'data' => [
'id' => 'edit_form',
'action' => $this->getUrl('*/*/save', ['id' => $this->getRequest()->getParam('id')]),
'method' => 'post',
'id' => 'edit_form',
'action' => $this->getUrl('*/*/save', ['id' => $this->getRequest()->getParam('id')]),
'method' => 'post',
'enctype' => 'multipart/form-data'
]
]
Expand Down
76 changes: 38 additions & 38 deletions Block/Adminhtml/Banner/Edit/Tab/Banner.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ public function __construct(
WysiwygConfig $wysiwygConfig,
array $data = []
) {
$this->typeOptions = $typeOptions;
$this->template = $template;
$this->statusOptions = $statusOptions;
$this->imageHelper = $imageHelper;
$this->_fieldFactory = $fieldFactory;
$this->typeOptions = $typeOptions;
$this->template = $template;
$this->statusOptions = $statusOptions;
$this->imageHelper = $imageHelper;
$this->_fieldFactory = $fieldFactory;
$this->_objectConverter = $objectConverter;
$this->_wysiwygConfig = $wysiwygConfig;
$this->_wysiwygConfig = $wysiwygConfig;

parent::__construct($context, $registry, $formFactory, $data);
}
Expand Down Expand Up @@ -174,12 +174,12 @@ protected function _prepareForm()
{
/** @var \Mageplaza\BannerSlider\Model\Banner $banner */
$banner = $this->_coreRegistry->registry('mpbannerslider_banner');
$form = $this->_formFactory->create();
$form = $this->_formFactory->create();
$form->setHtmlIdPrefix('banner_');
$form->setFieldNameSuffix('banner');
$fieldset = $form->addFieldset('base_fieldset', [
'legend' => __('Banner Information'),
'class' => 'fieldset-wide'
'class' => 'fieldset-wide'
]);

if ($banner->getId()) {
Expand All @@ -191,89 +191,89 @@ protected function _prepareForm()
}

$fieldset->addField('name', 'text', [
'name' => 'name',
'label' => __('Name'),
'title' => __('Name'),
'name' => 'name',
'label' => __('Name'),
'title' => __('Name'),
'required' => true,
]);

$fieldset->addField('status', 'select', [
'name' => 'status',
'label' => __('Status'),
'title' => __('Status'),
'name' => 'status',
'label' => __('Status'),
'title' => __('Status'),
'values' => $this->statusOptions->toOptionArray(),
]);

$typeBanner = $fieldset->addField('type', 'select', [
'name' => 'type',
'label' => __('Type'),
'title' => __('Type'),
'name' => 'type',
'label' => __('Type'),
'title' => __('Type'),
'values' => $this->typeOptions->toOptionArray(),
]);

$uploadBanner = $fieldset->addField('image', BannerImage::class, [
'name' => 'image',
'name' => 'image',
'label' => __('Upload Image'),
'title' => __('Upload Image'),
'path' => $this->imageHelper->getBaseMediaPath(HelperImage::TEMPLATE_MEDIA_TYPE_BANNER)
'path' => $this->imageHelper->getBaseMediaPath(HelperImage::TEMPLATE_MEDIA_TYPE_BANNER)
]);

$titleBanner = $fieldset->addField('title', 'text', [
'name' => 'title',
'name' => 'title',
'label' => __('Banner title'),
'title' => __('Banner title'),
]);

$urlBanner = $fieldset->addField('url_banner', 'text', [
'name' => 'url_banner',
'name' => 'url_banner',
'label' => __('Url'),
'title' => __('Url'),
]);

$newTab = $fieldset->addField('newtab', 'select', [
'name' => 'newtab',
'label' => __('Open new tab after click'),
'title' => __('Open new tab after click'),
'name' => 'newtab',
'label' => __('Open new tab after click'),
'title' => __('Open new tab after click'),
'values' => $this->statusOptions->toOptionArray(),
'note' => __('Automatically open new tab after clicking on the banner')
'note' => __('Automatically open new tab after clicking on the banner')

]);

if (!$banner->getId()) {
$defaultImage = array_values(Data::jsonDecode($this->template->getImageUrls()))[0];
$demoTemplate = $fieldset->addField('default_template', 'select', [
'name' => 'default_template',
'label' => __('Demo template'),
'title' => __('Demo template'),
'name' => 'default_template',
'label' => __('Demo template'),
'title' => __('Demo template'),
'values' => $this->template->toOptionArray(),
'note' => '<img src="' . $defaultImage . '" alt="demo" class="article_image" id="mp-demo-image">'
'note' => '<img src="' . $defaultImage . '" alt="demo" class="article_image" id="mp-demo-image">'
]);

$insertVariableButton = $this->getLayout()->createBlock(Button::class, '', [
'data' => [
'type' => 'button',
'type' => 'button',
'label' => __('Load Template'),
]
]);
$insertButton = $fieldset->addField('load_template', 'note', [
'text' => $insertVariableButton->toHtml(),
$insertButton = $fieldset->addField('load_template', 'note', [
'text' => $insertVariableButton->toHtml(),
'label' => ''
]);
}

$content = $fieldset->addField('content', 'editor', [
'name' => 'content',
'name' => 'content',
'required' => false,
'config' => $this->_wysiwygConfig->getConfig([
'hidden' => true,
'add_variables' => false,
'add_widgets' => false,
'config' => $this->_wysiwygConfig->getConfig([
'hidden' => true,
'add_variables' => false,
'add_widgets' => false,
'add_directives' => true
])
]);

$fieldset->addField('sliders_ids', Slider::class, [
'name' => 'sliders_ids',
'name' => 'sliders_ids',
'label' => __('Sliders'),
'title' => __('Sliders'),
]);
Expand Down
2 changes: 1 addition & 1 deletion Block/Adminhtml/Banner/Edit/Tab/Render/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function getElementHtml()
{
$html = '';

if ((string) $this->getValue()) {
if ((string)$this->getValue()) {
$url = $this->_getUrl();

if (!preg_match("/^http\:\/\/|https\:\/\//", $url)) {
Expand Down
8 changes: 4 additions & 4 deletions Block/Adminhtml/Banner/Edit/Tab/Render/Slider.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function __construct(
array $data = []
) {
$this->collectionFactory = $collectionFactory;
$this->authorization = $authorization;
$this->authorization = $authorization;

parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
}
Expand Down Expand Up @@ -141,10 +141,10 @@ public function getSliderCollection()
$collection = $this->collectionFactory->create();
$sliderById = [];
foreach ($collection as $slider) {
$sliderId = $slider->getId();
$sliderById[$sliderId]['value'] = $sliderId;
$sliderId = $slider->getId();
$sliderById[$sliderId]['value'] = $sliderId;
$sliderById[$sliderId]['is_active'] = 1;
$sliderById[$sliderId]['label'] = $slider->getName();
$sliderById[$sliderId]['label'] = $slider->getName();
}

return $sliderById;
Expand Down
2 changes: 1 addition & 1 deletion Block/Adminhtml/Config/Field/Responsive.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected function _prepareToRender()
['label' => __('Number of items'), 'renderer' => false, 'class' => 'required-entry validate-digits']
);

$this->_addAfter = false;
$this->_addAfter = false;
$this->_addButtonLabel = __('Add');
}
}
6 changes: 3 additions & 3 deletions Block/Adminhtml/Slider.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ class Slider extends Container
*/
protected function _construct()
{
$this->_controller = 'adminhtml_slider';
$this->_blockGroup = 'Mageplaza_BannerSlider';
$this->_headerText = __('Sliders');
$this->_controller = 'adminhtml_slider';
$this->_blockGroup = 'Mageplaza_BannerSlider';
$this->_headerText = __('Sliders');
$this->_addButtonLabel = __('Create New Slider');

parent::_construct();
Expand Down
8 changes: 4 additions & 4 deletions Block/Adminhtml/Slider/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,20 @@ public function __construct(
*/
protected function _construct()
{
$this->_objectId = 'slider_id';
$this->_objectId = 'slider_id';
$this->_blockGroup = 'Mageplaza_BannerSlider';
$this->_controller = 'adminhtml_slider';
parent::_construct();
$this->buttonList->update('save', 'label', __('Save Slider'));
$this->buttonList->add(
'save-and-continue',
[
'label' => __('Save and Continue Edit'),
'class' => 'save',
'label' => __('Save and Continue Edit'),
'class' => 'save',
'data_attribute' => [
'mage-init' => [
'button' => [
'event' => 'saveAndContinueEdit',
'event' => 'saveAndContinueEdit',
'target' => '#edit_form'
]
]
Expand Down
6 changes: 3 additions & 3 deletions Block/Adminhtml/Slider/Edit/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ protected function _prepareForm()
$form = $this->_formFactory->create(
[
'data' => [
'id' => 'edit_form',
'action' => $this->getUrl('*/*/save', ['id' => $this->getRequest()->getParam('id')]),
'method' => 'post',
'id' => 'edit_form',
'action' => $this->getUrl('*/*/save', ['id' => $this->getRequest()->getParam('id')]),
'method' => 'post',
'enctype' => 'multipart/form-data'
]
]
Expand Down
56 changes: 28 additions & 28 deletions Block/Adminhtml/Slider/Edit/Tab/Banner.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ public function __construct(
array $data = []
) {
$this->bannerCollectionFactory = $bannerCollectionFactory;
$this->coreRegistry = $coreRegistry;
$this->bannerFactory = $bannerFactory;
$this->coreRegistry = $coreRegistry;
$this->bannerFactory = $bannerFactory;

parent::__construct($context, $backendHelper, $data);
}
Expand Down Expand Up @@ -142,60 +142,60 @@ protected function _prepareColumns()
{
$this->addColumn('in_banners', [
'header_css_class' => 'a-center',
'type' => 'checkbox',
'name' => 'in_banner',
'values' => $this->_getSelectedBanners(),
'align' => 'center',
'index' => 'banner_id'
'type' => 'checkbox',
'name' => 'in_banner',
'values' => $this->_getSelectedBanners(),
'align' => 'center',
'index' => 'banner_id'
]);
$this->addColumn('banner_id', [
'header' => __('ID'),
'sortable' => true,
'index' => 'banner_id',
'type' => 'number',
'header' => __('ID'),
'sortable' => true,
'index' => 'banner_id',
'type' => 'number',
'header_css_class' => 'col-id',
'column_css_class' => 'col-id'
]);

$this->addColumn('image', [
'header' => __('Image'),
'index' => 'image',
'header' => __('Image'),
'index' => 'image',
'header_css_class' => 'col-image',
'column_css_class' => 'col-image',
'sortable' => false,
'renderer' => GridImage::class
'sortable' => false,
'renderer' => GridImage::class
]);

$this->addColumn('name', [
'header' => __('Name'),
'index' => 'name',
'header' => __('Name'),
'index' => 'name',
'header_css_class' => 'col-name',
'column_css_class' => 'col-name'
]);

$this->addColumn('type', [
'header' => __('Type'),
'index' => 'type',
'header' => __('Type'),
'index' => 'type',
'header_css_class' => 'col-type',
'column_css_class' => 'col-type',
'renderer' => Type::class
'renderer' => Type::class
]);

$this->addColumn('status', [
'header' => __('Status'),
'index' => 'status',
'header' => __('Status'),
'index' => 'status',
'header_css_class' => 'col-status',
'column_css_class' => 'col-status',
'renderer' => Status::class
'renderer' => Status::class
]);

$this->addColumn('position', [
'header' => __('Position'),
'name' => 'position',
'type' => 'number',
'header' => __('Position'),
'name' => 'position',
'type' => 'number',
'validate_class' => 'validate-number validate-zero-or-greater validate-digits',
'index' => 'position',
'editable' => true,
'index' => 'position',
'editable' => true,
]);

return $this;
Expand Down
Loading

0 comments on commit f47ba4f

Please sign in to comment.