/** * Iterate all active modules "etc" folders and combine data from * specidied xml file name to one object * * @param string $fileName * @param null|Mage_Core_Model_Config_Base $mergeToObject * @return Mage_Core_Model_Config_Base */ public function loadPackageConfiguration($mergeToObject = null, $mergeModel = null) { if ($mergeToObject === null) { $mergeToObject = new Mage_Core_Model_Config_Base(); $mergeToObject->loadString('<config/>'); } if ($mergeModel === null) { $mergeModel = new Mage_Core_Model_Config_Base(); } $channels = Mage::getModel('channel/channel')->getCollection(); foreach ($channels as $id => $channel) { // if the store is an activated channel if ($channel->load($id)->isChannel()) { if ($mergeModel->loadString($channel->getApiConfig())) { $mergeToObject->extend($mergeModel, true); } } } /* $packages = Mage::getModel('catalog/product') ->getCollection() ->addFieldToFilter( 'type_id', Faett_Package_Model_Product_Type::TYPE_PACKAGE ); foreach ($packages as $id => $package) { if ($mergeModel->loadString($package->load($id)->getApiConfig())) { $mergeToObject->extend($mergeModel, true); } } */ return $mergeToObject; }
/** * Iterate all active modules "etc" folders and combine data from * specidied xml file name to one object * * @param string $fileName * @param null|Mage_Core_Model_Config_Base $mergeToObject * @return Mage_Core_Model_Config_Base */ public function loadPackageConfiguration($mergeToObject = null, $mergeModel = null) { // initialize the configuration XML structure to append if ($mergeToObject === null) { $mergeToObject = new Mage_Core_Model_Config_Base(); $mergeToObject->loadString('<config/>'); } // initialize the configuration XML structure if ($mergeModel === null) { $mergeModel = new Mage_Core_Model_Config_Base(); } // load the Collection with all channels $channels = Mage::getModel('channel/channel')->getCollection(); // iterate over the channels foreach ($channels as $id => $channel) { // if the store is an activated channel if ($channel->load($id)->isChannel()) { // merge the channel to the ACL's if ($mergeModel->loadString($channel->getApiConfig())) { $mergeToObject->extend($mergeModel, true); } // load the package Collection $packages = Mage::helper('channel')->getPackageCollection($channel); // merge the packages to the channel's ACL's foreach ($packages as $id => $package) { if ($mergeModel->loadString($package->load($id)->getApiConfig($channel))) { $mergeToObject->extend($mergeModel, true); } } } } // return the configuration structure return $mergeToObject; }
/** * Extend extra configs from etc folder of module on system init configs * * @param Varien_Event_Observer $observer */ public function extendConfig($observer) { $storeCode = Mage::helper("jmbasetheme")->getCurrentStoreCode("backend"); $profiles = array_keys(Mage::helper("jmbasetheme")->getProfiles($storeCode)); $mergeObject = new Mage_Core_Model_Config_Base(); $profilePath = Mage::helper("jmbasetheme")->getProfilePath($storeCode); foreach ($profiles as $profile) { if (file_exists($profilePath . "core" . DS . $profile . ".xml")) { $mergeObject->loadFile($profilePath . "core" . DS . $profile . ".xml"); } else { $mergeObject->loadFile($profilePath . "local" . DS . $profile . ".xml"); } $observer->config->extend($mergeObject, false); } if (file_exists($profilePath . "core" . DS . "core.xml")) { $mergeObject->loadFile($profilePath . "core" . DS . "core.xml"); $observer->config->extend($mergeObject, false); } //extend tablet settings $mergeObject->loadFile(Mage::getModuleDir('etc', 'Wavethemes_Jmbasetheme') . "/device.xml"); $observer->config->extend($mergeObject, false); //extend mobile settings $mergeObject->loadFile(Mage::getModuleDir('etc', 'Wavethemes_Jmbasetheme') . "/mobile.xml"); $observer->config->extend($mergeObject, false); }
public function testConstruct() { $config = new Mage_Core_Model_Config_Base(<<<XML <?xml version="1.0"?> <root><key>value</key></root> XML ); $this->assertInstanceOf('Mage_Core_Model_Config_Element', $config->getNode('key')); }
public function addMageOneFourConfig($observer) { if (version_compare(Mage::getVersion(), '1.5.0.0', '<')) { $file = Mage::getModuleDir('etc', 'MageBase_DpsPaymentExpress') . DS . 'config-1.4.xml'; $config = Mage::getConfig(); $prototype = new Mage_Core_Model_Config_Base(); $prototype->loadFile($file); $config->extend($prototype); $config->saveCache(); } }
protected function _initSectionsAndTabs() { if (Mage::helper('advanced')->isAnyStoreDisabled()) { $mergeConfig = Mage::getModel('core/config_base'); $config = Mage::getConfig()->loadModulesConfiguration('system.xml'); //these 4 lines are the only added content $configFile = Mage::helper('advanced')->getEtcPath() . DS . 'system-disabled.xml'; $mergeModel = new Mage_Core_Model_Config_Base(); $mergeModel->loadFile($configFile); $config = $config->extend($mergeModel, true); $this->_sections = $config->getNode('sections'); $this->_tabs = $config->getNode('tabs'); } else { return parent::_initSectionsAndTabs(); } return parent::_initSectionsAndTabs(); }
public function __construct($sourceData = null) { $this->setCacheId('config_urapidflow'); $this->setCacheTags(array(self::CACHE_TAG)); $this->setCacheChecksum(null); parent::__construct($sourceData); $this->_construct(); }
public function __construct($arg) { list($sourceData, $moduleName) = $arg; parent::__construct($sourceData); $this->_config = Mage::getConfig(); $this->_moduleName = $moduleName; $this->_moduleDir = realpath(Mage::getModuleDir('', $moduleName)); $this->_etcModuleDir = realpath(Mage::getModuleDir('etc', $moduleName)); }
/** * Load dependencies for active & allowed modules into an array structure * * @param Mage_Core_Model_Config_Base $modulesConfig * @param array $allowedModules * @return array */ protected function _loadModuleDependencies(Mage_Core_Model_Config_Base $modulesConfig, array $allowedModules) { $result = array(); foreach ($modulesConfig->getNode('modules')->children() as $moduleName => $moduleNode) { $isModuleActive = 'true' === (string) $moduleNode->active; $isModuleAllowed = empty($allowedModules) || in_array($moduleName, $allowedModules); if (!$isModuleActive || !$isModuleAllowed) { continue; } $dependencies = array(); if ($moduleNode->depends) { /** @var $dependencyNode Varien_Simplexml_Element */ foreach ($moduleNode->depends->children() as $dependencyNode) { $dependencyModuleName = $dependencyNode->getName(); $dependencies[$dependencyModuleName] = $this->_getDependencyType($dependencyNode); } } $result[$moduleName] = array('module' => $moduleName, 'dependencies' => $dependencies); } return $result; }
public function loadModules(array $files) { $this->loadString('<config/>'); $loadedModules = array(); foreach ($files as $file) { $this->_magento2config->loadFile($file); $moduleName = $this->_magento2config->getNode('module')->getAttribute('name'); if ($this->isModuleLoaded($moduleName)) { $loadedModules[] = $moduleName; continue; } $loadedModules[] = $moduleName; $version = $this->_magento2config->getNode('module')->getAttribute('schema_version'); $modules = Mage::getConfig()->getNode('modules'); $child = $modules->addChild($moduleName); $child->addChild('active', 'true'); $child->addChild('codePool', 'community'); $child->addChild('version', $version); $this->loadString('<config/>'); } return $loadedModules; }
public function Extendconfig($observer) { $profiles = array_keys(Mage::helper("jmbasetheme")->getProfiles()); $mergeobject = new Mage_Core_Model_Config_Base(); foreach ($profiles as $profile) { if (file_exists(Mage::helper("jmbasetheme")->getprofileFolder() . DS . "core" . DS . $profile . ".xml")) { $mergeobject->loadFile(Mage::helper("jmbasetheme")->getprofileFolder() . DS . "core" . DS . $profile . ".xml"); } else { $mergeobject->loadFile(Mage::helper("jmbasetheme")->getprofileFolder() . DS . "local" . DS . $profile . ".xml"); } $observer->config->extend($mergeobject, false); } if (file_exists(Mage::helper("jmbasetheme")->getprofileFolder() . DS . "core" . DS . "core.xml")) { $mergeobject->loadFile(Mage::helper("jmbasetheme")->getprofileFolder() . DS . "core" . DS . "core.xml"); $observer->config->extend($mergeobject, false); } //extend tablet settings $mergeobject->loadFile(Mage::getModuleDir('etc', 'Wavethemes_Jmbasetheme') . "/device.xml"); $observer->config->extend($mergeobject, false); //extend mobile settings $mergeobject->loadFile(Mage::getModuleDir('etc', 'Wavethemes_Jmbasetheme') . "/mobile.xml"); $observer->config->extend($mergeobject, false); }
public function __construct() { error_reporting(E_ALL & ~E_NOTICE); // We have no interest in supporting notice based errors. Just turn them off. // grab the nodes with the connection information $foreignNode = Mage::getConfig()->getNode('global/resources/pap_foreign/connection'); // grab the connection information from the store config $host = Mage::getStoreConfig('pap_config/connection/host'); $username = Mage::getStoreConfig('pap_config/connection/username'); $password = Mage::getStoreConfig('pap_config/connection/password'); $dbname = Mage::getStoreConfig('pap_config/connection/dbname'); // also get API information $this->apiusername = Mage::getStoreConfig('pap_config/api/username'); $this->apipassword = Mage::getStoreConfig('pap_config/api/password'); // update the configuration information in memory from the store configuration // We have to do this so that when things attempt to connect to a database, // the right database can be found and connected to $foreignNode->setNode('host', $host); $foreignNode->setNode('username', $username); $foreignNode->setNode('password', $password); $foreignNode->setNode('dbname', $dbname); // remember whether we have enough information to connect $this->dbconfigured = $host && $username && $password && $dbname; $this->configured = $this->apiusername && $this->apipassword; if ($this->dbconfigured && !$this->configured) { // we have the old DB information, but not the new password information. // The module was rewritten to use the API (which requires a PAP username // and password, rather than database access.) // Try to get an admin password from the DB. $foreignConnection = Mage::getSingleton('core/resource')->getConnection('pap_foreign'); try { if ($mercaccount = $foreignConnection->fetchRow("SELECT au.username AS username, au.rpassword AS password FROM qu_g_authusers AS au INNER JOIN qu_g_users AS u ON au.authid = u.authid WHERE u.roleid = 'pap_merc'")) { // we found the first merchant account. remember the username and password. $this->apiusername = $mercaccount['username']; $this->apipassword = $mercaccount['password']; // recalculate the "configured" value. $this->configured = $this->apiusername && $this->apipassword; // save off the username and password so we don't have to recalculate again. Mage::getConfig()->saveConfig('pap_config/api/username', $this->apiusername); Mage::getConfig()->saveConfig('pap_config/api/password', $this->apipassword); } } catch (Exception $e) { // Something bad happened. I guess we won't be able to update this automatically. } } parent::__construct(Mage::getConfig()->getNode('global')); }
/** * Constructor * * Loading of custom configuration files * from different modules * * @param string $sourceData */ function __construct($sourceData = null) { $tags = array(self::CACHE_TAG); $useCache = Mage::app()->useCache(self::CACHE_TAG); $this->setCacheId(self::CACHE_KEY); $this->setCacheTags($tags); if ($useCache && ($cache = Mage::app()->loadCache(self::CACHE_KEY))) { parent::__construct($cache); } else { parent::__construct(self::CONFIG_TEMPLATE); Mage::getConfig()->loadModulesConfiguration(self::CONFIG_FILENAME, $this); if ($useCache) { $xmlString = $this->getXmlString(); Mage::app()->saveCache($xmlString, self::CACHE_KEY, $tags); } } }
/** * Constructor. * Load configuration from enabled modules with appropriate caching. * * @param Varien_Simplexml_Element|string|null $data */ public function __construct($data = null) { parent::__construct($data); $canUseCache = Mage::app()->useCache('config'); if ($canUseCache) { /* Setup caching with no checksum validation */ $this->setCache(Mage::app()->getCache())->setCacheChecksum(null)->setCacheId('fieldset_config')->setCacheTags(array(Mage_Core_Model_Config::CACHE_TAG)); if ($this->loadCache()) { return; } } $config = Mage::getConfig()->loadModulesConfiguration('fieldset.xml'); $this->setXml($config->getNode()); if ($canUseCache) { $this->saveCache(); } }
/** * Check base url settings, if not set it rises an exception * * @param Mage_Core_Model_Config_Base $original * @param Mage_Core_Model_Config_Base $test * @return EcomDev_PHPUnit_Model_Config * @throws RuntimeException */ protected function _checkBaseUrl($original, $test) { $baseUrlSecure = (string) $test->getNode(self::XML_PATH_SECURE_BASE_URL); $baseUrlUnsecure = (string) $test->getNode(self::XML_PATH_UNSECURE_BASE_URL); if (empty($baseUrlSecure) || empty($baseUrlUnsecure) || $baseUrlSecure == self::CHANGE_ME || $baseUrlUnsecure == self::CHANGE_ME) { throw new RuntimeException('The base url is not set for proper controller tests. ' . 'Please run ecomdev-phpunit.php with magento-config action.'); } }
public function mergeConfig($mergeToObject, $extensions) { foreach ($extensions as $extension) { if ($extension) { $mergeModel = new Mage_Core_Model_Config_Base(); if ($mergeModel->loadString($extension)) { $mergeToObject->extend($mergeModel->getNode(), true); } } } return $mergeToObject; }
/** * Constructor */ public function __construct() { parent::__construct(Mage::getConfig()->getNode('global/sales/order')); }
/** * Check base url settings, if not set it rises an exception * * @param Mage_Core_Model_Config_Base $original * @param Mage_Core_Model_Config_Base $test * @return Mage_Test_Model_Config * @throws RuntimeException */ protected function _checkBaseUrl($original, $test) { $baseUrlSecure = (string) $test->getNode(self::XML_PATH_SECURE_BASE_URL); $baseUrlUnsecure = (string) $test->getNode(self::XML_PATH_UNSECURE_BASE_URL); if (empty($baseUrlSecure) || empty($baseUrlUnsecure) || $baseUrlSecure == self::CHANGE_ME || $baseUrlUnsecure == self::CHANGE_ME) { echo sprintf('Please change values in %s file for nodes %s and %s. ' . 'It will help in setting up proper controller test cases', 'app/etc/local.xml.phpunit', self::XML_PATH_SECURE_BASE_URL, self::XML_PATH_UNSECURE_BASE_URL); exit; } }
public function isModuleEnabled($module) { $fileConfig = new Mage_Core_Model_Config_Base(); $fileConfig->loadFile(Mage::getBaseDir('etc') . DS . 'modules' . DS . $module . '.xml'); $isActive = $fileConfig->getNode('modules/' . $module . '/active'); if (!$isActive || !in_array((string) $isActive, array('true', '1'))) { return false; } return true; }
/** * Load declared modules configuration * * @return Mage_Core_Model_Config */ protected function _loadDeclaredModules() { Magento_Profiler::start('load_modules_files'); $moduleFiles = $this->_getDeclaredModuleFiles(); if (!$moduleFiles) { return $this; } Magento_Profiler::stop('load_modules_files'); Magento_Profiler::start('load_modules_declaration'); $unsortedConfig = new Mage_Core_Model_Config_Base('<config/>'); $emptyConfig = new Mage_Core_Model_Config_Element('<config><modules/></config>'); $declaredModules = array(); foreach ($moduleFiles as $oneConfigFile) { $path = explode(DIRECTORY_SEPARATOR, $oneConfigFile); $moduleConfig = new Mage_Core_Model_Config_Base($oneConfigFile); $modules = $moduleConfig->getXpath('modules/*'); if (!$modules) { continue; } $cPath = count($path); if ($cPath > 4) { $moduleName = $path[$cPath - 4] . '_' . $path[$cPath - 3]; $this->_modulesCache[$moduleName] = $moduleConfig; } foreach ($modules as $module) { $moduleName = $module->getName(); $isActive = (string) $module->active; if (isset($declaredModules[$moduleName])) { $declaredModules[$moduleName]['active'] = $isActive; continue; } $newModule = clone $emptyConfig; $newModule->modules->appendChild($module); $declaredModules[$moduleName] = array('active' => $isActive, 'module' => $newModule); } } foreach ($declaredModules as $moduleName => $module) { if ($module['active'] == 'true') { $module['module']->modules->{$moduleName}->active = 'true'; $unsortedConfig->extend(new Mage_Core_Model_Config_Base($module['module'])); } } $sortedConfig = new Mage_Core_Model_Config_Module($unsortedConfig, $this->_allowedModules); $this->extend($sortedConfig); Magento_Profiler::stop('load_modules_declaration'); return $this; }
/** * Returns node found by the $path and scope info * * @param string $path * @param string $scope * @param string $scopeCode * @return Mage_Core_Model_Config_Element */ public function getNode($path = null, $scope = '', $scopeCode = null) { if (!empty($scope)) { if ('store' === $scope || 'website' === $scope) { $scope .= 's'; } if ('default' !== $scope && is_int($scopeCode)) { if ('stores' == $scope) { $scopeCode = Mage::app()->getStore($scopeCode)->getCode(); } elseif ('websites' == $scope) { $scopeCode = Mage::app()->getWebsite($scopeCode)->getCode(); } else { Mage::throwException(Mage::helper('core')->__('Unknown scope "%s"', $scope)); } } $path = $scope . ($scopeCode ? '/' . $scopeCode : '') . (empty($path) ? '' : '/' . $path); } return parent::getNode($path); }
function __construct($sourceData = null) { parent::__construct($sourceData); }
/** * @param $type * @param Mage_Core_Model_Config_Base $moduleConfig * @return Mage_Core_Model_Config_Element */ protected function _getClassConfig($type, Mage_Core_Model_Config_Base $moduleConfig) { $xpath = "global/{$type}s/*[class]"; $classConfigs = $moduleConfig->getNode()->xpath($xpath); if ($classConfigs) { return $classConfigs[0]; } return false; }
/** * Init fieldset fields * * @param Varien_Data_Form_Element_Fieldset $fieldset * @param Varien_Simplexml_Element $group * @param Varien_Simplexml_Element $section * @param string $fieldPrefix * @param string $labelPrefix * @return Soon_StockReleaser_Block_Adminhtml_System_Config_Form */ public function initFields($fieldset, $group, $section, $fieldPrefix = '', $labelPrefix = '') { if (!$group->is('use_custom_form', 1)) { return parent::initFields($fieldset, $group, $section, $fieldPrefix = '', $labelPrefix = ''); } if (!$this->_configDataObject) { $this->_initObjects(); } // Extends for config data $configDataAdditionalGroups = array(); $paymentMethods = Mage::helper('payment')->getPaymentMethods(); $xmlString = "<config><fields>"; $sort_order = 0; foreach ($paymentMethods as $code => $paymentMethod) { if (!isset($paymentMethod['active']) || $paymentMethod['active'] == 0) { continue; } ++$sort_order; $xmlString .= ' <' . $code . ' translate="label"> <label>' . $paymentMethod['title'] . '</label> <frontend_type>text</frontend_type> <sort_order>' . $sort_order . '</sort_order> <validate>validate-number</validate> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </' . $code . '>'; ++$sort_order; $xmlString .= ' <' . $code . '-unit translate="label"> <frontend_type>select</frontend_type> <source_model>stockreleaser/system_config_source_unit</source_model> <sort_order>' . $sort_order . '</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </' . $code . '-unit>'; } $xmlString .= "</fields></config>"; $element = new Mage_Core_Model_Config_Base(); $element->loadString($xmlString); foreach ($element->getNode('fields') as $elements) { $elements = (array) $elements; // sort either by sort_order or by child node values bypassing the sort_order if ($group->sort_fields && $group->sort_fields->by) { $fieldset->setSortElementsByAttribute((string) $group->sort_fields->by, $group->sort_fields->direction_desc ? SORT_DESC : SORT_ASC); } else { usort($elements, array($this, '_sortForm')); } foreach ($elements as $e) { if (!$this->_canShowField($e)) { continue; } /** * Look for custom defined field path */ $path = (string) $e->config_path; if (empty($path)) { $path = $section->getName() . '/' . $group->getName() . '/' . $fieldPrefix . $e->getName(); } elseif (strrpos($path, '/') > 0) { // Extend config data with new section group $groupPath = substr($path, 0, strrpos($path, '/')); if (!isset($configDataAdditionalGroups[$groupPath])) { $this->_configData = $this->_configDataObject->extendConfig($groupPath, false, $this->_configData); $configDataAdditionalGroups[$groupPath] = true; } } $id = $section->getName() . '_' . $group->getName() . '_' . $fieldPrefix . $e->getName(); if (isset($this->_configData[$path])) { $data = $this->_configData[$path]; $inherit = false; } else { $data = $this->_configRoot->descend($path); $inherit = true; } if ($e->frontend_model) { $fieldRenderer = Mage::getBlockSingleton((string) $e->frontend_model); } else { $fieldRenderer = $this->_defaultFieldRenderer; } $fieldRenderer->setForm($this); $fieldRenderer->setConfigData($this->_configData); $helperName = $this->_configFields->getAttributeModule($section, $group, $e); $fieldType = (string) $e->frontend_type ? (string) $e->frontend_type : 'text'; $name = 'groups[' . $group->getName() . '][fields][' . $fieldPrefix . $e->getName() . '][value]'; $label = Mage::helper($helperName)->__($labelPrefix) . ' ' . Mage::helper($helperName)->__((string) $e->label); $hint = (string) $e->hint ? Mage::helper($helperName)->__((string) $e->hint) : ''; if ($e->backend_model) { $model = Mage::getModel((string) $e->backend_model); if (!$model instanceof Mage_Core_Model_Config_Data) { Mage::throwException('Invalid config field backend model: ' . (string) $e->backend_model); } $model->setPath($path)->setValue($data)->setWebsite($this->getWebsiteCode())->setStore($this->getStoreCode())->afterLoad(); $data = $model->getValue(); } $comment = $this->_prepareFieldComment($e, $helperName, $data); $tooltip = $this->_prepareFieldTooltip($e, $helperName); if ($e->depends) { foreach ($e->depends->children() as $dependent) { $dependentId = $section->getName() . '_' . $group->getName() . '_' . $fieldPrefix . $dependent->getName(); $shouldBeAddedDependence = true; $dependentValue = (string) $dependent; $dependentFieldName = $fieldPrefix . $dependent->getName(); $dependentField = $group->fields->{$dependentFieldName}; /* * If dependent field can't be shown in current scope and real dependent config value * is not equal to preferred one, then hide dependence fields by adding dependence * based on not shown field (not rendered field) */ if (!$this->_canShowField($dependentField)) { $dependentFullPath = $section->getName() . '/' . $group->getName() . '/' . $fieldPrefix . $dependent->getName(); $shouldBeAddedDependence = $dependentValue != Mage::getStoreConfig($dependentFullPath, $this->getStoreCode()); } if ($shouldBeAddedDependence) { $this->_getDependence()->addFieldMap($id, $id)->addFieldMap($dependentId, $dependentId)->addFieldDependence($id, $dependentId, $dependentValue); } } } $field = $fieldset->addField($id, $fieldType, array('name' => $name, 'label' => $label, 'comment' => $comment, 'tooltip' => $tooltip, 'hint' => $hint, 'value' => $data, 'inherit' => $inherit, 'class' => $e->frontend_class, 'field_config' => $e, 'scope' => $this->getScope(), 'scope_id' => $this->getScopeId(), 'scope_label' => $this->getScopeLabel($e), 'can_use_default_value' => $this->canUseDefaultValue((int) $e->show_in_default), 'can_use_website_value' => $this->canUseWebsiteValue((int) $e->show_in_website))); $this->_prepareFieldOriginalData($field, $e); if (isset($e->validate)) { $field->addClass($e->validate); } if (isset($e->frontend_type) && 'multiselect' === (string) $e->frontend_type && isset($e->can_be_empty)) { $field->setCanBeEmpty(true); } $field->setRenderer($fieldRenderer); if ($e->source_model) { // determine callback for the source model $factoryName = (string) $e->source_model; $method = false; if (preg_match('/^([^:]+?)::([^:]+?)$/', $factoryName, $matches)) { array_shift($matches); list($factoryName, $method) = array_values($matches); } $sourceModel = Mage::getSingleton($factoryName); if ($sourceModel instanceof Varien_Object) { $sourceModel->setPath($path); } if ($method) { if ($fieldType == 'multiselect') { $optionArray = $sourceModel->{$method}(); } else { $optionArray = array(); foreach ($sourceModel->{$method}() as $value => $label) { $optionArray[] = array('label' => $label, 'value' => $value); } } } else { $optionArray = $sourceModel->toOptionArray($fieldType == 'multiselect'); } $field->setValues($optionArray); } } } return $this; }
/** * Define node * */ public function __construct() { parent::__construct(Mage::getConfig()->getNode()->global->customer->address); }
/** * Generate class rewrite conflicts * * @return array */ protected function _generateClassRewriteConflictsData() { $modules = Mage::app()->getConfig()->getNode('modules')->children(); $data = $systemReport = $_conflicts = $_rewrites = array(); foreach ($modules as $modName => $module) { $configFile = $this->_getModulePath($modName, $this->_getModuleCodePoolByClassName($modName)); $configFile .= 'etc' . DS . 'config.xml'; try { $config = new Mage_Core_Model_Config_Base($configFile); } catch (Exception $e) { // } if (!isset($config)) { continue; } $classes = $config->getXpath('global/*/*/rewrite'); if (!$classes) { continue; } /** @var $element Mage_Core_Model_Config_Element */ foreach ($classes as $element) { //module node $moduleNode = $element->getParent(); //scope node (models|blocks|helpers) $scopeNode = $moduleNode->getParent(); //scope name $scopeName = $scopeNode->getName(); if (!in_array($scopeName, array('models', 'blocks', 'helpers'))) { continue; } /** @var $rewrite Mage_Core_Model_Config_Element */ foreach ($element as $rewrite) { $_rewriteFactoryName = $element->getParent()->getName() . '/' . $rewrite->getName(); if (!array_key_exists($_rewriteFactoryName, $_rewrites)) { $_rewrites[$_rewriteFactoryName] = array('pool' => (string) $module->codePool, 'rewrite' => trim($rewrite), 'is_active' => $this->_isModuleActiveByClassName($modName)); } else { if (!array_key_exists($_rewriteFactoryName, $_conflicts)) { $_conflicts[$_rewriteFactoryName][] = $_rewrites[$_rewriteFactoryName]; } $_conflicts[$_rewriteFactoryName][] = array('pool' => (string) $module->codePool, 'rewrite' => trim($rewrite), 'is_active' => $this->_isModuleActiveByClassName($modName)); } } } unset($config); } if ($_conflicts) { foreach ($_conflicts as $factoryName => $conflicts) { foreach ($conflicts as $conflict) { $data[] = array($factoryName, $conflict['rewrite'] . "\n" . ' {' . $this->_getClassPath($conflict['rewrite'], $conflict['pool']) . '}', $conflict['is_active'] ? 'Yes' : 'No'); } } } $systemReport['Class Rewrite Conflicts'] = array('header' => array('Factory Name', 'Class', 'Is Active'), 'data' => $data); return $systemReport; }
/** * Makes all events to lower-case * * @param string $area * @param Mage_Core_Model_Config_Base $mergeModel */ protected function _makeEventsLowerCase($area, Mage_Core_Model_Config_Base $mergeModel) { $events = $mergeModel->getNode($area . "/" . Mage_Core_Model_App_Area::PART_EVENTS); if ($events !== false) { $children = clone $events->children(); /** @var Mage_Core_Model_Config_Element $event */ foreach ($children as $event) { if ($this->_isNodeNameHasUpperCase($event)) { $oldName = $event->getName(); $newEventName = strtolower($oldName); if (!isset($events->{$newEventName})) { /** @var Mage_Core_Model_Config_Element $newNode */ $newNode = $events->addChild($newEventName, $event); $newNode->extend($event); } unset($events->{$oldName}); } } } }
public function __construct() { parent::__construct(Mage::getConfig()->getNode('global/customer/address')); }
/** * Load declared modules configuration * * @param null $mergeConfig depricated * @return Mage_Core_Model_Config */ protected function _loadDeclaredModules($mergeConfig = null) { $moduleFiles = $this->_getDeclaredModuleFiles(); if (!$moduleFiles) { return; } Varien_Profiler::start('config/load-modules-declaration'); $unsortedConfig = new Mage_Core_Model_Config_Base(); $unsortedConfig->loadString('<config/>'); $fileConfig = new Mage_Core_Model_Config_Base(); // load modules declarations foreach ($moduleFiles as $file) { $fileConfig->loadFile($file); $unsortedConfig->extend($fileConfig); } $moduleDepends = array(); foreach ($unsortedConfig->getNode('modules')->children() as $moduleName => $moduleNode) { if (!$this->_isAllowedModule($moduleName)) { continue; } $depends = array(); if ($moduleNode->depends) { foreach ($moduleNode->depends->children() as $depend) { $depends[$depend->getName()] = true; } } $moduleDepends[$moduleName] = array('module' => $moduleName, 'depends' => $depends, 'active' => 'true' === (string) $moduleNode->active ? true : false); } // check and sort module dependence $moduleDepends = $this->_sortModuleDepends($moduleDepends); // create sorted config $sortedConfig = new Mage_Core_Model_Config_Base(); $sortedConfig->loadString('<config><modules/></config>'); foreach ($unsortedConfig->getNode()->children() as $nodeName => $node) { if ($nodeName != 'modules') { $sortedConfig->getNode()->appendChild($node); } } foreach ($moduleDepends as $moduleProp) { $node = $unsortedConfig->getNode('modules/' . $moduleProp['module']); $sortedConfig->getNode('modules')->appendChild($node); } $this->extend($sortedConfig); Varien_Profiler::stop('config/load-modules-declaration'); return $this; }
protected function isRedisEnabled() { $fileConfig = new Mage_Core_Model_Config_Base(); $fileConfig->loadFile(Mage::getBaseDir('etc') . DS . 'modules' . DS . 'Cm_RedisSession.xml'); $isActive = $fileConfig->getNode('modules/Cm_RedisSession/active'); if (!$isActive || !in_array((string) $isActive, array('true', '1'))) { return false; } return true; }