Пример #1
0
 protected function _construct()
 {
     $this->_systemConfig = $this->hasData('systemConfig') ? $this->getData('systemConfig') : Mage::getSingleton('Mage_Backend_Model_Config_Structure_Reader')->getConfiguration();
     parent::_construct();
     $sectionCode = $this->getRequest()->getParam('section');
     $this->_section = $this->_systemConfig->getSection($sectionCode);
     $this->setTitle($this->_section['label']);
     $this->setHeaderCss(isset($this->_section['header_css']) ? $this->_section['header_css'] : '');
 }
Пример #2
0
 /**
  * Initialize form element
  *
  * @param array $element
  * @param Varien_Data_Form_Element_Fieldset $fieldset
  * @param array $group
  * @param array $section
  * @param string $path
  * @param string $fieldPrefix
  * @param string $labelPrefix
  */
 protected function _initElement($element, $fieldset, $group, $section, $path, $fieldPrefix = '', $labelPrefix = '')
 {
     $elementId = $section['id'] . '_' . $group['id'] . '_' . $fieldPrefix . $element['id'];
     if (array_key_exists($path, $this->_configData)) {
         $data = $this->_configData[$path];
         $inherit = false;
     } else {
         $data = $this->_configRoot->descend($path);
         $inherit = true;
     }
     $fieldRenderer = $this->_getFieldRenderer($element);
     $fieldRenderer->setForm($this);
     $fieldRenderer->setConfigData($this->_configData);
     $helperName = $this->_systemConfig->getAttributeModule($section, $group, $element);
     $fieldType = isset($element['type']) ? $element['type'] : 'text';
     $name = 'groups[' . $group['id'] . '][fields][' . $fieldPrefix . $element['id'] . '][value]';
     $label = $this->helper($helperName)->__($labelPrefix) . ' ' . $this->helper($helperName)->__(array_key_exists('label', $element) ? (string) $element['label'] : '');
     $hint = isset($element['hint']) ? $this->helper($helperName)->__($element['hint']) : '';
     if (isset($element['backend_model'])) {
         $data = $this->_fetchBackendModelData($element, $path, $data);
     }
     $comment = $this->_prepareFieldComment($element, $helperName, $data);
     $tooltip = $this->_prepareFieldTooltip($element, $helperName);
     if (isset($element['depends'])) {
         $this->_processElementDependencies($element, $section, $group, $elementId, $fieldPrefix);
     }
     $field = $fieldset->addField($elementId, $fieldType, array('name' => $name, 'label' => $label, 'comment' => $comment, 'tooltip' => $tooltip, 'hint' => $hint, 'value' => $data, 'inherit' => $inherit, 'class' => isset($element['frontend_class']) ? $element['frontend_class'] : '', 'field_config' => $element, 'scope' => $this->getScope(), 'scope_id' => $this->getScopeId(), 'scope_label' => $this->getScopeLabel($element), 'can_use_default_value' => $this->canUseDefaultValue(isset($element['showInDefault']) ? (int) $element['showInDefault'] : 0), 'can_use_website_value' => $this->canUseWebsiteValue(isset($element['showInWebsite']) ? (int) $element['showInWebsite'] : 0)));
     $this->_applyFieldConfiguration($field, $element);
     $field->setRenderer($fieldRenderer);
     if (isset($element['source_model'])) {
         $field->setValues($this->_extractDataFromSourceModel($element, $path, $fieldType));
     }
 }
Пример #3
0
 /**
  * Initialize tabs
  *
  * @param array $tabs
  * @return void
  */
 protected function _initializeTabs(array $tabs)
 {
     foreach ($tabs as $tab) {
         $helperName = $this->_systemConfig->getAttributeModule($tab);
         $label = $this->helper($helperName)->__($tab['label']);
         $this->addTab($tab['id'], array('label' => $label, 'class' => isset($tab['class']) ? $tab['class'] : ''));
     }
 }