_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(); } }