--- /dev/null
+<?php
+
+ class mw_data_config extends mw_data{
+
+ function config($key = null){
+ $value = false;
+ if(isset($key)){
+ $value = "";
+ if(
+ (
+ $config = $this->data_read(
+ array(
+ "table_name" => "config",
+ "index_name" => "key",
+ "index_value" => $key
+ )
+ )
+ ) === false
+ ) return false;
+ if(isset($config["value"])) $value = $config["value"];
+ }
+ else{
+ $value = array();
+ if(
+ (
+ $config_list = $this->data_list(
+ array(
+ "table_name" => "config",
+ "index_name" => "key"
+ )
+ )
+ ) === false
+ ) return false;
+ foreach($config_list["list"] as $config) $value[$config["key"]] = $config["value"];
+ }
+ return $value;
+ }
+
+ function config_exists($key){
+ if(
+ (
+ $config = $this->data_read(
+ array(
+ "table_name" => "config",
+ "index_name" => "key",
+ "index_value" => $key
+ )
+ )
+ ) === false
+ ) return false;
+ return $config ? 1 : 0;
+ }
+
+ function set_config($key, $value){
+ if(
+ (
+ $config = $this->data_read(
+ array(
+ "table_name" => "config",
+ "index_name" => "key",
+ "index_value" => $key
+ )
+ )
+ ) === false
+ ) return false;
+ if($config){
+ return $this->data_update(
+ array(
+ "table_name" => "config",
+ "index_name" => "key",
+ "index_value" => $key,
+ "values" => array(
+ "value" => $value
+ )
+ )
+ );
+ }
+ else{
+ return $this->data_insert(
+ array(
+ "table_name" => "config",
+ "values" => array(
+ "key" => $key,
+ "value" => $value
+ )
+ )
+ );
+ }
+ }
+
+ function del_config($key){
+ return $this->data_delete(
+ array(
+ "table_name" => "config",
+ "index_name" => "key",
+ "index_value" => $key
+ )
+ );
+ }
+
+ }
+
+?>
\ No newline at end of file