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_Page_Edit_Tab_Main
36: extends Mage_Adminhtml_Block_Widget_Form
37: implements Mage_Adminhtml_Block_Widget_Tab_Interface
38: {
39: protected function _prepareForm()
40: {
41:
42: $model = Mage::registry('cms_page');
43:
44: 45: 46:
47: if ($this->_isAllowedAction('save')) {
48: $isElementDisabled = false;
49: } else {
50: $isElementDisabled = true;
51: }
52:
53:
54: $form = new Varien_Data_Form();
55:
56: $form->setHtmlIdPrefix('page_');
57:
58: $fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('cms')->__('Page Information')));
59:
60: if ($model->getPageId()) {
61: $fieldset->addField('page_id', 'hidden', array(
62: 'name' => 'page_id',
63: ));
64: }
65:
66: $fieldset->addField('title', 'text', array(
67: 'name' => 'title',
68: 'label' => Mage::helper('cms')->__('Page Title'),
69: 'title' => Mage::helper('cms')->__('Page Title'),
70: 'required' => true,
71: 'disabled' => $isElementDisabled
72: ));
73:
74: $fieldset->addField('identifier', 'text', array(
75: 'name' => 'identifier',
76: 'label' => Mage::helper('cms')->__('URL Key'),
77: 'title' => Mage::helper('cms')->__('URL Key'),
78: 'required' => true,
79: 'class' => 'validate-identifier',
80: 'note' => Mage::helper('cms')->__('Relative to Website Base URL'),
81: 'disabled' => $isElementDisabled
82: ));
83:
84: 85: 86:
87: if (!Mage::app()->isSingleStoreMode()) {
88: $field = $fieldset->addField('store_id', 'multiselect', array(
89: 'name' => 'stores[]',
90: 'label' => Mage::helper('cms')->__('Store View'),
91: 'title' => Mage::helper('cms')->__('Store View'),
92: 'required' => true,
93: 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
94: 'disabled' => $isElementDisabled,
95: ));
96: $renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
97: $field->setRenderer($renderer);
98: }
99: else {
100: $fieldset->addField('store_id', 'hidden', array(
101: 'name' => 'stores[]',
102: 'value' => Mage::app()->getStore(true)->getId()
103: ));
104: $model->setStoreId(Mage::app()->getStore(true)->getId());
105: }
106:
107: $fieldset->addField('is_active', 'select', array(
108: 'label' => Mage::helper('cms')->__('Status'),
109: 'title' => Mage::helper('cms')->__('Page Status'),
110: 'name' => 'is_active',
111: 'required' => true,
112: 'options' => $model->getAvailableStatuses(),
113: 'disabled' => $isElementDisabled,
114: ));
115: if (!$model->getId()) {
116: $model->setData('is_active', $isElementDisabled ? '0' : '1');
117: }
118:
119: Mage::dispatchEvent('adminhtml_cms_page_edit_tab_main_prepare_form', array('form' => $form));
120:
121: $form->setValues($model->getData());
122: $this->setForm($form);
123:
124: return parent::_prepareForm();
125: }
126:
127: 128: 129: 130: 131:
132: public function getTabLabel()
133: {
134: return Mage::helper('cms')->__('Page Information');
135: }
136:
137: 138: 139: 140: 141:
142: public function getTabTitle()
143: {
144: return Mage::helper('cms')->__('Page Information');
145: }
146:
147: 148: 149: 150: 151:
152: public function canShowTab()
153: {
154: return true;
155: }
156:
157: 158: 159: 160: 161:
162: public function isHidden()
163: {
164: return false;
165: }
166:
167: 168: 169: 170: 171: 172:
173: protected function _isAllowedAction($action)
174: {
175: return Mage::getSingleton('admin/session')->isAllowed('cms/page/' . $action);
176: }
177: }
178: