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_Form extends Mage_Adminhtml_Block_Widget_Form
36: {
37: 38: 39: 40:
41: public function __construct()
42: {
43: parent::__construct();
44: }
45:
46: 47: 48: 49: 50:
51: public function getModel()
52: {
53: return Mage::registry('_current_template');
54: }
55:
56: 57: 58: 59: 60:
61: protected function _prepareForm()
62: {
63: $model = $this->getModel();
64: $identity = Mage::getStoreConfig(Mage_Newsletter_Model_Subscriber::XML_PATH_UNSUBSCRIBE_EMAIL_IDENTITY);
65: $identityName = Mage::getStoreConfig('trans_email/ident_'.$identity.'/name');
66: $identityEmail = Mage::getStoreConfig('trans_email/ident_'.$identity.'/email');
67:
68: $form = new Varien_Data_Form(array(
69: 'id' => 'edit_form',
70: 'action' => $this->getData('action'),
71: 'method' => 'post'
72: ));
73:
74: $fieldset = $form->addFieldset('base_fieldset', array(
75: 'legend' => Mage::helper('newsletter')->__('Template Information'),
76: 'class' => 'fieldset-wide'
77: ));
78:
79: if ($model->getId()) {
80: $fieldset->addField('id', 'hidden', array(
81: 'name' => 'id',
82: 'value' => $model->getId(),
83: ));
84: }
85:
86: $fieldset->addField('code', 'text', array(
87: 'name' => 'code',
88: 'label' => Mage::helper('newsletter')->__('Template Name'),
89: 'title' => Mage::helper('newsletter')->__('Template Name'),
90: 'required' => true,
91: 'value' => $model->getTemplateCode(),
92: ));
93:
94: $fieldset->addField('subject', 'text', array(
95: 'name' => 'subject',
96: 'label' => Mage::helper('newsletter')->__('Template Subject'),
97: 'title' => Mage::helper('newsletter')->__('Template Subject'),
98: 'required' => true,
99: 'value' => $model->getTemplateSubject(),
100: ));
101:
102: $fieldset->addField('sender_name', 'text', array(
103: 'name' =>'sender_name',
104: 'label' => Mage::helper('newsletter')->__('Sender Name'),
105: 'title' => Mage::helper('newsletter')->__('Sender Name'),
106: 'required' => true,
107: 'value' => $model->getId() !== null
108: ? $model->getTemplateSenderName()
109: : $identityName,
110: ));
111:
112: $fieldset->addField('sender_email', 'text', array(
113: 'name' =>'sender_email',
114: 'label' => Mage::helper('newsletter')->__('Sender Email'),
115: 'title' => Mage::helper('newsletter')->__('Sender Email'),
116: 'class' => 'validate-email',
117: 'required' => true,
118: 'value' => $model->getId() !== null
119: ? $model->getTemplateSenderEmail()
120: : $identityEmail
121: ));
122:
123:
124: $widgetFilters = array('is_email_compatible' => 1);
125: $wysiwygConfig = Mage::getSingleton('cms/wysiwyg_config')->getConfig(array('widget_filters' => $widgetFilters));
126: if ($model->isPlain()) {
127: $wysiwygConfig->setEnabled(false);
128: }
129: $fieldset->addField('text', 'editor', array(
130: 'name' => 'text',
131: 'label' => Mage::helper('newsletter')->__('Template Content'),
132: 'title' => Mage::helper('newsletter')->__('Template Content'),
133: 'required' => true,
134: 'state' => 'html',
135: 'style' => 'height:36em;',
136: 'value' => $model->getTemplateText(),
137: 'config' => $wysiwygConfig
138: ));
139:
140: if (!$model->isPlain()) {
141: $fieldset->addField('template_styles', 'textarea', array(
142: 'name' =>'styles',
143: 'label' => Mage::helper('newsletter')->__('Template Styles'),
144: 'container_id' => 'field_template_styles',
145: 'value' => $model->getTemplateStyles()
146: ));
147: }
148:
149: $form->setAction($this->getUrl('*/*/save'));
150: $form->setUseContainer(true);
151: $this->setForm($form);
152:
153: return parent::_prepareForm();
154: }
155: }
156: