*/ class Mage_Adminhtml_Block_System_Config_Form_Fieldset extends Mage_Adminhtml_Block_Abstract implements Varien_Data_Form_Element_Renderer_Interface { /** * Render fieldset html * * @param Varien_Data_Form_Element_Abstract $element * @return string */ public function render(Varien_Data_Form_Element_Abstract $element) { $this->setElement($element); $html = $this->_getHeaderHtml($element); foreach ($element->getSortedElements() as $field) { $html.= $field->toHtml(); } $html .= $this->_getFooterHtml($element); return $html; } /** * Return header html for fieldset * * @param Varien_Data_Form_Element_Abstract $element * @return string */ protected function _getHeaderHtml($element) { if ($element->getIsNested()) { $html = '
'; } else { $html = '
'; } $html .= $this->_getHeaderTitleHtml($element); $html .= ''; $html .= '
'; $html .= '' . $element->getLegend() . ''; $html .= $this->_getHeaderCommentHtml($element); // field label column $html .= ''; if ($this->getRequest()->getParam('website') || $this->getRequest()->getParam('store')) { $html .= ''; } $html .= ''; return $html; } /** * Get frontend class * * @param Varien_Data_Form_Element_Abstract $element * @return string */ protected function _getFrontendClass($element) { $frontendClass = (string)$this->getGroup($element)->frontend_class; return 'section-config' . (empty($frontendClass) ? '' : (' ' . $frontendClass)); } /** * Get group xml data of the element * * @param null|Varien_Data_Form_Element_Abstract $element * @return Mage_Core_Model_Config_Element */ public function getGroup($element = null) { if (is_null($element)) { $element = $this->getElement(); } if ($element && $element->getGroup() instanceof Mage_Core_Model_Config_Element) { return $element->getGroup(); } return new Mage_Core_Model_Config_Element(''); } /** * Return header title part of html for fieldset * * @param Varien_Data_Form_Element_Abstract $element * @return string */ protected function _getHeaderTitleHtml($element) { return '
' . $element->getLegend() . '
'; } /** * Return header comment part of html for fieldset * * @param Varien_Data_Form_Element_Abstract $element * @return string */ protected function _getHeaderCommentHtml($element) { return $element->getComment() ? '
' . $element->getComment() . '
' : ''; } /** * Return full css class name for form fieldset * * @param null|Varien_Data_Form_Element_Abstract $element * @return string */ protected function _getFieldsetCss($element = null) { $configCss = (string)$this->getGroup($element)->fieldset_css; return 'config collapseable' . ($configCss ? ' ' . $configCss : ''); } /** * Return footer html for fieldset * Add extra tooltip comments to elements * * @param Varien_Data_Form_Element_Abstract $element * @return string */ protected function _getFooterHtml($element) { $tooltipsExist = false; $html = '
'; $html .= '
' . $this->_getExtraJs($element, $tooltipsExist); if ($element->getIsNested()) { $html .= '
'; } else { $html .= '
'; } return $html; } /** * Return js code for fieldset: * - observe fieldset rows; * - apply collapse; * * @param Varien_Data_Form_Element_Abstract $element * @param bool $tooltipsExist Init tooltips observer or not * @return string */ protected function _getExtraJs($element, $tooltipsExist = false) { $id = $element->getHtmlId(); $js = "Fieldset.applyCollapse('{$id}');"; return Mage::helper('adminhtml/js')->getScript($js); } /** * Collapsed or expanded fieldset when page loaded? * * @param Varien_Data_Form_Element_Abstract $element * @return bool */ protected function _getCollapseState($element) { if ($element->getExpanded() !== null) { return 1; } $extra = Mage::getSingleton('admin/session')->getUser()->getExtra(); if (isset($extra['configState'][$element->getId()])) { return $extra['configState'][$element->getId()]; } return false; } }