/** * Initialize sections * * @param $sections * @return string */ protected function _initializeSections($sections) { $current = $this->getRequest()->getParam('section'); $websiteCode = $this->getRequest()->getParam('website'); $storeCode = $this->getRequest()->getParam('store'); /** @var $section array */ foreach ($sections as $section) { $this->_eventManager->dispatch('adminhtml_block_system_config_init_tab_sections_before', array('section' => $section)); $code = $section['id']; $sectionAllowed = false; if (isset($section['resource'])) { $sectionAllowed = $this->checkSectionPermissions($section['resource']); } if (empty($current) && $sectionAllowed) { $current = $code; $this->getRequest()->setParam('section', $current); } $helperName = $this->_systemConfig->getAttributeModule($section); $label = $this->helper($helperName)->__($section['label']); if ($code == $current) { if (!$this->getRequest()->getParam('website') && !$this->getRequest()->getParam('store')) { $this->_addBreadcrumb($label); } else { $this->_addBreadcrumb($label, '', $this->getUrl('*/*/*', array('section' => $code))); } $this->setActiveTab($section['tab']); $this->setActiveSection($code); } $hasChildren = $this->_systemConfig->hasChildren($section, $websiteCode, $storeCode); if ($sectionAllowed && $hasChildren) { $this->addSection($code, $section['tab'], array('class' => isset($section['class']) ? $section['class'] : '', 'label' => $label, 'url' => $this->getUrl('*/*/*', array('_current' => true, 'section' => $code)))); } } return $current; }
/** * Initialize element group * * @param array $group * @param array $section * @param Varien_Data_Form $form */ protected function _initGroup($group, $section, $form) { if (isset($group['frontend_model'])) { $fieldsetRenderer = Mage::getBlockSingleton((string) $group['frontend_model']); } else { $fieldsetRenderer = $this->_defaultFieldsetRenderer; } $fieldsetRenderer->setForm($this); $fieldsetRenderer->setConfigData($this->_configData); $fieldsetRenderer->setGroup($group); if ($this->_systemConfig->hasChildren($group, $this->getWebsiteCode(), $this->getStoreCode())) { $helperName = $this->_systemConfig->getAttributeModule($section, $group); $fieldsetConfig = array('legend' => $this->helper($helperName)->__(array_key_exists('label', $group) ? $group['label'] : '')); if (isset($group['comment'])) { $fieldsetConfig['comment'] = $this->helper($helperName)->__($group['comment']); } if (isset($group['expanded'])) { $fieldsetConfig['expanded'] = (bool) $group['expanded']; } $fieldset = $form->addFieldset($section['id'] . '_' . $group['id'], $fieldsetConfig)->setRenderer($fieldsetRenderer); $this->_prepareFieldOriginalData($fieldset, $group); $this->_addElementTypes($fieldset); if (isset($group['clone_fields'])) { if (isset($group['clone_model'])) { $cloneModel = $this->_cloneModelFactory->create($group['clone_model']); } else { Mage::throwException('Config form fieldset clone model required to be able to clone fields'); } foreach ($cloneModel->getPrefixes() as $prefix) { $this->initFields($fieldset, $group, $section, $prefix['field'], $prefix['label']); } } else { $this->initFields($fieldset, $group, $section); } $this->_fieldsets[$group['id']] = $fieldset; } }