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 class Mage_Adminhtml_Block_Newsletter_Template_Preview extends Mage_Adminhtml_Block_Widget
00035 {
00036
00037 protected function _toHtml()
00038 {
00039 $template = Mage::getModel('newsletter/template');
00040 if($id = (int)$this->getRequest()->getParam('id')) {
00041 $template->load($id);
00042 } else {
00043 $template->setTemplateType($this->getRequest()->getParam('type'));
00044 $template->setTemplateText($this->getRequest()->getParam('text'));
00045 }
00046
00047 Varien_Profiler::start("email_template_proccessing");
00048 $vars = array();
00049
00050 if($this->getRequest()->getParam('subscriber')) {
00051 $vars['subscriber'] = Mage::getModel('newsletter/subscriber')
00052 ->load($this->getRequest()->getParam('subscriber'));
00053 }
00054
00055 $templateProcessed = $template->getProcessedTemplate($vars, true);
00056
00057 if($template->isPlain()) {
00058 $templateProcessed = "<pre>" . htmlspecialchars($templateProcessed) . "</pre>";
00059 }
00060
00061 Varien_Profiler::stop("email_template_proccessing");
00062
00063 return $templateProcessed;
00064 }
00065
00066 }