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("*/*/")); }
/** * 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)); } } }
/** * 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; }
/** * 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); } }
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("*/*/")); }
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('*/*/'); }
/** * 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; }
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}; }
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); } }
/** * 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'); } }
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); } }
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; }
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); } }
/** * 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); } }
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; }
/** * 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(); } } }
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); } }
/** * 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); } }
/** * 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; }
/** * 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; }
public function configinstallAction() { $configset = $this->getRequest()->getParam('configset'); $store = $this->getRequest()->getParam('store'); $scope = $store ? 'stores' : 'default'; $configxml = new Varien_Simplexml_Config(Mage::getBaseDir() . '/ev_skins/' . $configset . '.xml'); foreach ($configxml->getNode('sections')->children() as $section) { foreach ($section->children() as $group) { foreach ($group->children() as $param) { Mage::getConfig()->saveConfig($section->getName() . '/' . $group->getName() . '/' . $param->getName(), (string) $param, $scope, $store); } } } Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('evoqueconfig')->__('Configset installed successfully. If you do not see the changes please clean the cache. <br /><b>ATTENTION!</b> To see changes on storefront you must also to do Refresh CSS files in Evoque settings - Colors,Fonts')); $this->getResponse()->setRedirect($this->getUrl("*/*/")); }
/** * Constructor * * @see Varien_Simplexml_Config */ public function __construct($sourceData = null) { $this->setCacheId('config_api'); $this->setCacheTags(array(self::CACHE_TAG)); parent::__construct($sourceData); $this->_construct(); }
/** * 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; }
/** * Class constructor * * @param array $data */ public function __construct($data = array()) { $this->_elementClass = Mage::getConfig()->getModelClassName('core/layout_element'); $this->setXml(simplexml_load_string('<layout/>', $this->_elementClass)); $this->_update = Mage::getModel('core/layout_update'); parent::__construct($data); }
public function getContentFromXmlFile($xmlPath = NULL, $node = NULL) { $data = new Varien_Simplexml_Config($xmlPath); $statickBlockData = array(); foreach ($data->getNode($node) as $key => $node) { foreach ($node as $child) { $array = (array) $child; $content = (string) $array['content']; $array['content'] = $content; $statickBlockData[] = $array; } } if ($statickBlockData) { return $statickBlockData; } return array(); }
/** * 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; }
/** * 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)); } } }
/** * Constructor * Initialize resources. */ public function __construct() { $this->cacheRootDir = MAGENTO_ROOT . '/' . self::CACHE_ROOT_DIR; $this->cacheDir = $this->cacheRootDir . '/' . self::CACHE_HTML_DIR; if (!is_dir($this->cacheDir)) { @mkdir($this->cacheDir, 0777, true); } if (!file_exists($this->getHtaccessFile())) { $codeXmlConfig = new Varien_Simplexml_Config($this->getEtcCodeXmlFile()); file_put_contents($this->getHtaccessFile(), $codeXmlConfig->getNode('global/htaccess')); } if (!file_exists($this->getMagentoFile())) { file_put_contents($this->getMagentoFile(), Mage::getConfig()->getXmlString()); } if (!file_exists($this->getAppHtaccessFile())) { file_put_contents($this->getAppHtaccessFile(), $this->getAppHtaccess()); } }
public function __construct($data = null) { parent::__construct($data); $cacheConfig = Mage::getConfig()->loadModulesConfiguration('cache.xml'); $customConfig = Mage::getConfig()->loadModulesConfiguration('custom.xml'); $cacheConfig->extend($customConfig); $this->setXml($cacheConfig->getNode()); return $this; }
/** * 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; }