Better color in data picker
[fa-stable.git] / includes / lang / language.php
index 819e83aa3a9d7a485636d2a9b5ab37740a4396f3..62866f0b0279564036e144e42a07576351652d18 100644 (file)
@@ -1,16 +1,16 @@
 <?php
 /**********************************************************************
-    Copyright (C) 2008  FrontAccounting, LLC.
-       Released under the terms of the GNU Affero General Public License,
-       AGPL, as published by the Free Software Foundation, either version 
-       of the License, or (at your option) any later version.
+    Copyright (C) FrontAccounting, LLC.
+       Released under the terms of the GNU General Public License, GPL, 
+       as published by the Free Software Foundation, either version 3 
+       of the License, or (at your option) any later version.
     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
-    See the License here <http://www.gnu.org/licenses/agpl-3.0.html>.
+    See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
 ***********************************************************************/
 if (!isset($path_to_root) || isset($_GET['path_to_root']) || isset($_POST['path_to_root']))
-       die("Restricted access");
+       die(_("Restricted access"));
 include_once($path_to_root . "/lang/installed_languages.inc");
 include_once($path_to_root . "/includes/lang/gettext.php");
 
@@ -56,8 +56,6 @@ class language
                        $locale = $path_to_root . "/lang/" . $_SESSION['language']->code . "/locale.inc";
                        // check id file exists only once for session
                        $_SESSION['language']->is_locale_file = file_exists($locale);
-                   //reload_page("");
-                       meta_forward($_SERVER['PHP_SELF']);
                }
        }
 
@@ -67,7 +65,7 @@ class language
      */
        function load_languages() 
        {
-               global $installed_languages;
+               global $installed_languages, $dflt_lang;
 
                $_SESSION['languages'] = array();
 
@@ -80,7 +78,7 @@ class language
         }
 
                if (!isset($_SESSION['language']))
-                       $_SESSION['language'] = $_SESSION['languages']['en_GB'];
+                       $_SESSION['language'] = $_SESSION['languages'][$dflt_lang];
        }
 
 }
@@ -103,46 +101,14 @@ function has_locale($fun=null)
        return false;
 }
 
-session_name('FrontAccounting'.user_company());
-session_start();
-// this is to fix the "back-do-you-want-to-refresh" issue - thanx PHPFreaks
-header("Cache-control: private");
-
-// Page Initialisation
-if (!isset($_SESSION['languages'])) 
-{
-       language::load_languages();
-}
-
-$lang = $_SESSION['language'];
-
-// get_text support
-get_text::init();
-get_text::set_language($lang->code, $lang->encoding);
-//get_text::add_domain("wa", $path_to_root . "/lang");
-get_text::add_domain($lang->code, $path_to_root . "/lang");
-// Unnecessary for ajax calls. 
-// Due to bug in php 4.3.10 for this version set globally in php.ini
-ini_set('default_charset', $_SESSION['language']->encoding);
-
-if (!function_exists("_")) 
-{
-       function _($text) 
-       {
-               $retVal = get_text::gettext($text);
-               if ($retVal == "")
-                       return $text;
-               return $retVal;
-       }
-}
-
 function _set($key,$value) 
 {
        get_text::set_var($key,$value);
 }
-/*
+
 function reload_page($msg) 
 {
+       global $Ajax;
 //     header("Location: $_SERVER['PHP_SELF']."");
 //     exit;
        echo "<html>";
@@ -157,8 +123,17 @@ function reload_page($msg)
        echo "</div>";  
        echo "</body>";
        echo "</html>";
+       $Ajax->redirect($_SERVER['PHP_SELF']);
 }
-*/
-
 
+if (!function_exists("_")) 
+{
+       function _($text) 
+       {
+               $retVal = get_text::gettext($text);
+               if ($retVal == "")
+                       return $text;
+               return $retVal;
+       }
+}
 ?>
\ No newline at end of file