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


PHP Varien_Simplexml_Element::descend方法代码示例

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


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

示例1: _initElement

 /**
  * 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));
     }
 }
开发者ID:nickimproove,项目名称:magento2,代码行数:44,代码来源:Form.php

示例2: 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;
         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:jauderho,项目名称:magento-mirror,代码行数:67,代码来源:Form.php

示例3: getNode

 /**
  * Returns node found by the $path
  *
  * @see     Varien_Simplexml_Element::descend
  * @param   string $path
  * @return  Varien_Simplexml_Element
  */
 public function getNode($path = null)
 {
     if (!$this->_xml instanceof Varien_Simplexml_Element) {
         return false;
     } elseif ($path === null) {
         return $this->_xml;
     } else {
         return $this->_xml->descend($path);
     }
 }
开发者ID:chucky515,项目名称:Magento-CE-Mirror,代码行数:17,代码来源:Config.php

示例4: loadModule

 /**
  * load a module
  *
  * @access public
  * @param Varien_Simplexml_Element $xml
  * @return bool|Ultimate_ModuleCreator_Model_Module
  * @author Marius Strajeru <ultimate.module.creator@gmail.com>
  */
 public function loadModule($xml)
 {
     /** @var Ultimate_ModuleCreator_Model_Module $module */
     $module = Mage::getModel('modulecreator/module');
     $moduleFields = $module->getXmlAttributes();
     $data = array();
     foreach ($moduleFields as $field) {
         $data[$field] = (string) $xml->{$field};
     }
     $module->setData($data);
     /** @var Ultimate_ModuleCreator_Model_Entity $entity */
     $entity = Mage::getModel('modulecreator/entity');
     $entityFields = $entity->getXmlAttributes();
     foreach ($xml->entities->entity as $entityNode) {
         $data = array();
         foreach ($entityFields as $field) {
             $data[$field] = (string) $entityNode->{$field};
         }
         $entity = Mage::getModel('modulecreator/entity');
         $entity->setData($data);
         $module->addEntity($entity);
         foreach ($entityNode->attributes->attribute as $attributeNode) {
             $attributeData = (array) $attributeNode;
             foreach ($attributeData as $key => $value) {
                 $attributeData[$key] = (string) $value;
             }
             $attribute = Mage::getModel('modulecreator/attribute');
             $attribute->setData($attributeData);
             $entity->addAttribute($attribute);
         }
     }
     $relations = (array) $xml->descend('relations');
     if ($relations) {
         foreach ($relations as $key => $type) {
             $parts = explode('_', $key);
             if (count($parts) == 2) {
                 $e1 = $module->getEntity($parts[0]);
                 $e2 = $module->getEntity($parts[1]);
                 if ($e1 && $e2) {
                     /** @var Ultimate_ModuleCreator_Model_Relation $relation */
                     $relation = Mage::getModel('modulecreator/relation');
                     $relation->setEntities($e1, $e2, (string) $type);
                     $module->addRelation($relation);
                 }
             }
         }
     }
     return $module;
 }
开发者ID:cojaco,项目名称:UltimateModuleCreator,代码行数:57,代码来源:Data.php

示例5: 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) : '';
             $hint = (string) $e->hint ? Mage::helper($helperName)->__((string) $e->hint) : '';
             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();
             }
             if ($e->depends) {
                 foreach ($e->depends->children() as $dependent) {
                     $dependentId = $section->getName() . '_' . $group->getName() . '_' . $fieldPrefix . $dependent->getName();
                     $dependentValue = (string) $dependent;
                     $this->_getDependence()->addFieldMap($id, $id)->addFieldMap($dependentId, $dependentId)->addFieldDependence($id, $dependentId, $dependentValue);
                 }
             }
             $field = $fieldset->addField($id, $fieldType, array('name' => $name, 'label' => $label, 'comment' => $comment, 'hint' => $hint, 'value' => $data, 'inherit' => $inherit, 'class' => $e->frontend_class, 'field_config' => $e, 'scope' => $this->getScope(), 'scope_id' => $this->getScopeId(), 'scope_label' => $this->getScopeLabel($e), '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) {
                 // determine callback for the source model
                 $factoryName = (string) $e->source_model;
                 $method = false;
                 if (preg_match('/^([^:]+?)::([^:]+?)$/', $factoryName, $matches)) {
                     array_shift($matches);
                     list($factoryName, $method) = array_values($matches);
                 }
                 $sourceModel = Mage::getSingleton($factoryName);
                 if ($sourceModel instanceof Varien_Object) {
                     $sourceModel->setPath($path);
                 }
                 if ($method) {
                     if ($fieldType == 'multiselect') {
                         $optionArray = $sourceModel->{$method}();
                     } else {
                         $optionArray = array();
                         foreach ($sourceModel->{$method}() as $value => $label) {
                             $optionArray[] = array('label' => $label, 'value' => $value);
                         }
                     }
                 } else {
                     $optionArray = $sourceModel->toOptionArray($fieldType == 'multiselect');
                 }
                 $field->setValues($optionArray);
             }
         }
     }
     return $this;
 }
开发者ID:hunnybohara,项目名称:magento-chinese-localization,代码行数:99,代码来源:Form.php


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