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_XmlConnect_Block_Adminhtml_Template_Edit_Form
35: extends Mage_XmlConnect_Block_Adminhtml_Mobile_Widget_Form
36: {
37: 38: 39: 40: 41:
42: protected $_fieldsEnabled = true;
43:
44: 45: 46: 47: 48:
49: protected $_dependentFields = array();
50:
51: 52: 53:
54: protected function _prepareLayout()
55: {
56: parent::_prepareLayout();
57: if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
58: $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
59: }
60: }
61:
62: 63: 64: 65: 66:
67: protected function _prepareForm()
68: {
69: $model = Mage::registry('current_template');
70:
71: if (!$model) {
72: $model = new Varien_Object();
73: }
74:
75: $action = $this->getUrl('*/*/saveTemplate');
76:
77: $form = new Varien_Data_Form(array(
78: 'id' => 'edit_form',
79: 'action' => $action,
80: 'method' => 'post',
81: 'enctype' => 'multipart/form-data'
82: ));
83: $form->setHtmlIdPrefix('template_');
84:
85: $fieldset = $form->addFieldset('edit_template', array('legend' => $this->__('Template')));
86: $this->_addElementTypes($fieldset);
87:
88: if ($model->getId()) {
89: $fieldset->addField('id', 'hidden', array(
90: 'name' => 'id',
91: ));
92: $fieldset->addField('template_id', 'hidden', array(
93: 'name' => 'template_id',
94: ));
95: }
96:
97: $fieldset->addField('application_id', 'select', array(
98: 'name' => 'application_id',
99: 'label' => $this->__('Application'),
100: 'title' => $this->__('Application'),
101: 'disabled' => $model->getId() || !$this->_fieldsEnabled ? true : false,
102: 'values' => Mage::helper('xmlconnect')->getApplicationOptions(),
103: 'note' => $this->__('Creating a Template is allowed only for applications which have device type iPhone.'),
104: 'required' => true,
105: ));
106:
107: $fieldset->addField('name', 'text', array(
108: 'name' => 'name',
109: 'label' => $this->__('Template Name'),
110: 'title' => $this->__('Template Name'),
111: 'required' => true,
112: 'disabled' => $model->getId() || !$this->_fieldsEnabled ? true : false,
113: 'note' => $this->__('Maximum length is 255'),
114: 'maxlength' => 255
115: ));
116:
117: $fieldset->addField('push_title', 'text', array(
118: 'name' => 'push_title',
119: 'label' => $this->__('Push Title'),
120: 'title' => $this->__('Push Title'),
121: 'required' => true,
122: 'disabled' => !$this->_fieldsEnabled ? true : false,
123: 'note' => $this->__('Maximum length is 140'),
124: 'maxlength' => 140
125: ));
126:
127: $this->_dependentFields['message_title'] = $fieldset->addField('message_title', 'text', array(
128: 'name' => 'message_title',
129: 'label' => $this->__('Message Title'),
130: 'title' => $this->__('Message Title'),
131: 'required' => true,
132: 'disabled' => !$this->_fieldsEnabled ? true : false,
133: 'note' => $this->__('Maximum length is 255'),
134: 'maxlength' => 255
135: ));
136:
137: $widgetFilters = array('is_email_compatible' => 1);
138: $wysiwygConfig = Mage::getSingleton('cms/wysiwyg_config')->getConfig(array(
139:
140:
141: 'widget_filters' => $widgetFilters
142: ));
143:
144: $this->_dependentFields['content'] = $fieldset->addField('content', 'editor', array(
145: 'label' => $this->__('Template Content'),
146: 'title' => $this->__('Template Content'),
147: 'name' => 'content',
148: 'style' => 'height:30em;',
149: 'state' => 'html',
150: 'required' => true,
151: 'disabled' => !$this->_fieldsEnabled ? true : false,
152: 'config' => $wysiwygConfig
153: ));
154:
155: $form->setValues($model->getData());
156: $form->setUseContainer(true);
157: $this->setForm($form);
158: return parent::_prepareForm();
159: }
160: }
161: