From f3db537f93fb10e7d73c7725252d1c2d4efc99b9 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@users.sourceforge.net>
Date: Fri, 25 May 2007 20:43:47 +0000
Subject: [PATCH] =?UTF-8?q?Am=E9lioration=20du=20support=20UTF-8=20pour=20?=
 =?UTF-8?q?la=20g=E9n=E9ration=20des=20pages=20Web.=20La=20variable=20du?=
 =?UTF-8?q?=20charset=20d'affichage=20qui=20est=20mis=20dna=20sle=20fichie?=
 =?UTF-8?q?r=20config=20est=20stock=E9=20dans=20l'objet=20$conf=20et=20non?=
 =?UTF-8?q?=20en=20session.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../includes/menus/barre_left/eldy_backoffice.php |  1 +
 htdocs/install/inc.php                            |  4 +++-
 htdocs/langs/fr_FR/main.lang                      |  3 ++-
 htdocs/lib/functions.inc.php                      |  2 +-
 htdocs/translate.class.php                        | 15 +++++++++++++--
 5 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/htdocs/includes/menus/barre_left/eldy_backoffice.php b/htdocs/includes/menus/barre_left/eldy_backoffice.php
index df8a823f02f..5ee4c5ba37a 100644
--- a/htdocs/includes/menus/barre_left/eldy_backoffice.php
+++ b/htdocs/includes/menus/barre_left/eldy_backoffice.php
@@ -137,6 +137,7 @@ class MenuLeft {
 					if ($leftmenu=="setup") $newmenu->add_submenu(DOL_URL_ROOT."/admin/dict.php", $langs->trans("DictionnarySetup"));
 					if ($leftmenu=="setup") $newmenu->add_submenu(DOL_URL_ROOT."/admin/const.php", $langs->trans("OtherSetup"));
 
+	$newmenu->add(DOL_URL_ROOT."/admin/system/index.php?leftmenu=system", $langs->trans("DatabaseConnection"));
 					$newmenu->add(DOL_URL_ROOT."/admin/system/index.php?leftmenu=system", $langs->trans("SystemInfo"));
 					if ($leftmenu=="system") $newmenu->add_submenu(DOL_URL_ROOT."/admin/system/dolibarr.php", $langs->trans("Dolibarr"),1);
 					if ($leftmenu=="system") $newmenu->add_submenu(DOL_URL_ROOT."/admin/system/constall.php", $langs->trans("AllParameters"),2);
diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php
index d8307654a6e..35c3357560b 100644
--- a/htdocs/install/inc.php
+++ b/htdocs/install/inc.php
@@ -42,12 +42,14 @@ $conffile = "../conf/conf.php";
 $charset="ISO-8859-1";
 if (file_exists($conffile))
 {
-	include_once($conffile);
+	include_once($conffile);	// Fichier conf charg�
 	$charset=$character_set_client;
 	if ($dolibarr_main_document_root)
 	{
 		require_once($dolibarr_main_document_root . "/conf/conf.class.php");
 		$conf=new Conf();
+		if (! isset($character_set_client) || ! $character_set_client) $character_set_client='ISO-8859-1';
+		$conf->character_set_client=$character_set_client;
 	}
 	if ($dolibarr_main_document_root && $dolibarr_main_db_type && ! defined('DONOTLOADCONF'))
 	{
diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang
index 80a49c17b52..1a74b279524 100644
--- a/htdocs/langs/fr_FR/main.lang
+++ b/htdocs/langs/fr_FR/main.lang
@@ -1,5 +1,6 @@
 # Dolibarr language file - fr_FR - main
-charset=iso-8859-1
+CHARSET=ISO-8859-1
+DatabaseConnection=Connexion � la base
 SeparatorDecimal=,
 SeparatorThousand= 
 Error=Erreur
diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php
index 7aa15409b60..6e39bc46eea 100644
--- a/htdocs/lib/functions.inc.php
+++ b/htdocs/lib/functions.inc.php
@@ -1292,7 +1292,7 @@ function accessforbidden($message='',$printheader=1)
 */
 function dolibarr_print_error($db='',$error='')
 {
-    global $langs,$argv;
+    global $conf,$langs,$argv;
     $syslog = '';
 
     // Si erreur intervenue avant chargement langue
diff --git a/htdocs/translate.class.php b/htdocs/translate.class.php
index 27738a3782f..118b94fba41 100644
--- a/htdocs/translate.class.php
+++ b/htdocs/translate.class.php
@@ -199,9 +199,9 @@ class Translate {
 							else
 							{
 								// On stocke toujours dans le tableau Tab en ISO
-	                        	if ($this->charset_inputfile == 'ISO-8859-1') $value=$value;
 	                        	if ($this->charset_inputfile == 'UTF-8')      $value=utf8_decode($value);
-					
+	                        	//if ($this->charset_inputfile == 'ISO-8859-1') $value=$value;
+
 								$this->setTransFromTab($key,$value);
 							}
                         }
@@ -256,7 +256,18 @@ class Translate {
             $newstr=ereg_replace('>','__gt__',$newstr);
             $newstr=ereg_replace('"','__quot__',$newstr);
 
+/*
+			if ($key=='DatabaseConnection') {
+				print utf8_encode($newstr).'-'.$newstr;					
+				print '-'.$this->charset_output;
+				print '-'.htmlentities($newstr,ENT_QUOTES,'UTF-8').'<br>';
+			}
+*/			
+			if ($this->charset_output=='UTF-8')      $newstr=utf8_encode($newstr);
+			//if ($this->charset_output=='ISO-8859-1') $newstr=$newstr;
+			
             // Cryptage en html de la chaine
+			// $newstr est une chaine stockee en memoire au format $this->charset_output
             $newstr=htmlentities($newstr,ENT_QUOTES,$this->charset_output);
 
             // On restaure les tags HTML
-- 
GitLab