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_Settings
35: extends Mage_Adminhtml_Block_Widget_Form
36: implements Mage_Adminhtml_Block_Widget_Tab_Interface
37: {
38: protected function _construct()
39: {
40: parent::_construct();
41: $this->setActive(true);
42: }
43:
44: 45: 46: 47: 48:
49: public function getTabLabel()
50: {
51: return Mage::helper('widget')->__('Settings');
52: }
53:
54: 55: 56: 57: 58:
59: public function getTabTitle()
60: {
61: return Mage::helper('widget')->__('Settings');
62: }
63:
64: 65: 66: 67: 68:
69: public function canShowTab()
70: {
71: return !(bool)$this->getWidgetInstance()->isCompleteToCreate();
72: }
73:
74: 75: 76: 77: 78:
79: public function isHidden()
80: {
81: return false;
82: }
83:
84: 85: 86: 87: 88:
89: public function getWidgetInstance()
90: {
91: return Mage::registry('current_widget_instance');
92: }
93:
94: 95: 96: 97: 98:
99: protected function _prepareForm()
100: {
101: $widgetInstance = $this->getWidgetInstance();
102: $form = new Varien_Data_Form(array(
103: 'id' => 'edit_form',
104: 'action' => $this->getData('action'),
105: 'method' => 'post'
106: ));
107:
108: $fieldset = $form->addFieldset('base_fieldset',
109: array('legend'=>Mage::helper('widget')->__('Settings'))
110: );
111:
112: $this->_addElementTypes($fieldset);
113:
114: $fieldset->addField('type', 'select', array(
115: 'name' => 'type',
116: 'label' => Mage::helper('widget')->__('Type'),
117: 'title' => Mage::helper('widget')->__('Type'),
118: 'required' => true,
119: 'values' => $this->getTypesOptionsArray()
120: ));
121:
122: $fieldset->addField('package_theme', 'select', array(
123: 'name' => 'package_theme',
124: 'label' => Mage::helper('widget')->__('Design Package/Theme'),
125: 'title' => Mage::helper('widget')->__('Design Package/Theme'),
126: 'required' => true,
127: 'values' => $this->getPackegeThemeOptionsArray()
128: ));
129: $continueButton = $this->getLayout()
130: ->createBlock('adminhtml/widget_button')
131: ->setData(array(
132: 'label' => Mage::helper('widget')->__('Continue'),
133: 'onclick' => "setSettings('".$this->getContinueUrl()."', 'type', 'package_theme')",
134: 'class' => 'save'
135: ));
136: $fieldset->addField('continue_button', 'note', array(
137: 'text' => $continueButton->toHtml(),
138: ));
139:
140: $this->setForm($form);
141:
142: return parent::_prepareForm();
143: }
144:
145: 146: 147: 148: 149:
150: public function getContinueUrl()
151: {
152: return $this->getUrl('*/*/*', array(
153: '_current' => true,
154: 'type' => '{{type}}',
155: 'package' => '{{package}}',
156: 'theme' => '{{theme}}'
157: ));
158: }
159:
160: 161: 162: 163: 164:
165: public function getTypesOptionsArray()
166: {
167: $widgets = $this->getWidgetInstance()->getWidgetsOptionArray();
168: array_unshift($widgets, array(
169: 'value' => '',
170: 'label' => Mage::helper('widget')->__('-- Please Select --')
171: ));
172: return $widgets;
173: }
174:
175: 176: 177: 178: 179: 180: 181:
182: protected function _sortWidgets($a, $b)
183: {
184: return strcmp($a["label"], $b["label"]);
185: }
186:
187: 188: 189: 190: 191:
192: public function getPackegeThemeOptionsArray()
193: {
194: return Mage::getModel('core/design_source_design')
195: ->setIsFullLabel(true)->getAllOptions(true);
196: }
197: }
198: