*/ class Mage_Widget_Block_Adminhtml_Widget_Instance_Edit_Tab_Settings extends Mage_Adminhtml_Block_Widget_Form implements Mage_Adminhtml_Block_Widget_Tab_Interface { protected function _construct() { parent::_construct(); $this->setActive(true); } /** * Prepare label for tab * * @return string */ public function getTabLabel() { return Mage::helper('widget')->__('Settings'); } /** * Prepare title for tab * * @return string */ public function getTabTitle() { return Mage::helper('widget')->__('Settings'); } /** * Returns status flag about this tab can be showen or not * * @return true */ public function canShowTab() { return !(bool)$this->getWidgetInstance()->isCompleteToCreate(); } /** * Returns status flag about this tab hidden or not * * @return true */ public function isHidden() { return false; } /** * Getter * * @return Mage_Widget_Model_Widget_Instance */ public function getWidgetInstance() { return Mage::registry('current_widget_instance'); } /** * Prepare form before rendering HTML * * @return Mage_Widget_Block_Adminhtml_Widget_Instance_Edit_Tab_Settings */ protected function _prepareForm() { $widgetInstance = $this->getWidgetInstance(); $form = new Varien_Data_Form(array( 'id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post' )); $fieldset = $form->addFieldset('base_fieldset', array('legend'=>Mage::helper('widget')->__('Settings')) ); $this->_addElementTypes($fieldset); $fieldset->addField('type', 'select', array( 'name' => 'type', 'label' => Mage::helper('widget')->__('Type'), 'title' => Mage::helper('widget')->__('Type'), 'required' => true, 'values' => $this->getTypesOptionsArray() )); $fieldset->addField('package_theme', 'select', array( 'name' => 'package_theme', 'label' => Mage::helper('widget')->__('Design Package/Theme'), 'title' => Mage::helper('widget')->__('Design Package/Theme'), 'required' => true, 'values' => $this->getPackegeThemeOptionsArray() )); $continueButton = $this->getLayout() ->createBlock('adminhtml/widget_button') ->setData(array( 'label' => Mage::helper('widget')->__('Continue'), 'onclick' => "setSettings('".$this->getContinueUrl()."', 'type', 'package_theme')", 'class' => 'save' )); $fieldset->addField('continue_button', 'note', array( 'text' => $continueButton->toHtml(), )); $this->setForm($form); return parent::_prepareForm(); } /** * Return url for continue button * * @return string */ public function getContinueUrl() { return $this->getUrl('*/*/*', array( '_current' => true, 'type' => '{{type}}', 'package' => '{{package}}', 'theme' => '{{theme}}' )); } /** * Retrieve array (widget_type => widget_name) of available widgets * * @return array */ public function getTypesOptionsArray() { $widgets = $this->getWidgetInstance()->getWidgetsOptionArray(); array_unshift($widgets, array( 'value' => '', 'label' => Mage::helper('widget')->__('-- Please Select --') )); return $widgets; } /** * User-defined widgets sorting by Name * * @param array $a * @param array $b * @return boolean */ protected function _sortWidgets($a, $b) { return strcmp($a["label"], $b["label"]); } /** * Retrieve package/theme options array * * @return array */ public function getPackegeThemeOptionsArray() { return Mage::getModel('core/design_source_design') ->setIsFullLabel(true)->getAllOptions(true); } }