本文整理汇总了PHP中Varien_Simplexml_Element::xpath方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Simplexml_Element::xpath方法的具体用法?PHP Varien_Simplexml_Element::xpath怎么用?PHP Varien_Simplexml_Element::xpath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Simplexml_Element
的用法示例。
在下文中一共展示了Varien_Simplexml_Element::xpath方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSystemConfigNodeLabel
/**
* System configuration section, fieldset or field label getter
*
* @param string $sectionName
* @param string $groupName
* @param string $fieldName
* @return string
*/
public function getSystemConfigNodeLabel($sectionName, $groupName = null, $fieldName = null)
{
$sectionName = trim($sectionName, '/');
$path = '//sections/' . $sectionName;
$groupNode = $fieldNode = null;
$sectionNode = $this->_sections->xpath($path);
if (!empty($groupName)) {
$path .= '/groups/' . trim($groupName, '/');
$groupNode = $this->_sections->xpath($path);
}
if (!empty($fieldName)) {
if (!empty($groupName)) {
$path .= '/fields/' . trim($fieldName, '/');
$fieldNode = $this->_sections->xpath($path);
} else {
Mage::throwException(Mage::helper('Mage_Adminhtml_Helper_Data')->__('The group node name must be specified with field node name.'));
}
}
$moduleName = $this->getAttributeModule($sectionNode, $groupNode, $fieldNode);
$systemNode = $this->_sections->xpath($path);
foreach ($systemNode as $node) {
return Mage::helper($moduleName)->__((string) $node->label);
}
return '';
}
示例2: getXpath
/**
* Returns nodes found by xpath expression
*
* @param string $xpath
* @return array
*/
public function getXpath($xpath)
{
if (empty($this->_xml)) {
return false;
}
if (!($result = @$this->_xml->xpath($xpath))) {
return false;
}
return $result;
}
示例3: _createPrimaryKey
/**
* @param Varien_Object $context
* @param Varien_Simplexml_Element $module
* @param Varien_Simplexml_Element $entity
* @param Varien_Simplexml_Element $scope
*/
public function _createPrimaryKey($context, $module, $entity, $scope)
{
if ((string) $scope['module'] != $this->getModuleName() || (string) $scope['version'] != $this->getVersion()) {
return;
}
/* @var $configHelper Mana_Db_Helper_Config */
$configHelper = Mage::helper('mana_db/config');
$primaryField = $scope->xpath('fields/*[primary="1"]');
if (empty($primaryField)) {
$scope->fields->id->type = 'bigint';
$field = $scope->fields->id;
$field->primary = 1;
$field->role = Mana_Db_Helper_Config::ROLE_PRIMARY_KEY;
$configHelper->propagateName($field);
$configHelper->propagateAttributes($scope, $field, array('module', 'version'));
}
}
示例4: _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);
}
示例5: isValid
/**
* Returns true if and only if $value meets the validation requirements
*
* If $value fails validation, then this method returns false, and
* getMessages() will return an array of messages that explain why the
* validation failed.
*
* @throws Exception Throw exception when xml object is not
* instance of Varien_Simplexml_Element
* @param Varien_Simplexml_Element|string $value
* @return bool
*/
public function isValid($value)
{
if (is_string($value)) {
$value = trim($value);
try {
//wrap XML value in the "config" tag because config cannot
//contain multiple root tags
$value = new Varien_Simplexml_Element('<config>' . $value . '</config>');
} catch (Exception $e) {
$this->_error(self::XML_INVALID);
return false;
}
} elseif (!$value instanceof Varien_Simplexml_Element) {
throw new Exception(Mage::helper('adminhtml')->__('XML object is not instance of "Varien_Simplexml_Element".'));
}
$this->_setValue($value);
foreach ($this->_protectedExpressions as $key => $xpr) {
if ($this->_value->xpath($xpr)) {
$this->_error($key);
return false;
}
}
return true;
}
示例6: findTranslationModuleName
/**
* Lookup module name for translation from current specified layout node
*
* Priorities:
* 1) "module" attribute in the element
* 2) "module" attribute in any ancestor element
* 3) layout handle name - first 1 or 2 parts (namespace is determined automatically)
*
* @param Varien_Simplexml_Element $node
* @return string
*/
public static function findTranslationModuleName(Varien_Simplexml_Element $node)
{
$result = $node->getAttribute('module');
if ($result) {
return (string) $result;
}
foreach (array_reverse($node->xpath('ancestor::*[@module]')) as $element) {
$result = $element->getAttribute('module');
if ($result) {
return (string) $result;
}
}
foreach ($node->xpath('ancestor-or-self::*[last()-1]') as $handle) {
$name = Mage::getConfig()->determineOmittedNamespace($handle->getName());
if ($name) {
return $name;
}
}
return 'core';
}
示例7: findTranslationModuleName
/**
* Lookup module name for translation from current specified layout node
*
* Priorities:
* 1) "module" attribute in the element
* 2) "module" attribute in any ancestor element
* 3) layout handle name - first 1 or 2 parts (namespace is determined automatically)
*
* @param Varien_Simplexml_Element $node
* @return string
*/
public static function findTranslationModuleName(Varien_Simplexml_Element $node)
{
// Commented out code uses not yet implemented functionality.
$result = (string) $node->getAttribute('module');
if ($result) {
//return Mage::getConfig()->getModuleConfig($result) ? $result : 'core';
return $result;
}
foreach (array_reverse($node->xpath('ancestor::*[@module]')) as $element) {
$result = (string) $element->getAttribute('module');
if ($result) {
//return Mage::getConfig()->getModuleConfig($result) ? $result : 'core';
return $result;
}
}
foreach ($node->xpath('ancestor-or-self::*[last()-1]') as $handle) {
$name = Mage::getConfig()->determineOmittedNamespace($handle->getName(), true);
if ($name) {
//return Mage::getConfig()->getModuleConfig($name) ? $name : 'core';
return $name;
}
}
return 'Mage_Core';
}
示例8: _sanitizeReference
/**
* Cleanup reference node according to the block it refers to
*
* Look for the block by reference name and if the block is "unsafe", cleanup the reference node from actions
*
* @param Varien_Simplexml_Element $node
*/
protected static function _sanitizeReference(Varien_Simplexml_Element $node)
{
$attributes = $node->attributes();
$name = $attributes['name'];
$result = $node->xpath("//block[@name='{$name}']") ?: array();
foreach ($result as $block) {
$isTypeSafe = self::_isTypeSafe($block->getAttribute('type'));
if (!$isTypeSafe || !self::_isParentSafe($block)) {
self::_deleteNodes($node, 'action');
}
break;
}
}
示例9: filterAclNodes
/**
* Delete nodes that have "acl" attribute but value is "not allowed"
*
* In any case, the "acl" attribute will be unset
*
* @param Varien_Simplexml_Element $xml
*/
public function filterAclNodes(Varien_Simplexml_Element $xml)
{
$limitations = $xml->xpath('//*[@acl]') ?: array();
foreach ($limitations as $node) {
if (!$this->isAllowed($node['acl'])) {
$node->unsetSelf();
} else {
unset($node['acl']);
}
}
}