From 5ea042041c5b8750c8a3a5c929d337a3e8588f87 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sat, 10 Jul 2004 10:59:37 +0000 Subject: [PATCH] fixed not showing up langs like 'es-ca' which hasn't been in phpgw_languages (or only as just 'ca') --- phpgwapi/inc/class.setup_detection.inc.php | 6 ++++-- phpgwapi/setup/setup.inc.php | 3 ++- phpgwapi/setup/tables_current.inc.php | 5 ++--- phpgwapi/setup/tables_update.inc.php | 23 ++++++++++++++++++++++ setup/inc/functions.inc.php | 7 +++---- setup/lang.php | 4 +++- 6 files changed, 37 insertions(+), 11 deletions(-) diff --git a/phpgwapi/inc/class.setup_detection.inc.php b/phpgwapi/inc/class.setup_detection.inc.php index 040e8177c3..c65acdfba2 100644 --- a/phpgwapi/inc/class.setup_detection.inc.php +++ b/phpgwapi/inc/class.setup_detection.inc.php @@ -378,8 +378,10 @@ { $sql = "SELECT lang_name FROM $languagestbl WHERE lang_id = '".$value."'"; $GLOBALS['phpgw_setup']->db->query($sql); - $GLOBALS['phpgw_setup']->db->next_record(); - $GLOBALS['phpgw_info']['setup']['installed_langs'][$value] = $GLOBALS['phpgw_setup']->db->f('lang_name'); + if ($GLOBALS['phpgw_setup']->db->next_record()) + { + $GLOBALS['phpgw_info']['setup']['installed_langs'][$value] = $GLOBALS['phpgw_setup']->db->f('lang_name'); + } } $GLOBALS['phpgw_info']['setup']['header_msg'] = 'Stage 3 (Completed)'; return 10; diff --git a/phpgwapi/setup/setup.inc.php b/phpgwapi/setup/setup.inc.php index 6e80fb33ec..00be9924c2 100755 --- a/phpgwapi/setup/setup.inc.php +++ b/phpgwapi/setup/setup.inc.php @@ -14,7 +14,7 @@ /* Basic information about this app */ $setup_info['phpgwapi']['name'] = 'phpgwapi'; $setup_info['phpgwapi']['title'] = 'phpgwapi'; - $setup_info['phpgwapi']['version'] = '1.0.0.000'; + $setup_info['phpgwapi']['version'] = '1.0.0.001'; $setup_info['phpgwapi']['versions']['current_header'] = '1.27'; $setup_info['phpgwapi']['enable'] = 3; $setup_info['phpgwapi']['app_order'] = 1; @@ -55,3 +55,4 @@ + diff --git a/phpgwapi/setup/tables_current.inc.php b/phpgwapi/setup/tables_current.inc.php index b2885d93ca..b171a7e99f 100644 --- a/phpgwapi/setup/tables_current.inc.php +++ b/phpgwapi/setup/tables_current.inc.php @@ -141,12 +141,11 @@ 'phpgw_languages' => array( 'fd' => array( 'lang_id' => array('type' => 'varchar','precision' => '5','nullable' => False), - 'lang_name' => array('type' => 'varchar','precision' => '50','nullable' => False), - 'available' => array('type' => 'char','precision' => '3','nullable' => False,'default' => 'No') + 'lang_name' => array('type' => 'varchar','precision' => '50','nullable' => False) ), 'pk' => array('lang_id'), - 'ix' => array(), 'fk' => array(), + 'ix' => array(), 'uc' => array() ), 'phpgw_lang' => array( diff --git a/phpgwapi/setup/tables_update.inc.php b/phpgwapi/setup/tables_update.inc.php index f1dc5cc44f..5675f7fd79 100644 --- a/phpgwapi/setup/tables_update.inc.php +++ b/phpgwapi/setup/tables_update.inc.php @@ -1371,4 +1371,27 @@ $GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.0.0.000'; return $GLOBALS['setup_info']['phpgwapi']['currentver']; } + + + $test[] = '1.0.0.000'; + function phpgwapi_upgrade1_0_0_000() + { + // removing the not longer needed 'availible' column, that information is in the file setup/lang/languages + $GLOBALS['phpgw_setup']->oProc->DropColumn('phpgw_languages',array( + 'fd' => array( + 'lang_id' => array('type' => 'varchar','precision' => '5','nullable' => False), + 'lang_name' => array('type' => 'varchar','precision' => '50','nullable' => False) + ), + 'pk' => array('lang_id'), + 'ix' => array(), + 'fk' => array(), + 'uc' => array() + ),'available'); + + // correcting the id for Catalan + $GLOBALS['phpgw_setup']->oProc->query("UPDATE phpgw_languages SET lang_id='es-ca' WHERE lang_id='ca'"); + + $GLOBALS['setup_info']['phpgwapi']['currentver'] = '1.0.0.001'; + return $GLOBALS['setup_info']['phpgwapi']['currentver']; + } ?> diff --git a/setup/inc/functions.inc.php b/setup/inc/functions.inc.php index adfb5165ba..82f46ce436 100644 --- a/setup/inc/functions.inc.php +++ b/setup/inc/functions.inc.php @@ -89,12 +89,11 @@ fclose($f); $d = dir('./lang'); - while($entry=$d->read()) + while($file=$d->read()) { - if(ereg('^phpgw_',$entry)) + if(preg_match('/^phpgw_([-a-z]+).lang$/i',$file,$matches)) { - $z = substr($entry,6,2); - $languages[$z]['available'] = True; + $languages[$matches[1]]['available'] = True; } } $d->close(); diff --git a/setup/lang.php b/setup/lang.php index 7425430d75..4372526fb4 100644 --- a/setup/lang.php +++ b/setup/lang.php @@ -61,7 +61,9 @@ } $select_box_desc = lang('Select which languages you would like to use'); $select_box = ''; - foreach(get_langs() as $id => $data) + $languages = get_langs(); + uasort($languages,create_function('$a,$b','return strcmp(@$a[\'descr\'],@$b[\'descr\']);')); + foreach($languages as $id => $data) { $select_box_langs = @$select_box_langs