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_Newsletter_Template_Edit extends Mage_Adminhtml_Block_Widget
00036 {
00037
00038
00039
00040
00041
00042 protected $_editMode = false;
00043
00044
00045
00046
00047
00048 public function __construct()
00049 {
00050 parent::__construct();
00051 $this->setTemplate('newsletter/template/edit.phtml');
00052 }
00053
00054
00055
00056
00057
00058
00059 public function getModel()
00060 {
00061 return Mage::registry('_current_template');
00062 }
00063
00064
00065
00066
00067
00068
00069 protected function _prepareLayout()
00070 {
00071 $this->setChild('back_button',
00072 $this->getLayout()->createBlock('adminhtml/widget_button')
00073 ->setData(array(
00074 'label' => Mage::helper('newsletter')->__('Back'),
00075 'onclick' => "window.location.href = '" . $this->getUrl('*/*') . "'",
00076 'class' => 'back'
00077 ))
00078 );
00079
00080 $this->setChild('reset_button',
00081 $this->getLayout()->createBlock('adminhtml/widget_button')
00082 ->setData(array(
00083 'label' => Mage::helper('newsletter')->__('Reset'),
00084 'onclick' => 'window.location.href = window.location.href'
00085 ))
00086 );
00087
00088 $this->setChild('to_plain_button',
00089 $this->getLayout()->createBlock('adminhtml/widget_button')
00090 ->setData(array(
00091 'label' => Mage::helper('newsletter')->__('Convert to Plain Text'),
00092 'onclick' => 'templateControl.stripTags();',
00093 'id' => 'convert_button',
00094 'class' => 'task'
00095 ))
00096 );
00097
00098 $this->setChild('to_html_button',
00099 $this->getLayout()->createBlock('adminhtml/widget_button')
00100 ->setData(array(
00101 'label' => Mage::helper('newsletter')->__('Return Html Version'),
00102 'onclick' => 'templateControl.unStripTags();',
00103 'id' => 'convert_button_back',
00104 'style' => 'display:none',
00105 'class' => 'task'
00106 ))
00107 );
00108
00109 $this->setChild('toggle_button',
00110 $this->getLayout()->createBlock('adminhtml/widget_button')
00111 ->setData(array(
00112 'label' => Mage::helper('newsletter')->__('Toggle Editor'),
00113 'onclick' => 'templateControl.toggleEditor();',
00114 'id' => 'toggle_button',
00115 'class' => 'task'
00116 ))
00117 );
00118
00119 $this->setChild('save_button',
00120 $this->getLayout()->createBlock('adminhtml/widget_button')
00121 ->setData(array(
00122 'label' => Mage::helper('newsletter')->__('Save Template'),
00123 'onclick' => 'templateControl.save();',
00124 'class' => 'save'
00125 ))
00126 );
00127
00128 $this->setChild('save_as_button',
00129 $this->getLayout()->createBlock('adminhtml/widget_button')
00130 ->setData(array(
00131 'label' => Mage::helper('newsletter')->__('Save As'),
00132 'onclick' => 'templateControl.saveAs();',
00133 'class' => 'save'
00134 ))
00135 );
00136
00137 $this->setChild('preview_button',
00138 $this->getLayout()->createBlock('adminhtml/widget_button')
00139 ->setData(array(
00140 'label' => Mage::helper('newsletter')->__('Preview Template'),
00141 'onclick' => 'templateControl.preview();',
00142 'class' => 'task'
00143 ))
00144 );
00145
00146 $this->setChild('delete_button',
00147 $this->getLayout()->createBlock('adminhtml/widget_button')
00148 ->setData(array(
00149 'label' => Mage::helper('newsletter')->__('Delete Template'),
00150 'onclick' => 'templateControl.deleteTemplate();',
00151 'class' => 'delete'
00152 ))
00153 );
00154
00155 return parent::_prepareLayout();
00156 }
00157
00158
00159
00160
00161
00162
00163 public function getBackButtonHtml()
00164 {
00165 return $this->getChildHtml('back_button');
00166 }
00167
00168
00169
00170
00171
00172
00173 public function getToggleButtonHtml()
00174 {
00175 return $this->getChildHtml('toggle_button');
00176 }
00177
00178
00179
00180
00181
00182
00183 public function getResetButtonHtml()
00184 {
00185 return $this->getChildHtml('reset_button');
00186 }
00187
00188
00189
00190
00191
00192
00193 public function getToPlainButtonHtml()
00194 {
00195 return $this->getChildHtml('to_plain_button');
00196 }
00197
00198
00199
00200
00201
00202
00203 public function getToHtmlButtonHtml()
00204 {
00205 return $this->getChildHtml('to_html_button');
00206 }
00207
00208
00209
00210
00211
00212
00213 public function getSaveButtonHtml()
00214 {
00215 return $this->getChildHtml('save_button');
00216 }
00217
00218
00219
00220
00221
00222
00223 public function getPreviewButtonHtml()
00224 {
00225 return $this->getChildHtml('preview_button');
00226 }
00227
00228
00229
00230
00231
00232
00233 public function getDeleteButtonHtml()
00234 {
00235 return $this->getChildHtml('delete_button');
00236 }
00237
00238
00239
00240
00241
00242
00243 public function getSaveAsButtonHtml()
00244 {
00245 return $this->getChildHtml('save_as_button');
00246 }
00247
00248
00249
00250
00251
00252
00253
00254 public function setEditMode($value = true)
00255 {
00256 $this->_editMode = (bool)$value;
00257 return $this;
00258 }
00259
00260
00261
00262
00263
00264
00265 public function getEditMode()
00266 {
00267 return $this->_editMode;
00268 }
00269
00270
00271
00272
00273
00274
00275 public function getHeaderText()
00276 {
00277 if ($this->getEditMode()) {
00278 return Mage::helper('newsletter')->__('Edit Newsletter Template');
00279 }
00280
00281 return Mage::helper('newsletter')->__('New Newsletter Template');
00282 }
00283
00284
00285
00286
00287
00288
00289 public function getForm()
00290 {
00291 return $this->getLayout()
00292 ->createBlock('adminhtml/newsletter_template_edit_form')
00293 ->toHtml();
00294 }
00295
00296
00297
00298
00299
00300
00301 public function getJsTemplateName()
00302 {
00303 return addcslashes($this->getModel()->getTemplateCode(), "\"\r\n\\");
00304 }
00305
00306
00307
00308
00309
00310
00311 public function getSaveUrl()
00312 {
00313 return $this->getUrl('*/*/save');
00314 }
00315
00316
00317
00318
00319
00320
00321 public function getPreviewUrl()
00322 {
00323 return $this->getUrl('*/*/preview');
00324 }
00325
00326
00327
00328
00329
00330
00331 public function isTextType()
00332 {
00333 return $this->getModel()->isPlain();
00334 }
00335
00336
00337
00338
00339
00340
00341 public function getDeleteUrl()
00342 {
00343 return $this->getUrl('*/*/delete', array('id' => $this->getRequest()->getParam('id')));
00344 }
00345
00346
00347
00348
00349
00350
00351 public function getSaveAsFlag()
00352 {
00353 return $this->getRequest()->getParam('_save_as_flag') ? '1' : '';
00354 }
00355 }