Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
Config.inc.php
1 <?php
2 
23 define('CONFIG_FILE', Core::getBaseDir() . DIRECTORY_SEPARATOR . 'config.inc.php');
24 
25 import('lib.pkp.classes.config.ConfigParser');
26 
27 class Config {
35  static function getVar($section, $key, $default = null) {
36  $configData =& Config::getData();
37  return isset($configData[$section][$key]) ? $configData[$section][$key] : $default;
38  }
39 
44  static function &getData() {
45  $configData =& Registry::get('configData', true, null);
46 
47  if ($configData === null) {
48  // Load configuration data only once per request, implicitly
49  // sets config data by ref in the registry.
50  $configData = Config::reloadData();
51  }
52 
53  return $configData;
54  }
55 
61  static function &reloadData() {
62  if (($configData =& ConfigParser::readConfig(Config::getConfigFileName())) === false) {
63  fatalError(sprintf('Cannot read configuration file %s', Config::getConfigFileName()));
64  }
65 
66  return $configData;
67  }
68 
73  static function setConfigFileName($configFile) {
74  // Reset the config data
75  $configData = null;
76  Registry::set('configData', $configData);
77 
78  // Set the config file
79  Registry::set('configFile', $configFile);
80  }
81 
86  static function getConfigFileName() {
87  return Registry::get('configFile', true, CONFIG_FILE);
88  }
89 }
90 
91 ?>
static set($key, &$value)
static getConfigFileName()
Definition: Config.inc.php:86
static setConfigFileName($configFile)
Definition: Config.inc.php:73
static & reloadData()
Definition: Config.inc.php:61
Config class for accessing configuration parameters.
Definition: Config.inc.php:27
static getVar($section, $key, $default=null)
Definition: Config.inc.php:35
static & getData()
Definition: Config.inc.php:44
static & get($key, $createIfEmpty=false, $createWithDefault=null)
static getBaseDir()
Definition: Core.inc.php:37
static & readConfig($file)