本文整理汇总了PHP中Varien_Simplexml_Config::loadFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Simplexml_Config::loadFile方法的具体用法?PHP Varien_Simplexml_Config::loadFile怎么用?PHP Varien_Simplexml_Config::loadFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Simplexml_Config
的用法示例。
在下文中一共展示了Varien_Simplexml_Config::loadFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* load theme xml
*/
public function __construct()
{
parent::__construct();
$this->settings = new Varien_Simplexml_Config();
$this->settings->loadFile(Mage::getBaseDir() . $this->_file);
if (!$this->settings) {
throw new Exception('Can not read theme config file ' . Mage::getBaseDir() . $this->_file);
}
}
示例2: __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();
}
}
示例3: 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("*/*/"));
}
示例4: 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;
}
示例5: _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);
}
}
示例6: __construct
/**
* Init License Config Information
* XML Path: app/code/local/Magestore/license_certificates
*
* @param type $sourceData
*/
public function __construct($sourceData = null)
{
$certificateFolder = 'app/code/local/Magestore/license_certificates';
$certificateFolder = str_replace('/', DS, $certificateFolder);
$configFiles = glob(BP . DS . $certificateFolder . DS . '*.xml');
$this->loadFile(current($configFiles));
while ($file = next($configFiles)) {
$merge = new Varien_Simplexml_Config();
$merge->loadFile($file);
$this->extend($merge);
}
}
示例7: getFallbackConfig
/**
* Load widget XML config and merge with theme widget config
*
* @param array $defaults
*
* @return Varien_Simplexml_Element
*/
protected function getFallbackConfig($defaults)
{
if ($this->_fallbackConfigXml === null) {
$configFile = Mage::getSingleton('core/design_package')->getBaseDir(array('_area' => $defaults['_area'], '_package' => $defaults['_package'], '_theme' => $defaults['_theme'], '_type' => 'etc')) . DS . 'fallback.xml';
if (is_readable($configFile)) {
$themeFallbackConfig = new Varien_Simplexml_Config();
$themeFallbackConfig->loadFile($configFile);
if ($themeWidgetTypeConfig = $themeFallbackConfig->getNode('fallback')) {
$this->_fallbackConfigXml = $themeWidgetTypeConfig;
}
} else {
$this->_fallbackConfigXml = false;
}
}
return $this->_fallbackConfigXml;
}
示例8: 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();
$defaults->loadFile(Mage::getBaseDir() . '/app/code/local/MagenThemes/MTGhost/etc/config.xml');
$this->_restoreSettings($defaults->getNode('default/mtghost_design')->children(), 'mtghost_design');
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Default Settings for MTGhost 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("*/*/"));
}
示例9: 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/ThemeOptionsBlacknwhite/etc/config.xml');
$this->_restoreSettings($defaults->getNode('default/meigee_blacknwhite_general')->children(), 'meigee_blacknwhite_general');
$this->_restoreSettings($defaults->getNode('default/meigee_blacknwhite_design')->children(), 'meigee_blacknwhite_design');
$this->_restoreSettings($defaults->getNode('default/meigee_blacknwhite_productpage')->children(), 'meigee_blacknwhite_productpage');
$this->_restoreSettings($defaults->getNode('default/meigee_blacknwhite_sidebar')->children(), 'meigee_blacknwhite_sidebar');
$this->_restoreSettings($defaults->getNode('default/meigee_blacknwhite_headerslider')->children(), 'meigee_blacknwhite_headerslider');
$this->_restoreSettings($defaults->getNode('default/meigee_blacknwhite_bgslider')->children(), 'meigee_blacknwhite_bgslider');
if ($setup_pages) {
Mage::getModel('ThemeOptionsBlacknwhite/restore')->setupPages();
}
if ($setup_blocks) {
Mage::getModel('ThemeOptionsBlacknwhite/restore')->setupBlocks();
}
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('ThemeOptionsBlacknwhite')->__('Default settings has been restored. Please clear all the cache (System > Cache management)'));
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('ThemeOptionsBlacknwhite')->__('An error occurred while restoring theme. ' . $e->getMessage()));
}
$this->getResponse()->setRedirect($this->getUrl("*/*/"));
}
}
示例10: restoreAction
public function restoreAction()
{
$this->_stores = $this->getRequest()->getParam('stores', array(0));
$this->_clear = $this->getRequest()->getParam('clear_scope', false);
$setup_cms = $this->getRequest()->getParam('setup_cms', 0);
if ($this->_clear) {
if (!in_array(0, $this->_stores)) {
$stores[] = 0;
}
}
try {
$defaults = new Varien_Simplexml_Config();
$defaults->loadFile(Mage::getBaseDir() . '/app/code/local/Queldorei/ShopperSettings/etc/config.xml');
$this->_restoreSettings($defaults->getNode('default/shoppersettings')->children(), 'shoppersettings');
if ($setup_cms) {
Mage::getModel('shoppersettings/settings')->setupCms();
}
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('shoppersettings')->__('Default Settings for Shopper Theme has been restored. Please clear cache (System > Cache management) if you do not see changes in storefront'));
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('shoppersettings')->__('An error occurred while restoring theme settings.'));
}
$this->getResponse()->setRedirect($this->getUrl("*/*/"));
}
示例11: __construct
private function __construct()
{
$moduleFiles = glob(BP . '/app/etc/modules/*.xml');
$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>');
$fileConfig = new Varien_Simplexml_Config();
foreach ($unsortedConfig->getNode('modules')->children() as $moduleName => $moduleNode) {
if ('true' === (string) $moduleNode->active) {
$codePool = (string) $moduleNode->codePool;
$configPath = BP . '/app/code/' . $codePool . '/' . uc_words($moduleName, '/') . '/etc/config.xml';
$fileConfig->loadFile($configPath);
$unsortedConfig->extend($fileConfig);
}
}
$this->_config = $unsortedConfig;
}
示例12: loadFile
public function loadFile($file)
{
if (in_array($file, $this->_loadedFiles)) {
return false;
}
$res = parent::loadFile($file);
if ($res) {
$this->addLoadedFile($file);
}
return $this;
}
示例13: getConflictList
/**
* Retrive possible conflicts list
*
* @return array
*/
public function getConflictList()
{
$moduleFiles = glob($this->_etcDir . 'modules' . DIRECTORY_SEPARATOR . '*.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 = $this->_codeDir . $codePool . DIRECTORY_SEPARATOR . uc_words($moduleName, DS) . DIRECTORY_SEPARATOR . '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();
foreach ($moduleItems->rewrite as $rewriteLine) {
foreach ($rewriteLine as $key => $value) {
$moduleItemsArray['rewrite'][$key] = (string) $value;
}
#echo "<pre>".print_r($moduleItemsArray['rewrite'],1)."</pre>";
}
if ($moduleItems->rewrite) {
$_finalResult[$param] = array_merge_recursive($_finalResult[$param], array($moduleKey => $moduleItemsArray));
}
}
}
}
}
}
$_finalResult = $this->_fillAllClassesToRewrite($_finalResult);
$_finalResult = $this->_clearEmptyRows($_finalResult);
$_finalResult = $this->_recoverDeletedClassRewrites($_finalResult);
// filter aitoc modules
foreach ($_finalResult as $type => $data) {
foreach ($data as $module => $data) {
foreach ($data['rewrite'] as $model => $classes) {
$remove = true;
foreach ($classes as $class) {
if (strstr($class, 'Aitoc') || strstr($class, 'AdjustWare')) {
$remove = false;
break;
}
}
if ($remove) {
unset($_finalResult[$type][$module]['rewrite'][$model]);
}
}
if (!$_finalResult[$type][$module]['rewrite']) {
unset($_finalResult[$type][$module]);
}
}
}
return $_finalResult;
}
示例14: getConflictList
/**
* Retrive possible conflicts list
*
* @return array
*/
public function getConflictList()
{
$moduleFiles = glob($this->_etcDir . 'modules' . DIRECTORY_SEPARATOR . '*.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();
$_finalResultAbstract = array();
foreach ($sortedConfig->getNode('modules')->children() as $moduleName => $moduleNode) {
$codePool = (string) $moduleNode->codePool;
$configPath = $this->_codeDir . $codePool . DIRECTORY_SEPARATOR . uc_words($moduleName, DS) . DIRECTORY_SEPARATOR . '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();
foreach ($moduleItems->rewrite as $rewriteLine) {
foreach ($rewriteLine as $key => $value) {
$moduleItemsArray['rewrite'][$key] = (string) $value;
}
#$moduleItemsArray['rewrite'] += $rewriteLine->asArray();
#echo "<pre>".print_r($moduleItemsArray['rewrite'],1)."</pre>";
}
if ($moduleItems->rewrite) {
// $_finalResult[$param] = array_merge_recursive($_finalResult[$param], array($moduleKey => $moduleItems->asArray()));
$_finalResult[$param] = array_merge_recursive($_finalResult[$param], array($moduleKey => $moduleItemsArray));
}
}
}
}
#echo "<pre>".print_r($_finalResult,1)."</pre>";
if ($rewrites = $fileConfig->getXpath('global/' . $param . '/*/rewriteabstract')) {
foreach ($rewrites as $rewrite) {
$parentElement = $rewrite->xpath('../..');
foreach ($parentElement[0] as $moduleKey => $moduleItems) {
if ($moduleItems->rewriteabstract) {
// $_finalResultAbstract[$param] = array_merge_recursive($_finalResultAbstract[$param], array($moduleKey => $moduleItems->asArray()));
$list = array();
foreach ($moduleItems->rewriteabstract->children() as $key => $value) {
$list[$key] = (string) $value;
}
#echo "<pre>--".print_r($list,1)."</pre>";
#echo "<pre>++".print_r($moduleItems->asArray(),1)."</pre>";
$_finalResultAbstract[$param] = array($moduleKey => array('rewriteabstract' => $list));
}
}
}
}
}
}
foreach (array_keys($_finalResult) as $groupType) {
foreach (array_keys($_finalResult[$groupType]) as $key) {
// remove some repeating elements after merging all parents
foreach ($_finalResult[$groupType][$key]['rewrite'] as $key1 => $value) {
if (is_array($value)) {
$_finalResult[$groupType][$key]['rewrite'][$key1] = array_unique($value);
}
// if rewrites count < 2 - no conflicts - remove
if (gettype($_finalResult[$groupType][$key]['rewrite'][$key1]) == 'array' && count($_finalResult[$groupType][$key]['rewrite'][$key1]) < 2 || gettype($_finalResult[$groupType][$key]['rewrite'][$key1]) == 'string') {
unset($_finalResult[$groupType][$key]['rewrite'][$key1]);
}
}
// clear empty elements
if (count($_finalResult[$groupType][$key]['rewrite']) < 1) {
unset($_finalResult[$groupType][$key]);
}
}
// clear empty elements
if (count($_finalResult[$groupType]) < 1) {
unset($_finalResult[$groupType]);
}
}
//.........这里部分代码省略.........
示例15: 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;
}