Changeset 3480 for extensions/CommentEditor
- Timestamp:
- Jun 30, 2009, 11:38:31 PM (15 years ago)
- Location:
- extensions/CommentEditor
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/CommentEditor/classes/ce_config.class.php
r3475 r3480 9 9 var $config_values; 10 10 var $default_config; 11 var $db_key ;12 var $db_comment ;11 var $db_key = null; 12 var $db_comment = null; 13 13 14 14 /* ************************ */ … … 18 18 function CE_Config($default_config = array()) { 19 19 $this->default_config = $default_config; 20 $this->db_key = CE_CFG_DB_KEY;21 $this->db_comment = CE_CFG_DB_COMMENT;22 20 } 23 21 … … 33 31 } 34 32 33 function setValue($key, $value) { 34 $this->config_values[$key] = $value; 35 } 36 37 function getVersion() { 38 if (isset($this->config_values[CE_CFG_VERSION])) { 39 return $this->config_values[CE_CFG_VERSION]; 40 } 41 return CE_VERSION; 42 } 43 35 44 function setDBKey($key) { 36 45 $this->db_key = $key; 37 }38 39 function setDBComment($comment) {40 $this->db_comment = $comment;41 }42 43 function setValue($key, $value) {44 $this->config_values[$key] = $value;45 46 } 46 47 … … 50 51 51 52 function loadConfig() { 52 $query = ' 53 SELECT value 54 FROM '.CONFIG_TABLE.' 55 WHERE param = \''.CE_CFG_DB_KEY.'\' 56 ;'; 57 $result = pwg_query($query); 58 if($result) { 59 $row = mysql_fetch_row($result); 60 if(is_string($row[0])) { 61 $this->config_values = unserialize($row[0]); 53 if (null != $this->db_key) { 54 $query = ' 55 SELECT value 56 FROM '.CONFIG_TABLE.' 57 WHERE param = \''. $this->db_key .'\' 58 ;'; 59 $result = pwg_query($query); 60 if($result) { 61 $row = mysql_fetch_row($result); 62 if(is_string($row[0])) { 63 $this->config_values = unserialize($row[0]); 64 } 62 65 } 63 66 } … … 78 81 79 82 function saveConfig() { 83 if (null == $this->db_key) { 84 return false; 85 } 86 $db_comment = sprintf($this->config_values[CE_CFG_COMMENT], 87 $this->db_key, 88 $this->getVersion()); 80 89 $query = ' 81 90 REPLACE INTO '.CONFIG_TABLE.' … … 83 92 \''. $this->db_key .'\', 84 93 \''.serialize($this->config_values).'\', 85 \''. $ this->db_comment . '\')94 \''. $db_comment . '\') 86 95 ;'; 87 96 $result = pwg_query($query); … … 99 108 static function install($plugin_id, $default_config = array()) { 100 109 $config = new CE_Config($default_config); 101 $config->setDBComment('Factory settings for '. $plugin_id);102 110 $config->setDBKey($plugin_id); 103 111 $config->loadConfig(); 112 if (isset($default_config[CE_CFG_VERSION])) { 113 // Override version 114 $config->config_values[CE_CFG_VERSION] = $default_config[CE_CFG_VERSION]; 115 } 116 if (isset($default_config[CE_CFG_COMMENT])) { 117 // Override comment 118 $config->config_values[CE_CFG_COMMENT] = $default_config[CE_CFG_COMMENT]; 119 } 104 120 $result = $config->saveConfig(); 105 121 return $result; -
extensions/CommentEditor/classes/ce_plugin.class.php
r3475 r3480 1 1 <?php 2 /* $Id: ce_plugin.class.php,v 1.1 3 2009/06/30 19:01:50 Criss Exp $ */2 /* $Id: ce_plugin.class.php,v 1.14 2009/06/30 21:36:20 Criss Exp $ */ 3 3 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 4 4 … … 20 20 $this->config = $config; 21 21 if (null != $this->config) { 22 $this->config->setDBKey(CE_CFG_DB_KEY); 22 23 $this->config->loadConfig(); 24 $this->config->setValue(CE_CFG_COMMENT, CE_CFG_DB_COMMENT); 23 25 } 24 26 } … … 118 120 119 121 function getVersion() { 120 if (isset($this->config->config_values[CE_CFG_VERSION])) { 121 return $this->config->config_values[CE_CFG_VERSION]; 122 } 123 return CE_VERSION; 122 return $this->config->getVersion(); 124 123 } 125 124 -
extensions/CommentEditor/include/ce_common.inc.php
r3476 r3480 1 1 <?php 2 /* $Id: ce_common.inc.php,v 1.1 4 2009/06/30 19:22:06Criss Exp $ */2 /* $Id: ce_common.inc.php,v 1.15 2009/06/30 21:36:20 Criss Exp $ */ 3 3 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 4 4 … … 42 42 if (isset($plugin)) { 43 43 define('CE_CFG_DB_KEY', $plugin['id']); 44 define('CE_CFG_DB_COMMENT', 'Configuration of plugin ' . $plugin['id']);45 44 } 45 define('CE_CFG_DB_FACTORY', 'Factory settings for plugin %s [%s]'); 46 define('CE_CFG_DB_COMMENT', 'Configuration of plugin %s [%s]'); 46 47 define('CE_CFG_DISPLAY_ERROR', 'display_error'); 47 48 define('CE_CFG_DISPLAY_INFO', 'display_info'); 49 define('CE_CFG_COMMENT', 'comment'); 48 50 define('CE_CFG_VERSION', 'version'); 49 51 -
extensions/CommentEditor/maintain.inc.php
r3476 r3480 11 11 12 12 function plugin_install($plugin_id, $version, &$errors) { 13 include_once(CE_PATH . 'include/ce_common.inc.php'); 14 // Include language advices 15 load_language('plugin.lang', CE_PATH); 16 if ($version != CE_VERSION) { 17 array_push($errors, sprintf(l10n('ce_inconsistent_version'), $plugin_id)); 18 return; 19 } 20 $ce_config_default[CE_CFG_COMMENT] = CE_CFG_DB_FACTORY; 13 21 update_config($plugin_id, $version, $errors); 14 22 } … … 29 37 function update_config($plugin_id, $version, &$errors) { 30 38 include_once(CE_PATH . 'include/ce_common.inc.php'); 31 // Include language advices32 load_language('plugin.lang', CE_PATH);33 if ($version != CE_VERSION) {34 array_push($errors, sprintf(l10n('ce_inconsistent_version'), $plugin_id));35 return;36 }37 39 $clean = ce_clean_obsolete_files(CE_OBSOLETE); 38 $ce_config_default[CE_CFG_VERSION] = $version;40 $ce_config_default[CE_CFG_VERSION] = CE_VERSION; 39 41 $install = CE_Config::install($plugin_id, $ce_config_default); 40 42 }
Note: See TracChangeset
for help on using the changeset viewer.