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_Queue_Edit extends Mage_Adminhtml_Block_Template
36: {
37: 38: 39: 40:
41: protected function _construct()
42: {
43: parent::_construct();
44: $templateId = $this->getRequest()->getParam('template_id');
45: if ($templateId) {
46: $this->setTemplateId($templateId);
47: }
48: }
49:
50: 51: 52: 53: 54:
55: public function getQueue()
56: {
57: return Mage::registry('current_queue');
58: }
59:
60: protected function _beforeToHtml() {
61:
62: $this->setTemplate('newsletter/queue/edit.phtml');
63:
64: $this->setChild('form',
65: $this->getLayout()->createBlock('adminhtml/newsletter_queue_edit_form','form')
66: );
67:
68: return parent::_beforeToHtml();
69: }
70:
71: public function getSaveUrl()
72: {
73: if ($this->getTemplateId()) {
74: $params = array('template_id' => $this->getTemplateId());
75: } else {
76: $params = array('id' => $this->getRequest()->getParam('id'));
77: }
78: return $this->getUrl('*/*/save', $params);
79: }
80:
81: protected function _prepareLayout()
82: {
83:
84: if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
85: $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
86: }
87:
88: $this->setChild('preview_button',
89: $this->getLayout()->createBlock('adminhtml/widget_button')
90: ->setData(array(
91: 'label' => Mage::helper('newsletter')->__('Preview Template'),
92: 'onclick' => 'queueControl.preview();',
93: 'class' => 'task'
94: ))
95: );
96:
97: $this->setChild('save_button',
98: $this->getLayout()->createBlock('adminhtml/widget_button')
99: ->setData(array(
100: 'label' => Mage::helper('newsletter')->__('Save Newsletter'),
101: 'onclick' => 'queueControl.save()',
102: 'class' => 'save'
103: ))
104: );
105:
106: $this->setChild('save_and_resume',
107: $this->getLayout()->createBlock('adminhtml/widget_button')
108: ->setData(array(
109: 'label' => Mage::helper('newsletter')->__('Save and Resume'),
110: 'onclick' => 'queueControl.resume()',
111: 'class' => 'save'
112: ))
113: );
114:
115: $this->setChild('reset_button',
116: $this->getLayout()->createBlock('adminhtml/widget_button')
117: ->setData(array(
118: 'label' => Mage::helper('newsletter')->__('Reset'),
119: 'onclick' => 'window.location = window.location'
120: ))
121: );
122:
123: $this->setChild('back_button',
124: $this->getLayout()->createBlock('adminhtml/widget_button')
125: ->setData(
126: array(
127: 'label' => Mage::helper('newsletter')->__('Back'),
128: 'onclick' => "window.location.href = '" . $this->getUrl((
129: $this->getTemplateId() ? '*/newsletter_template/' : '*/*')) . "'",
130: 'class' => 'back'
131: )
132: )
133: );
134:
135: return parent::_prepareLayout();
136: }
137:
138: 139: 140: 141: 142:
143: public function getPreviewUrl()
144: {
145: return $this->getUrl('*/*/preview');
146: }
147:
148: 149: 150: 151: 152:
153: public function getPreviewButtonHtml()
154: {
155: return $this->getChildHtml('preview_button');
156: }
157:
158: 159: 160: 161: 162:
163: public function getSaveButtonHtml()
164: {
165: return $this->getChildHtml('save_button');
166: }
167:
168: 169: 170: 171: 172:
173: public function getResetButtonHtml()
174: {
175: return $this->getChildHtml('reset_button');
176: }
177:
178: 179: 180: 181: 182:
183: public function getBackButtonHtml()
184: {
185: return $this->getChildHtml('back_button');
186: }
187:
188: 189: 190: 191: 192:
193: public function getResumeButtonHtml()
194: {
195: return $this->getChildHtml('save_and_resume');
196: }
197:
198: 199: 200: 201: 202:
203: public function getIsPreview()
204: {
205: return !in_array($this->getQueue()->getQueueStatus(), array(
206: Mage_Newsletter_Model_Queue::STATUS_NEVER,
207: Mage_Newsletter_Model_Queue::STATUS_PAUSE
208: ));
209: }
210:
211: 212: 213: 214: 215:
216: protected function isSingleStoreMode()
217: {
218: return Mage::app()->isSingleStoreMode();
219: }
220:
221: 222: 223: 224: 225:
226: protected function getStoreId()
227: {
228: return Mage::app()->getStore(true)->getId();
229: }
230:
231: 232: 233: 234: 235:
236: public function getIsTextType()
237: {
238: return $this->getQueue()->isPlain();
239: }
240:
241: 242: 243: 244: 245:
246: public function getCanResume()
247: {
248: return in_array($this->getQueue()->getQueueStatus(), array(
249: Mage_Newsletter_Model_Queue::STATUS_PAUSE
250: ));
251: }
252:
253: 254: 255: 256: 257:
258: public function ()
259: {
260: return ( $this->getIsPreview() ? Mage::helper('newsletter')->__('View Newsletter') : Mage::helper('newsletter')->__('Edit Newsletter'));
261: }
262: }
263: