[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Administrator 5 * @subpackage com_mails 6 * 7 * @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 */ 10 11 namespace Joomla\Component\Mails\Administrator\View\Template; 12 13 use Joomla\CMS\Factory; 14 use Joomla\CMS\Language\Text; 15 use Joomla\CMS\MVC\View\GenericDataException; 16 use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; 17 use Joomla\CMS\Object\CMSObject; 18 use Joomla\CMS\Toolbar\Toolbar; 19 use Joomla\CMS\Toolbar\ToolbarHelper; 20 21 // phpcs:disable PSR1.Files.SideEffects 22 \defined('_JEXEC') or die; 23 // phpcs:enable PSR1.Files.SideEffects 24 25 /** 26 * View to edit a mail template. 27 * 28 * @since 4.0.0 29 */ 30 class HtmlView extends BaseHtmlView 31 { 32 /** 33 * The Form object 34 * 35 * @var \Joomla\CMS\Form\Form 36 */ 37 protected $form; 38 39 /** 40 * The active item 41 * 42 * @var CMSObject 43 */ 44 protected $item; 45 46 /** 47 * The model state 48 * 49 * @var object 50 */ 51 protected $state; 52 53 /** 54 * The template data 55 * 56 * @var array 57 */ 58 protected $templateData; 59 60 /** 61 * Master data for the mail template 62 * 63 * @var CMSObject 64 */ 65 protected $master; 66 67 /** 68 * Execute and display a template script. 69 * 70 * @param string $tpl The name of the template file to parse; automatically searches through the template paths. 71 * 72 * @return void 73 * 74 * @since 4.0.0 75 */ 76 public function display($tpl = null) 77 { 78 $this->state = $this->get('State'); 79 $this->item = $this->get('Item'); 80 $this->master = $this->get('Master'); 81 $this->form = $this->get('Form'); 82 83 // Check for errors. 84 if (count($errors = $this->get('Errors'))) { 85 throw new GenericDataException(implode("\n", $errors), 500); 86 } 87 88 list($component, $template_id) = explode('.', $this->item->template_id, 2); 89 $fields = array('subject', 'body', 'htmlbody'); 90 $this->templateData = array(); 91 $language = Factory::getLanguage(); 92 $language->load($component, JPATH_SITE, $this->item->language, true); 93 $language->load($component, JPATH_SITE . '/components/' . $component, $this->item->language, true); 94 $language->load($component, JPATH_ADMINISTRATOR, $this->item->language, true); 95 $language->load($component, JPATH_ADMINISTRATOR . '/components/' . $component, $this->item->language, true); 96 97 $this->master->subject = Text::_($this->master->subject); 98 $this->master->body = Text::_($this->master->body); 99 100 if ($this->master->htmlbody) { 101 $this->master->htmlbody = Text::_($this->master->htmlbody); 102 } else { 103 $this->master->htmlbody = nl2br($this->master->body, false); 104 } 105 106 $this->templateData = [ 107 'subject' => $this->master->subject, 108 'body' => $this->master->body, 109 'htmlbody' => $this->master->htmlbody, 110 ]; 111 112 foreach ($fields as $field) { 113 if (is_null($this->item->$field) || $this->item->$field == '') { 114 $this->item->$field = $this->master->$field; 115 $this->form->setValue($field, null, $this->item->$field); 116 } 117 } 118 119 $this->addToolbar(); 120 121 parent::display($tpl); 122 } 123 124 /** 125 * Add the page title and toolbar. 126 * 127 * @return void 128 * 129 * @since 4.0.0 130 */ 131 protected function addToolbar() 132 { 133 Factory::getApplication()->input->set('hidemainmenu', true); 134 $toolbar = Toolbar::getInstance(); 135 136 ToolbarHelper::title( 137 Text::_('COM_MAILS_PAGE_EDIT_MAIL'), 138 'pencil-2 article-add' 139 ); 140 141 $saveGroup = $toolbar->dropdownButton('save-group'); 142 143 $saveGroup->configure( 144 function (Toolbar $childBar) { 145 $childBar->apply('template.apply'); 146 $childBar->save('template.save'); 147 } 148 ); 149 150 $toolbar->cancel('template.cancel', 'JTOOLBAR_CLOSE'); 151 152 $toolbar->divider(); 153 $toolbar->help('Mail_Template:_Edit'); 154 } 155 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |