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_Widget_Block_Adminhtml_Widget_Instance_Edit_Tab_Main
35: extends Mage_Adminhtml_Block_Widget_Form
36: implements Mage_Adminhtml_Block_Widget_Tab_Interface
37: {
38: 39: 40: 41:
42: protected function _construct()
43: {
44: parent::_construct();
45: $this->setActive(true);
46: }
47:
48: 49: 50: 51: 52:
53: public function getTabLabel()
54: {
55: return Mage::helper('widget')->__('Frontend Properties');
56: }
57:
58: 59: 60: 61: 62:
63: public function getTabTitle()
64: {
65: return Mage::helper('widget')->__('Frontend Properties');
66: }
67:
68: 69: 70: 71: 72:
73: public function canShowTab()
74: {
75: return $this->getWidgetInstance()->isCompleteToCreate();
76: }
77:
78: 79: 80: 81: 82:
83: public function isHidden()
84: {
85: return false;
86: }
87:
88: 89: 90: 91: 92:
93: public function getWidgetInstance()
94: {
95: return Mage::registry('current_widget_instance');
96: }
97:
98: 99: 100: 101: 102:
103: protected function _prepareForm()
104: {
105: $widgetInstance = $this->getWidgetInstance();
106: $form = new Varien_Data_Form(array(
107: 'id' => 'edit_form',
108: 'action' => $this->getData('action'),
109: 'method' => 'post'
110: ));
111:
112: $fieldset = $form->addFieldset('base_fieldset',
113: array('legend' => Mage::helper('widget')->__('Frontend Properties'))
114: );
115:
116: if ($widgetInstance->getId()) {
117: $fieldset->addField('instance_id', 'hidden', array(
118: 'name' => 'isntance_id',
119: ));
120: }
121:
122: $this->_addElementTypes($fieldset);
123:
124: $fieldset->addField('type', 'select', array(
125: 'name' => 'type',
126: 'label' => Mage::helper('widget')->__('Type'),
127: 'title' => Mage::helper('widget')->__('Type'),
128: 'class' => '',
129: 'values' => $this->getTypesOptionsArray(),
130: 'disabled' => true
131: ));
132:
133: $fieldset->addField('package_theme', 'select', array(
134: 'name' => 'package_theme',
135: 'label' => Mage::helper('widget')->__('Design Package/Theme'),
136: 'title' => Mage::helper('widget')->__('Design Package/Theme'),
137: 'required' => false,
138: 'values' => $this->getPackegeThemeOptionsArray(),
139: 'disabled' => true
140: ));
141:
142: $fieldset->addField('title', 'text', array(
143: 'name' => 'title',
144: 'label' => Mage::helper('widget')->__('Widget Instance Title'),
145: 'title' => Mage::helper('widget')->__('Widget Instance Title'),
146: 'class' => '',
147: 'required' => true,
148: ));
149:
150: if (!Mage::app()->isSingleStoreMode()) {
151: $field = $fieldset->addField('store_ids', 'multiselect', array(
152: 'name' => 'store_ids[]',
153: 'label' => Mage::helper('widget')->__('Assign to Store Views'),
154: 'title' => Mage::helper('widget')->__('Assign to Store Views'),
155: 'required' => true,
156: 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
157: ));
158: $renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
159: $field->setRenderer($renderer);
160: }
161:
162: $fieldset->addField('sort_order', 'text', array(
163: 'name' => 'sort_order',
164: 'label' => Mage::helper('widget')->__('Sort Order'),
165: 'title' => Mage::helper('widget')->__('Sort Order'),
166: 'class' => '',
167: 'required' => false,
168: 'note' => Mage::helper('widget')->__('Sort Order of widget instances in the same block reference')
169: ));
170:
171:
172: $layoutBlock = $this->getLayout()
173: ->createBlock('widget/adminhtml_widget_instance_edit_tab_main_layout')
174: ->setWidgetInstance($widgetInstance);
175: $fieldset = $form->addFieldset('layout_updates_fieldset',
176: array('legend' => Mage::helper('widget')->__('Layout Updates'))
177: );
178: $fieldset->addField('layout_updates', 'note', array(
179: ));
180: $form->getElement('layout_updates_fieldset')->setRenderer($layoutBlock);
181: $this->setForm($form);
182:
183: return parent::_prepareForm();
184: }
185:
186: 187: 188: 189: 190:
191: public function getTypesOptionsArray()
192: {
193: return $this->getWidgetInstance()->getWidgetsOptionArray();
194: }
195:
196: 197: 198: 199: 200:
201: public function getPackegeThemeOptionsArray()
202: {
203: return Mage::getModel('core/design_source_design')
204: ->setIsFullLabel(true)->getAllOptions(true);
205: }
206:
207: 208: 209: 210: 211:
212: protected function _initFormValues()
213: {
214: $this->getForm()->addValues($this->getWidgetInstance()->getData());
215: return parent::_initFormValues();
216: }
217: }
218: