123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <?php
- /**
- * Copyright © 2016 Ihor Vansach (ihor@magefan.com). All rights reserved.
- * See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
- *
- * Glory to Ukraine! Glory to the heroes!
- */
- namespace Magefan\Blog\Block\Adminhtml\Post;
- /**
- * Admin blog post
- */
- class Edit extends \Magento\Backend\Block\Widget\Form\Container
- {
- /**
- * Core registry
- *
- * @var \Magento\Framework\Registry
- */
- protected $_coreRegistry = null;
- /**
- * @param \Magento\Backend\Block\Widget\Context $context
- * @param \Magento\Framework\Registry $registry
- * @param array $data
- */
- public function __construct(
- \Magento\Backend\Block\Widget\Context $context,
- \Magento\Framework\Registry $registry,
- array $data = []
- ) {
- $this->_coreRegistry = $registry;
- parent::__construct($context, $data);
- }
- /**
- * Initialize cms page edit block
- *
- * @return void
- */
- protected function _construct()
- {
- $this->_objectId = 'id';
- $this->_blockGroup = 'Magefan_Blog';
- $this->_controller = 'adminhtml_post';
- parent::_construct();
- if ($this->_isAllowedAction('Magefan_Blog::post')) {
- $this->buttonList->add(
- 'saveandcontinue',
- [
- 'label' => __('Save and Continue Edit'),
- 'class' => 'save',
- 'data_attribute' => [
- 'mage-init' => [
- 'button' => ['event' => 'saveAndContinueEdit', 'target' => '#edit_form'],
- ],
- ]
- ],
- -100
- );
- } else {
- $this->buttonList->remove('save');
- }
- if (!$this->_isAllowedAction('Magefan_Blog::post')) {
- $this->buttonList->remove('delete');
- }
- }
- /**
- * Check permission for passed action
- *
- * @param string $resourceId
- * @return bool
- */
- protected function _isAllowedAction($resourceId)
- {
- return $this->_authorization->isAllowed($resourceId);
- }
- /**
- * Getter of url for "Save and Continue" button
- * tab_id will be replaced by desired by JS later
- *
- * @return string
- */
- protected function _getSaveAndContinueUrl()
- {
- return $this->getUrl('*/*/save', ['_current' => true, 'back' => 'edit', 'active_tab' => '{{tab_id}}']);
- }
- /**
- * Prepare layout
- *
- * @return \Magento\Framework\View\Element\AbstractBlock
- */
- protected function _prepareLayout()
- {
- $this->_formScripts[] = "
- function toggleEditor() {
- if (tinyMCE.getInstanceById('post_content') == null) {
- tinyMCE.execCommand('mceAddControl', false, 'post_content');
- } else {
- tinyMCE.execCommand('mceRemoveControl', false, 'post_content');
- }
- };
- ";
- return parent::_prepareLayout();
- }
- }
|