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: class Mage_Adminhtml_Block_Cms_Page_Edit_Tab_Design
27: extends Mage_Adminhtml_Block_Widget_Form
28: implements Mage_Adminhtml_Block_Widget_Tab_Interface
29: {
30: public function __construct()
31: {
32: parent::__construct();
33: $this->setShowGlobalIcon(true);
34: }
35:
36: protected function _prepareForm()
37: {
38: 39: 40:
41: if ($this->_isAllowedAction('save')) {
42: $isElementDisabled = false;
43: } else {
44: $isElementDisabled = true;
45: }
46:
47: $form = new Varien_Data_Form();
48:
49: $form->setHtmlIdPrefix('page_');
50:
51: $model = Mage::registry('cms_page');
52:
53: $layoutFieldset = $form->addFieldset('layout_fieldset', array(
54: 'legend' => Mage::helper('cms')->__('Page Layout'),
55: 'class' => 'fieldset-wide',
56: 'disabled' => $isElementDisabled
57: ));
58:
59: $layoutFieldset->addField('root_template', 'select', array(
60: 'name' => 'root_template',
61: 'label' => Mage::helper('cms')->__('Layout'),
62: 'required' => true,
63: 'values' => Mage::getSingleton('page/source_layout')->toOptionArray(),
64: 'disabled' => $isElementDisabled
65: ));
66: if (!$model->getId()) {
67: $model->setRootTemplate(Mage::getSingleton('page/source_layout')->getDefaultValue());
68: }
69:
70: $layoutFieldset->addField('layout_update_xml', 'textarea', array(
71: 'name' => 'layout_update_xml',
72: 'label' => Mage::helper('cms')->__('Layout Update XML'),
73: 'style' => 'height:24em;',
74: 'disabled' => $isElementDisabled
75: ));
76:
77: $designFieldset = $form->addFieldset('design_fieldset', array(
78: 'legend' => Mage::helper('cms')->__('Custom Design'),
79: 'class' => 'fieldset-wide',
80: 'disabled' => $isElementDisabled
81: ));
82:
83: $dateFormatIso = Mage::app()->getLocale()->getDateFormat(
84: Mage_Core_Model_Locale::FORMAT_TYPE_SHORT
85: );
86:
87: $designFieldset->addField('custom_theme_from', 'date', array(
88: 'name' => 'custom_theme_from',
89: 'label' => Mage::helper('cms')->__('Custom Design From'),
90: 'image' => $this->getSkinUrl('images/grid-cal.gif'),
91: 'format' => $dateFormatIso,
92: 'disabled' => $isElementDisabled
93: ));
94:
95: $designFieldset->addField('custom_theme_to', 'date', array(
96: 'name' => 'custom_theme_to',
97: 'label' => Mage::helper('cms')->__('Custom Design To'),
98: 'image' => $this->getSkinUrl('images/grid-cal.gif'),
99: 'format' => $dateFormatIso,
100: 'disabled' => $isElementDisabled
101: ));
102:
103: $designFieldset->addField('custom_theme', 'select', array(
104: 'name' => 'custom_theme',
105: 'label' => Mage::helper('cms')->__('Custom Theme'),
106: 'values' => Mage::getModel('core/design_source_design')->getAllOptions(),
107: 'disabled' => $isElementDisabled
108: ));
109:
110:
111: $designFieldset->addField('custom_root_template', 'select', array(
112: 'name' => 'custom_root_template',
113: 'label' => Mage::helper('cms')->__('Custom Layout'),
114: 'values' => Mage::getSingleton('page/source_layout')->toOptionArray(true),
115: 'disabled' => $isElementDisabled
116: ));
117:
118: $designFieldset->addField('custom_layout_update_xml', 'textarea', array(
119: 'name' => 'custom_layout_update_xml',
120: 'label' => Mage::helper('cms')->__('Custom Layout Update XML'),
121: 'style' => 'height:24em;',
122: 'disabled' => $isElementDisabled
123: ));
124:
125: Mage::dispatchEvent('adminhtml_cms_page_edit_tab_design_prepare_form', array('form' => $form));
126:
127: $form->setValues($model->getData());
128:
129: $this->setForm($form);
130:
131: return parent::_prepareForm();
132: }
133:
134: 135: 136: 137: 138:
139: public function getTabLabel()
140: {
141: return Mage::helper('cms')->__('Design');
142: }
143:
144: 145: 146: 147: 148:
149: public function getTabTitle()
150: {
151: return Mage::helper('cms')->__('Design');
152: }
153:
154: 155: 156: 157: 158:
159: public function canShowTab()
160: {
161: return true;
162: }
163:
164: 165: 166: 167: 168:
169: public function isHidden()
170: {
171: return false;
172: }
173:
174: 175: 176: 177: 178: 179:
180: protected function _isAllowedAction($action)
181: {
182: return Mage::getSingleton('admin/session')->isAllowed('cms/page/' . $action);
183: }
184: }
185: