当前位置: 首页>>代码示例>>PHP>>正文


PHP Varien_Data_Form_Element_Fieldset::setSortElementsByAttribute方法代码示例

本文整理汇总了PHP中Varien_Data_Form_Element_Fieldset::setSortElementsByAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Data_Form_Element_Fieldset::setSortElementsByAttribute方法的具体用法?PHP Varien_Data_Form_Element_Fieldset::setSortElementsByAttribute怎么用?PHP Varien_Data_Form_Element_Fieldset::setSortElementsByAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Varien_Data_Form_Element_Fieldset的用法示例。


在下文中一共展示了Varien_Data_Form_Element_Fieldset::setSortElementsByAttribute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: initFields

 /**
  * Init fieldset fields
  *
  * @param Varien_Data_Form_Element_Fieldset $fieldset
  * @param Varien_Simplexml_Element $group
  * @param Varien_Simplexml_Element $section
  * @param string $fieldPrefix
  * @param string $labelPrefix
  * @return Mage_Adminhtml_Block_System_Config_Form
  */
 public function initFields($fieldset, $group, $section, $fieldPrefix = '', $labelPrefix = '')
 {
     if (!$this->_configDataObject) {
         $this->_initObjects();
     }
     // Extends for config data
     $configDataAdditionalGroups = array();
     foreach ($group->fields as $elements) {
         $elements = (array) $elements;
         // sort either by sort_order or by child node values bypassing the sort_order
         if ($group->sort_fields && $group->sort_fields->by) {
             $fieldset->setSortElementsByAttribute((string) $group->sort_fields->by, $group->sort_fields->direction_desc ? SORT_DESC : SORT_ASC);
         } else {
             usort($elements, array($this, '_sortForm'));
         }
         foreach ($elements as $element) {
             if (!$this->_canShowField($element)) {
                 continue;
             }
             if ((string) $element->getAttribute('type') == 'group') {
                 $this->_initGroup($fieldset->getForm(), $element, $section, $fieldset);
                 continue;
             }
             /**
              * Look for custom defined field path
              */
             $path = (string) $element->config_path;
             if (empty($path)) {
                 $path = $section->getName() . '/' . $group->getName() . '/' . $fieldPrefix . $element->getName();
             } elseif (strrpos($path, '/') > 0) {
                 // Extend config data with new section group
                 $groupPath = substr($path, 0, strrpos($path, '/'));
                 if (!isset($configDataAdditionalGroups[$groupPath])) {
                     $this->_configData = $this->_configDataObject->extendConfig($groupPath, false, $this->_configData);
                     $configDataAdditionalGroups[$groupPath] = true;
                 }
             }
             $data = $this->_configDataObject->getConfigDataValue($path, $inherit, $this->_configData);
             if ($element->frontend_model) {
                 $fieldRenderer = Mage::getBlockSingleton((string) $element->frontend_model);
             } else {
                 $fieldRenderer = $this->_defaultFieldRenderer;
             }
             $fieldRenderer->setForm($this);
             $fieldRenderer->setConfigData($this->_configData);
             $helperName = $this->_configFields->getAttributeModule($section, $group, $element);
             $fieldType = (string) $element->frontend_type ? (string) $element->frontend_type : 'text';
             $name = 'groups[' . $group->getName() . '][fields][' . $fieldPrefix . $element->getName() . '][value]';
             $label = Mage::helper($helperName)->__($labelPrefix) . ' ' . Mage::helper($helperName)->__((string) $element->label);
             $hint = (string) $element->hint ? Mage::helper($helperName)->__((string) $element->hint) : '';
             if ($element->backend_model) {
                 $model = Mage::getModel((string) $element->backend_model);
                 if (!$model instanceof Mage_Core_Model_Config_Data) {
                     Mage::throwException('Invalid config field backend model: ' . (string) $element->backend_model);
                 }
                 $model->setPath($path)->setValue($data)->setWebsite($this->getWebsiteCode())->setStore($this->getStoreCode())->afterLoad();
                 $data = $model->getValue();
             }
             $comment = $this->_prepareFieldComment($element, $helperName, $data);
             $tooltip = $this->_prepareFieldTooltip($element, $helperName);
             $id = $section->getName() . '_' . $group->getName() . '_' . $fieldPrefix . $element->getName();
             if ($element->depends) {
                 foreach ($element->depends->children() as $dependent) {
                     /* @var $dependent Mage_Core_Model_Config_Element */
                     if (isset($dependent->fieldset)) {
                         $dependentFieldGroupName = (string) $dependent->fieldset;
                         if (!isset($this->_fieldsets[$dependentFieldGroupName])) {
                             $dependentFieldGroupName = $group->getName();
                         }
                     } else {
                         $dependentFieldGroupName = $group->getName();
                     }
                     $dependentFieldNameValue = $dependent->getName();
                     $dependentFieldGroup = $dependentFieldGroupName == $group->getName() ? $group : $this->_fieldsets[$dependentFieldGroupName]->getGroup();
                     $dependentId = $section->getName() . '_' . $dependentFieldGroupName . '_' . $fieldPrefix . $dependentFieldNameValue;
                     $shouldBeAddedDependence = true;
                     $dependentValue = (string) (isset($dependent->value) ? $dependent->value : $dependent);
                     if (isset($dependent['separator'])) {
                         $dependentValue = explode((string) $dependent['separator'], $dependentValue);
                     }
                     $dependentFieldName = $fieldPrefix . $dependent->getName();
                     $dependentField = $dependentFieldGroup->fields->{$dependentFieldName};
                     /*
                      * If dependent field can't be shown in current scope and real dependent config value
                      * is not equal to preferred one, then hide dependence fields by adding dependence
                      * based on not shown field (not rendered field)
                      */
                     if (!$this->_canShowField($dependentField)) {
                         $dependentFullPath = $section->getName() . '/' . $dependentFieldGroupName . '/' . $fieldPrefix . $dependent->getName();
                         $dependentValueInStore = Mage::getStoreConfig($dependentFullPath, $this->getStoreCode());
//.........这里部分代码省略.........
开发者ID:monkviper,项目名称:magento-lite,代码行数:101,代码来源:Form.php

示例2: _sortElements

 /**
  * @param array $group
  * @param Varien_Data_Form_Element_Fieldset $fieldset
  * @param array $elements
  * @return mixed
  */
 protected function _sortElements($group, $fieldset, $elements)
 {
     if (isset($group['sort_fields']) && isset($group['sort_fields']['by'])) {
         $fieldset->setSortElementsByAttribute($group['sort_fields']['by'], isset($group['sort_fields']['direction_desc']) ? SORT_DESC : SORT_ASC);
     } else {
         usort($elements, array($this, '_sortForm'));
     }
     return $elements;
 }
开发者ID:nickimproove,项目名称:magento2,代码行数:15,代码来源:Form.php

示例3: initFields

 /**
  * Init fieldset fields
  *
  * @param Varien_Data_Form_Element_Fieldset $fieldset
  * @param Varien_Simplexml_Element $group
  * @param Varien_Simplexml_Element $section
  * @param string $fieldPrefix
  * @param string $labelPrefix
  * @return Mage_Adminhtml_Block_System_Config_Form
  */
 public function initFields($fieldset, $group, $section, $fieldPrefix = '', $labelPrefix = '')
 {
     foreach ($group->fields as $elements) {
         $elements = (array) $elements;
         // sort either by sort_order or by child node values bypassing the sort_order
         if ($group->sort_fields && $group->sort_fields->by) {
             $fieldset->setSortElementsByAttribute((string) $group->sort_fields->by, $group->sort_fields->direction_desc ? SORT_DESC : SORT_ASC);
         } else {
             usort($elements, array($this, '_sortForm'));
         }
         foreach ($elements as $e) {
             if (!$this->_canShowField($e)) {
                 continue;
             }
             $path = $section->getName() . '/' . $group->getName() . '/' . $fieldPrefix . $e->getName();
             $id = $section->getName() . '_' . $group->getName() . '_' . $fieldPrefix . $e->getName();
             if (isset($this->_configData[$path])) {
                 $data = $this->_configData[$path];
                 $inherit = false;
             } else {
                 $data = $this->_configRoot->descend($path);
                 $inherit = true;
             }
             if ($e->frontend_model) {
                 $fieldRenderer = Mage::getBlockSingleton((string) $e->frontend_model);
             } else {
                 $fieldRenderer = $this->_defaultFieldRenderer;
             }
             $fieldRenderer->setForm($this);
             $fieldRenderer->setConfigData($this->_configData);
             $helperName = $this->_configFields->getAttributeModule($section, $group, $e);
             $fieldType = (string) $e->frontend_type ? (string) $e->frontend_type : 'text';
             $name = 'groups[' . $group->getName() . '][fields][' . $fieldPrefix . $e->getName() . '][value]';
             $label = Mage::helper($helperName)->__($labelPrefix) . ' ' . Mage::helper($helperName)->__((string) $e->label);
             $comment = (string) $e->comment ? Mage::helper($helperName)->__((string) $e->comment) : '';
             if ($e->backend_model) {
                 $model = Mage::getModel((string) $e->backend_model);
                 if (!$model instanceof Mage_Core_Model_Config_Data) {
                     Mage::throwException('Invalid config field backend model: ' . (string) $e->backend_model);
                 }
                 $model->setPath($path)->setValue($data)->afterLoad();
                 $data = $model->getValue();
             }
             $field = $fieldset->addField($id, $fieldType, array('name' => $name, 'label' => $label, 'comment' => $comment, 'value' => $data, 'inherit' => $inherit, 'class' => $e->frontend_class, 'field_config' => $e, 'scope' => $this->getScope(), 'scope_id' => $this->getScopeId(), 'can_use_default_value' => $this->canUseDefaultValue((int) $e->show_in_default), 'can_use_website_value' => $this->canUseWebsiteValue((int) $e->show_in_website)));
             if (isset($e->validate)) {
                 $field->addClass($e->validate);
             }
             if (isset($e->frontend_type) && 'multiselect' === (string) $e->frontend_type && isset($e->can_be_empty)) {
                 $field->setCanBeEmpty(true);
             }
             $field->setRenderer($fieldRenderer);
             if ($e->source_model) {
                 $sourceModel = Mage::getSingleton((string) $e->source_model);
                 if ($sourceModel instanceof Varien_Object) {
                     $sourceModel->setPath($path);
                 }
                 $field->setValues($sourceModel->toOptionArray($fieldType == 'multiselect'));
             }
         }
     }
     return $this;
 }
开发者ID:Rinso,项目名称:magento-mirror,代码行数:72,代码来源:Form.php

示例4: _sortElements

 /**
  * @param Varien_SimpleXml_Element $group
  * @param Varien_Data_Form_Element_Fieldset $fieldset
  * @param array $elements
  * @return mixed
  */
 protected function _sortElements($group, $fieldset, $elements)
 {
     if ($group->sort_fields && $group->sort_fields->by) {
         $fieldset->setSortElementsByAttribute((string) $group->sort_fields->by, $group->sort_fields->direction_desc ? SORT_DESC : SORT_ASC);
     } else {
         usort($elements, array($this, '_sortForm'));
     }
     return $elements;
 }
开发者ID:rorteg,项目名称:magento2,代码行数:15,代码来源:Form.php


注:本文中的Varien_Data_Form_Element_Fieldset::setSortElementsByAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。