default_config = $default_config; } /* ************************ */ /* ** Get/Set methods ** */ /* ************************ */ function getValue($key) { if (isset($this->config_values[$key])) { return $this->config_values[$key]; } return null; } function setValue($key, $value) { $this->config_values[$key] = $value; } /* ************************ */ /* ** Loading methods ** */ /* ************************ */ function loadConfig() { $query = ' SELECT value FROM '.CONFIG_TABLE.' WHERE param = \''.CE_CFG_DB_KEY.'\' ;'; $result = pwg_query($query); if($result) { $row = mysql_fetch_row($result); if(is_string($row[0])) { $this->config_values = unserialize($row[0]); } } $this->loadDefaultConfig(); } private function loadDefaultConfig() { foreach ($this->default_config as $key => $value) { if (!isset($this->config_values[$key])) { $this->config_values[$key] = $value; } } } /* ************************ */ /* ** Saving methods ** */ /* ************************ */ function saveConfig() { $query = ' REPLACE INTO '.CONFIG_TABLE.' VALUES( \''.CE_CFG_DB_KEY.'\', \''.serialize($this->config_values).'\', \''. CE_CFG_DB_COMMENT . '\') ;'; $result = pwg_query($query); if($result) { return true; } else { return false; } } /* ************************ */ /* ** Maintain methods ** */ /* ************************ */ static function install($plugin_id, $default_config = array()) { $query = ' REPLACE INTO '.CONFIG_TABLE.' VALUES( \''.$plugin_id.'\', \''.serialize($default_config).'\', \'Factory settings for '. $plugin_id . '\') ;'; $result = pwg_query($query); if($result) { return true; } else { return false; } } static function uninstall($plugin_id) { $query = ' DELETE FROM '.CONFIG_TABLE.' WHERE param = \''.$plugin_id.'\' ;'; $result = pwg_query($query); if($result) { return true; } else { return false; } } } ?>