init
This commit is contained in:
+242
@@ -0,0 +1,242 @@
|
||||
<?php
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Mageplaza\Blog\Block\Adminhtml\Post;
|
||||
|
||||
use Magento\Backend\Block\Widget\Context;
|
||||
use Magento\Backend\Block\Widget\Form\Container;
|
||||
use Magento\Framework\Registry;
|
||||
use Mageplaza\Blog\Model\Post;
|
||||
|
||||
/**
|
||||
* Class Edit
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Post
|
||||
*/
|
||||
class Edit extends Container
|
||||
{
|
||||
/**
|
||||
* Core registry
|
||||
*
|
||||
* @var Registry
|
||||
*/
|
||||
public $coreRegistry;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @param Registry $coreRegistry
|
||||
* @param Context $context
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Registry $coreRegistry,
|
||||
Context $context,
|
||||
array $data = []
|
||||
) {
|
||||
$this->coreRegistry = $coreRegistry;
|
||||
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Post edit block
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_blockGroup = 'Mageplaza_Blog';
|
||||
$this->_controller = 'adminhtml_post';
|
||||
|
||||
parent::_construct();
|
||||
|
||||
if (!$this->getRequest()->getParam('history')) {
|
||||
$post = $this->coreRegistry->registry('mageplaza_blog_post');
|
||||
|
||||
$this->buttonList->remove('save');
|
||||
$this->buttonList->add(
|
||||
'save',
|
||||
[
|
||||
'label' => __('Save'),
|
||||
'class' => 'save primary',
|
||||
'data_attribute' => [
|
||||
'mage-init' => [
|
||||
'button' => [
|
||||
'event' => 'save',
|
||||
'target' => '#edit_form'
|
||||
]
|
||||
]
|
||||
],
|
||||
'class_name' => \Magento\Ui\Component\Control\Container::SPLIT_BUTTON,
|
||||
'options' => $this->getOptions($post),
|
||||
],
|
||||
-100
|
||||
);
|
||||
|
||||
$this->buttonList->add(
|
||||
'save-and-continue',
|
||||
[
|
||||
'label' => __('Save and Continue Edit'),
|
||||
'class' => 'save',
|
||||
'data_attribute' => [
|
||||
'mage-init' => [
|
||||
'button' => [
|
||||
'event' => 'saveAndContinueEdit',
|
||||
'target' => '#edit_form'
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
-100
|
||||
);
|
||||
if ($post->getId() && !$this->_request->getParam('duplicate')) {
|
||||
$this->buttonList->add(
|
||||
'duplicate',
|
||||
[
|
||||
'label' => __('Duplicate'),
|
||||
'class' => 'duplicate',
|
||||
'onclick' => sprintf("location.href = '%s';", $this->getDuplicateUrl()),
|
||||
],
|
||||
-101
|
||||
);
|
||||
} else {
|
||||
$this->buttonList->remove('delete');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve options
|
||||
*
|
||||
* @param Post $post
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions($post)
|
||||
{
|
||||
if ($post->getId() && !$this->_request->getParam('duplicate')) {
|
||||
$options[] = [
|
||||
'id_hard' => 'save_and_draft',
|
||||
'label' => __('Save as Draft'),
|
||||
'data_attribute' => [
|
||||
'mage-init' => [
|
||||
'button' => [
|
||||
'event' => 'save',
|
||||
'target' => '#edit_form',
|
||||
'eventData' => [
|
||||
'action' => ['args' => ['action' => 'draft']]
|
||||
],
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
$options[] = [
|
||||
'id_hard' => 'save_and_history',
|
||||
'label' => __(' Save & add History'),
|
||||
'data_attribute' => [
|
||||
'mage-init' => [
|
||||
'button' => [
|
||||
'event' => 'save',
|
||||
'target' => '#edit_form',
|
||||
'eventData' => [
|
||||
'action' => ['args' => ['action' => 'add']]
|
||||
],
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve text for header element depending on loaded Post
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHeaderText()
|
||||
{
|
||||
/** @var Post $post */
|
||||
$post = $this->coreRegistry->registry('mageplaza_blog_post');
|
||||
|
||||
if ($this->getRequest()->getParam('history')) {
|
||||
return __("Edit History Post '%1'", $this->escapeHtml($post->getName()));
|
||||
}
|
||||
|
||||
if ($post->getId() && $post->getDuplicate()) {
|
||||
return __("Edit Post '%1'", $this->escapeHtml($post->getName()));
|
||||
}
|
||||
|
||||
return __('New Post');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get form action URL
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFormActionUrl()
|
||||
{
|
||||
/** @var Post $post */
|
||||
$post = $this->coreRegistry->registry('mageplaza_blog_post');
|
||||
if ($post->getId()) {
|
||||
if ($post->getDuplicate()) {
|
||||
$ar = [];
|
||||
} else {
|
||||
$ar = ['id' => $post->getId()];
|
||||
}
|
||||
if ($this->getRequest()->getParam('history')) {
|
||||
$ar['post_id'] = $this->getRequest()->getParam('post_id');
|
||||
}
|
||||
|
||||
return $this->getUrl('*/*/save', $ar);
|
||||
}
|
||||
|
||||
return parent::getFormActionUrl();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getDuplicateUrl()
|
||||
{
|
||||
$post = $this->coreRegistry->registry('mageplaza_blog_post');
|
||||
|
||||
return $this->getUrl('*/*/duplicate', ['id' => $post->getId(), 'duplicate' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getSaveDraftUrl()
|
||||
{
|
||||
return $this->getUrl('*/*/save', ['action' => 'draft']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getSaveAddHistoryUrl()
|
||||
{
|
||||
return $this->getUrl('*/*/save', ['action' => 'add']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Mageplaza\Blog\Block\Adminhtml\Post\Edit;
|
||||
|
||||
use Magento\Backend\Block\Widget\Form\Generic;
|
||||
|
||||
/**
|
||||
* Class Form
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Post\Edit
|
||||
*/
|
||||
class Form extends Generic
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function _prepareForm()
|
||||
{
|
||||
/** @var \Magento\Framework\Data\Form $form */
|
||||
$form = $this->_formFactory->create([
|
||||
'data' => [
|
||||
'id' => 'edit_form',
|
||||
'action' => $this->getData('action'),
|
||||
'method' => 'post',
|
||||
'enctype' => 'multipart/form-data'
|
||||
]
|
||||
]);
|
||||
$form->setUseContainer(true);
|
||||
$this->setForm($form);
|
||||
|
||||
return parent::_prepareForm();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,353 @@
|
||||
<?php
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab;
|
||||
|
||||
use Exception;
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Backend\Block\Widget\Grid\Extended;
|
||||
use Magento\Backend\Block\Widget\Tab\TabInterface;
|
||||
use Magento\Backend\Helper\Data;
|
||||
use Magento\Framework\Exception\FileSystemException;
|
||||
use Magento\Framework\Registry;
|
||||
use Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer\History\Action;
|
||||
use Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer\History\Author;
|
||||
use Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer\History\Categories;
|
||||
use Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer\History\Store;
|
||||
use Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer\History\Tags;
|
||||
use Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer\History\Topics;
|
||||
use Mageplaza\Blog\Model\AuthorFactory;
|
||||
use Mageplaza\Blog\Model\ResourceModel\PostHistory\Collection;
|
||||
use Mageplaza\Blog\Model\Tag;
|
||||
|
||||
/**
|
||||
* Class Product
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab
|
||||
*/
|
||||
class History extends Extended implements TabInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Registry
|
||||
*/
|
||||
public $coreRegistry;
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
*/
|
||||
protected $historyCollection;
|
||||
|
||||
/**
|
||||
* @var \Mageplaza\Blog\Helper\Data
|
||||
*/
|
||||
protected $_helperData;
|
||||
|
||||
/**
|
||||
* Product constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param Registry $coreRegistry
|
||||
* @param Data $backendHelper
|
||||
* @param Collection $historyCollection
|
||||
* @param \Mageplaza\Blog\Helper\Data $_helperData
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Registry $coreRegistry,
|
||||
Data $backendHelper,
|
||||
Collection $historyCollection,
|
||||
\Mageplaza\Blog\Helper\Data $_helperData,
|
||||
array $data = []
|
||||
) {
|
||||
$this->coreRegistry = $coreRegistry;
|
||||
$this->historyCollection = $historyCollection;
|
||||
$this->_helperData = $_helperData;
|
||||
|
||||
parent::__construct($context, $backendHelper, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set grid params
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function _construct()
|
||||
{
|
||||
parent::_construct();
|
||||
|
||||
$this->setId('history_id');
|
||||
$this->setDefaultSort('history_id');
|
||||
$this->setDefaultDir('DESC');
|
||||
$this->setSaveParametersInSession(false);
|
||||
$this->setUseAjax(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function _prepareCollection()
|
||||
{
|
||||
/** @var Collection $collection */
|
||||
$collection = $this->historyCollection;
|
||||
$id = $this->getRequest()->getParam('id', 0);
|
||||
$collection->addFieldToFilter('post_id', $id);
|
||||
$this->setCollection($collection);
|
||||
|
||||
return parent::_prepareCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function _prepareColumns()
|
||||
{
|
||||
$this->addColumn('history_id', [
|
||||
'header' => __('ID'),
|
||||
'sortable' => true,
|
||||
'index' => 'history_id',
|
||||
'type' => 'number',
|
||||
'header_css_class' => 'col-id',
|
||||
'column_css_class' => 'col-id'
|
||||
]);
|
||||
$this->addColumn('name', [
|
||||
'header' => __('Name'),
|
||||
'index' => 'name',
|
||||
'header_css_class' => 'col-name',
|
||||
'column_css_class' => 'col-name'
|
||||
]);
|
||||
$this->addColumn('short_description', [
|
||||
'header' => __('Short Description'),
|
||||
'index' => 'short_description',
|
||||
'header_css_class' => 'col-short-description',
|
||||
'column_css_class' => 'col-short-description'
|
||||
]);
|
||||
$this->addColumn('store_ids', [
|
||||
'header' => __('Store View'),
|
||||
'index' => 'store_ids',
|
||||
'renderer' => Store::class,
|
||||
'filter' => false,
|
||||
'header_css_class' => 'col-store-ids',
|
||||
'column_css_class' => 'col-store-ids'
|
||||
]);
|
||||
$this->addColumn('category_ids', [
|
||||
'header' => __('Categories'),
|
||||
'index' => 'category_ids',
|
||||
'filter' => false,
|
||||
'renderer' => Categories::class,
|
||||
'header_css_class' => 'col-category-ids',
|
||||
'column_css_class' => 'col-category-ids'
|
||||
]);
|
||||
$this->addColumn('topic_ids', [
|
||||
'header' => __('Topics'),
|
||||
'index' => 'topic_ids',
|
||||
'filter' => false,
|
||||
'renderer' => Topics::class,
|
||||
'header_css_class' => 'col-topic-ids',
|
||||
'column_css_class' => 'col-topic-ids'
|
||||
]);
|
||||
$this->addColumn('tag_ids', [
|
||||
'header' => __('Tags'),
|
||||
'index' => 'tag_ids',
|
||||
'filter' => false,
|
||||
'renderer' => Tags::class,
|
||||
'header_css_class' => 'col-tag-ids',
|
||||
'column_css_class' => 'col-tag-ids'
|
||||
]);
|
||||
$this->addColumn('modifier_id', [
|
||||
'header' => __('Modified by'),
|
||||
'index' => 'modifier_id',
|
||||
'type' => 'options',
|
||||
'options' => $this->_getModifierOptions(),
|
||||
'renderer' => Author::class,
|
||||
'filter_condition_callback' => [$this, '_filterByModifierId'],
|
||||
'header_css_class' => 'col-modifier-id',
|
||||
'column_css_class' => 'col-modifier-id'
|
||||
]);
|
||||
$this->addColumn('updated_at', [
|
||||
'header' => __('Modified At'),
|
||||
'index' => 'updated_at',
|
||||
'header_css_class' => 'col-updated-at',
|
||||
'column_css_class' => 'col-updated-at',
|
||||
'type' => 'datetime',
|
||||
'filter_condition_callback' => [$this, '_filterByUpdatedAt'],
|
||||
]);
|
||||
$this->addColumn(
|
||||
'action',
|
||||
[
|
||||
'header' => __('Action'),
|
||||
'index' => 'template_id',
|
||||
'sortable' => false,
|
||||
'filter' => false,
|
||||
'no_link' => true,
|
||||
'renderer' => Action::class,
|
||||
'header_css_class' => 'col-actions',
|
||||
'column_css_class' => 'col-actions'
|
||||
]
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Tag|Object $item
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRowUrl($item)
|
||||
{
|
||||
return '#';
|
||||
}
|
||||
|
||||
/**
|
||||
* get grid url
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getGridUrl()
|
||||
{
|
||||
return $this->getUrl('*/*/historyGrid', ['id' => $this->getPost()->getId()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Mageplaza\Blog\Model\Post
|
||||
*/
|
||||
public function getPost()
|
||||
{
|
||||
return $this->coreRegistry->registry('mageplaza_blog_post');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabLabel()
|
||||
{
|
||||
return __('Edit History');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isHidden()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabTitle()
|
||||
{
|
||||
return $this->getTabLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function canShowTab()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabUrl()
|
||||
{
|
||||
return $this->getUrl('mageplaza_blog/post/history', ['_current' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabClass()
|
||||
{
|
||||
return 'ajax only';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Modifiers as Author of Post
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function _getModifierOptions()
|
||||
{
|
||||
/** @var AuthorFactory $authors */
|
||||
$authors = $this->_helperData->getFactoryByType('author');
|
||||
|
||||
$authors = $authors->create()->getCollection()->addFieldToSelect(['user_id', 'name'])->getItems();
|
||||
$options = [];
|
||||
foreach ($authors as $author) {
|
||||
$options[$author->getUserId()] = $author->getName();
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $collection
|
||||
* @param \Magento\Backend\Block\Widget\Grid\Column\Extended $column
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function _filterByModifierId(
|
||||
Collection $collection,
|
||||
\Magento\Backend\Block\Widget\Grid\Column\Extended $column
|
||||
) {
|
||||
if (!$value = $column->getFilter()->getValue()) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$collection->addFieldToFilter('modifier_id', $value);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $collection
|
||||
* @param \Magento\Backend\Block\Widget\Grid\Column\Extended $column
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function _filterByUpdatedAt(
|
||||
Collection $collection,
|
||||
\Magento\Backend\Block\Widget\Grid\Column\Extended $column
|
||||
) {
|
||||
if (!$value = $column->getFilter()->getValue()) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$formValue = $value['from'] ?? '';
|
||||
$toValue = $value['to'] ?? '';
|
||||
|
||||
if ($formValue && $toValue) {
|
||||
$updateFilter = ['from' => $formValue, 'to' => $toValue];
|
||||
} elseif ($formValue) {
|
||||
$updateFilter = ['from' => $formValue];
|
||||
} else {
|
||||
$updateFilter = ['to' => $toValue];
|
||||
}
|
||||
|
||||
$collection->addFieldToFilter('updated_at', $updateFilter);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,403 @@
|
||||
<?php
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab;
|
||||
|
||||
use DateTimeZone;
|
||||
use Exception;
|
||||
use Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element;
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Backend\Block\Widget\Form\Generic;
|
||||
use Magento\Backend\Block\Widget\Tab\TabInterface;
|
||||
use Magento\Backend\Model\Auth\Session;
|
||||
use Magento\Cms\Model\Page\Source\PageLayout as BasePageLayout;
|
||||
use Magento\Cms\Model\Wysiwyg\Config;
|
||||
use Magento\Config\Model\Config\Source\Design\Robots;
|
||||
use Magento\Config\Model\Config\Source\Yesno;
|
||||
use Magento\Framework\Data\Form;
|
||||
use Magento\Framework\Data\Form\Element\Renderer\RendererInterface;
|
||||
use Magento\Framework\Data\FormFactory;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Framework\Stdlib\DateTime\DateTime;
|
||||
use Magento\Store\Model\System\Store;
|
||||
use Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer\Category;
|
||||
use Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer\Tag;
|
||||
use Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer\Topic;
|
||||
use Mageplaza\Blog\Helper\Image;
|
||||
use Mageplaza\Blog\Model\Config\Source\Author;
|
||||
use Mageplaza\Blog\Model\Config\Source\AuthorStatus;
|
||||
|
||||
/**
|
||||
* Class Post
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab
|
||||
*/
|
||||
class Post extends Generic implements TabInterface
|
||||
{
|
||||
/**
|
||||
* Wysiwyg config
|
||||
*
|
||||
* @var Config
|
||||
*/
|
||||
public $wysiwygConfig;
|
||||
|
||||
/**
|
||||
* Country options
|
||||
*
|
||||
* @var Yesno
|
||||
*/
|
||||
public $booleanOptions;
|
||||
|
||||
/**
|
||||
* @var Robots
|
||||
*/
|
||||
public $metaRobotsOptions;
|
||||
|
||||
/**
|
||||
* @var Store
|
||||
*/
|
||||
public $systemStore;
|
||||
|
||||
/**
|
||||
* @var Session
|
||||
*/
|
||||
protected $authSession;
|
||||
|
||||
/**
|
||||
* @var Image
|
||||
*/
|
||||
protected $imageHelper;
|
||||
|
||||
/**
|
||||
* @var DateTime
|
||||
*/
|
||||
protected $_date;
|
||||
|
||||
/**
|
||||
* @var BasePageLayout
|
||||
*/
|
||||
protected $_layoutOptions;
|
||||
|
||||
/**
|
||||
* @var Author
|
||||
*/
|
||||
protected $_author;
|
||||
|
||||
/**
|
||||
* @var AuthorStatus
|
||||
*/
|
||||
protected $_status;
|
||||
|
||||
/**
|
||||
* Post constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param Registry $registry
|
||||
* @param Session $authSession
|
||||
* @param DateTime $dateTime
|
||||
* @param BasePageLayout $layoutOption
|
||||
* @param FormFactory $formFactory
|
||||
* @param Config $wysiwygConfig
|
||||
* @param Yesno $booleanOptions
|
||||
* @param Robots $metaRobotsOptions
|
||||
* @param Store $systemStore
|
||||
* @param Image $imageHelper
|
||||
* @param Author $author
|
||||
* @param AuthorStatus $status
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Registry $registry,
|
||||
Session $authSession,
|
||||
DateTime $dateTime,
|
||||
BasePageLayout $layoutOption,
|
||||
FormFactory $formFactory,
|
||||
Config $wysiwygConfig,
|
||||
Yesno $booleanOptions,
|
||||
Robots $metaRobotsOptions,
|
||||
Store $systemStore,
|
||||
Image $imageHelper,
|
||||
Author $author,
|
||||
AuthorStatus $status,
|
||||
array $data = []
|
||||
) {
|
||||
$this->wysiwygConfig = $wysiwygConfig;
|
||||
$this->booleanOptions = $booleanOptions;
|
||||
$this->metaRobotsOptions = $metaRobotsOptions;
|
||||
$this->systemStore = $systemStore;
|
||||
$this->authSession = $authSession;
|
||||
$this->_date = $dateTime;
|
||||
$this->_layoutOptions = $layoutOption;
|
||||
$this->imageHelper = $imageHelper;
|
||||
$this->_author = $author;
|
||||
$this->_status = $status;
|
||||
|
||||
parent::__construct($context, $registry, $formFactory, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function _prepareForm()
|
||||
{
|
||||
/** @var \Mageplaza\Blog\Model\Post $post */
|
||||
$post = $this->_coreRegistry->registry('mageplaza_blog_post');
|
||||
|
||||
/** @var Form $form */
|
||||
$form = $this->_formFactory->create();
|
||||
|
||||
$form->setHtmlIdPrefix('post_');
|
||||
$form->setFieldNameSuffix('post');
|
||||
|
||||
$fieldset = $form->addFieldset('base_fieldset', [
|
||||
'legend' => __('Post Information'),
|
||||
'class' => 'fieldset-wide'
|
||||
]);
|
||||
|
||||
if ($this->_request->getParam('duplicate')) {
|
||||
$fieldset->addField('duplicate', 'hidden', [
|
||||
'name' => 'duplicate',
|
||||
'value' => 1
|
||||
]);
|
||||
}
|
||||
$fieldset->addField('name', 'text', [
|
||||
'name' => 'name',
|
||||
'label' => __('Name'),
|
||||
'title' => __('Name'),
|
||||
'required' => true
|
||||
]);
|
||||
$fieldset->addField('url_key', 'text', [
|
||||
'name' => 'url_key',
|
||||
'label' => __('URL Key'),
|
||||
'title' => __('URL Key')
|
||||
]);
|
||||
$fieldset->addField('author_id', 'select', [
|
||||
'name' => 'author_id',
|
||||
'label' => __('Author'),
|
||||
'title' => __('Author'),
|
||||
'required' => true,
|
||||
'values' => $this->_author->toOptionArray()
|
||||
]);
|
||||
$fieldset->addField('enabled', 'select', [
|
||||
'name' => 'enabled',
|
||||
'label' => __('Status'),
|
||||
'title' => __('Status'),
|
||||
'values' => $this->_status->toOptionArray()
|
||||
]);
|
||||
if (!$post->hasData('enabled')) {
|
||||
$post->setEnabled(1);
|
||||
}
|
||||
|
||||
$fieldset->addField('short_description', 'textarea', [
|
||||
'name' => 'short_description',
|
||||
'label' => __('Short Description'),
|
||||
'title' => __('Short Description')
|
||||
]);
|
||||
$fieldset->addField('post_content', 'editor', [
|
||||
'name' => 'post_content',
|
||||
'label' => __('Content'),
|
||||
'title' => __('Content'),
|
||||
'config' => $this->wysiwygConfig->getConfig([
|
||||
'add_variables' => false,
|
||||
'add_widgets' => true,
|
||||
'add_directives' => true
|
||||
])
|
||||
]);
|
||||
|
||||
if ($this->_storeManager->isSingleStoreMode()) {
|
||||
$fieldset->addField('store_ids', 'hidden', [
|
||||
'name' => 'store_ids',
|
||||
'value' => $this->_storeManager->getStore()->getId()
|
||||
]);
|
||||
} else {
|
||||
/** @var RendererInterface $rendererBlock */
|
||||
$rendererBlock = $this->getLayout()->createBlock(Element::class);
|
||||
$fieldset->addField('store_ids', 'multiselect', [
|
||||
'name' => 'store_ids',
|
||||
'label' => __('Store Views'),
|
||||
'title' => __('Store Views'),
|
||||
'values' => $this->systemStore->getStoreValuesForForm(false, true)
|
||||
])->setRenderer($rendererBlock);
|
||||
|
||||
if (!$post->hasData('store_ids')) {
|
||||
$post->setStoreIds(0);
|
||||
}
|
||||
}
|
||||
|
||||
$fieldset->addField('image', \Mageplaza\Blog\Block\Adminhtml\Renderer\Image::class, [
|
||||
'name' => 'image',
|
||||
'label' => __('Image'),
|
||||
'title' => __('Image'),
|
||||
'path' => $this->imageHelper->getBaseMediaPath(Image::TEMPLATE_MEDIA_TYPE_POST),
|
||||
'note' => __('The appropriate size is 265px * 250px.')
|
||||
]);
|
||||
$fieldset->addField('categories_ids', Category::class, [
|
||||
'name' => 'categories_ids',
|
||||
'label' => __('Categories'),
|
||||
'title' => __('Categories'),
|
||||
]);
|
||||
if (!$post->getCategoriesIds()) {
|
||||
$post->setCategoriesIds($post->getCategoryIds());
|
||||
}
|
||||
|
||||
$fieldset->addField('topics_ids', Topic::class, [
|
||||
'name' => 'topics_ids',
|
||||
'label' => __('Topics'),
|
||||
'title' => __('Topics'),
|
||||
]);
|
||||
if (!$post->getTopicsIds()) {
|
||||
$post->setTopicsIds($post->getTopicIds());
|
||||
}
|
||||
|
||||
$fieldset->addField('tags_ids', Tag::class, [
|
||||
'name' => 'tags_ids',
|
||||
'label' => __('Tags'),
|
||||
'title' => __('Tags'),
|
||||
]);
|
||||
if (!$post->getTagsIds()) {
|
||||
$post->setTagsIds($post->getTagIds());
|
||||
}
|
||||
|
||||
$fieldset->addField('in_rss', 'select', [
|
||||
'name' => 'in_rss',
|
||||
'label' => __('In RSS'),
|
||||
'title' => __('In RSS'),
|
||||
'values' => $this->booleanOptions->toOptionArray(),
|
||||
]);
|
||||
$fieldset->addField('allow_comment', 'select', [
|
||||
'name' => 'allow_comment',
|
||||
'label' => __('Allow Comment'),
|
||||
'title' => __('Allow Comment'),
|
||||
'values' => $this->booleanOptions->toOptionArray(),
|
||||
]);
|
||||
$fieldset->addField(
|
||||
'publish_date',
|
||||
'date',
|
||||
[
|
||||
'name' => 'publish_date',
|
||||
'label' => __('Publish Date'),
|
||||
'title' => __('Publish Date'),
|
||||
'date_format' => 'yyyy-MM-dd',
|
||||
'timezone' => false,
|
||||
'time_format' => 'hh:mm:ss'
|
||||
]
|
||||
);
|
||||
$this->_eventManager->dispatch('after_adminhtml_blog_post_info_tab', ['fieldset' => $fieldset]);
|
||||
|
||||
$seoFieldset = $form->addFieldset('seo_fieldset', [
|
||||
'legend' => __('Search Engine Optimization'),
|
||||
'class' => 'fieldset-wide'
|
||||
]);
|
||||
|
||||
$seoFieldset->addField('meta_title', 'text', [
|
||||
'name' => 'meta_title',
|
||||
'label' => __('Meta Title'),
|
||||
'title' => __('Meta Title'),
|
||||
'note' => __('If empty, the post name will be used.')
|
||||
]);
|
||||
$seoFieldset->addField('meta_keywords', 'textarea', [
|
||||
'name' => 'meta_keywords',
|
||||
'label' => __('Meta Keywords'),
|
||||
'title' => __('Meta Keywords'),
|
||||
'note' => __('Enter comma-separated keywords.')
|
||||
]);
|
||||
$seoFieldset->addField('meta_description', 'textarea', [
|
||||
'name' => 'meta_description',
|
||||
'label' => __('Meta Description'),
|
||||
'title' => __('Meta Description'),
|
||||
'note' => __('If empty, the global blog meta description will be used.')
|
||||
]);
|
||||
|
||||
$designFieldset = $form->addFieldset('design_fieldset', [
|
||||
'legend' => __('Design'),
|
||||
'class' => 'fieldset-wide'
|
||||
]);
|
||||
|
||||
$designFieldset->addField('layout', 'select', [
|
||||
'name' => 'layout',
|
||||
'label' => __('Layout'),
|
||||
'title' => __('Layout'),
|
||||
'values' => $this->_layoutOptions->toOptionArray()
|
||||
]);
|
||||
|
||||
if (!$post->getId()) {
|
||||
$post->addData([
|
||||
'allow_comment' => 1
|
||||
]);
|
||||
}
|
||||
|
||||
/** Get the public_date from database */
|
||||
if ($post->getData('publish_date')) {
|
||||
$publicDateTime = new \DateTime($post->getData('publish_date'), new DateTimeZone('UTC'));
|
||||
$publicDateTime->setTimezone(new DateTimeZone($this->_localeDate->getConfigTimezone()));
|
||||
$publicDateTime = $publicDateTime->format('m/d/Y H:i:s');
|
||||
$post->setData('publish_date', $publicDateTime);
|
||||
}
|
||||
|
||||
$form->addValues($post->getData());
|
||||
$this->setForm($form);
|
||||
|
||||
$this->_eventManager->dispatch('adminhtml_blog_edit_form_prepare_form', ['block' => $this]);
|
||||
|
||||
return parent::_prepareForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare label for tab
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTabLabel()
|
||||
{
|
||||
return __('Post');
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare title for tab
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTabTitle()
|
||||
{
|
||||
return $this->getTabLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Can show tab in tabs
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function canShowTab()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tab is hidden
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isHidden()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,316 @@
|
||||
<?php
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab;
|
||||
|
||||
use Exception;
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Backend\Block\Widget\Grid\Column;
|
||||
use Magento\Backend\Block\Widget\Grid\Extended;
|
||||
use Magento\Backend\Block\Widget\Tab\TabInterface;
|
||||
use Magento\Backend\Helper\Data;
|
||||
use Magento\Catalog\Model\ResourceModel\Product\Collection;
|
||||
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
|
||||
use Magento\Framework\App\RequestInterface;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\Registry;
|
||||
use Mageplaza\Blog\Model\Tag;
|
||||
|
||||
/**
|
||||
* Class Product
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab
|
||||
*/
|
||||
class Product extends Extended implements TabInterface
|
||||
{
|
||||
/**
|
||||
* @var CollectionFactory
|
||||
*/
|
||||
public $productCollectionFactory;
|
||||
|
||||
/**
|
||||
* @var Registry
|
||||
*/
|
||||
public $coreRegistry;
|
||||
|
||||
/**
|
||||
* @var RequestInterface
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Product constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param Registry $coreRegistry
|
||||
* @param Data $backendHelper
|
||||
* @param RequestInterface $request
|
||||
* @param CollectionFactory $productCollectionFactory
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Registry $coreRegistry,
|
||||
Data $backendHelper,
|
||||
RequestInterface $request,
|
||||
CollectionFactory $productCollectionFactory,
|
||||
array $data = []
|
||||
) {
|
||||
$this->productCollectionFactory = $productCollectionFactory;
|
||||
$this->coreRegistry = $coreRegistry;
|
||||
$this->request = $request;
|
||||
|
||||
parent::__construct($context, $backendHelper, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set grid params
|
||||
*/
|
||||
public function _construct()
|
||||
{
|
||||
parent::_construct();
|
||||
|
||||
$this->setId('product_grid');
|
||||
$this->setDefaultSort('position');
|
||||
$this->setDefaultDir('ASC');
|
||||
$this->setSaveParametersInSession(false);
|
||||
$this->setUseAjax(true);
|
||||
|
||||
if ($this->getPost()->getId()) {
|
||||
$this->setDefaultFilter(['in_products' => 1]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function _prepareCollection()
|
||||
{
|
||||
/** @var Collection $collection */
|
||||
$collection = $this->productCollectionFactory->create();
|
||||
$collection->clear();
|
||||
|
||||
$collection->getSelect()->joinLeft(
|
||||
['mp_p' => $collection->getTable('mageplaza_blog_post_product')],
|
||||
'e.entity_id = mp_p.entity_id',
|
||||
['position']
|
||||
)->group('e.entity_id');
|
||||
|
||||
$this->setCollection($collection);
|
||||
|
||||
return parent::_prepareCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function _prepareColumns()
|
||||
{
|
||||
$this->addColumn('in_products', [
|
||||
'header_css_class' => 'a-center',
|
||||
'type' => 'checkbox',
|
||||
'name' => 'in_product',
|
||||
'values' => $this->_getSelectedProducts(),
|
||||
'align' => 'center',
|
||||
'index' => 'entity_id'
|
||||
]);
|
||||
$this->addColumn('entity_id', [
|
||||
'header' => __('ID'),
|
||||
'sortable' => true,
|
||||
'index' => 'entity_id',
|
||||
'type' => 'number',
|
||||
'header_css_class' => 'col-id',
|
||||
'column_css_class' => 'col-id'
|
||||
]);
|
||||
$this->addColumn('title', [
|
||||
'header' => __('Sku'),
|
||||
'index' => 'sku',
|
||||
'header_css_class' => 'col-name',
|
||||
'column_css_class' => 'col-name'
|
||||
]);
|
||||
|
||||
if ($this->request->getParam('post_id') || $this->getPost()->getId()) {
|
||||
$this->addColumn('position', [
|
||||
'header' => __('Position'),
|
||||
'name' => 'position',
|
||||
'width' => 60,
|
||||
'type' => 'number',
|
||||
'validate_class' => 'validate-number',
|
||||
'index' => 'position',
|
||||
'editable' => true,
|
||||
'edit_only' => true,
|
||||
]);
|
||||
} else {
|
||||
$this->addColumn('position', [
|
||||
'header' => __('Position'),
|
||||
'name' => 'position',
|
||||
'width' => 60,
|
||||
'type' => 'number',
|
||||
'validate_class' => 'validate-number',
|
||||
'index' => 'position',
|
||||
'editable' => true,
|
||||
'filter' => false,
|
||||
'edit_only' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve selected Tags
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function _getSelectedProducts()
|
||||
{
|
||||
$products = $this->getRequest()->getPost('post_products', null);
|
||||
if (!is_array($products)) {
|
||||
$products = $this->getPost()->getProductsPosition();
|
||||
|
||||
return array_keys($products);
|
||||
}
|
||||
|
||||
return $products;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve selected Tags
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getSelectedProducts()
|
||||
{
|
||||
$selected = $this->getPost()->getProductsPosition();
|
||||
if (!is_array($selected)) {
|
||||
$selected = [];
|
||||
} else {
|
||||
foreach ($selected as $key => $value) {
|
||||
$selected[$key] = ['position' => $value];
|
||||
}
|
||||
}
|
||||
|
||||
return $selected;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Tag|Object $item
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRowUrl($item)
|
||||
{
|
||||
return '#';
|
||||
}
|
||||
|
||||
/**
|
||||
* get grid url
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getGridUrl()
|
||||
{
|
||||
return $this->getUrl('*/*/productsGrid', ['post_id' => $this->getPost()->getId()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Mageplaza\Blog\Model\Post
|
||||
*/
|
||||
public function getPost()
|
||||
{
|
||||
return $this->coreRegistry->registry('mageplaza_blog_post');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Column $column
|
||||
*
|
||||
* @return $this
|
||||
* @throws LocalizedException
|
||||
*/
|
||||
protected function _addColumnFilterToCollection($column)
|
||||
{
|
||||
if ($column->getId() === 'in_products') {
|
||||
$productIds = $this->_getSelectedProducts();
|
||||
if (empty($productIds)) {
|
||||
$productIds = 0;
|
||||
}
|
||||
if ($column->getFilter()->getValue()) {
|
||||
$this->getCollection()->addFieldToFilter('entity_id', ['in' => $productIds]);
|
||||
} else {
|
||||
if ($productIds) {
|
||||
$this->getCollection()->addFieldToFilter('entity_id', ['nin' => $productIds]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
parent::_addColumnFilterToCollection($column);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabLabel()
|
||||
{
|
||||
return __('Products');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isHidden()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabTitle()
|
||||
{
|
||||
return $this->getTabLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function canShowTab()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabUrl()
|
||||
{
|
||||
return $this->getUrl('mageplaza_blog/post/products', ['_current' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabClass()
|
||||
{
|
||||
return 'ajax only';
|
||||
}
|
||||
}
|
||||
+284
@@ -0,0 +1,284 @@
|
||||
<?php
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer;
|
||||
|
||||
use Magento\Catalog\Model\Category as CategoryModel;
|
||||
use Magento\Framework\AuthorizationInterface;
|
||||
use Magento\Framework\Data\Form\Element\CollectionFactory;
|
||||
use Magento\Framework\Data\Form\Element\Factory;
|
||||
use Magento\Framework\Data\Form\Element\Multiselect;
|
||||
use Magento\Framework\Escaper;
|
||||
use Magento\Framework\UrlInterface;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Category\Collection;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Category\CollectionFactory as BlogCategoryCollectionFactory;
|
||||
|
||||
/**
|
||||
* Class Category
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer
|
||||
*/
|
||||
class Category extends Multiselect
|
||||
{
|
||||
/**
|
||||
* @var BlogCategoryCollectionFactory
|
||||
*/
|
||||
public $collectionFactory;
|
||||
|
||||
/**
|
||||
* @var AuthorizationInterface
|
||||
*/
|
||||
public $authorization;
|
||||
|
||||
/**
|
||||
* @var UrlInterface
|
||||
*/
|
||||
protected $_urlBuilder;
|
||||
|
||||
/**
|
||||
* Category constructor.
|
||||
*
|
||||
* @param Factory $factoryElement
|
||||
* @param CollectionFactory $factoryCollection
|
||||
* @param Escaper $escaper
|
||||
* @param BlogCategoryCollectionFactory $collectionFactory
|
||||
* @param AuthorizationInterface $authorization
|
||||
* @param UrlInterface $urlBuilder
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Factory $factoryElement,
|
||||
CollectionFactory $factoryCollection,
|
||||
Escaper $escaper,
|
||||
BlogCategoryCollectionFactory $collectionFactory,
|
||||
AuthorizationInterface $authorization,
|
||||
UrlInterface $urlBuilder,
|
||||
array $data = []
|
||||
) {
|
||||
$this->collectionFactory = $collectionFactory;
|
||||
$this->authorization = $authorization;
|
||||
$this->_urlBuilder = $urlBuilder;
|
||||
|
||||
parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getElementHtml()
|
||||
{
|
||||
$html = '<div class="admin__field-control admin__control-grouped">';
|
||||
$html .= '<div id="blog-category-select" class="admin__field"
|
||||
data-bind="scope:\'blogCategory\'" data-index="index">';
|
||||
$html .= '<!-- ko foreach: elems() -->';
|
||||
$html .= '<input name="post[categories_ids]" data-bind="value: value" style="display: none"/>';
|
||||
$html .= '<!-- ko template: elementTmpl --><!-- /ko -->';
|
||||
$html .= '<!-- /ko -->';
|
||||
$html .= '</div>';
|
||||
|
||||
$html .= '<div class="admin__field admin__field-group-additional admin__field-small"
|
||||
data-bind="scope:\'create_category_button\'">';
|
||||
$html .= '<div class="admin__field-control">';
|
||||
$html .= '<!-- ko template: elementTmpl --><!-- /ko -->';
|
||||
$html .= '</div></div></div>';
|
||||
|
||||
$html .= '<!-- ko scope: \'create_category_modal\' -->
|
||||
<!-- ko template: getTemplate() --><!-- /ko --><!-- /ko -->';
|
||||
|
||||
$html .= $this->getAfterElementHtml();
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get no display
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getNoDisplay()
|
||||
{
|
||||
$isNotAllowed = !$this->authorization->isAllowed('Mageplaza_Blog::category');
|
||||
|
||||
return $this->getData('no_display') || $isNotAllowed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCategoriesTree()
|
||||
{
|
||||
/* @var $collection \Magento\Catalog\Model\ResourceModel\Category\Collection */
|
||||
$collection = $this->collectionFactory->create();
|
||||
|
||||
$categoryById = [
|
||||
CategoryModel::TREE_ROOT_ID => [
|
||||
'value' => CategoryModel::TREE_ROOT_ID,
|
||||
'optgroup' => null,
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($collection as $category) {
|
||||
foreach ([$category->getId(), $category->getParentId()] as $categoryId) {
|
||||
if (!isset($categoryById[$categoryId])) {
|
||||
$categoryById[$categoryId] = ['value' => $categoryId];
|
||||
}
|
||||
}
|
||||
|
||||
$categoryById[$category->getId()]['is_active'] = 1;
|
||||
$categoryById[$category->getId()]['label'] = $category->getName();
|
||||
$categoryById[$category->getParentId()]['optgroup'][] = &$categoryById[$category->getId()];
|
||||
}
|
||||
|
||||
return $categoryById[CategoryModel::TREE_ROOT_ID]['optgroup'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get values for select
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getValues()
|
||||
{
|
||||
$values = $this->getValue();
|
||||
if (!is_array($values)) {
|
||||
$values = explode(',', $values);
|
||||
}
|
||||
|
||||
if (!count($values)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
/* @var $collection Collection */
|
||||
$collection = $this->collectionFactory->create()
|
||||
->addIdFilter($values);
|
||||
|
||||
$options = [];
|
||||
foreach ($collection as $category) {
|
||||
$options[] = $category->getId();
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach Blog Category suggest widget initialization
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAfterElementHtml()
|
||||
{
|
||||
$html = '<script type="text/x-magento-init">
|
||||
{
|
||||
"*": {
|
||||
"Magento_Ui/js/core/app": {
|
||||
"components": {
|
||||
"blogCategory": {
|
||||
"component": "uiComponent",
|
||||
"children": {
|
||||
"blog_select_category": {
|
||||
"component": "Mageplaza_Blog/js/components/new-category",
|
||||
"config": {
|
||||
"filterOptions": true,
|
||||
"disableLabel": true,
|
||||
"chipsEnabled": true,
|
||||
"levelsVisibility": "1",
|
||||
"elementTmpl": "ui/grid/filters/elements/ui-select",
|
||||
"options": ' . json_encode($this->getCategoriesTree()) . ',
|
||||
"value": ' . json_encode($this->getValues()) . ',
|
||||
"listens": {
|
||||
"index=create_category:responseData": "setParsed",
|
||||
"newOption": "toggleOptionSelected"
|
||||
},
|
||||
"config": {
|
||||
"dataScope": "blog_select_category",
|
||||
"sortOrder": 10
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"create_category_button": {
|
||||
"title": "' . __('New Category') . '",
|
||||
"formElement": "container",
|
||||
"additionalClasses": "admin__field-small",
|
||||
"componentType": "container",
|
||||
"component": "Magento_Ui/js/form/components/button",
|
||||
"template": "ui/form/components/button/container",
|
||||
"actions": [
|
||||
{
|
||||
"targetName": "create_category_modal",
|
||||
"actionName": "toggleModal"
|
||||
},
|
||||
{
|
||||
"targetName": "create_category_modal.create_category",
|
||||
"actionName": "render"
|
||||
},
|
||||
{
|
||||
"targetName": "create_category_modal.create_category",
|
||||
"actionName": "resetForm"
|
||||
}
|
||||
],
|
||||
"additionalForGroup": true,
|
||||
"provider": false,
|
||||
"source": "product_details",
|
||||
"displayArea": "insideGroup"
|
||||
},
|
||||
"create_category_modal": {
|
||||
"config": {
|
||||
"isTemplate": false,
|
||||
"componentType": "container",
|
||||
"component": "Magento_Ui/js/modal/modal-component",
|
||||
"options": {
|
||||
"title": "' . __('New Category') . '",
|
||||
"type": "slide"
|
||||
},
|
||||
"imports": {
|
||||
"state": "!index=create_category:responseStatus"
|
||||
}
|
||||
},
|
||||
"children": {
|
||||
"create_category": {
|
||||
"label": "",
|
||||
"componentType": "container",
|
||||
"component": "Magento_Ui/js/form/components/insert-form",
|
||||
"dataScope": "",
|
||||
"update_url": "' . $this->_urlBuilder->getUrl('mui/index/render') . '",
|
||||
"render_url": "' .
|
||||
$this->_urlBuilder->getUrl(
|
||||
'mui/index/render_handle',
|
||||
['handle' => 'mageplaza_blog_category_create', 'buttons' => 1]
|
||||
) . '",
|
||||
"autoRender": false,
|
||||
"ns": "blog_new_category_form",
|
||||
"externalProvider": "blog_new_category_form.new_category_form_data_source",
|
||||
"toolbarContainer": "${ $.parentName }",
|
||||
"formSubmitType": "ajax"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer\History;
|
||||
|
||||
use Exception;
|
||||
use Magento\Backend\Block\Context;
|
||||
use Magento\Framework\DataObject;
|
||||
use Magento\Framework\Json\EncoderInterface;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
|
||||
/**
|
||||
* Class Action
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer
|
||||
*/
|
||||
class Action extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Action
|
||||
{
|
||||
/**
|
||||
* @var StoreManagerInterface
|
||||
*/
|
||||
protected $_storeManager;
|
||||
|
||||
/**
|
||||
* Action constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param StoreManagerInterface $storeManager
|
||||
* @param EncoderInterface $jsonEncoder
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
StoreManagerInterface $storeManager,
|
||||
EncoderInterface $jsonEncoder,
|
||||
array $data = []
|
||||
) {
|
||||
$this->_storeManager = $storeManager;
|
||||
parent::__construct($context, $jsonEncoder, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DataObject $row
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render(DataObject $row)
|
||||
{
|
||||
$actions[] = [
|
||||
'url' =>
|
||||
$this->getUrl('*/history/edit', [
|
||||
'id' => $row->getId(),
|
||||
'post_id' => $row->getPostId(),
|
||||
'history' => true
|
||||
]),
|
||||
'popup' => false,
|
||||
'caption' => __('Edit'),
|
||||
];
|
||||
try {
|
||||
$actions[] = [
|
||||
'url' => $this->_storeManager->getStore()->getBaseUrl()
|
||||
. 'mpblog/post/preview?id=' . $row->getPostId() . '&historyId=' . $row->getId(),
|
||||
'popup' => true,
|
||||
'caption' => __('Preview'),
|
||||
];
|
||||
} catch (Exception $exception) {
|
||||
$actions[] = [];
|
||||
}
|
||||
$actions[] = [
|
||||
'url' =>
|
||||
$this->getUrl('*/history/restore', [
|
||||
'id' => $row->getId(),
|
||||
'post_id' => $row->getPostId()
|
||||
]),
|
||||
'popup' => false,
|
||||
'caption' => __('Restore'),
|
||||
'confirm' => 'Are you sure you want to do this?'
|
||||
];
|
||||
|
||||
$actions[] = [
|
||||
'url' =>
|
||||
$this->getUrl('*/history/delete', [
|
||||
'id' => $row->getId(),
|
||||
'post_id' => $row->getPostId()
|
||||
]),
|
||||
'popup' => false,
|
||||
'caption' => __('Delete'),
|
||||
'confirm' => 'Are you sure you want to do this?'
|
||||
];
|
||||
|
||||
$this->getColumn()->setActions($actions);
|
||||
|
||||
return parent::render($row);
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer\History;
|
||||
|
||||
use Magento\Backend\Block\Context;
|
||||
use Magento\Backend\Block\Widget\Grid\Column\Renderer\Text;
|
||||
use Magento\Framework\DataObject;
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
|
||||
/**
|
||||
* Class Action
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer
|
||||
*/
|
||||
class Author extends Text
|
||||
{
|
||||
/**
|
||||
* @var Data
|
||||
*/
|
||||
protected $_helperData;
|
||||
|
||||
/**
|
||||
* Categories constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param Data $_helperData
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Data $_helperData,
|
||||
array $data = []
|
||||
) {
|
||||
$this->_helperData = $_helperData;
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DataObject $row
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render(DataObject $row)
|
||||
{
|
||||
if (!empty($row->getData($this->getColumn()->getIndex()))) {
|
||||
$userId = $row->getData($this->getColumn()->getIndex());
|
||||
$author = $this->_helperData->getFactoryByType('author')->create()->load($userId);
|
||||
$row->setData($this->getColumn()->getIndex(), $author->getName());
|
||||
}
|
||||
|
||||
return parent::render($row);
|
||||
}
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer\History;
|
||||
|
||||
use Magento\Backend\Block\Context;
|
||||
use Magento\Backend\Block\Widget\Grid\Column\Renderer\Text;
|
||||
use Magento\Framework\DataObject;
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
|
||||
/**
|
||||
* Class Action
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer
|
||||
*/
|
||||
class Categories extends Text
|
||||
{
|
||||
/**
|
||||
* @var Data
|
||||
*/
|
||||
protected $_helperData;
|
||||
|
||||
/**
|
||||
* Categories constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param Data $_helperData
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Data $_helperData,
|
||||
array $data = []
|
||||
) {
|
||||
$this->_helperData = $_helperData;
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DataObject $row
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render(DataObject $row)
|
||||
{
|
||||
if (!empty($row->getData($this->getColumn()->getIndex()))) {
|
||||
$text = '';
|
||||
$CategoryIds = explode(',', $row->getData($this->getColumn()->getIndex()) ?? '');
|
||||
foreach ($CategoryIds as $categoryId) {
|
||||
$category = $this->_helperData->getFactoryByType('category')->create()->load($categoryId);
|
||||
$text .= $category->getName() . ',';
|
||||
}
|
||||
$row->setData($this->getColumn()->getIndex(), trim($text, ','));
|
||||
}
|
||||
|
||||
return parent::render($row);
|
||||
}
|
||||
}
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_LayeredNavigationUltimate
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer\History;
|
||||
|
||||
use Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer;
|
||||
use Magento\Framework\DataObject;
|
||||
use Magento\Framework\Escaper;
|
||||
use Magento\Store\Model\System\Store as SystemStore;
|
||||
|
||||
/**
|
||||
* Class Name
|
||||
* @package Mageplaza\LayeredNavigationUltimate\Block\Adminhtml\Grid\Renderer
|
||||
*/
|
||||
class Store extends AbstractRenderer
|
||||
{
|
||||
/**
|
||||
* @var Escaper
|
||||
*/
|
||||
protected $escaper;
|
||||
|
||||
/**
|
||||
* System store
|
||||
*
|
||||
* @var SystemStore
|
||||
*/
|
||||
protected $systemStore;
|
||||
|
||||
/**
|
||||
* Store constructor.
|
||||
*
|
||||
* @param SystemStore $systemStore
|
||||
* @param Escaper $escaper
|
||||
*/
|
||||
public function __construct(
|
||||
SystemStore $systemStore,
|
||||
Escaper $escaper
|
||||
) {
|
||||
$this->systemStore = $systemStore;
|
||||
$this->escaper = $escaper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders grid column
|
||||
*
|
||||
* @param DataObject $row
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render(DataObject $row)
|
||||
{
|
||||
if ($row) {
|
||||
$store = '';
|
||||
$store .= $this->prepareItem($row->getData());
|
||||
|
||||
return $store;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $item
|
||||
* @return \Magento\Framework\Phrase|string
|
||||
*/
|
||||
protected function prepareItem(array $item)
|
||||
{
|
||||
$content = '';
|
||||
$origStores = [];
|
||||
$items = explode(",", $item['store_ids']);
|
||||
|
||||
foreach ($items as $storeId) {
|
||||
$origStores[] = $storeId;
|
||||
}
|
||||
|
||||
if (in_array(0, $origStores)) {
|
||||
return __('All Store Views');
|
||||
}
|
||||
|
||||
$data = $this->systemStore->getStoresStructure(false, $origStores);
|
||||
foreach ($data as $website) {
|
||||
$content .= "<b>" . $website['label'] . "</b><br/>";
|
||||
foreach ($website['children'] as $group) {
|
||||
$content .= str_repeat(' ', 3) . "<b>" . $this->escaper->escapeHtml($group['label']) . "</b><br/>";
|
||||
foreach ($group['children'] as $store) {
|
||||
$content .= str_repeat(' ', 6) . $this->escaper->escapeHtml($store['label']) . "<br/>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer\History;
|
||||
|
||||
use Magento\Backend\Block\Context;
|
||||
use Magento\Backend\Block\Widget\Grid\Column\Renderer\Text;
|
||||
use Magento\Framework\DataObject;
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
|
||||
/**
|
||||
* Class Action
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer
|
||||
*/
|
||||
class Tags extends Text
|
||||
{
|
||||
/**
|
||||
* @var Data
|
||||
*/
|
||||
protected $_helperData;
|
||||
|
||||
/**
|
||||
* Categories constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param Data $_helperData
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Data $_helperData,
|
||||
array $data = []
|
||||
) {
|
||||
$this->_helperData = $_helperData;
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DataObject $row
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render(DataObject $row)
|
||||
{
|
||||
if (!empty($row->getData($this->getColumn()->getIndex()))) {
|
||||
$text = '';
|
||||
$tagIds = explode(',', $row->getData($this->getColumn()->getIndex()));
|
||||
foreach ($tagIds as $tagId) {
|
||||
$tag = $this->_helperData->getFactoryByType('tag')->create()->load($tagId);
|
||||
$text .= $tag->getName() . ',';
|
||||
}
|
||||
$row->setData($this->getColumn()->getIndex(), trim($text, ','));
|
||||
}
|
||||
|
||||
return parent::render($row);
|
||||
}
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer\History;
|
||||
|
||||
use Magento\Backend\Block\Context;
|
||||
use Magento\Backend\Block\Widget\Grid\Column\Renderer\Text;
|
||||
use Magento\Framework\DataObject;
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
|
||||
/**
|
||||
* Class Action
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer
|
||||
*/
|
||||
class Topics extends Text
|
||||
{
|
||||
/**
|
||||
* @var Data
|
||||
*/
|
||||
protected $_helperData;
|
||||
|
||||
/**
|
||||
* Categories constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param Data $_helperData
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Data $_helperData,
|
||||
array $data = []
|
||||
) {
|
||||
$this->_helperData = $_helperData;
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DataObject $row
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render(DataObject $row)
|
||||
{
|
||||
if (!empty($row->getData($this->getColumn()->getIndex()))) {
|
||||
$text = '';
|
||||
$topicIds = explode(',', $row->getData($this->getColumn()->getIndex()));
|
||||
foreach ($topicIds as $topicId) {
|
||||
$topic = $this->_helperData->getFactoryByType('topic')->create()->load($topicId);
|
||||
$text .= $topic->getName() . ',';
|
||||
}
|
||||
$row->setData($this->getColumn()->getIndex(), trim($text, ','));
|
||||
}
|
||||
|
||||
return parent::render($row);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,274 @@
|
||||
<?php
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer;
|
||||
|
||||
use Magento\Framework\AuthorizationInterface;
|
||||
use Magento\Framework\Data\Form\Element\CollectionFactory;
|
||||
use Magento\Framework\Data\Form\Element\Factory;
|
||||
use Magento\Framework\Data\Form\Element\Multiselect;
|
||||
use Magento\Framework\Escaper;
|
||||
use Magento\Framework\UrlInterface;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Tag\Collection;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Tag\CollectionFactory as BlogTagCollectionFactory;
|
||||
|
||||
/**
|
||||
* Class Tag
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer
|
||||
*/
|
||||
class Tag extends Multiselect
|
||||
{
|
||||
/**
|
||||
* @var BlogTagCollectionFactory
|
||||
*/
|
||||
public $collectionFactory;
|
||||
|
||||
/**
|
||||
* Authorization
|
||||
*
|
||||
* @var AuthorizationInterface
|
||||
*/
|
||||
public $authorization;
|
||||
|
||||
/**
|
||||
* @var UrlInterface
|
||||
*/
|
||||
protected $_urlBuilder;
|
||||
|
||||
/**
|
||||
* Tag constructor.
|
||||
*
|
||||
* @param Factory $factoryElement
|
||||
* @param CollectionFactory $factoryCollection
|
||||
* @param Escaper $escaper
|
||||
* @param BlogTagCollectionFactory $collectionFactory
|
||||
* @param AuthorizationInterface $authorization
|
||||
* @param UrlInterface $urlBuilder
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Factory $factoryElement,
|
||||
CollectionFactory $factoryCollection,
|
||||
Escaper $escaper,
|
||||
BlogTagCollectionFactory $collectionFactory,
|
||||
AuthorizationInterface $authorization,
|
||||
UrlInterface $urlBuilder,
|
||||
array $data = []
|
||||
) {
|
||||
$this->collectionFactory = $collectionFactory;
|
||||
$this->authorization = $authorization;
|
||||
$this->_urlBuilder = $urlBuilder;
|
||||
|
||||
parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getElementHtml()
|
||||
{
|
||||
$html = '<div class="admin__field-control admin__control-grouped">';
|
||||
$html .= '<div id="blog-tag-select" class="admin__field" data-bind="scope:\'blogTag\'" data-index="index">';
|
||||
$html .= '<!-- ko foreach: elems() -->';
|
||||
$html .= '<input name="post[tags_ids]" data-bind="value: value" style="display: none"/>';
|
||||
$html .= '<!-- ko template: elementTmpl --><!-- /ko -->';
|
||||
$html .= '<!-- /ko -->';
|
||||
$html .= '</div>';
|
||||
|
||||
$html .= '<div class="admin__field admin__field-group-additional admin__field-small"'
|
||||
. 'data-bind="scope:\'create_tag_button\'">';
|
||||
$html .= '<div class="admin__field-control">';
|
||||
$html .= '<!-- ko template: elementTmpl --><!-- /ko -->';
|
||||
$html .= '</div></div></div>';
|
||||
|
||||
$html .= '<!-- ko scope: \'create_tag_modal\' --><!-- ko template: getTemplate() --><!-- /ko --><!-- /ko -->';
|
||||
|
||||
$html .= $this->getAfterElementHtml();
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get no display
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getNoDisplay()
|
||||
{
|
||||
$isNotAllowed = !$this->authorization->isAllowed('Mageplaza_Blog::tag');
|
||||
|
||||
return $this->getData('no_display') || $isNotAllowed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTagsCollection()
|
||||
{
|
||||
/* @var $collection Collection */
|
||||
$collection = $this->collectionFactory->create();
|
||||
$tagById = [];
|
||||
foreach ($collection as $tag) {
|
||||
$tagById[$tag->getId()]['value'] = $tag->getId();
|
||||
$tagById[$tag->getId()]['is_active'] = 1;
|
||||
$tagById[$tag->getId()]['label'] = $tag->getName();
|
||||
}
|
||||
|
||||
return $tagById;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get values for select
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getValues()
|
||||
{
|
||||
$values = $this->getValue();
|
||||
|
||||
if (!is_array($values)) {
|
||||
$values = explode(',', $values);
|
||||
}
|
||||
|
||||
if (!count($values)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
/* @var $collection Collection */
|
||||
$collection = $this->collectionFactory->create()
|
||||
->addIdFilter($values);
|
||||
|
||||
$options = [];
|
||||
foreach ($collection as $tag) {
|
||||
$options[] = $tag->getId();
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach Blog Tag suggest widget initialization
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAfterElementHtml()
|
||||
{
|
||||
$html = '<script type="text/x-magento-init">
|
||||
{
|
||||
"*": {
|
||||
"Magento_Ui/js/core/app": {
|
||||
"components": {
|
||||
"blogTag": {
|
||||
"component": "uiComponent",
|
||||
"children": {
|
||||
"blog_select_tag": {
|
||||
"component": "Mageplaza_Blog/js/components/new-category",
|
||||
"config": {
|
||||
"filterOptions": true,
|
||||
"disableLabel": true,
|
||||
"chipsEnabled": true,
|
||||
"levelsVisibility": "1",
|
||||
"elementTmpl": "ui/grid/filters/elements/ui-select",
|
||||
"options": ' . json_encode($this->getTagsCollection()) . ',
|
||||
"value": ' . json_encode($this->getValues()) . ',
|
||||
"listens": {
|
||||
"index=create_tag:responseData": "setParsed",
|
||||
"newOption": "toggleOptionSelected"
|
||||
},
|
||||
"config": {
|
||||
"dataScope": "blog_select_tag",
|
||||
"sortOrder": 10
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"create_tag_button": {
|
||||
"title": "' . __('New Tag') . '",
|
||||
"formElement": "container",
|
||||
"additionalClasses": "admin__field-small",
|
||||
"componentType": "container",
|
||||
"component": "Magento_Ui/js/form/components/button",
|
||||
"template": "ui/form/components/button/container",
|
||||
"actions": [
|
||||
{
|
||||
"targetName": "create_tag_modal",
|
||||
"actionName": "toggleModal"
|
||||
},
|
||||
{
|
||||
"targetName": "create_tag_modal.create_tag",
|
||||
"actionName": "render"
|
||||
},
|
||||
{
|
||||
"targetName": "create_tag_modal.create_tag",
|
||||
"actionName": "resetForm"
|
||||
}
|
||||
],
|
||||
"additionalForGroup": true,
|
||||
"provider": false,
|
||||
"source": "product_details",
|
||||
"displayArea": "insideGroup"
|
||||
},
|
||||
"create_tag_modal": {
|
||||
"config": {
|
||||
"isTemplate": false,
|
||||
"componentType": "container",
|
||||
"component": "Magento_Ui/js/modal/modal-component",
|
||||
"options": {
|
||||
"title": "' . __('New Tag') . '",
|
||||
"type": "slide"
|
||||
},
|
||||
"imports": {
|
||||
"state": "!index=create_tag:responseStatus"
|
||||
}
|
||||
},
|
||||
"children": {
|
||||
"create_tag": {
|
||||
"label": "",
|
||||
"componentType": "container",
|
||||
"component": "Magento_Ui/js/form/components/insert-form",
|
||||
"dataScope": "",
|
||||
"update_url": "' . $this->_urlBuilder->getUrl('mui/index/render') . '",
|
||||
"render_url": "' .
|
||||
$this->_urlBuilder->getUrl(
|
||||
'mui/index/render_handle',
|
||||
[
|
||||
'handle' => 'mageplaza_blog_tag_create',
|
||||
'buttons' => 1
|
||||
]
|
||||
) . '",
|
||||
"autoRender": false,
|
||||
"ns": "blog_new_tag_form",
|
||||
"externalProvider": "blog_new_tag_form.new_tag_form_data_source",
|
||||
"toolbarContainer": "${ $.parentName }",
|
||||
"formSubmitType": "ajax"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,274 @@
|
||||
<?php
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer;
|
||||
|
||||
use Magento\Framework\AuthorizationInterface;
|
||||
use Magento\Framework\Data\Form\Element\CollectionFactory;
|
||||
use Magento\Framework\Data\Form\Element\Factory;
|
||||
use Magento\Framework\Data\Form\Element\Multiselect;
|
||||
use Magento\Framework\Escaper;
|
||||
use Magento\Framework\UrlInterface;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Topic\Collection;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Topic\CollectionFactory as BlogTopicCollectionFactory;
|
||||
|
||||
/**
|
||||
* Class Topic
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer
|
||||
*/
|
||||
class Topic extends Multiselect
|
||||
{
|
||||
/**
|
||||
* @var BlogTopicCollectionFactory
|
||||
*/
|
||||
public $collectionFactory;
|
||||
|
||||
/**
|
||||
* Authorization
|
||||
*
|
||||
* @var AuthorizationInterface
|
||||
*/
|
||||
public $authorization;
|
||||
|
||||
/**
|
||||
* @var UrlInterface
|
||||
*/
|
||||
protected $_urlBuilder;
|
||||
|
||||
/**
|
||||
* Topic constructor.
|
||||
*
|
||||
* @param Factory $factoryElement
|
||||
* @param CollectionFactory $factoryCollection
|
||||
* @param Escaper $escaper
|
||||
* @param BlogTopicCollectionFactory $collectionFactory
|
||||
* @param AuthorizationInterface $authorization
|
||||
* @param UrlInterface $urlBuilder
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Factory $factoryElement,
|
||||
CollectionFactory $factoryCollection,
|
||||
Escaper $escaper,
|
||||
BlogTopicCollectionFactory $collectionFactory,
|
||||
AuthorizationInterface $authorization,
|
||||
UrlInterface $urlBuilder,
|
||||
array $data = []
|
||||
) {
|
||||
$this->collectionFactory = $collectionFactory;
|
||||
$this->authorization = $authorization;
|
||||
$this->_urlBuilder = $urlBuilder;
|
||||
|
||||
parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getElementHtml()
|
||||
{
|
||||
$html = '<div class="admin__field-control admin__control-grouped">';
|
||||
$html .= '<div id="blog-topic-select" class="admin__field" data-bind="scope:\'blogTopic\'" data-index="index">';
|
||||
$html .= '<!-- ko foreach: elems() -->';
|
||||
$html .= '<input name="post[topics_ids]" data-bind="value: value" style="display: none"/>';
|
||||
$html .= '<!-- ko template: elementTmpl --><!-- /ko -->';
|
||||
$html .= '<!-- /ko -->';
|
||||
$html .= '</div>';
|
||||
|
||||
$html .= '<div class="admin__field admin__field-group-additional admin__field-small"'
|
||||
. ' data-bind="scope:\'create_topic_button\'">';
|
||||
$html .= '<div class="admin__field-control">';
|
||||
$html .= '<!-- ko template: elementTmpl --><!-- /ko -->';
|
||||
$html .= '</div></div></div>';
|
||||
|
||||
$html .= '<!-- ko scope: \'create_topic_modal\' --><!-- ko template: getTemplate() --><!-- /ko --><!-- /ko -->';
|
||||
|
||||
$html .= $this->getAfterElementHtml();
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get no display
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getNoDisplay()
|
||||
{
|
||||
$isNotAllowed = !$this->authorization->isAllowed('Mageplaza_Blog::topic');
|
||||
|
||||
return $this->getData('no_display') || $isNotAllowed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTopicsCollection()
|
||||
{
|
||||
/* @var $collection Collection */
|
||||
$collection = $this->collectionFactory->create();
|
||||
$topicById = [];
|
||||
foreach ($collection as $topic) {
|
||||
$topicById[$topic->getId()]['value'] = $topic->getId();
|
||||
$topicById[$topic->getId()]['is_active'] = 1;
|
||||
$topicById[$topic->getId()]['label'] = $topic->getName();
|
||||
}
|
||||
|
||||
return $topicById;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get values for select
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getValues()
|
||||
{
|
||||
$values = $this->getValue();
|
||||
|
||||
if (!is_array($values)) {
|
||||
$values = explode(',', $values);
|
||||
}
|
||||
|
||||
if (!count($values)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
/* @var $collection Collection */
|
||||
$collection = $this->collectionFactory->create()
|
||||
->addIdFilter($values);
|
||||
|
||||
$options = [];
|
||||
foreach ($collection as $topic) {
|
||||
$options[] = $topic->getId();
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach Blog Topic suggest widget initialization
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAfterElementHtml()
|
||||
{
|
||||
$html = '<script type="text/x-magento-init">
|
||||
{
|
||||
"*": {
|
||||
"Magento_Ui/js/core/app": {
|
||||
"components": {
|
||||
"blogTopic": {
|
||||
"component": "uiComponent",
|
||||
"children": {
|
||||
"blog_select_topic": {
|
||||
"component": "Mageplaza_Blog/js/components/new-category",
|
||||
"config": {
|
||||
"filterOptions": true,
|
||||
"disableLabel": true,
|
||||
"chipsEnabled": true,
|
||||
"levelsVisibility": "1",
|
||||
"elementTmpl": "ui/grid/filters/elements/ui-select",
|
||||
"options": ' . json_encode($this->getTopicsCollection()) . ',
|
||||
"value": ' . json_encode($this->getValues()) . ',
|
||||
"listens": {
|
||||
"index=create_topic:responseData": "setParsed",
|
||||
"newOption": "toggleOptionSelected"
|
||||
},
|
||||
"config": {
|
||||
"dataScope": "blog_select_topic",
|
||||
"sortOrder": 10
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"create_topic_button": {
|
||||
"title": "' . __('New Topic') . '",
|
||||
"formElement": "container",
|
||||
"additionalClasses": "admin__field-small",
|
||||
"componentType": "container",
|
||||
"component": "Magento_Ui/js/form/components/button",
|
||||
"template": "ui/form/components/button/container",
|
||||
"actions": [
|
||||
{
|
||||
"targetName": "create_topic_modal",
|
||||
"actionName": "toggleModal"
|
||||
},
|
||||
{
|
||||
"targetName": "create_topic_modal.create_topic",
|
||||
"actionName": "render"
|
||||
},
|
||||
{
|
||||
"targetName": "create_topic_modal.create_topic",
|
||||
"actionName": "resetForm"
|
||||
}
|
||||
],
|
||||
"additionalForGroup": true,
|
||||
"provider": false,
|
||||
"source": "product_details",
|
||||
"displayArea": "insideGroup"
|
||||
},
|
||||
"create_topic_modal": {
|
||||
"config": {
|
||||
"isTemplate": false,
|
||||
"componentType": "container",
|
||||
"component": "Magento_Ui/js/modal/modal-component",
|
||||
"options": {
|
||||
"title": "' . __('New Topic') . '",
|
||||
"type": "slide"
|
||||
},
|
||||
"imports": {
|
||||
"state": "!index=create_topic:responseStatus"
|
||||
}
|
||||
},
|
||||
"children": {
|
||||
"create_topic": {
|
||||
"label": "",
|
||||
"componentType": "container",
|
||||
"component": "Magento_Ui/js/form/components/insert-form",
|
||||
"dataScope": "",
|
||||
"update_url": "' . $this->_urlBuilder->getUrl('mui/index/render') . '",
|
||||
"render_url": "' .
|
||||
$this->_urlBuilder->getUrl(
|
||||
'mui/index/render_handle',
|
||||
[
|
||||
'handle' => 'mageplaza_blog_topic_create',
|
||||
'buttons' => 1
|
||||
]
|
||||
) . '",
|
||||
"autoRender": false,
|
||||
"ns": "blog_new_topic_form",
|
||||
"externalProvider": "blog_new_topic_form.new_topic_form_data_source",
|
||||
"toolbarContainer": "${ $.parentName }",
|
||||
"formSubmitType": "ajax"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Mageplaza\Blog\Block\Adminhtml\Post\Edit;
|
||||
|
||||
/**
|
||||
* Class Tabs
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Post\Edit
|
||||
*/
|
||||
class Tabs extends \Magento\Backend\Block\Widget\Tabs
|
||||
{
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
parent::_construct();
|
||||
|
||||
$this->setId('post_tabs');
|
||||
$this->setDestElementId('edit_form');
|
||||
$this->setTitle(__('Post Information'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user