本文整理汇总了PHP中Varien_Simplexml_Config::loadString方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Simplexml_Config::loadString方法的具体用法?PHP Varien_Simplexml_Config::loadString怎么用?PHP Varien_Simplexml_Config::loadString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Simplexml_Config
的用法示例。
在下文中一共展示了Varien_Simplexml_Config::loadString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例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: 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);
}
}
示例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: _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;
}
示例6: _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();
}
}
}
示例7: __construct
/**
* Load config from cache or merged from logging.xml files
*/
public function __construct()
{
$configXml = Mage::app()->loadCache('enterprise_logging_config');
if ($configXml) {
$this->_xmlConfig = new Varien_Simplexml_Config($configXml);
} else {
$config = new Varien_Simplexml_Config();
$config->loadString('<?xml version="1.0"?><logging></logging>');
Mage::getConfig()->loadModulesConfiguration('logging.xml', $config);
$this->_xmlConfig = $config;
if (Mage::app()->useCache('config')) {
Mage::app()->saveCache($config->getXmlString(), 'enterprise_logging_config', array(Mage_Core_Model_Config::CACHE_TAG));
}
}
}
示例8: getXmlConfig
/**
* Load Widgets XML config from widget.xml files and cache it
*
* @return Varien_Simplexml_Config
*/
public function getXmlConfig()
{
$cachedXml = Mage::app()->loadCache('widget_config');
if ($cachedXml) {
$xmlConfig = new Varien_Simplexml_Config($cachedXml);
} else {
$config = new Varien_Simplexml_Config();
$config->loadString('<?xml version="1.0"?><widgets></widgets>');
Mage::getConfig()->loadModulesConfiguration('widget.xml', $config);
$xmlConfig = $config;
if (Mage::app()->useCache('config')) {
Mage::app()->saveCache($config->getXmlString(), 'widget_config', array(Mage_Core_Model_Config::CACHE_TAG));
}
}
return $xmlConfig;
}
示例9: getXmlConfig
/**
* Load config from giftregistry.xml files and try to cache it
*
* @return Varien_Simplexml_Config
*/
public function getXmlConfig()
{
if (is_null($this->_config)) {
if ($cachedXml = Mage::app()->loadCache('giftregistry_config')) {
$xmlConfig = new Varien_Simplexml_Config($cachedXml);
} else {
$xmlConfig = new Varien_Simplexml_Config();
$xmlConfig->loadString('<?xml version="1.0"?><prototype></prototype>');
Mage::getConfig()->loadModulesConfiguration('giftregistry.xml', $xmlConfig);
if (Mage::app()->useCache('config')) {
Mage::app()->saveCache($xmlConfig->getXmlString(), 'giftregistry_config', array(Mage_Core_Model_Config::CACHE_TAG));
}
}
$this->_config = $xmlConfig;
}
return $this->_config;
}
示例10: __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;
if (Mage::app()->useCache('config')) {
Mage::app()->saveCache($adminhtmlConfig->getXmlString(), $this->getCacheId(), array(Mage_Core_Model_Config::CACHE_TAG));
}
}
}
示例11: getXml
/**
* Load XML config from m_db.xml files and caches it
*
* @return Varien_Simplexml_Config
*/
public function getXml()
{
if (!$this->_xml) {
$cachedXml = Mage::app()->loadCache('m_db_config');
if ($cachedXml) {
$this->_xml = new Varien_Simplexml_Config($cachedXml);
} else {
$config = new Varien_Simplexml_Config();
$config->loadString('<?xml version="1.0"?><config></config>');
Mage::getConfig()->loadModulesConfiguration('m_db.xml', $config);
$this->_xml = $config;
$this->_prepareXml();
if (Mage::app()->useCache('config')) {
Mage::app()->saveCache($config->getXmlString(), 'm_db_config', array(Mage_Core_Model_Config::CACHE_TAG));
}
}
}
return $this->_xml;
}
示例12: getXmlConfig
public function getXmlConfig()
{
$cachedXml = Mage::app()->loadCache('easytemplate_config');
if ($cachedXml) {
$xmlConfig = new Varien_Simplexml_Config($cachedXml);
} else {
$config = new Varien_Simplexml_Config();
$config->loadString('<?xml version="1.0"?><config><easytemplate></easytemplate></config>');
Mage::getConfig()->loadModulesConfiguration('easytemplate.xml', $config);
$xmlConfig = $config;
if (Mage::app()->useCache('config')) {
Mage::app()->saveCache($config->getXmlString(), 'easytemplate_config', array(Mage_Core_Model_Config::CACHE_TAG));
if (Mage::getStoreConfig('easytemplate/configuration/automatically_clean_database', Mage::app()->getStore()->getId())) {
// Clean the database just if caching is active to avoid performance issues
$this->cleanDatabase();
}
}
}
return $xmlConfig;
}
示例13: getXmlConfig
/**
* Load whole customgrid configuration, retrieve a sub part
*
* @param string $type Configuration part type
* @return Varien_Simplexml_Config
*/
public function getXmlConfig($type)
{
if (is_null($this->_xmlConfigs)) {
$cachedXml = Mage::app()->loadCache(self::CACHE_KEY);
if ($cachedXml) {
$xmlConfig = new Varien_Simplexml_Config($cachedXml);
} else {
$config = new Varien_Simplexml_Config();
$config->loadString('<?xml version="1.0"?><customgrid></customgrid>');
Mage::getConfig()->loadModulesConfiguration('customgrid.xml', $config);
$xmlConfig = $config;
if (Mage::app()->useCache('config')) {
Mage::app()->saveCache($config->getXmlString(), self::CACHE_KEY, array(Mage_Core_Model_Config::CACHE_TAG));
}
}
// Split config in main parts
$this->_xmlConfigs = array(self::TYPE_GRID_TYPES => new Varien_Simplexml_Config($xmlConfig->getNode('grid_types')), self::TYPE_COLUMN_RENDERERS_COLLECTION => new Varien_Simplexml_Config($xmlConfig->getNode('column_renderers/collection')), self::TYPE_COLUMN_RENDERERS_ATTRIBUTE => new Varien_Simplexml_Config($xmlConfig->getNode('column_renderers/attribute')));
}
return isset($this->_xmlConfigs[$type]) ? $this->_xmlConfigs[$type] : null;
}
示例14: __construct
/**
* Load config from merged adminhtml.xml files
* @param array $arguments
*/
public function __construct(array $arguments = array())
{
$this->_app = isset($arguments['app']) ? $arguments['app'] : Mage::app();
$this->_appConfig = isset($arguments['appConfig']) ? $arguments['appConfig'] : Mage::getConfig();
if (isset($arguments['helpers'])) {
$this->_helpers = $arguments['helpers'];
}
parent::__construct();
$this->setCacheId('adminhtml_acl_menu_config');
/* @var $adminhtmlConfig Varien_Simplexml_Config */
$adminhtmlConfig = $this->_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>');
$this->_appConfig->loadModulesConfiguration('adminhtml.xml', $adminhtmlConfig);
$this->_adminhtmlConfig = $adminhtmlConfig;
if ($this->_app->useCache('config')) {
$this->_app->saveCache($adminhtmlConfig->getXmlString(), $this->getCacheId(), array(Mage_Core_Model_Config::CACHE_TAG));
}
}
}
示例15: __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;
}