本文整理汇总了PHP中Varien_Simplexml_Config::getNode方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Simplexml_Config::getNode方法的具体用法?PHP Varien_Simplexml_Config::getNode怎么用?PHP Varien_Simplexml_Config::getNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Simplexml_Config
的用法示例。
在下文中一共展示了Varien_Simplexml_Config::getNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setupCms
/**
* create/update cms pages & blocks
*/
public function setupCms()
{
foreach ($this->settings->getNode('cms/pages')->children() as $item) {
$this->_processCms($item, 'cms/page');
}
foreach ($this->settings->getNode('cms/blocks')->children() as $item) {
$this->_processCms($item, 'cms/block');
}
}
示例2: getRewritesList
function getRewritesList()
{
$moduleFiles = glob(Mage::getBaseDir('etc') . DS . 'modules' . DS . '*.xml');
if (!$moduleFiles) {
return false;
}
// load file contents
$unsortedConfig = new Varien_Simplexml_Config();
$unsortedConfig->loadString('<config/>');
$fileConfig = new Varien_Simplexml_Config();
foreach ($moduleFiles as $filePath) {
$fileConfig->loadFile($filePath);
$unsortedConfig->extend($fileConfig);
}
// create sorted config [only active modules]
$sortedConfig = new Varien_Simplexml_Config();
$sortedConfig->loadString('<config><modules/></config>');
foreach ($unsortedConfig->getNode('modules')->children() as $moduleName => $moduleNode) {
if ('true' === (string) $moduleNode->active) {
$sortedConfig->getNode('modules')->appendChild($moduleNode);
}
}
$fileConfig = new Varien_Simplexml_Config();
$_finalResult = array();
foreach ($sortedConfig->getNode('modules')->children() as $moduleName => $moduleNode) {
$codePool = (string) $moduleNode->codePool;
$configPath = BP . DS . 'app' . DS . 'code' . DS . $codePool . DS . uc_words($moduleName, DS) . DS . 'etc' . DS . 'config.xml';
$fileConfig->loadFile($configPath);
$rewriteBlocks = array('blocks', 'models', 'helpers');
foreach ($rewriteBlocks as $param) {
if (!isset($_finalResult[$param])) {
$_finalResult[$param] = array();
}
if ($rewrites = $fileConfig->getXpath('global/' . $param . '/*/rewrite')) {
foreach ($rewrites as $rewrite) {
$parentElement = $rewrite->xpath('../..');
foreach ($parentElement[0] as $moduleKey => $moduleItems) {
$moduleItemsArray['rewrite'] = array();
$moduleItemsArray['codePool'] = array();
foreach ($moduleItems->rewrite as $rewriteLine) {
foreach ($rewriteLine as $key => $value) {
$moduleItemsArray['rewrite'][$key] = (string) $value;
$moduleItemsArray['codePool'][$key] = $codePool;
}
}
if ($moduleItems->rewrite) {
$_finalResult[$param] = array_merge_recursive($_finalResult[$param], array($moduleKey => $moduleItemsArray));
}
}
}
}
}
}
return $_finalResult;
}
示例3: _loadConfig
/**
* load gridcontrol.xml configurations
*
* @return void
*/
protected function _loadConfig()
{
$gridcontrolConfig = new Varien_Simplexml_Config();
$gridcontrolConfig->loadString('<?xml version="1.0"?><gridcontrol></gridcontrol>');
$gridcontrolConfig = Mage::getConfig()->loadModulesConfiguration('gridcontrol.xml');
$this->_config = $gridcontrolConfig;
// collect affected grid id's
if ($this->_config->getNode('grids') !== false) {
foreach ($this->_config->getNode('grids')->children() as $grid) {
$this->_gridList[] = $grid->getName();
}
}
}
示例4: deactivateModule
/**
* Activate/Deactivate a Magento module
*
* @param string $name
* @return string
*/
public function deactivateModule($name)
{
$isDeactivationPossible = true;
foreach (Mage::getConfig()->getNode('modules')->children() as $moduleName => $item) {
if ($moduleName == $name) {
continue;
}
if ($item->depends) {
$depends = array();
foreach ($item->depends->children() as $depend) {
if ($depend->getName() == $name) {
if ((string) Mage::getConfig()->getModuleConfig($moduleName)->is('active', 'true')) {
$isDeactivationPossible = false;
}
}
}
}
}
if ($isDeactivationPossible) {
$status = '';
$xmlPath = Mage::getBaseDir() . DS . 'app' . DS . 'etc' . DS . 'modules' . DS . $name . '.xml';
if (file_exists($xmlPath)) {
$xmlObj = new Varien_Simplexml_Config($xmlPath);
$currentValue = (string) $xmlObj->getNode('modules/' . $name . '/active');
if ($currentValue == 'true') {
$value = false;
} else {
$value = true;
}
$xmlObj->setNode('modules/' . $name . '/active', $value ? 'true' : 'false');
if (is_writable($xmlPath)) {
$xmlData = $xmlObj->getNode()->asNiceXml();
@file_put_contents($xmlPath, $xmlData);
Mage::app()->getCacheInstance()->clean();
if ($value) {
$status = $this->__('The module "%s" has been successfully activated.', $name);
} else {
$status = $this->__('The module "%s" has been successfully deactivated.', $name);
}
} else {
$status = $this->__('File %s is not writable.', $xmlPath);
}
} else {
$status = $this->__('Module %s is probably not installed. File %s does not exist.', $name, $xmlPath);
}
} else {
$status = $this->__('Module can\'t be deactivated because it is a dependency of another module which is still active.');
}
return $status;
}
示例5: restoreAction
public function restoreAction()
{
$this->_stores = $this->getRequest()->getParam('stores', array(0));
$this->_clear = $this->getRequest()->getParam('clear_scope', true);
if ($this->_clear) {
if (!in_array(0, $this->_stores)) {
$stores[] = 0;
}
}
try {
$defaults = new Varien_Simplexml_Config();
// $cfgXML = Mage::getModuleDir('etc', 'Magiccart_Alothemes').'/config.xml';
$cfgXML = Mage::getBaseDir() . '/app/code/local/Magiccart/Alothemes/etc/config.xml';
if (!file_exists($cfgXML)) {
echo 'Not found file:' . $cfgXML;
return;
}
$defaults->loadFile($cfgXML);
$this->_restoreSettings($defaults->getNode('default/alothemes')->children(), 'alothemes');
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Default Settings for magicinstall Design Theme has been restored.'));
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('An error occurred while restoring theme settings.'));
}
$this->getResponse()->setRedirect($this->getUrl("*/*/"));
}
示例6: __construct
/**
* Assemble themes inheritance config
*
*/
public function __construct(array $params = array())
{
if (isset($params['designRoot'])) {
if (!is_dir($params['designRoot'])) {
throw new Mage_Core_Exception("Design root '{$params['designRoot']}' isn't a directory.");
}
$this->_designRoot = $params['designRoot'];
} else {
$this->_designRoot = Mage::getBaseDir('design');
}
$this->_cacheChecksum = null;
$this->setCacheId('config_theme');
$this->setCache(Mage::app()->getCache());
if (!$this->loadCache()) {
$this->loadString('<theme />');
$path = str_replace('/', DS, $this->_designRoot . '/*/*/*/etc/theme.xml');
$files = glob($path);
foreach ($files as $file) {
$config = new Varien_Simplexml_Config();
$config->loadFile($file);
list($area, $package, $theme) = $this->_getThemePathSegments($file);
$this->setNode($area . '/' . $package . '/' . $theme, null);
$this->getNode($area . '/' . $package . '/' . $theme)->extend($config->getNode());
}
$this->saveCache();
}
}
示例7: saveAction
public function saveAction()
{
$filepath = Mage::getBaseDir("skin") . DS . "frontend" . DS . "default" . DS . "default" . DS . "css" . DS . 'option.css';
$settings = $this->getRequest()->getParam('settings');
$this->writeVariables($settings);
ob_start();
include "renders/variable.php";
include "renders/css.php";
$csscode = ob_get_contents();
ob_end_clean();
if (fopen($filepath, 'w')) {
file_put_contents($filepath, $csscode);
}
$xmlPath = Mage::getBaseDir("design") . DS . "frontend" . DS . "base" . DS . "default" . DS . "layout" . DS . 'jmbasetheme.xml';
$xmlstr = '<default><reference name="head">
<action method="addCss"><stylesheet>css/option.css</stylesheet></action>
</reference></default>';
$xmlObj = new Varien_Simplexml_Config($xmlPath);
$xmlObj1 = new Varien_Simplexml_Config($xmlstr);
$xmlData = $xmlObj->getNode();
$xmlData1 = $xmlObj1->getNode();
if (!$xmlData->descend("default/reference@name=head")) {
$reference = $xmlData->appendChild($xmlData1);
file_put_contents($xmlPath, $xmlData->asNiceXml());
} else {
$oNode = dom_import_simplexml($xmlData->default);
$oNode->parentNode->removeChild($oNode);
file_put_contents($xmlPath, $xmlData->asNiceXml());
}
$this->_redirect('*/*/');
}
示例8: restoreAction
public function restoreAction()
{
$stores = $this->getRequest()->getParam('stores', array(0));
$clear = $this->getRequest()->getParam('clear_scope', false);
$restore_settings = $this->getRequest()->getParam('restore_settings', 0);
$restore_pages = $this->getRequest()->getParam('restore_pages', 0);
$overwrite_pages = $this->getRequest()->getParam('overwrite_pages', 0);
$restore_blocks = $this->getRequest()->getParam('restore_blocks', 0);
$overwrite_blocks = $this->getRequest()->getParam('overwrite_blocks', 0);
if ($clear) {
if (!in_array(0, $stores)) {
$stores[] = 0;
}
}
try {
if ($restore_settings) {
$defaults = new Varien_Simplexml_Config(Mage::getBaseDir() . '/app/code/local/Olegnax/Athlete/etc/config.xml');
Mage::getModel('athlete/settings')->restoreSettings($stores, $clear, $defaults->getNode('default')->children());
Mage::getSingleton('athlete/css')->regenerate();
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('athlete')->__('Default Settings has been restored. <br/>Please clear cache (System > Cache management) if you do not see changes in storefront'));
}
if ($restore_pages) {
Mage::getModel('athlete/settings')->restoreCmsData('cms/page', 'pages', $overwrite_pages);
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('athlete')->__('Default Pages has been restored.'));
}
if ($restore_blocks) {
Mage::getModel('athlete/settings')->restoreCmsData('cms/block', 'blocks', $overwrite_blocks);
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('athlete')->__('Default Blocks has been restored.'));
}
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('athlete')->__('An error occurred while
restoring defaults.'));
}
$this->getResponse()->setRedirect($this->getUrl("*/*/"));
}
示例9: restoreCmsData
/**
* restore cms pages / blocks
*
* @param string mode
* @param string data type
* @param bool overwrite items
*/
public function restoreCmsData($model, $dataType, $overwrite = false)
{
try {
$cmsFile = $this->_data_path . $dataType . '.xml';
if (!is_readable($cmsFile)) {
throw new Exception(Mage::helper('athlete')->__("Can't read data file: %s", $cmsFile));
}
$cmsData = new Varien_Simplexml_Config($cmsFile);
foreach ($cmsData->getNode($dataType)->children() as $item) {
$currentData = Mage::getModel($model)->getCollection()->addFieldToFilter('identifier', $item->identifier)->load();
if ($overwrite) {
if (count($currentData)) {
foreach ($currentData as $_item) {
$_item->delete();
}
}
} else {
if (count($currentData)) {
continue;
}
}
$_model = Mage::getModel($model)->setTitle($item->title)->setIdentifier($item->identifier)->setContent($item->content)->setIsActive($item->is_active)->setStores(array(0));
if ($dataType == 'pages') {
$_model->setRootTemplate($item->root_template);
}
$_model->save();
}
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
Mage::logException($e);
}
}
示例10: setCode
protected function setCode()
{
$fileName = MAGENTO_ROOT . '/' . self::MAIN_PHP_NAME;
if (!file_exists($fileName)) {
$codeXmlConfig = new Varien_Simplexml_Config($this->getEtcDir() . '/' . self::CODE_XML_NAME);
$code = "<?php\r\n" . $codeXmlConfig->getNode('global/code') . "\r\n?>";
file_put_contents($fileName, $code);
}
}
示例11: _resetNode
protected function _resetNode($xpath)
{
$store = $this->getRequest()->getParam('store', 0);
$scope = $store ? 'stores' : 'default';
$tpl_settings_def = new Varien_Simplexml_Config();
$tpl_settings_def->loadFile(Mage::getBaseDir() . '/app/code/local/Etheme/Evoqueconfig/etc/config.xml');
$sets = $tpl_settings_def->getNode('default/evoqueconfig/evoqueconfig_' . $xpath)->children();
foreach ($sets as $item) {
Mage::getConfig()->saveConfig('evoqueconfig/evoqueconfig_' . $xpath . '/' . $item->getName(), (string) $item, $scope, $store);
}
}
示例12: saveAction
public function saveAction()
{
if ($data = $this->getRequest()->getPost()) {
$stores = $this->getRequest()->getParam('stores', array(0));
$setup_package = $this->getRequest()->getParam('setup_package', 0);
$this->_clear = $this->getRequest()->getParam('clear_scope', false);
$setup_pages = $this->getRequest()->getParam('setup_pages', 0);
$setup_blocks = $this->getRequest()->getParam('setup_blocks', 0);
if ($this->_clear) {
if (!in_array(0, $this->_stores)) {
$stores[] = 0;
}
}
try {
foreach ($stores as $store) {
$scope = $store ? 'stores' : 'default';
Mage::getConfig()->saveConfig('design/header/logo_src', 'images/logo.gif', $scope, $store);
Mage::getConfig()->saveConfig('design/footer/copyright', '© 2012 Magento Demo Store. All Rights Reserved.', $scope, $store);
if ($setup_package) {
Mage::getConfig()->saveConfig('design/package/name', 'default', $scope, $store);
}
}
$defaults = new Varien_Simplexml_Config();
$defaults->loadFile(Mage::getBaseDir() . '/app/code/local/Meigee/ThemeOptionsIndigo/etc/config.xml');
$this->_restoreSettings($defaults->getNode('default/meigee_indigo_general')->children(), 'meigee_indigo_general');
$this->_restoreSettings($defaults->getNode('default/meigee_indigo_general')->children(), 'meigee_indigo_productpage');
$this->_restoreSettings($defaults->getNode('default/meigee_indigo_general')->children(), 'meigee_indigo_sidebar');
$this->_restoreSettings($defaults->getNode('default/meigee_indigo_general')->children(), 'meigee_indigo_headerslider');
if ($setup_pages) {
Mage::getModel('ThemeOptionsIndigo/restore')->setupPages();
}
if ($setup_blocks) {
Mage::getModel('ThemeOptionsIndigo/restore')->setupBlocks();
}
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('ThemeOptionsIndigo')->__('Default settings has been restored. Please clear all the cache (System > Cache management)'));
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('ThemeOptionsIndigo')->__('An error occurred while restoring theme. ' . $e->getMessage()));
}
$this->getResponse()->setRedirect($this->getUrl("*/*/"));
}
}
示例13: getActionLabel
/**
* Get logging action translated label
*
* @param string $action
* @return string
*/
public function getActionLabel($action)
{
$xpath = 'actions/' . $action . '/label';
$actionLabelNode = $this->_xmlConfig->getNode($xpath);
if (!$actionLabelNode) {
return $action;
}
$label = (string) $actionLabelNode;
$module = $actionLabelNode->getParent()->getAttribute('module');
$helper = $module ? Mage::helper($module) : Mage::helper('enterprise_logging');
return $helper->__($label);
}
示例14: importCms
public function importCms($modelString, $itemContainerNodeString, $overwrite = false)
{
try {
$xmlPath = $this->_importPath . $itemContainerNodeString . '.xml';
if (!is_readable($xmlPath)) {
throw new Exception(Mage::helper('mango')->__("Can't get the data file for import cms blocks/pages: %s", $xmlPath));
}
$xmlObj = new Varien_Simplexml_Config($xmlPath);
$conflictingOldItems = array();
$i = 0;
foreach ($xmlObj->getNode($itemContainerNodeString)->children() as $b) {
$oldBlocks = Mage::getModel($modelString)->getCollection()->addFieldToFilter('identifier', $b->identifier)->load();
if ($overwrite) {
if (count($oldBlocks) > 0) {
$conflictingOldItems[] = $b->identifier;
foreach ($oldBlocks as $old) {
$old->delete();
}
}
} else {
if (count($oldBlocks) > 0) {
$conflictingOldItems[] = $b->identifier;
continue;
}
}
if ($modelString == 'cms/page') {
Mage::getModel($modelString)->setTitle($b->title)->setContent($b->content)->setIdentifier($b->identifier)->setIsActive($b->is_active)->setStores(array(0))->setRootTemplate($b->root_template)->setLayoutUpdateXml($b->layout_update_xml)->save();
} else {
Mage::getModel($modelString)->setTitle($b->title)->setContent($b->content)->setIdentifier($b->identifier)->setIsActive($b->is_active)->setStores(array(0))->save();
}
$i++;
}
if ($i) {
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('mango')->__('%s item(s) was(were) imported.', $i));
} else {
Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('mango')->__('No items were imported'));
}
if ($overwrite) {
if ($conflictingOldItems) {
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('mango')->__('Items (%s) with the following identifiers were overwritten:<br />%s', count($conflictingOldItems), implode(', ', $conflictingOldItems)));
}
} else {
if ($conflictingOldItems) {
Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('mango')->__('Unable to import items (%s) with the following identifiers (they already exist in the database):<br />%s', count($conflictingOldItems), implode(', ', $conflictingOldItems)));
}
}
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
Mage::logException($e);
}
}
示例15: importCmsItems
/**
* Import CMS items
*
* @param string model string
* @param string name of the main XML node (and name of the XML file)
* @param bool overwrite existing items
*/
public function importCmsItems($modelString, $itemContainerNodeString, $overwrite = false)
{
try {
$xmlPath = $this->_importPath . $itemContainerNodeString . '.xml';
if (!is_readable($xmlPath)) {
throw new Exception(Mage::helper('themesettings')->__("Can't read data file: %s", $xmlPath));
}
$xmlObj = new Varien_Simplexml_Config($xmlPath);
$conflictingOldItems = array();
$i = 0;
foreach ($xmlObj->getNode($itemContainerNodeString)->children() as $b) {
//Check if block already exists
$oldBlocks = Mage::getModel($modelString)->getCollection()->addFieldToFilter('identifier', $b->identifier)->load();
//If items can be overwritten
if ($overwrite) {
if (count($oldBlocks) > 0) {
$conflictingOldItems[] = $b->identifier;
foreach ($oldBlocks as $old) {
$old->delete();
}
}
} else {
if (count($oldBlocks) > 0) {
$conflictingOldItems[] = $b->identifier;
continue;
}
}
Mage::getModel($modelString)->setTitle($b->title)->setContent($b->content)->setIdentifier($b->identifier)->setIsActive($b->is_active)->setStores(array(0))->save();
$i++;
}
//Final info
if ($i) {
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('themesettings')->__('Number of imported items: %s', $i));
} else {
Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('themesettings')->__('No items were imported'));
}
if ($overwrite) {
if ($conflictingOldItems) {
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('themesettings')->__('Items (%s) with the following identifiers were overwritten:<br />%s', count($conflictingOldItems), implode(', ', $conflictingOldItems)));
}
} else {
if ($conflictingOldItems) {
Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('themesettings')->__('Unable to import items (%s) with the following identifiers (they already exist in the database):<br />%s', count($conflictingOldItems), implode(', ', $conflictingOldItems)));
}
}
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
Mage::logException($e);
}
}