本文整理汇总了PHP中Varien_Simplexml_Element::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Simplexml_Element::getName方法的具体用法?PHP Varien_Simplexml_Element::getName怎么用?PHP Varien_Simplexml_Element::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Simplexml_Element
的用法示例。
在下文中一共展示了Varien_Simplexml_Element::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addStagingItemToCollection
/**
* Add items into collection object
*
* @param Varien_Simplexml_Element $stagingItem
* @return Enterprise_Staging_Model_Resource_Staging_Item_Xml_Collection
*/
public function addStagingItemToCollection($stagingItem)
{
$extendInfo = $this->getExtendInfo();
$_code = (string) $stagingItem->getName();
$item = Mage::getModel('enterprise_staging/staging_item')->loadFromXmlStagingItem($stagingItem);
$disabled = false;
$checked = true;
$availabilityText = "";
//process extend information
if (!empty($extendInfo) && is_array($extendInfo) && isset($extendInfo[$_code])) {
$item->addData($extendInfo[$_code]);
if ($extendInfo[$_code]["disabled"] == true) {
$disabled = true;
$checked = false;
$availabilityText = $extendInfo[$_code]["reason"];
} else {
$availabilityText = Mage::helper('enterprise_staging')->__('available');
}
}
$item->setData('id', $_code);
$item->setData('code', $_code);
$item->setData('checked', $checked);
$item->setData('disabled', $disabled);
$item->setData('availability_text', $availabilityText);
$this->addItem($item);
return $this;
}
示例2: createConfigFields
/**
* Create config field during runtime.
*
* @param Varien_Simplexml_Element $section
* @return N98_CheckoutFilters_Model_Adminhtml_Config_Observer
*/
public function createConfigFields($section)
{
/**
* Check if we are in sales tab and sub-tab payment or shipping.
* Then we create SimpleXMLElements for form init.
*/
if ($section->tab == 'sales') {
if (in_array($section->label, array('Payment Methods', 'Shipping Methods'))) {
foreach ($section->groups as $group) {
foreach ($group as $subGroup) {
if (isset($subGroup->fields)) {
$this->_addCustomergroupFieldToConfigGroup($subGroup);
}
}
}
}
// Add fields only for payment methods
if (in_array($section->label, array('Payment Methods'))) {
foreach ($section->groups as $group) {
foreach ($group as $subGroup) {
if (isset($subGroup->fields)) {
$this->_addMinYearFieldToConfigGroup($subGroup);
}
}
}
}
}
/**
* Paypal uses a special config tab
*/
if ($section->tab == 'sales' && $section->getName() == 'paypal') {
if (isset($section->groups->express)) {
$this->_addCustomergroupFieldToConfigGroup($section->groups->express);
$this->_addMinYearFieldToConfigGroup($section->groups->express);
}
if (isset($section->groups->wps)) {
$this->_addCustomergroupFieldToConfigGroup($section->groups->wps);
$this->_addMinYearFieldToConfigGroup($section->groups->wps);
}
if (isset($section->groups->wpp)) {
$this->_addCustomergroupFieldToConfigGroup($section->groups->wpp);
$this->_addMinYearFieldToConfigGroup($section->groups->wpp);
}
}
/**
* Ebizmarts_Sagepay uses a special config tab
*/
if ('sales' == $section->tab && 'sagepaysuite' == $section->getName()) {
$my_groups = array('sagepayserver', 'sagepayserver_moto', 'sagepaydirectpro_moto', 'sagepaydirectpro', 'sagepayform', 'sagepaypaypal', 'sagepayrepeat');
foreach ($my_groups as $group) {
$this_group = $section->groups->{$group};
$this->_addCustomergroupFieldToConfigGroup($this_group);
$this->_addMinYearFieldToConfigGroup($this_group);
}
}
return $this;
}
示例3: 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;
}
示例4: _sanitizeLayout
/**
* Sanitize nodes which names match the specified one
*
* Recursively goes through all underlying nodes
*
* @param Varien_Simplexml_Element $node
* @param string $nodeName
*/
protected static function _sanitizeLayout(Varien_Simplexml_Element $node, $nodeName)
{
if ($node->getName() == $nodeName) {
switch ($nodeName) {
case 'block':
self::_sanitizeBlock($node);
break;
case 'reference':
self::_sanitizeReference($node);
break;
}
}
foreach ($node->children() as $child) {
self::_sanitizeLayout($child, $nodeName);
}
}
示例5: getWidgetConfig
/**
* Load widget XML config and merge with theme widget config
*
* @return Varien_Simplexml_Element|null
*/
public function getWidgetConfig()
{
if ($this->_widgetConfigXml === null) {
$this->_widgetConfigXml = Mage::getSingleton('widget/widget')->getXmlElementByType($this->getType());
if ($this->_widgetConfigXml) {
$configFile = Mage::getSingleton('core/design_package')->getBaseDir(array('_area' => $this->getArea(), '_package' => $this->getPackage(), '_theme' => $this->getTheme(), '_type' => 'etc')) . DS . 'widget.xml';
if (is_readable($configFile)) {
$themeWidgetsConfig = new Varien_Simplexml_Config();
$themeWidgetsConfig->loadFile($configFile);
if ($themeWidgetTypeConfig = $themeWidgetsConfig->getNode($this->_widgetConfigXml->getName())) {
$this->_widgetConfigXml->extend($themeWidgetTypeConfig);
}
}
}
}
return $this->_widgetConfigXml;
}
示例6: getWidgetConfig
/**
* Load widget XML config and merge with theme widget config
*
* @return Varien_Simplexml_Element|null
*/
public function getWidgetConfig()
{
if ($this->_widgetConfigXml === null) {
$this->_widgetConfigXml = Mage::getSingleton('Mage_Widget_Model_Widget')->getXmlElementByType($this->getType());
if ($this->_widgetConfigXml) {
$configFile = Mage::getDesign()->getFilename('widget.xml', array('_area' => $this->getArea(), '_package' => $this->getPackage(), '_theme' => $this->getTheme(), '_module' => Mage::getConfig()->determineOmittedNamespace(preg_replace('/^(.+?)\\/.+$/', '\\1', $this->getType()), true)));
if (is_readable($configFile)) {
$themeWidgetsConfig = new Varien_Simplexml_Config();
$themeWidgetsConfig->loadFile($configFile);
if ($themeWidgetTypeConfig = $themeWidgetsConfig->getNode($this->_widgetConfigXml->getName())) {
$this->_widgetConfigXml->extend($themeWidgetTypeConfig);
}
}
}
}
return $this->_widgetConfigXml;
}
示例7: updateMenu
public function updateMenu(Varien_Simplexml_Element $node)
{
$entityTypesCollection = $this->_getEntityTypesCollection();
if ($entityTypesCollection->getSize()) {
$children = $node->addChild('children');
$index = 0;
foreach ($entityTypesCollection as $entityType) {
$index += 10;
$menuItem = $children->addChild(sprintf('goodahead_etm_entity_type_%d', $entityType->getId()));
$menuItem->addChild('title', strlen($entityType->getEntityTypeName()) ? $entityType->getEntityTypeName() : $entityType->getEntityTypeCode());
$menuItem->addChild('sort_order', $index);
$menuItem->addChild('action', sprintf((string) $node->base_link, $entityType->getId()));
}
} else {
$nodeName = $node->getName();
unset($node->getParent()->{$nodeName});
}
}
示例8: flattenScope
/**
* @param Mana_Db_Model_Entity_Indexer $indexer provides access to process record and indexer setup
* @param Varien_Simplexml_Element $target setup in config.xml
* @param Varien_Simplexml_Element $scope setup in m_db.xml
* @param array $options on which records to run
* @return void
*/
public function flattenScope($indexer, $target, $scope, $options)
{
/** @noinspection PhpUndefinedFieldInspection */
$targetEntity = (string) $target->entity . '/' . $scope->getName();
if (isset($options['entity_filters']) && !isset($options['entity_filters'][$targetEntity])) {
return;
}
$options = array_merge(array('provide_field_details_in_exceptions' => true), $options);
if (isset($options['entity_filters']) && !isset($options['entity_filter_formula'])) {
$options['entity_filter_formula'] = '{{= ' . $options['entity_filters'][$targetEntity] . '}}';
}
$db = $this->_getWriteAdapter();
/* @var $res Mage_Core_Model_Resource */
$res = Mage::getSingleton('core/resource');
/* @var $dbHelper Mana_Db_Helper_Data */
$dbHelper = Mage::helper('mana_db');
/* @var $formulaHelper Mana_Db_Helper_Formula */
$formulaHelper = Mage::helper('mana_db/formula');
// get basic select from all source tables, properly joined (based on m_db.xml)
/** @noinspection PhpUndefinedFieldInspection */
$entity = (string) $scope->flattens;
//$db->query($formulaHelper->delete($entity, $targetEntity));
// get formula hashes and formula texts
$formulaGroups = $formulaHelper->getFormulaGroups($targetEntity, $options);
// for each formula hash => formula text
foreach ($formulaGroups as $formulas) {
$formulas = $formulas ? json_decode($formulas, true) : array();
// filter basic select by formula hash
$context = $formulaHelper->select($targetEntity, $formulas, $options);
// convert SELECT into UPDATE which acts as INSERT on DUPLICATE unique keys
$sql = $context->getSelect()->insertFromSelect($res->getTableName($dbHelper->getScopedName($targetEntity)), $context->getFields());
// run the statement
try {
$db->query($sql);
} catch (Exception $e) {
/* @var $logger Mana_Core_Helper_Logger */
$logger = Mage::helper('mana_core/logger');
$logger->logDbIndexerFailure($sql);
throw $e;
}
}
}
示例9: _getBaseClass
protected function _getBaseClass(Varien_Simplexml_Element $config)
{
$model = null;
if ($config->class) {
$model = (string) $config->class;
} elseif ($config->model) {
$model = (string) $config->model;
} else {
/**
* Backwards compatibility for pre-MMDB extensions. MMDB introduced since Magebto 1.6.0.0
* In MMDB release resource nodes <..._mysql4> were renamed to <..._resource>. So <deprecatedNode> is left
* to keep name of previously used nodes, that still may be used by non-updated extensions.
*/
$deprecatedNodes = $config->xpath('../*[deprecatedNode="' . (string) $config->getName() . '"]');
if ($deprecatedNodes && $deprecatedNodes[0]->class) {
$model = (string) $deprecatedNodes[0]->class;
}
}
if (is_null($model)) {
return false;
}
return $this->_getModelClassName($model, $config);
}
示例10: postDispatchReport
/**
* Handler for reports
*
* @param Varien_Simplexml_Element $config
* @param Enterprise_Logging_Model_Event $eventModel
* @return Enterprise_Logging_Model_Event|false
*/
public function postDispatchReport($config, $eventModel, $processor)
{
$fullActionNameParts = explode('_report_', $config->getName(), 2);
if (empty($fullActionNameParts[1])) {
return false;
}
$request = Mage::app()->getRequest();
$filter = $request->getParam('filter');
//Filtering request data
$data = array_intersect_key($request->getParams(), array('report_from' => null, 'report_to' => null, 'report_period' => null, 'store' => null, 'website' => null, 'group' => null));
//Need when in request data there are was no period info
if ($filter) {
$filterData = Mage::app()->getHelper('adminhtml')->prepareFilterString($filter);
$data = array_merge($data, (array) $filterData);
}
//Add log entry details
if ($data) {
$change = Mage::getModel('enterprise_logging/event_changes');
$processor->addEventChanges($change->setSourceName('params')->setOriginalData(array())->setResultData($data));
}
return $eventModel->setInfo($fullActionNameParts[1]);
}
示例11: extendChild
/**
* Extends one node
*
* @param Varien_Simplexml_Element $source
* @param boolean $overwrite
* @return Varien_Simplexml_Element
*/
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}->hasChildren()) {
return $this;
}
if ($overwrite) {
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 $childKey => $childNode) {
$targetChild->extendChild($childNode, $overwrite);
}
return $this;
}
示例12: appendChild
/**
* Appends $source to current node
*
* @param Varien_Simplexml_Element $source
* @return Varien_Simplexml_Element
*/
public function appendChild($n, $source)
{
if ($source->children()) {
/**
* @see http://bugs.php.net/bug.php?id=41867 , fixed in 5.2.4
*/
if (version_compare(phpversion(), '5.2.4', '<') === true) {
$name = $source->children()->getName();
} else {
$name = $source->getName();
}
$child = $n->addChild($name);
} else {
$child = $n->addChild($source->getName(), $this->xmlentities($source));
}
$attributes = $source->attributes();
foreach ($attributes as $key => $value) {
$child->addAttribute($key, $this->xmlentities($value));
}
foreach ($source->children() as $sourceChild) {
$this->appendChild($child, $sourceChild);
}
return $n;
}
示例13: 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) {
// sort either by sort_order or by child node values bypassing the sort_order
$elements = $this->_sortElements($group, $fieldset, (array) $elements);
foreach ($elements as $element) {
if (!$this->_canShowField($element)) {
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;
}
}
$this->_initElement($element, $fieldset, $group, $section, $path, $fieldPrefix, $labelPrefix);
}
}
return $this;
}
示例14: propagateName
/**
* @param Varien_Simplexml_Element $target
*/
public function propagateName($target)
{
$target->name = $target->getName();
}
示例15: _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);
}
}