00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class Mage_Adminhtml_Block_System_Email_Template_Edit extends Mage_Adminhtml_Block_Widget
00036 {
00037
00038
00039 public function __construct()
00040 {
00041 parent::__construct();
00042 $this->setTemplate('system/email/template/edit.phtml');
00043 Mage::register('email_template', Mage::getModel('core/email_template'));
00044 if ($templateId = (int) $this->getRequest()->getParam('id')) {
00045 $this->getEmailTemplate()->load($templateId);
00046 }
00047 }
00048
00049 protected function _prepareLayout()
00050 {
00051 $this->setChild('back_button',
00052 $this->getLayout()->createBlock('adminhtml/widget_button')
00053 ->setData(
00054 array(
00055 'label' => Mage::helper('adminhtml')->__('Back'),
00056 'onclick' => "window.location.href = '" . $this->getUrl('*/*') . "'",
00057 'class' => 'back'
00058 )
00059 )
00060 );
00061
00062
00063 $this->setChild('reset_button',
00064 $this->getLayout()->createBlock('adminhtml/widget_button')
00065 ->setData(
00066 array(
00067 'label' => Mage::helper('adminhtml')->__('Reset'),
00068 'onclick' => 'window.location.href = window.location.href'
00069 )
00070 )
00071 );
00072
00073
00074 $this->setChild('delete_button',
00075 $this->getLayout()->createBlock('adminhtml/widget_button')
00076 ->setData(
00077 array(
00078 'label' => Mage::helper('adminhtml')->__('Delete Template'),
00079 'onclick' => 'templateControl.deleteTemplate();',
00080 'class' => 'delete'
00081 )
00082 )
00083 );
00084
00085 $this->setChild('to_plain_button',
00086 $this->getLayout()->createBlock('adminhtml/widget_button')
00087 ->setData(
00088 array(
00089 'label' => Mage::helper('adminhtml')->__('Convert to Plain Text'),
00090 'onclick' => 'templateControl.stripTags();',
00091 'id' => 'convert_button'
00092 )
00093 )
00094 );
00095
00096
00097 $this->setChild('to_html_button',
00098 $this->getLayout()->createBlock('adminhtml/widget_button')
00099 ->setData(
00100 array(
00101 'label' => Mage::helper('adminhtml')->__('Return Html Version'),
00102 'onclick' => 'templateControl.unStripTags();',
00103 'id' => 'convert_button_back',
00104 'style' => 'display:none'
00105 )
00106 )
00107 );
00108
00109 $this->setChild('toggle_button',
00110 $this->getLayout()->createBlock('adminhtml/widget_button')
00111 ->setData(
00112 array(
00113 'label' => Mage::helper('adminhtml')->__('Toggle Editor'),
00114 'onclick' => 'templateControl.toggleEditor();',
00115 'id' => 'toggle_button'
00116 )
00117 )
00118 );
00119
00120
00121 $this->setChild('preview_button',
00122 $this->getLayout()->createBlock('adminhtml/widget_button')
00123 ->setData(
00124 array(
00125 'label' => Mage::helper('adminhtml')->__('Preview Template'),
00126 'onclick' => 'templateControl.preview();'
00127 )
00128 )
00129 );
00130
00131 $this->setChild('save_button',
00132 $this->getLayout()->createBlock('adminhtml/widget_button')
00133 ->setData(
00134 array(
00135 'label' => Mage::helper('adminhtml')->__('Save Template'),
00136 'onclick' => 'templateControl.save();',
00137 'class' => 'save'
00138 )
00139 )
00140 );
00141
00142 $this->setChild('load_button',
00143 $this->getLayout()->createBlock('adminhtml/widget_button')
00144 ->setData(
00145 array(
00146 'label' => Mage::helper('adminhtml')->__('Load Template'),
00147 'onclick' => 'templateControl.load();',
00148 'type' => 'button',
00149 'class' => 'save'
00150 )
00151 )
00152 );
00153
00154
00155 $this->setChild('form',
00156 $this->getLayout()->createBlock('adminhtml/system_email_template_edit_form')
00157 );
00158 return parent::_prepareLayout();
00159 }
00160
00161 public function getBackButtonHtml()
00162 {
00163 return $this->getChildHtml('back_button');
00164 }
00165
00166 public function getToggleButtonHtml()
00167 {
00168 return $this->getChildHtml('toggle_button');
00169 }
00170
00171
00172 public function getResetButtonHtml()
00173 {
00174 return $this->getChildHtml('reset_button');
00175 }
00176
00177 public function getToPlainButtonHtml()
00178 {
00179 return $this->getChildHtml('to_plain_button');
00180 }
00181
00182 public function getToHtmlButtonHtml()
00183 {
00184 return $this->getChildHtml('to_html_button');
00185 }
00186
00187 public function getSaveButtonHtml()
00188 {
00189 return $this->getChildHtml('save_button');
00190 }
00191
00192 public function getPreviewButtonHtml()
00193 {
00194 return $this->getChildHtml('preview_button');
00195 }
00196
00197 public function getDeleteButtonHtml()
00198 {
00199 return $this->getChildHtml('delete_button');
00200 }
00201
00202 public function getLoadButtonHtml()
00203 {
00204 return $this->getChildHtml('load_button');
00205 }
00206
00207
00208
00209
00210
00211
00212 public function getEditMode()
00213 {
00214 return $this->getEmailTemplate()->getId();
00215 }
00216
00217
00218
00219
00220
00221
00222 public function getHeaderText()
00223 {
00224 if($this->getEditMode()) {
00225 return Mage::helper('adminhtml')->__('Edit Email Template');
00226 }
00227
00228 return Mage::helper('adminhtml')->__('New Email Template');
00229 }
00230
00231
00232
00233
00234
00235
00236
00237 public function getFormHtml()
00238 {
00239 return $this->getChildHtml('form');
00240 }
00241
00242
00243
00244
00245
00246
00247 public function getSaveUrl()
00248 {
00249 return $this->getUrl('*/*/save', array('_current' => true));
00250 }
00251
00252
00253
00254
00255
00256
00257 public function getPreviewUrl()
00258 {
00259 return $this->getUrl('*/*/preview');
00260 }
00261
00262 public function isTextType()
00263 {
00264 return $this->getEmailTemplate()->isPlain();
00265 }
00266
00267
00268
00269
00270
00271
00272 public function getDeleteUrl()
00273 {
00274 return $this->getUrl('*/*/delete', array('_current' => true));
00275 }
00276
00277
00278
00279
00280
00281
00282 public function getEmailTemplate()
00283 {
00284 return Mage::registry('email_template');
00285 }
00286
00287 public function getLocaleOptions()
00288 {
00289 return Mage::app()->getLocale()->getOptionLocales();
00290 }
00291
00292 public function getTemplateOptions()
00293 {
00294 return Mage_Core_Model_Email_Template::getDefaultTemplatesAsOptionsArray();
00295 }
00296
00297 public function getCurrentLocale()
00298 {
00299 return Mage::app()->getLocale()->getLocaleCode();
00300 }
00301
00302
00303
00304
00305
00306
00307 public function getLoadUrl()
00308 {
00309 return $this->getUrl('*/*/defaultTemplate');
00310 }
00311 }