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


PHP Varien_Simplexml_Element::children方法代码示例

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


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

示例1: _readImportSpec

 /**
  * reads an import specification.
  * @see README.md
  * @param Varien_Simplexml_Element $specNode
  * @param Varien_Simplexml_Element $groupNode
  * @param string $configPath
  */
 private function _readImportSpec(Varien_Simplexml_Element $specNode, Varien_Simplexml_Element $groupNode, $configPath)
 {
     foreach ($specNode->children() as $moduleName => $moduleNode) {
         Mage::dispatchEvent(self::EVENT_PREFIX . $moduleName, $this->_prepareEventData($groupNode, $moduleNode, $configPath));
     }
     return $this;
 }
开发者ID:kojiromike,项目名称:magento-active-config,代码行数:14,代码来源:Observer.php

示例2: getResourceName

 /**
  * Returns setup resource for module setup scripts
  * 
  * @param Varien_Simplexml_Element $xml
  * @return string
  */
 protected function getResourceName(Varien_Simplexml_Element $xml)
 {
     foreach ($xml->children() as $resourceNode) {
         if (isset($resourceNode->setup->module) && (string) $resourceNode->setup->module === $this->_moduleName) {
             return $resourceNode->getName();
         }
     }
     return false;
 }
开发者ID:tiagosampaio,项目名称:EcomDev_PHPUnit,代码行数:15,代码来源:Script.php

示例3: getModuleSetupResources

 /**
  * Returns list of module setup resources
  * 
  * @param Varien_Simplexml_Element $xml
  * @return array
  */
 protected function getModuleSetupResources(Varien_Simplexml_Element $xml)
 {
     $resourcesForModule = array();
     foreach ($xml->children() as $resourceNode) {
         if (isset($resourceNode->setup->module) && (string) $resourceNode->setup->module === $this->_moduleName) {
             $resourcesForModule[] = $resourceNode->getName();
         }
     }
     return $resourcesForModule;
 }
开发者ID:NatashaOlut,项目名称:Mage_Test,代码行数:16,代码来源:Resource.php

示例4: extendChild

 /**
  * Extends one node
  *
  * @param Varien_Simplexml_Element $source
  * @param boolean                  $overwrite
  *
  * @return Varien_Simplexml_Element
  * @access public
  */
 public function extendChild($source, $overwrite = false)
 {
     // this will be our new target node
     $targetChild = null;
     // name of the source node
     $sourceName = $source->getName();
     // here we have children of our source node
     $sourceChildren = $source->children();
     if (!$source->hasChildren()) {
         // handle string node
         if (isset($this->{$sourceName})) {
             // if target already has children return without regard
             if ($this->{$sourceName}->children()) {
                 return $this;
             }
             if ($overwrite) {
                 if (Mage::registry('conflict_datastore_enabled')) {
                     $factory = new Bronto_Verify_Model_Path_Locator_Factory();
                     $locator = $factory->getLocator();
                     $dataStore = Mage::registry('conflict_datastore');
                     $dataStore->addRewrite((string) $this->{$sourceName}, (string) $source, Mage::registry('conflict_datastore_config_file'), $locator->getPath($source));
                 }
                 unset($this->{$sourceName});
             } else {
                 return $this;
             }
         }
         $targetChild = $this->addChild($sourceName, $source->xmlentities());
         $targetChild->setParent($this);
         foreach ($source->attributes() as $key => $value) {
             $targetChild->addAttribute($key, $this->xmlentities($value));
         }
         return $this;
     }
     if (isset($this->{$sourceName})) {
         $targetChild = $this->{$sourceName};
     }
     if (is_null($targetChild)) {
         // if child target is not found create new and descend
         $targetChild = $this->addChild($sourceName);
         $targetChild->setParent($this);
         foreach ($source->attributes() as $key => $value) {
             $targetChild->addAttribute($key, $this->xmlentities($value));
         }
     }
     // finally add our source node children to resulting new target node
     foreach ($sourceChildren as $childNode) {
         $targetChild->extendChild($childNode, $overwrite);
     }
     return $this;
 }
开发者ID:xiaoguizhidao,项目名称:blingjewelry-prod,代码行数:60,代码来源:Element.php

示例5: _runAction

 /**
  * If all ifconfig conditions are ok then action runs
  *
  * @param Varien_Simplexml_Element $node
  * @param Varien_Simplexml_Element $parent
  * @return Smartwave_All_Model_Core_Layout
  */
 private function _runAction($node, $parent)
 {
     $method = (string) $node['method'];
     if (!empty($node['block'])) {
         $parentName = (string) $node['block'];
     } else {
         $parentName = $parent->getBlockName();
     }
     $_profilerKey = 'BLOCK ACTION: ' . $parentName . ' -> ' . $method;
     Varien_Profiler::start($_profilerKey);
     if (!empty($parentName)) {
         $block = $this->getBlock($parentName);
     }
     if (!empty($block)) {
         $args = (array) $node->children();
         unset($args['@attributes']);
         foreach ($args as $key => $arg) {
             if ($arg instanceof Mage_Core_Model_Layout_Element) {
                 if (isset($arg['helper'])) {
                     $helperName = explode('/', (string) $arg['helper']);
                     $helperMethod = array_pop($helperName);
                     $helperName = implode('/', $helperName);
                     $arg = $arg->asArray();
                     unset($arg['@']);
                     $args[$key] = call_user_func_array(array(Mage::helper($helperName), $helperMethod), $arg);
                 } else {
                     /**
                      * if there is no helper we hope that this is assoc array
                      */
                     $arr = array();
                     foreach ($arg as $subkey => $value) {
                         $arr[(string) $subkey] = $value->asArray();
                     }
                     if (!empty($arr)) {
                         $args[$key] = $arr;
                     }
                 }
             }
         }
         if (isset($node['json'])) {
             $json = explode(' ', (string) $node['json']);
             foreach ($json as $arg) {
                 $args[$arg] = Mage::helper('core')->jsonDecode($args[$arg]);
             }
         }
         $this->_translateLayoutNode($node, $args);
         call_user_func_array(array($block, $method), $args);
     }
     Varien_Profiler::stop($_profilerKey);
     return $this;
 }
开发者ID:EagleSH,项目名称:besttoy,代码行数:58,代码来源:Layout.php

示例6: _translateNode

 /**
  * translate node
  *
  * @access protected
  * @param Varien_Simplexml_Element $node
  * @return Ultimate_ModuleCreator_Model_Config
  * @author Marius Strajeru <ultimate.module.creator@gmail.com>
  */
 protected function _translateNode(&$node)
 {
     if ($node->getAttribute('translate')) {
         $fields = explode(' ', $node->getAttribute('translate'));
         $module = $node->getAttribute('module') ? (string) $node->getAttribute('module') : $this->_getDefaultTranslateModule();
         foreach ($fields as $field) {
             if ($node->{$field}) {
                 $node->{$field} = Mage::helper($module)->__((string) $node->{$field});
             }
         }
     }
     if ($node->hasChildren()) {
         foreach ($node->children() as $child) {
             $this->_translateNode($child);
         }
     }
     return $this;
 }
开发者ID:cojaco,项目名称:UltimateModuleCreator,代码行数:26,代码来源:Config.php

示例7: toOptionArray

 public static function toOptionArray()
 {
     $result = array();
     $path = 'http://facebook.com/translations/FacebookLocales.xml';
     if (file_exists($path)) {
         $xml = new Varien_Simplexml_Element($path, 0, true);
         $xmlData = $xml->children();
         $locales = $xmlData;
         foreach ($locales as $locale) {
             $data = $locale->asArray();
             $codes = $data['codes'];
             $code = trim($codes['code']['standard']['representation']);
             $label = $data['englishName'];
             $result[] = array('value' => $code, 'label' => $label);
         }
     } else {
         $result[] = array('value' => 'en_US', 'label' => 'English (US)');
     }
     return $result;
 }
开发者ID:shebin512,项目名称:Magento_Zoff,代码行数:20,代码来源:Lang.php

示例8: evaluateLayoutDefinition

 /**
  * Checks layout definititions for expected file defined in the configuration
  *
  * @param Varien_Simplexml_Element $other
  * @return boolean
  */
 protected function evaluateLayoutDefinition($other)
 {
     foreach ($other->children() as $layoutUpdate) {
         if ((string) $layoutUpdate->file === $this->_expectedValue && ($this->_layoutUpdate === null || $this->_layoutUpdate === $layoutUpdate->getName())) {
             return true;
         }
     }
     if ($this->_layoutUpdate === null) {
         $this->_layoutUpdate = 'your_module';
     }
     $expected = clone $other;
     $expected->addChild($this->_layoutUpdate)->addChild('file', htmlspecialchars($this->_expectedValue));
     return $this->compareValues($this->getXmlAsDom($expected), $this->getXmlAsDom($other));
 }
开发者ID:tiagosampaio,项目名称:EcomDev_PHPUnit,代码行数:20,代码来源:Layout.php

示例9: _processConfigValue

 /**
  * Process config value
  *
  * @param string $fullPath
  * @param string $path
  * @param Varien_Simplexml_Element $node
  * @return string
  */
 protected function _processConfigValue($fullPath, $path, $node)
 {
     if (isset($this->_configCache[$path])) {
         return $this->_configCache[$path];
     }
     if ($node->hasChildren()) {
         $aValue = array();
         foreach ($node->children() as $k => $v) {
             $aValue[$k] = $this->_processConfigValue($fullPath . '/' . $k, $path . '/' . $k, $v);
         }
         $this->_configCache[$path] = $aValue;
         return $aValue;
     }
     $sValue = (string) $node;
     if (!empty($node['backend_model']) && !empty($sValue)) {
         $backend = Mage::getModel((string) $node['backend_model']);
         $backend->setPath($path)->setValue($sValue)->afterLoad();
         $sValue = $backend->getValue();
     }
     if (is_string($sValue) && preg_match('/{{(.*)}}.*/', $sValue, $matches)) {
         $placeholder = $matches[1];
         $url = false;
         if ($placeholder == 'unsecure_base_url' || $placeholder == 'unsecure_public_url') {
             $url = $this->getConfig(self::XML_PATH_UNSECURE_BASE_URL);
         } elseif ($placeholder == 'secure_base_url' || $placeholder == 'secure_public_url') {
             $url = $this->getConfig(self::XML_PATH_SECURE_BASE_URL);
         }
         if ($placeholder == 'unsecure_public_url' || $placeholder == 'secure_public_url') {
             $pubName = Mage_Core_Model_Config_Options::PUB_DIRECTORY;
             $url .= substr(dirname($_SERVER['SCRIPT_FILENAME']), -4) == '/' . $pubName ? '' : $pubName . '/';
         }
         if ($url) {
             $sValue = str_replace('{{' . $placeholder . '}}', $url, $sValue);
         } elseif (strpos($sValue, '{{base_url}}') !== false) {
             $sValue = Mage::getConfig()->substDistroServerVars($sValue);
         }
     }
     $this->_configCache[$path] = $sValue;
     return $sValue;
 }
开发者ID:nemphys,项目名称:magento2,代码行数:48,代码来源:Store.php

示例10: _saveUrlsInSystemConfig

 /**
  * Process core config data
  *
  * @param Mage_Core_Model_Website   $stagingWebsite
  * @param string $originalBaseUrl
  * @param string $baseUrl
  * @param string $mode
  * @param Varien_Simplexml_Element  $xmlConfig
  */
 protected function _saveUrlsInSystemConfig($stagingWebsite, $originalBaseUrl, $baseUrl, $mode = 'unsecure', $xmlConfig)
 {
     foreach ($xmlConfig->children() as $nodeName => $nodeValue) {
         if ($mode == 'secure' || $mode == 'unsecure') {
             if ($nodeName == 'base_url' || $nodeName == 'base_web_url' || $nodeName == 'base_link_url') {
                 $nodeValue = $baseUrl;
             } elseif ($mode == 'unsecure') {
                 if (strpos($nodeValue, '{{unsecure_base_url}}') !== false) {
                     $nodeValue = str_replace('{{unsecure_base_url}}', $originalBaseUrl, $nodeValue);
                 }
             } elseif ($mode == 'secure') {
                 if (strpos($nodeValue, '{{secure_base_url}}') !== false) {
                     $nodeValue = str_replace('{{secure_base_url}}', $originalBaseUrl, $nodeValue);
                 }
             }
         }
         $config = Mage::getModel('core/config_data');
         $path = 'web/' . $mode . '/' . $nodeName;
         $config->setPath($path);
         $config->setScope('websites');
         $config->setScopeId($stagingWebsite->getId());
         $config->setValue($nodeValue);
         $config->save();
     }
     return $this;
 }
开发者ID:jpbender,项目名称:mage_virtual,代码行数:35,代码来源:Website.php

示例11: _getTreeNode

 /**
  * Get tree node
  *
  * @param Varien_Simplexml_Element|array $node
  * @param int $level
  * @return array
  */
 protected function _getTreeNode($node, $level = 0)
 {
     $item = array();
     $isResource = false;
     $isGroup = false;
     $name = null;
     if ($level != 0) {
         $name = $node->getName();
         if (!(int) $node->resource) {
             if (self::NAME_RESOURCE_GROUPS != $name) {
                 $isGroup = true;
                 $item['id'] = self::NAME_GROUP . self::ID_SEPARATOR . $name;
             }
             $item['text'] = (string) $node->title;
         } else {
             $isResource = true;
             $item['id'] = self::NAME_RESOURCE . self::ID_SEPARATOR . $name;
             $item['text'] = $this->__('%s', (string) $node->title);
         }
         $item['checked'] = false;
         $item['sort_order'] = isset($node->sort_order) ? (string) $node->sort_order : 0;
     }
     if (isset($node->children)) {
         $children = $node->children->children();
     } else {
         $children = $node->children();
     }
     if (empty($children)) {
         /**
          * Node doesn't have any child nodes
          * and it should be skipped
          */
         return $item;
     }
     $item[self::NAME_CHILDREN] = array();
     if ($isResource) {
         if (self::TYPE_ATTRIBUTE == $this->_type) {
             if (!$this->_addOperations($item, $node, $name)) {
                 return null;
             }
         } elseif (self::TYPE_PRIVILEGE == $this->_type) {
             if (!$this->_addPrivileges($item, $node, $name)) {
                 return null;
             }
         }
     }
     /** @var $child Varien_Simplexml_Element */
     foreach ($children as $child) {
         if ($child->getName() != 'title' && $child->getName() != 'sort_order') {
             if (!(string) $child->title) {
                 continue;
             }
             if ($level != 0) {
                 $subNode = $this->_getTreeNode($child, $level + 1);
                 if (!$subNode) {
                     continue;
                 }
                 //if sub-node check then check current node
                 if (!empty($subNode['checked'])) {
                     $item['checked'] = true;
                 }
                 $item[self::NAME_CHILDREN][] = $subNode;
             } else {
                 $item = $this->_getTreeNode($child, $level + 1);
             }
         }
     }
     if (!empty($item[self::NAME_CHILDREN])) {
         usort($item[self::NAME_CHILDREN], array($this, '_sortTree'));
     } elseif ($isGroup) {
         //skip empty group
         return null;
     }
     return $item;
 }
开发者ID:ksaltik,项目名称:tooldexlive,代码行数:82,代码来源:Tree.php

示例12: _generateAction

 /**
  * Modified core generate action method
  *
  * @param Varien_Simplexml_Element $node
  * @param Varien_Simplexml_Element $parent
  * @return Mage_Core_Model_Layout
  */
 protected function _generateAction($node, $parent)
 {
     if (isset($node['ifconfig']) && ($configPath = (string) $node['ifconfig'])) {
         $ifConfig = Mage::getStoreConfigFlag($configPath);
         $nodeArray = (array) $node;
         $advIfconfig = null;
         $dependsCheck = false;
         $requiredDepends = false;
         if (isset($nodeArray['adv_ifconfig'])) {
             $advIfconfig = (array) $nodeArray['adv_ifconfig'];
             if (isset($advIfconfig['depends_check'])) {
                 $dependsCheck = $advIfconfig['depends_check'];
             }
             if (isset($advIfconfig['required_depends'])) {
                 $requiredDepends = $advIfconfig['required_depends'];
             }
         }
         if ($ifConfig && $dependsCheck) {
             if ($dependsCheck == 1 || $dependsCheck == 'tree') {
                 $configPath = explode('/', $configPath);
                 $ifConfig = $ifConfig && Mage::helper('advifconfig')->checkSystemConfigNodeDepends($configPath[0], $configPath[1], $configPath[2], $ifConfig);
             }
             if (($dependsCheck == 1 || $dependsCheck == 'required') && $requiredDepends) {
                 $additionalDepends = array_map('trim', explode(',', $requiredDepends));
                 foreach ($additionalDepends as $depend) {
                     $ifConfig = $ifConfig && Mage::getStoreConfigFlag($depend);
                 }
             }
         }
         if (!$ifConfig) {
             return $this;
         }
         if (isset($advIfconfig['custom_rules'])) {
             $data = array_merge(array('ifconfig' => false), (array) $advIfconfig['custom_rules']);
             $data = new Varien_Object($data);
             Mage::dispatchEvent('adv_ifconfig_custom_rules', $data);
             if (!$data->getIfconfig()) {
                 return $this;
             }
         }
     }
     $method = (string) $node['method'];
     if (!empty($node['block'])) {
         $parentName = (string) $node['block'];
     } else {
         $parentName = $parent->getBlockName();
     }
     $_profilerKey = 'BLOCK ACTION: ' . $parentName . ' -> ' . $method;
     Varien_Profiler::start($_profilerKey);
     if (!empty($parentName)) {
         $block = $this->getBlock($parentName);
     }
     if (!empty($block)) {
         $args = (array) $node->children();
         unset($args['@attributes']);
         if (isset($args['adv_ifconfig'])) {
             unset($args['adv_ifconfig']);
         }
         foreach ($args as $key => $arg) {
             if ($arg instanceof Mage_Core_Model_Layout_Element) {
                 if (isset($arg['helper'])) {
                     $helperName = explode('/', (string) $arg['helper']);
                     $helperMethod = array_pop($helperName);
                     $helperName = implode('/', $helperName);
                     $arg = $arg->asArray();
                     unset($arg['@']);
                     $args[$key] = call_user_func_array(array(Mage::helper($helperName), $helperMethod), $arg);
                 } else {
                     /**
                      * if there is no helper we hope that this is assoc array
                      */
                     $arr = array();
                     foreach ($arg as $subkey => $value) {
                         $arr[(string) $subkey] = $value->asArray();
                     }
                     if (!empty($arr)) {
                         $args[$key] = $arr;
                     }
                 }
             }
         }
         if (isset($node['json'])) {
             $json = explode(' ', (string) $node['json']);
             foreach ($json as $arg) {
                 $args[$arg] = Mage::helper('core')->jsonDecode($args[$arg]);
             }
         }
         $this->_translateLayoutNode($node, $args);
         call_user_func_array(array($block, $method), $args);
     }
     Varien_Profiler::stop($_profilerKey);
     return $this;
 }
开发者ID:amr-z,项目名称:advanced-ifconfig,代码行数:100,代码来源:Layout.php

示例13: _translateConfigRecursively

 /**
  * Enter description here ...
  * @param Varien_Simplexml_Element $config
  * @param array | null $fields
  * @param string | null $module
  */
 protected function _translateConfigRecursively($config, $fields = null, $module = null)
 {
     if ($fields && in_array($config->getName(), $fields)) {
         $name = $config->getName();
         $parent = $config->getParent();
         $value = (string) $config;
         $moduleName = $module ? $module : $this->_getModuleName();
         $parent->{$name} = Mage::app()->getTranslator()->translate(array(new Mage_Core_Model_Translate_Expr($value, $moduleName)));
     }
     $fields = isset($config['translate']) ? explode(',', (string) $config['translate']) : null;
     $module = isset($config['module']) ? (string) $config['module'] : null;
     foreach ($config->children() as $key => $value) {
         $this->_translateConfigRecursively($value, $fields, $module);
     }
 }
开发者ID:xiaoguizhidao,项目名称:autotech_design,代码行数:21,代码来源:Data.php

示例14: _xmlToArray

 /**
  * Convert xml to array
  *
  * @param Varien_Simplexml_Element $element XML element
  * @return array|string
  */
 protected function _xmlToArray(Varien_Simplexml_Element $element)
 {
     if (!$element->hasChildren()) {
         return (string) $element;
     }
     $result = array();
     foreach ($element->children() as $_name => $_child) {
         if (isset($result[$_name])) {
             if (!is_array($result[$_name]) || !isset($result[$_name]['__list'])) {
                 $result[$_name] = array($result[$_name]);
                 $result[$_name]['__list'] = true;
             }
             $result[$_name][] = $this->_xmlToArray($_child);
         } else {
             $result[$_name] = $this->_xmlToArray($_child);
         }
     }
     // Remove temp __list mark
     array_walk($result, function (&$node) {
         if (is_array($node)) {
             unset($node['__list']);
         }
     });
     return $result;
 }
开发者ID:rockxcn,项目名称:messenger,代码行数:31,代码来源:Xml.php

示例15: _getChildByHandle

 /**
  * Get child by handle
  *
  * @param Varien_Simplexml_Element $xmlObject
  * @param string $handle
  * @return Varien_Simplexml_Element
  */
 protected function _getChildByHandle($xmlObject, $handle)
 {
     foreach ($xmlObject->children() as $child) {
         if ($child->getName() == $handle) {
             return $child;
         }
     }
     return $xmlObject->addChild($handle);
 }
开发者ID:rorteg,项目名称:magento2,代码行数:16,代码来源:Collection.php


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