1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27:
28: 29: 30: 31: 32: 33: 34:
35: class Mage_Adminhtml_Block_Newsletter_Template_Edit extends Mage_Adminhtml_Block_Widget
36: {
37: 38: 39: 40: 41:
42: protected $_editMode = false;
43:
44: 45: 46: 47: 48:
49: public function getModel()
50: {
51: return Mage::registry('_current_template');
52: }
53:
54: 55: 56: 57: 58:
59: protected function _prepareLayout()
60: {
61:
62: if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled() && ($block = $this->getLayout()->getBlock('head'))) {
63: $block->setCanLoadTinyMce(true);
64: }
65:
66: $this->setChild('back_button',
67: $this->getLayout()->createBlock('adminhtml/widget_button')
68: ->setData(array(
69: 'label' => Mage::helper('newsletter')->__('Back'),
70: 'onclick' => "window.location.href = '" . $this->getUrl('*/*') . "'",
71: 'class' => 'back'
72: ))
73: );
74:
75: $this->setChild('reset_button',
76: $this->getLayout()->createBlock('adminhtml/widget_button')
77: ->setData(array(
78: 'label' => Mage::helper('newsletter')->__('Reset'),
79: 'onclick' => 'window.location.href = window.location.href'
80: ))
81: );
82:
83: $this->setChild('to_plain_button',
84: $this->getLayout()->createBlock('adminhtml/widget_button')
85: ->setData(array(
86: 'label' => Mage::helper('newsletter')->__('Convert to Plain Text'),
87: 'onclick' => 'templateControl.stripTags();',
88: 'id' => 'convert_button',
89: 'class' => 'task'
90: ))
91: );
92:
93: $this->setChild('to_html_button',
94: $this->getLayout()->createBlock('adminhtml/widget_button')
95: ->setData(array(
96: 'label' => Mage::helper('newsletter')->__('Return HTML Version'),
97: 'onclick' => 'templateControl.unStripTags();',
98: 'id' => 'convert_button_back',
99: 'style' => 'display:none',
100: 'class' => 'task'
101: ))
102: );
103:
104: $this->setChild('save_button',
105: $this->getLayout()->createBlock('adminhtml/widget_button')
106: ->setData(array(
107: 'label' => Mage::helper('newsletter')->__('Save Template'),
108: 'onclick' => 'templateControl.save();',
109: 'class' => 'save'
110: ))
111: );
112:
113: $this->setChild('save_as_button',
114: $this->getLayout()->createBlock('adminhtml/widget_button')
115: ->setData(array(
116: 'label' => Mage::helper('newsletter')->__('Save As'),
117: 'onclick' => 'templateControl.saveAs();',
118: 'class' => 'save'
119: ))
120: );
121:
122: $this->setChild('preview_button',
123: $this->getLayout()->createBlock('adminhtml/widget_button')
124: ->setData(array(
125: 'label' => Mage::helper('newsletter')->__('Preview Template'),
126: 'onclick' => 'templateControl.preview();',
127: 'class' => 'task'
128: ))
129: );
130:
131: $this->setChild('delete_button',
132: $this->getLayout()->createBlock('adminhtml/widget_button')
133: ->setData(array(
134: 'label' => Mage::helper('newsletter')->__('Delete Template'),
135: 'onclick' => 'templateControl.deleteTemplate();',
136: 'class' => 'delete'
137: ))
138: );
139:
140: return parent::_prepareLayout();
141: }
142:
143: 144: 145: 146: 147:
148: public function getBackButtonHtml()
149: {
150: return $this->getChildHtml('back_button');
151: }
152:
153: 154: 155: 156: 157:
158: public function getResetButtonHtml()
159: {
160: return $this->getChildHtml('reset_button');
161: }
162:
163: 164: 165: 166: 167:
168: public function getToPlainButtonHtml()
169: {
170: return $this->getChildHtml('to_plain_button');
171: }
172:
173: 174: 175: 176: 177:
178: public function getToHtmlButtonHtml()
179: {
180: return $this->getChildHtml('to_html_button');
181: }
182:
183: 184: 185: 186: 187:
188: public function getSaveButtonHtml()
189: {
190: return $this->getChildHtml('save_button');
191: }
192:
193: 194: 195: 196: 197:
198: public function getPreviewButtonHtml()
199: {
200: return $this->getChildHtml('preview_button');
201: }
202:
203: 204: 205: 206: 207:
208: public function getDeleteButtonHtml()
209: {
210: return $this->getChildHtml('delete_button');
211: }
212:
213: 214: 215: 216: 217:
218: public function getSaveAsButtonHtml()
219: {
220: return $this->getChildHtml('save_as_button');
221: }
222:
223: 224: 225: 226: 227: 228:
229: public function setEditMode($value = true)
230: {
231: $this->_editMode = (bool)$value;
232: return $this;
233: }
234:
235: 236: 237: 238: 239:
240: public function getEditMode()
241: {
242: return $this->_editMode;
243: }
244:
245: 246: 247: 248: 249:
250: public function ()
251: {
252: if ($this->getEditMode()) {
253: return Mage::helper('newsletter')->__('Edit Newsletter Template');
254: }
255:
256: return Mage::helper('newsletter')->__('New Newsletter Template');
257: }
258:
259: 260: 261: 262: 263:
264: public function getForm()
265: {
266: return $this->getLayout()
267: ->createBlock('adminhtml/newsletter_template_edit_form')
268: ->toHtml();
269: }
270:
271: 272: 273: 274: 275:
276: public function getJsTemplateName()
277: {
278: return addcslashes($this->getModel()->getTemplateCode(), "\"\r\n\\");
279: }
280:
281: 282: 283: 284: 285:
286: public function getSaveUrl()
287: {
288: return $this->getUrl('*/*/save');
289: }
290:
291: 292: 293: 294: 295:
296: public function getPreviewUrl()
297: {
298: return $this->getUrl('*/*/preview');
299: }
300:
301: 302: 303: 304: 305:
306: public function isTextType()
307: {
308: return $this->getModel()->isPlain();
309: }
310:
311: 312: 313: 314: 315:
316: public function getDeleteUrl()
317: {
318: return $this->getUrl('*/*/delete', array('id' => $this->getRequest()->getParam('id')));
319: }
320:
321: 322: 323: 324: 325:
326: public function getSaveAsFlag()
327: {
328: return $this->getRequest()->getParam('_save_as_flag') ? '1' : '';
329: }
330:
331: 332: 333: 334: 335:
336: protected function isSingleStoreMode()
337: {
338: return Mage::app()->isSingleStoreMode();
339: }
340:
341: 342: 343: 344: 345:
346: protected function getStoreId()
347: {
348: return Mage::app()->getStore(true)->getId();
349: }
350: }
351: