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_Cms_Block_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
36: {
37:
38: 39: 40:
41: public function __construct()
42: {
43: parent::__construct();
44: $this->setId('block_form');
45: $this->setTitle(Mage::helper('cms')->__('Block Information'));
46: }
47:
48: 49: 50:
51: protected function _prepareLayout()
52: {
53: parent::_prepareLayout();
54: if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
55: $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
56: }
57: }
58:
59: protected function _prepareForm()
60: {
61: $model = Mage::registry('cms_block');
62:
63: $form = new Varien_Data_Form(
64: array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post')
65: );
66:
67: $form->setHtmlIdPrefix('block_');
68:
69: $fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('cms')->__('General Information'), 'class' => 'fieldset-wide'));
70:
71: if ($model->getBlockId()) {
72: $fieldset->addField('block_id', 'hidden', array(
73: 'name' => 'block_id',
74: ));
75: }
76:
77: $fieldset->addField('title', 'text', array(
78: 'name' => 'title',
79: 'label' => Mage::helper('cms')->__('Block Title'),
80: 'title' => Mage::helper('cms')->__('Block Title'),
81: 'required' => true,
82: ));
83:
84: $fieldset->addField('identifier', 'text', array(
85: 'name' => 'identifier',
86: 'label' => Mage::helper('cms')->__('Identifier'),
87: 'title' => Mage::helper('cms')->__('Identifier'),
88: 'required' => true,
89: 'class' => 'validate-xml-identifier',
90: ));
91:
92: 93: 94:
95: if (!Mage::app()->isSingleStoreMode()) {
96: $field =$fieldset->addField('store_id', 'multiselect', array(
97: 'name' => 'stores[]',
98: 'label' => Mage::helper('cms')->__('Store View'),
99: 'title' => Mage::helper('cms')->__('Store View'),
100: 'required' => true,
101: 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
102: ));
103: $renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
104: $field->setRenderer($renderer);
105: }
106: else {
107: $fieldset->addField('store_id', 'hidden', array(
108: 'name' => 'stores[]',
109: 'value' => Mage::app()->getStore(true)->getId()
110: ));
111: $model->setStoreId(Mage::app()->getStore(true)->getId());
112: }
113:
114: $fieldset->addField('is_active', 'select', array(
115: 'label' => Mage::helper('cms')->__('Status'),
116: 'title' => Mage::helper('cms')->__('Status'),
117: 'name' => 'is_active',
118: 'required' => true,
119: 'options' => array(
120: '1' => Mage::helper('cms')->__('Enabled'),
121: '0' => Mage::helper('cms')->__('Disabled'),
122: ),
123: ));
124: if (!$model->getId()) {
125: $model->setData('is_active', '1');
126: }
127:
128: $fieldset->addField('content', 'editor', array(
129: 'name' => 'content',
130: 'label' => Mage::helper('cms')->__('Content'),
131: 'title' => Mage::helper('cms')->__('Content'),
132: 'style' => 'height:36em',
133: 'required' => true,
134: 'config' => Mage::getSingleton('cms/wysiwyg_config')->getConfig()
135: ));
136:
137: $form->setValues($model->getData());
138: $form->setUseContainer(true);
139: $this->setForm($form);
140:
141: return parent::_prepareForm();
142: }
143:
144: }
145: