public static function getConfig($asArray = true, $path = false, $default = false, $mode = APPLICATION_ENV, $asString = false) { if (!self::$config instanceof Zend_Config) { if (Zend_Registry::isRegistered('appConfig')) { self::$config = Zend_Registry::get('appConfig'); $config = self::$config; } else { if (self::hasSection(self::getConfigLocation(), $mode)) { $config = new Zend_Config_Ini(self::getConfigLocation(), $mode, array('allowModifications' => true)); if ($mode == APPLICATION_ENV) { self::$config = $config; } } else { return $default; } } } else { $config = self::$config; } if ($path) { if (strpos($path, '.')) { $path = explode('.', $path); } else { $path = array($path); } foreach ($path as $key) { $config = $config->get($key, $default); if (!$config instanceof Zend_Config && array_search($key, $path) != count($path) - 1) { if ($default === false) { throw new Exception('config path ' . implode('.', $path) . ' not found'); } $config = $default; break; } } } if ($asString) { if ($config instanceof Zend_Config) { return implode("|", $config->toArray()); } else { return $config; } } if ($asArray) { if ($config instanceof Zend_Config) { return $config->toArray(); } else { return $config; } } else { return $config; } }