classy
This commit is contained in:
parent
842be2696c
commit
8acb6ae01e
@ -80,14 +80,14 @@ abstract class BaseConfig implements Config {
|
|||||||
* A class for easy access to the 'config' table, can always be accessed
|
* A class for easy access to the 'config' table, can always be accessed
|
||||||
* through "global $config;"
|
* through "global $config;"
|
||||||
*/
|
*/
|
||||||
class DatabaseConfig {
|
class DatabaseConfig extends BaseConfig {
|
||||||
var $values = array();
|
var $values = array();
|
||||||
var $database = null;
|
var $database = null;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Load the config table from a database
|
* Load the config table from a database
|
||||||
*/
|
*/
|
||||||
public function Config($database) {
|
public function DatabaseConfig($database) {
|
||||||
$this->database = $database;
|
$this->database = $database;
|
||||||
$this->values = $this->database->db->GetAssoc("SELECT name, value FROM config");
|
$this->values = $this->database->db->GetAssoc("SELECT name, value FROM config");
|
||||||
}
|
}
|
||||||
@ -109,55 +109,5 @@ class DatabaseConfig {
|
|||||||
$this->database->db->CommitTrans();
|
$this->database->db->CommitTrans();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_int($name, $value) {
|
|
||||||
$this->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) {
|
|
||||||
// deprecated -- ints should be stored as ints now
|
|
||||||
return parse_shorthand_int($this->get($name, $default));
|
|
||||||
}
|
|
||||||
public function get_string($name, $default=null) {
|
|
||||||
return $this->get($name, $default);
|
|
||||||
}
|
|
||||||
public function get_bool($name, $default=null) {
|
|
||||||
// deprecated -- bools should be stored as Y/N now
|
|
||||||
return ($this->get($name, $default) == 'Y' || $this->get($name, $default) == '1');
|
|
||||||
}
|
|
||||||
|
|
||||||
private function get($name, $default=null) {
|
|
||||||
if(isset($this->values[$name])) {
|
|
||||||
return $this->values[$name];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return $default;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user