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: class Mage_Adminhtml_Block_Newsletter_Queue_Preview extends Mage_Adminhtml_Block_Widget
35: {
36:
37: protected function _toHtml()
38: {
39:
40: $template = Mage::getModel('newsletter/template');
41:
42: if($id = (int)$this->getRequest()->getParam('id')) {
43: $queue = Mage::getModel('newsletter/queue');
44: $queue->load($id);
45: $template->setTemplateType($queue->getNewsletterType());
46: $template->setTemplateText($queue->getNewsletterText());
47: $template->setTemplateStyles($queue->getNewsletterStyles());
48: } else {
49: $template->setTemplateType($this->getRequest()->getParam('type'));
50: $template->setTemplateText($this->getRequest()->getParam('text'));
51: $template->setTemplateStyles($this->getRequest()->getParam('styles'));
52: }
53:
54:
55: $storeId = (int)$this->getRequest()->getParam('store_id');
56: if(!$storeId) {
57: $storeId = Mage::app()->getDefaultStoreView()->getId();
58: }
59:
60: Varien_Profiler::start("newsletter_queue_proccessing");
61: $vars = array();
62:
63: $vars['subscriber'] = Mage::getModel('newsletter/subscriber');
64:
65: $template->emulateDesign($storeId);
66: $templateProcessed = $template->getProcessedTemplate($vars, true);
67: $template->revertDesign();
68:
69: if($template->isPlain()) {
70: $templateProcessed = "<pre>" . htmlspecialchars($templateProcessed) . "</pre>";
71: }
72:
73: Varien_Profiler::stop("newsletter_queue_proccessing");
74:
75: return $templateProcessed;
76:
77: }
78:
79: }
80: