diff --git a/core/config.class.php b/core/config.class.php index 218c6c2b..c99e37ea 100644 --- a/core/config.class.php +++ b/core/config.class.php @@ -1,9 +1,86 @@ values[$name] = parse_shorthand_int($value); + $this->save($name); + } + public function set_string($name, $value) { + $this->values[$name] = $value; + $this->save($name); + } + public function set_bool($name, $value) { + $this->values[$name] = (($value == 'on' || $value === true) ? 'Y' : 'N'); + $this->save($name); + } + + public function set_default_int($name, $value) { + if(is_null($this->get($name))) { + $this->values[$name] = parse_shorthand_int($value); + } + } + public function set_default_string($name, $value) { + if(is_null($this->get($name))) { + $this->values[$name] = $value; + } + } + public function set_default_bool($name, $value) { + if(is_null($this->get($name))) { + $this->values[$name] = (($value == 'on' || $value === true) ? 'Y' : 'N'); + } + } + + public function get_int($name, $default=null) { + return (int)($this->get($name, $default)); + } + public function get_string($name, $default=null) { + return $this->get($name, $default); + } + public function get_bool($name, $default=null) { + return ($this->get($name, $default) == 'Y'); + } + + private function get($name, $default=null) { + if(isset($this->values[$name])) { + return $this->values[$name]; + } + else { + return $default; + } + } +} + + /* * A class for easy access to the 'config' table, can always be accessed * through "global $config;" */ -class Config { +class DatabaseConfig { var $values = array(); var $database = null; diff --git a/index.php b/index.php index 17cf4e8b..839230ed 100644 --- a/index.php +++ b/index.php @@ -19,7 +19,7 @@ foreach($files as $filename) { // connect to database $database = new Database(); $database->db->fnExecute = '_count_execs'; -$config = new Config($database); +$config = new DatabaseConfig($database); // load the theme parts