diff options
Diffstat (limited to 'core/Config.php')
-rw-r--r-- | core/Config.php | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/core/Config.php b/core/Config.php index 40aecb36d1..2bbb63f541 100644 --- a/core/Config.php +++ b/core/Config.php @@ -55,20 +55,24 @@ class Piwik_Config */ static public function getDefaultUserConfigPath() { - return 'config/config.ini.php'; + return Piwik_Common::getPathToPiwikRoot() . '/config/config.ini.php'; } + static public function getDefaultDefaultConfigPath() + { + return Piwik_Common::getPathToPiwikRoot() . '/config/global.ini.php'; + } + /** * Builds the Config object, given the optional path for the user INI file * If not specified, it will use the default path * * @param string $pathIniFileUserConfig */ - function __construct($pathIniFileUserConfig = null) + function __construct($pathIniFileUserConfig = null, $pathIniFileDefaultConfig = null) { Zend_Registry::set('config', $this); - $this->pathIniFileDefaultConfig = Piwik_Common::getPathToPiwikRoot().'/config/global.ini.php'; if(is_null($pathIniFileUserConfig)) { $this->pathIniFileUserConfig = self::getDefaultUserConfigPath(); @@ -78,6 +82,15 @@ class Piwik_Config $this->pathIniFileUserConfig = $pathIniFileUserConfig; } + if(is_null($pathIniFileDefaultConfig)) + { + $this->pathIniFileDefaultConfig = self::getDefaultDefaultConfigPath(); + } + else + { + $this->pathIniFileDefaultConfig = $pathIniFileDefaultConfig; + } + $this->defaultConfig = new Zend_Config_Ini($this->pathIniFileDefaultConfig, null, true); if(!Zend_Loader::isReadable($this->pathIniFileUserConfig)) @@ -206,18 +219,21 @@ class Piwik_Config */ public function __get($name) { - if( !is_null($this->userConfig) - && null !== ($valueInUserConfig = $this->userConfig->$name)) + $value = array(); + if(null !== ($valueInDefaultConfig = $this->defaultConfig->$name)) { - return $valueInUserConfig; + $value = array_merge($value, $valueInDefaultConfig->toArray()); } - if(null !== ($valueInDefaultConfig = $this->defaultConfig->$name)) + if( !is_null($this->userConfig) + && null !== ($valueInUserConfig = $this->userConfig->$name)) { - return $valueInDefaultConfig; + $value = array_merge($value, $valueInUserConfig->toArray()); } - throw new Exception("The configuration parameter $name couldn't be found in your configuration file. - <br>Try to replace your default configuration file ({$this->pathIniFileDefaultConfig}) with - the <a href='".$this->urlToPiwikHelpMissingValueInConfigurationFile."'>default piwik configuration file</a> "); + return new Zend_Config($value); + +// throw new Exception("The configuration parameter $name couldn't be found in your configuration file. +// <br>Try to replace your default configuration file ({$this->pathIniFileDefaultConfig}) with +// the <a href='".$this->urlToPiwikHelpMissingValueInConfigurationFile."'>default piwik configuration file</a> "); } } |