40 private $_emailConfig;
47 protected $_template =
'Magento_Email::template/edit.phtml';
85 \
Magento\Framework\Json\EncoderInterface $jsonEncoder,
87 \
Magento\Backend\Model\Menu\Config $menuConfig,
88 \
Magento\Config\Model\Config\Structure $configStructure,
96 $this->_jsonEncoder = $jsonEncoder;
98 $this->_menuConfig = $menuConfig;
99 $this->_configStructure = $configStructure;
100 $this->_emailConfig = $emailConfig;
103 parent::__construct($context,
$data);
111 $this->buttonList->update($buttonId, $key,
$data);
120 return !
$item->isDeleted();
128 $this->buttonList->remove($buttonId);
140 $this->buttonList->add(
143 'label' =>
__(
'Back'),
144 'onclick' =>
"window.location.href = '" . $this->
getUrl(
'adminhtml/*') .
"'",
148 $this->buttonList->add(
150 [
'label' =>
__(
'Reset'),
'onclick' =>
'window.location.href = window.location.href']
154 $this->buttonList->add(
157 'label' =>
__(
'Delete Template'),
158 'data_attribute' => [
159 'role' =>
'template-delete',
166 $this->buttonList->add(
169 'label' =>
__(
'Convert to Plain Text'),
170 'data_attribute' => [
171 'role' =>
'template-strip',
173 'id' =>
'convert_button' 176 $this->buttonList->add(
179 'label' =>
__(
'Return Html Version'),
180 'data_attribute' => [
181 'role' =>
'template-unstrip',
183 'id' =>
'convert_button_back',
184 'style' =>
'display:none' 188 $this->buttonList->add(
191 'label' =>
__(
'Preview Template'),
192 'data_attribute' => [
193 'role' =>
'template-preview',
197 $this->buttonList->add(
200 'label' =>
__(
'Save Template'),
201 'data_attribute' => [
202 'role' =>
'template-save',
204 'class' =>
'save primary save-template' 207 $this->buttonList->add(
210 'label' =>
__(
'Load Template'),
211 'data_attribute' => [
212 'role' =>
'template-load',
221 $this->toolbar->pushButtons($this, $this->buttonList);
229 return parent::_prepareLayout();
235 public function addButton($buttonId,
$data, $level = 0, $sortOrder = 0, $region =
'toolbar')
237 $this->buttonList->add($buttonId,
$data, $level, $sortOrder, $region);
248 $groupedOptions = [];
252 ksort($groupedOptions);
253 $this->
setData(
'template_options', $groupedOptions);
255 return parent::_beforeToHtml();
266 [[
'value' =>
'',
'label' =>
'',
'group' =>
'']],
267 $this->_emailConfig->getAvailableTemplates()
271 function (array $firstElement, array $secondElement) {
272 return strcmp($firstElement[
'label'], $secondElement[
'label']);
306 return __(
'Edit Email Template');
308 return __(
'New Email Template');
328 return $this->
getUrl(
'adminhtml/*/save', [
'_current' =>
true]);
338 return $this->
getUrl(
'adminhtml/*/preview');
368 return $this->
getUrl(
'adminhtml/*/delete', [
'_current' =>
true]);
378 return $this->
getData(
'email_template');
388 return $this->
getUrl(
'adminhtml/*/defaultTemplate');
397 public function getCurrentlyUsedForPaths($asJSON =
true)
402 $pathsParts = $this->_getSystemConfigPathsParts(
$paths);
404 return $this->_jsonEncoder->encode($pathsParts);
416 protected function _getSystemConfigPathsParts(
$paths)
418 $result = $urlParams = $prefixParts = [];
419 $scopeLabel =
__(
'Default Config');
422 $menu = $this->_menuConfig->getMenu();
423 $item = $menu->get(
'Magento_Backend::stores');
425 $prefixParts[] = [
'title' =>
__(
$item->getTitle())];
426 $item = $menu->get(
'Magento_Config::system_config');
428 'title' =>
__(
$item->getTitle()),
429 'url' => $this->
getUrl(
'adminhtml/system_config/'),
432 $pathParts = $prefixParts;
433 foreach (
$paths as $pathData) {
434 $pathDataParts = explode(
'/', $pathData[
'path']);
435 $sectionName = array_shift($pathDataParts);
437 $urlParams = [
'section' => $sectionName];
438 if (isset($pathData[
'scope']) && isset($pathData[
'scope_id'])) {
439 switch ($pathData[
'scope']) {
441 $store = $this->_storeManager->getStore($pathData[
'scope_id']);
443 $urlParams[
'website'] =
$store->getWebsite()->getCode();
444 $urlParams[
'store'] =
$store->getCode();
445 $scopeLabel =
$store->getWebsite()->getName() .
'/' .
$store->getName();
449 $website = $this->_storeManager->getWebsite($pathData[
'scope_id']);
451 $urlParams[
'website'] =
$website->getCode();
460 'title' => $this->_configStructure->getElement($sectionName)->getLabel(),
461 'url' => $this->
getUrl(
'adminhtml/system_config/edit', $urlParams),
463 $elementPathParts = [$sectionName];
464 while (count($pathDataParts) != 1) {
465 $elementPathParts[] = array_shift($pathDataParts);
467 'title' => $this->_configStructure->getElementByPathParts($elementPathParts)->getLabel(),
470 $elementPathParts[] = array_shift($pathDataParts);
472 'title' => $this->_configStructure->getElementByPathParts($elementPathParts)->getLabel(),
473 'scope' => $scopeLabel,
476 $pathParts = $prefixParts;
_getDefaultTemplatesAsOptionsArray()
getData($key='', $index=null)
__construct(\Magento\Backend\Block\Template\Context $context, \Magento\Framework\Json\EncoderInterface $jsonEncoder, \Magento\Framework\Registry $registry, \Magento\Backend\Model\Menu\Config $menuConfig, \Magento\Config\Model\Config\Structure $configStructure, \Magento\Email\Model\Template\Config $emailConfig, \Magento\Framework\Json\Helper\Data $jsonHelper, \Magento\Backend\Block\Widget\Button\ButtonList $buttonList, \Magento\Backend\Block\Widget\Button\ToolbarInterface $toolbar, array $data=[])
addChild($alias, $block, $data=[])
updateButton($buttonId, $key, $data)
addButton($buttonId, $data, $level=0, $sortOrder=0, $region='toolbar')
getUrl($route='', $params=[])
setData($key, $value=null)
canRender(\Magento\Backend\Block\Widget\Button\Item $item)
getChildHtml($alias='', $useCache=true)