From fcae575b3d0953c2231d9cf0da7312fedda568ff Mon Sep 17 00:00:00 2001 From: slerena Date: Mon, 28 Dec 2009 12:20:29 +0000 Subject: [PATCH] 2009-12-28 Sancho Lerena * include/config_process: Fixed problems detected in system/user language settings. Now use config["language"] avoiding use of old token "language_code" * include/function_config.php: config["language"] is now a "stardard" config token, avoding to use as special one, was giving a big headache in order to maintain old compatibility. Now will use config["language"] always and create it if doesnt exist using english as base lang. * pandoradb_data.sql: Token is not "language" instead "language_code" * godmode/setup/setup.php: Use config["language"], manage like other variable in the sytem, avoiding conflicts and problems detected. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2246 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 16 ++++++++++++++++ pandora_console/godmode/setup/setup.php | 11 ++++++++++- pandora_console/include/config_process.php | 12 +++++++----- pandora_console/include/functions_config.php | 15 ++++++--------- pandora_console/pandoradb_data.sql | 2 +- 5 files changed, 40 insertions(+), 16 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 64a141f55d..f36ecc1bc2 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,19 @@ +2009-12-28 Sancho Lerena + + * include/config_process: Fixed problems detected in system/user + language settings. Now use config["language"] avoiding use of old + token "language_code" + + * include/function_config.php: config["language"] is now a "stardard" + config token, avoding to use as special one, was giving a big headache in + order to maintain old compatibility. Now will use config["language"] always + and create it if doesnt exist using english as base lang. + + * pandoradb_data.sql: Token is not "language" instead "language_code" + + * godmode/setup/setup.php: Use config["language"], manage like other + variable in the sytem, avoiding conflicts and problems detected. + 2009-12-27 Raúl Mateos * extensions/users/menu.png, extensions/dbmanager/menu.png: New files diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index c10c84ff95..50f3cb63a5 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -53,9 +53,18 @@ echo __('General configuration').""; $table->width = '90%'; $table->data = array (); + +// Current config["language"] could be set by user, not taken from global setup ! + +$current_system_lang = get_db_sql ('SELECT `value` FROM tconfig WHERE `token` = "language"'); + +if ($current_system_lang == ""){ + $current_system_lang = "en"; +} + $table->data[0][0] = __('Language code for Pandora'); $table->data[0][1] = print_select_from_sql ('SELECT id_language, name FROM tlanguage', - 'language', $config["language"], '', '', '', true); + 'language', $current_system_lang , '', '', '', true); $table->data[1][0] = __('Remote config directory'); $table->data[1][1] = print_input_text ('remote_config', $config["remote_config"], '', 30, 100, true); diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 0783037a21..f0b4a6cbc3 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -22,7 +22,7 @@ /** * Pandora build version and version */ -$build_version = 'PC091223'; +$build_version = 'PC091228'; $pandora_version = 'v3.0'; /* Help to debug problems. Override global PHP configuration */ @@ -72,18 +72,20 @@ require_once ('gettext.php'); global $REMOTE_ADDR; $config["remote_addr"] = $_SERVER['REMOTE_ADDR']; +$config['user_language'] = $config["language"]; // Set user language if provided, overriding System language if (isset ($config['id_user'])){ $userinfo = get_user_info ($config['id_user']); if ($userinfo["language"] != ""){ - $config['language'] = $userinfo["language"]; + $config['user_language'] = $userinfo["language"]; } } -$l10n = NULL; -if (file_exists ('./include/languages/'.$config["language"].'.mo')) { - $l10n = new gettext_reader (new CachedFileReader ('./include/languages/'.$config["language"].'.mo')); +$l10n = NULL; + +if (file_exists ('./include/languages/'.$config["user_language"].'.mo')) { + $l10n = new gettext_reader (new CachedFileReader ('./include/languages/'.$config["user_language"].'.mo')); $l10n->load_tables(); } diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index b9c4b67363..6e17212c36 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -128,12 +128,8 @@ function update_config () { $style = (string) get_parameter ('style', $config["style"]); if ($style != $config['style']) $style = substr ($style, 0, strlen ($style) - 4); - - /* Workaround for ugly language and language_code missmatch */ - $config['language_code'] = $config['language']; //Old value for comparation into update_config_value because in php use language but in db is language_code - update_config_value ('language_code', (string) get_parameter ('language', $config["language"])); - $config["language"] = (string) get_parameter ('language', $config["language"]); - + + update_config_value ('language', (string) get_parameter ('language', $config["language"])); update_config_value ('remote_config', (string) get_parameter ('remote_config', $config["remote_config"])); update_config_value ('block_size', (int) get_parameter ('block_size', $config["block_size"])); update_config_value ('days_purge', (int) get_parameter ('days_purge', $config["days_purge"])); @@ -191,9 +187,6 @@ function process_config () { /* Compatibility fix */ foreach ($configs as $c) { switch ($c["token"]) { - case "language_code": - $config['language'] = $c['value']; - break; case "auth": include ($config["homedir"]."/general/error_authconfig.php"); exit; @@ -202,6 +195,10 @@ function process_config () { } } + if (!isset ($config['language'])) { + update_config_value ('language', 'en'); + } + if (isset ($config['homeurl']) && $config['homeurl'][0] != '/') { $config['homeurl'] = '/'.$config['homeurl']; } diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 9200f760ec..58f6f788b3 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -40,7 +40,7 @@ INSERT INTO `talert_commands` VALUES (9,'SMS','sendsms _field1_ _field2_','Send LOCK TABLES `tconfig` WRITE; INSERT INTO `tconfig` VALUES -(1,'language_code','en'), +(1,'language','en'), (3,'block_size','20'), (4,'days_purge','60'), (5,'days_compact','15'),