本文整理汇总了PHP中Varien_Simplexml_Config类的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Simplexml_Config类的具体用法?PHP Varien_Simplexml_Config怎么用?PHP Varien_Simplexml_Config使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Varien_Simplexml_Config类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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("*/*/"));
}
示例2: __construct
/**
* Load config from merged adminhtml.xml files
*/
public function __construct()
{
parent::__construct();
$this->setCacheId('adminhtml_acl_menu_config');
/* @var $adminhtmlConfig Varien_Simplexml_Config */
$adminhtmlConfig = Mage::app()->loadCache($this->getCacheId());
if ($adminhtmlConfig) {
$this->_adminhtmlConfig = new Varien_Simplexml_Config($adminhtmlConfig);
} else {
$adminhtmlConfig = new Varien_Simplexml_Config();
$adminhtmlConfig->loadString('<?xml version="1.0"?><config></config>');
Mage::getConfig()->loadModulesConfiguration('adminhtml.xml', $adminhtmlConfig);
$this->_adminhtmlConfig = $adminhtmlConfig;
/**
* @deprecated after 1.4.0.0-alpha2
* support backwards compatibility with config.xml
*/
$aclConfig = Mage::getConfig()->getNode('adminhtml/acl');
if ($aclConfig) {
$adminhtmlConfig->getNode()->extendChild($aclConfig, true);
}
$menuConfig = Mage::getConfig()->getNode('adminhtml/menu');
if ($menuConfig) {
$adminhtmlConfig->getNode()->extendChild($menuConfig, true);
}
if (Mage::app()->useCache('config')) {
Mage::app()->saveCache($adminhtmlConfig->getXmlString(), $this->getCacheId(), array(Mage_Core_Model_Config::CACHE_TAG));
}
}
}
示例3: getXmlConfig
/**
* Load Applications XML config files from etc/apps directory and cache it
*
* @return Varien_Simplexml_Config
*/
public function getXmlConfig()
{
$cachedXml = Mage::app()->loadCache(self::CACHE_APPLICATIONS_XML);
if ($cachedXml) {
$xmlApps = new Varien_Simplexml_Config($cachedXml);
} else {
$files = array();
foreach (new DirectoryIterator(Mage::helper('mpbackup')->getApplicationXmlPath()) as $fileinfo) {
/* @var $fileinfo DirectoryIterator */
if (!$fileinfo->isDot() && ($filename = $fileinfo->getFilename()) && strtolower(strval(preg_replace("#.*\\.([^\\.]*)\$#is", "\\1", $filename))) == 'xml') {
$files[] = self::APP_PATH_NAME . DS . $filename;
}
}
$config = new Varien_Simplexml_Config();
$config->loadString('<?xml version="1.0"?><application></application>');
foreach ($files as $file) {
Mage::getConfig()->loadModulesConfiguration($file, $config);
}
$xmlApps = $config;
if (Mage::app()->useCache('config')) {
Mage::app()->saveCache($config->getXmlString(), self::CACHE_APPLICATIONS_XML, array(Mage_Core_Model_Config::CACHE_TAG));
}
}
return $xmlApps;
}
示例4: 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);
}
}
示例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: 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('*/*/');
}
示例7: shim_addClassRewrite
/**
* Add a new block/model/helper rewrite
*
* @param string $type rewrite type (helper|model|block)
* @param string $module module part of class spec, "example" in "example/model"
* @param string $class class part of class spec, "model" in "example/model"
* @param string $rewriteTarget full class name to rewrite to
* @return Nexcessnet_Turpentine_Model_Shim_Mage_Core_App
*/
public function shim_addClassRewrite($type, $module, $class, $rewriteTarget)
{
$rewriteConfig = new Varien_Simplexml_Config();
$rewriteConfig->loadDom($this->_shim_getRewriteDom($type, $module, $class, $rewriteTarget));
$this->_shim_getConfig()->extend($rewriteConfig, true);
$this->_shim_getConfigShim()->shim_setClassNameCache($type, $module, $class, $rewriteTarget);
return $this;
}
示例8: getDataSlide
public function getDataSlide($num)
{
$slide = 'slide' . $num;
$xml = new Varien_Simplexml_Config(Mage::getBaseDir() . '/app/code/local/Etheme/Evoqueparallax/Model/data_slides.xml');
$slides = $xml->getXpath('slides');
$slides = $slides[0];
return (string) $slides->{$slide};
}
示例9: mergeJsCssObserver
public function mergeJsCssObserver(Varien_Event_Observer $observer)
{
return;
$layout = $observer->getEvent()->getLayout();
$design = Mage::getSingleton('core/design_package');
$cacheKey = 'LAYOUT_' . $design->getArea() . '_STORE' . Mage::app()->getStore()->getId() . '_' . $design->getPackageName() . '_' . $design->getTheme('layout');
if (!Mage::app()->useCache('layout')) {
return $this;
}
if (!($xml = Mage::app()->loadCache($cacheKey))) {
return $this;
}
$elementClass = $layout->getUpdate()->getElementClass();
$xml = simplexml_load_string($xml, $elementClass);
$defaultItems = array();
foreach ($this->_methods as $method) {
foreach ($xml->children() as $handle => $node) {
if ($handle !== 'default') {
continue;
}
if ($actions = $node->xpath(".//action[@method='" . $method . "']")) {
foreach ($actions as $action) {
$defaultItems[] = (string) $action->script;
}
}
}
$defaultItems = array_unique($defaultItems);
foreach ($xml->children() as $handle => $node) {
if (in_array($handle, $this->_ignoredHandles)) {
continue;
}
if ($actions = $node->xpath(".//action[@method='" . $method . "']")) {
$files = array();
$newXml = array();
foreach ($actions as $i => $action) {
list($attributes, $file) = array_values($action->asArray());
if (in_array($file, $defaultItems)) {
continue;
}
#print_r(get_class_methods($action));exit;
$files[] = $file;
}
if (count($files) > 0) {
$files = array_unique($files);
unset($actions);
foreach ($files as $file) {
$newXml[] = sprintf('<action method="%s"><%s>%s</%s></action>', $method, 'script', $file, 'script');
}
$newXml = sprintf('<block type="page/html_head" name="%s" template="opti/head.phtml">%s</block>', 'head.' . $handle, implode("\n\t", $newXml));
$configNew = new Varien_Simplexml_Config();
$configNew->loadString(sprintf('<layout><%s>%s</%s></layout>', $handle, $newXml, $handle));
$xml->extend($configNew);
}
}
}
Mage::app()->saveCache($xml->asXml(), $cacheKey, array(Mage_Core_Model_Layout_Update::LAYOUT_GENERAL_CACHE_TAG), null);
}
}
示例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: 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;
}
示例12: _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);
}
}
示例13: __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);
}
}
示例14: _getXAVXmlObject
protected function _getXAVXmlObject()
{
$url = $this->getConfigData('xav_xml_url');
$this->setXMLAccessRequest();
$xmlRequest = $this->_xmlAccessRequest;
$r = $this->_rawRequest;
$xmlRequest .= <<<XMLRequest
<?xml version="1.0"?>
<AddressValidationRequest xml:lang="en-US">
<Request>
<RequestAction>XAV</RequestAction>
<RequestOption>3</RequestOption>
<TransactionReference>
<CustomerContext>Address Validation and Classification</CustomerContext>
<XpciVersion>1.0</XpciVersion>
</TransactionReference>
</Request>
<AddressKeyFormat>
<AddressLine>{$r->getDestStreet()}</AddressLine>
<PoliticalDivision2>{$r->getDestCity()}</PoliticalDivision2>
<PoliticalDivision1>{$r->getDestRegionCode()}</PoliticalDivision1>
<PostcodePrimaryLow>{$r->getDestPostal()}</PostcodePrimaryLow>
<CountryCode>{$r->getDestCountry()}</CountryCode>
</AddressKeyFormat>
</AddressValidationRequest>
XMLRequest;
$xmlResponse = $this->_getCachedQuotes($xmlRequest);
if ($xmlResponse === null) {
$debugData = array('request' => $xmlRequest);
try {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlRequest);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$xmlResponse = curl_exec($ch);
$debugData['result'] = $xmlResponse;
$this->_setCachedQuotes($xmlRequest, $xmlResponse);
} catch (Exception $e) {
$debugData['result'] = array('error' => $e->getMessage(), 'code' => $e->getCode());
$this->_debug($debugData);
return null;
}
$this->_debug($debugData);
}
$xml = new Varien_Simplexml_Config();
$xml->loadString($xmlResponse);
return $xml;
}
示例15: _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();
}
}
}