Your IP : 127.0.0.1
<?php
namespace Makarovsoft\Email\Block\Adminhtml\Template;
use Magento\Backend\Block\Widget\Form\Container as FormContainer;
use Magento\Backend\Block\Widget\Context;
use Magento\Framework\Registry;
class Edit extends FormContainer
{
/**
* Core registry
*
* @var \Magento\Framework\Registry
*/
protected $coreRegistry = null;
/**
* constructor
*
* @param Context $context
* @param Registry $registry
* @param array $data
*/
public function __construct(
Context $context,
Registry $registry,
array $data = []
)
{
$this->coreRegistry = $registry;
parent::__construct($context, $data);
}
/**
* Initialize template edit block
*
* @return void
*/
protected function _construct()
{
$this->_objectId = 'template_id';
$this->_blockGroup = 'Makarovsoft_Email';
$this->_controller = 'adminhtml_template';
parent::_construct();
$this->buttonList->update('save', 'label', __('Save Template'));
$this->buttonList->add(
'save-and-continue',
[
'label' => __('Save and Continue Edit'),
'class' => 'save',
'data_attribute' => [
'mage-init' => [
'button' => [
'event' => 'saveAndContinueEdit',
'target' => '#edit_form'
]
]
]
],
-100
);
$this->buttonList->update('delete', 'label', __('Delete Template'));
}
/**
* Retrieve text for header element depending on loaded template
*
* @return string
*/
public function getHeaderText()
{
/** @var \Makarovsoft\Email\Model\Template $template */
$template = $this->coreRegistry->registry('makarovsoft_email_template');
if ($template->getId()) {
return __("Edit Template '%1'", $this->escapeHtml($template->getName()));
}
return __('New Template');
}
/**
* Prepare layout
*
* @return \Magento\Framework\View\Element\AbstractBlock
*/
protected function _prepareLayout()
{
$this->_formScripts[] = "
function toggleEditor() {
if (tinyMCE.getInstanceById('template_content') == null) {
tinyMCE.execCommand('mceAddControl', false, 'template_content');
} else {
tinyMCE.execCommand('mceRemoveControl', false, 'template_content');
}
};
";
return parent::_prepareLayout();
}
}