Fixed get_post() support for numeric fields.
[fa-stable.git] / admin / inst_lang.php
index fdcc7f174c5ddaeecf082df72b7a0e6ec7f759be..b2264c1dfd8e7b1b92be0a34f92d3c3b75e3e742 100644 (file)
@@ -17,7 +17,7 @@ include_once($path_to_root."/includes/packages.inc");
 include_once($path_to_root . "/admin/db/maintenance_db.inc");
 include_once($path_to_root . "/includes/ui.inc");
 
-if ($use_popup_windows)
+if ($SysPrefs->use_popup_windows)
        $js = get_js_open_window(900, 500);
 
 page(_($help_context = "Install/Update Languages"), false, false, "", $js);
@@ -30,7 +30,7 @@ simple_page_mode(true);
 //
 function display_languages()
 {
-       global $table_style, $installed_languages, $dflt_lang;
+       global $installed_languages, $dflt_lang, $GetText;
        
        $th = array(_("Language"), _("Name"), _("Encoding"), _("Right To Left"),
                _("Installed"), _("Available"), _("Default"), "", "");
@@ -59,6 +59,9 @@ function display_languages()
        $langs = get_languages_list();
        foreach ($langs as $pkg_name => $lng)
        {
+               if ($lng == 'C') // skip default locale (aka no translation)
+                       continue;
+
                $lang = $lng['code'];
                $lang_name = $lng['name'];
                $charset = $lng['encoding'];
@@ -72,10 +75,9 @@ function display_languages()
                else
                        alt_table_row_color($k);
 
-               $support = ($lang == 'en_GB') ||
-                       $_SESSION['get_text']->check_support($lang, $charset);
+               $support = $GetText->check_support($lang, $charset);
 
-               if (function_exists('gettext') && !$support && !get_post('DisplayAll')) continue;
+               if (function_exists('gettext') && !$support && !get_post('DisplayAll') && $lang != 'C') continue;
 
                label_cell($lang);
                label_cell($available ? get_package_view_str($lang, $lang_name) : $lang_name);
@@ -94,7 +96,7 @@ function display_languages()
                if (function_exists('gettext') && check_value('DisplayAll'))
                        label_cell($support ? _("Yes") :_("No"));
 
-               if (!$available && ($lang != 'en_GB'))  // manually installed language
+               if (!$available && ($lang != 'C'))      // manually installed language
                        button_cell('Edit'.$id, _("Edit"), _('Edit non standard language configuration'), 
                                ICON_EDIT);
                elseif (check_pkg_upgrade($installed, $available)) // outdated or not installed language in repo
@@ -103,7 +105,7 @@ function display_languages()
                else
                        label_cell('');
 
-               if (($id !== null) && ($lang != $currlang) && ($lang != 'en_GB')) {
+               if (($id !== null) && ($lang != $currlang) && ($lang != 'C')) {
                        delete_button_cell('Delete'.$id, _('Delete'));
                        submit_js_confirm('Delete'.$id, 
                                sprintf(_("You are about to remove language \'%s\'.\nDo you want to continue ?"), 
@@ -167,7 +169,8 @@ function handle_submit($id)
        if (is_uploaded_file($_FILES['uploadfile']['tmp_name']))
        {
                $file1 = $_FILES['uploadfile']['tmp_name'];
-               $file2 = $directory . "/LC_MESSAGES/".$_POST['code'].".po";
+               $code = preg_replace('/[^a-zA-Z_]/', '', $_POST['code']);
+               $file2 = $directory . "/LC_MESSAGES/$code.po";
                if (file_exists($file2))
                        unlink($file2);
                move_uploaded_file($file1, $file2);
@@ -175,7 +178,8 @@ function handle_submit($id)
        if (is_uploaded_file($_FILES['uploadfile2']['tmp_name']))
        {
                $file1 = $_FILES['uploadfile2']['tmp_name'];
-               $file2 = $directory . "/LC_MESSAGES/".$_POST['code'].".mo";
+               $code = preg_replace('/[^a-zA-Z_]/', '', $_POST['code']);
+               $file2 = $directory . "/LC_MESSAGES/$code.mo";
                if (file_exists($file2))
                        unlink($file2);
                move_uploaded_file($file1, $file2);
@@ -204,7 +208,7 @@ function display_language_edit($selected_id)
                $_POST['code'] = $lang['code'];
                $_POST['name']  = $lang['name'];
                $_POST['encoding']  = $lang['encoding'];
-               if (isset($conn['rtl']))
+               if (isset($lang['rtl']) && $lang['rtl'] === true)
                        $_POST['rtl']  = $lang['rtl'];
                else
                        $_POST['rtl'] = false;
@@ -290,4 +294,3 @@ if (isset($_GET['popup']) || get_post('Add') || $Mode == 'Edit' || $Mode == 'ADD
 //---------------------------------------------------------------------------------------------
 end_page();
 
-?>
\ No newline at end of file