From e3e823d8f63d1d9c3caf212d4f08e65c17f4ed6b Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Mon, 15 Feb 2010 01:11:44 +0200 Subject: [PATCH] Feature #272 - Installation scripts: The code for the)language selection box has been reworked. It is about language during installation procedure. Some other minor reworks. --- main/install/install_functions.inc.php | 89 +++++++++----------------- main/install/install_upgrade.lib.php | 83 +++++++++++++++--------- main/install/upgrade.php | 23 ------- 3 files changed, 83 insertions(+), 112 deletions(-) diff --git a/main/install/install_functions.inc.php b/main/install/install_functions.inc.php index ea8d344e5b..bf2b640e74 100755 --- a/main/install/install_functions.inc.php +++ b/main/install/install_functions.inc.php @@ -231,50 +231,17 @@ function get_config_param($param, $updatePath = '') { */ function get_config_param_from_db($host, $login, $pass, $db_name, $param = '') { - $mydb = mysql_connect($host, $login, $pass); - @mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5) - - $myconnect = mysql_select_db($db_name); - - $sql = "SELECT * FROM settings_current WHERE variable = '$param'"; - $res = mysql_query($sql); - if ($res === false) { - return null; - } - - if (mysql_num_rows($res) > 0) { - $row = mysql_fetch_array($res); - $value = $row['selected_value']; - return $value; - } - return null; -} - -/** - * TODO: The main API is accessible here. Then we could use a function for this purpose from there? - * - * Return a list of language directories. - * @todo function does not belong here, move to code library, - * also see infocours.php which contains similar function - */ -function get_language_folder_list($dirname) { - if ($dirname[strlen($dirname) - 1] != '/') { - $dirname .= '/'; - } - $handle = opendir($dirname); - $language_list = array(); - - while ($entries = readdir($handle)) { - if ($entries == '.' || $entries == '..' || $entries=='CVS' || $entries == '.svn') { - continue; - } - if (is_dir($dirname.$entries)) { - $language_list[] = $entries; + Database::connect(array('server' => $host, 'username' => $login, 'password' => $pass)); + Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5) + Database::select_db($db_name); + + if (($res = Database::query("SELECT * FROM settings_current WHERE variable = '$param'")) !== false) { + if (Database::num_rows($res) > 0) { + $row = Database::fetch_array($res); + return $row['selected_value']; } } - - closedir($handle); - return $language_list; + return null; } /* @@ -284,34 +251,38 @@ function get_language_folder_list($dirname) { */ /** - * Displays a form (drop down menu) so the user can select - * his/her preferred language. + * Displays a drop down box for selection the preferred language. */ function display_language_selection_box() { - //get language list - $language_list = get_language_folder_list(api_get_path(SYS_LANG_PATH)); - sort($language_list); - //Reduce the number of languages shown to only show those with higher than 90% translation in DLTT - //This option can be easily removed later on. The aim is to test people response to less choice - //$language_to_display = $language_list; - $language_to_display = array('asturian', 'bulgarian', 'english', 'italian', 'french', 'slovenian', 'slovenian_unicode', 'spanish'); + // Reading language list. + $language_list = get_language_folder_list(); - //display - echo "\t\t\n"; + foreach ($language_list as $key => $value) { + if ($key == $default_language) { $option_end = ' selected="selected">'; } else { $option_end = '>'; } - echo "\t\t\t