Code

Fixed parameter expansion
[gosa.git] / include / accept-to-gettext.inc
index 005f3e74635a35dab8888d5c2ba5c9c400251d4c..adb5c1d3018939ffed7347513c0bd3003273393f 100644 (file)
@@ -90,15 +90,21 @@ function al2gt($gettextlangs, $mime)
   if(!isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])){
     $_SERVER["HTTP_ACCEPT_LANGUAGE"] = "";
   }
+  if(!isset($_SERVER["HTTP_ACCEPT_CHARSET"])){
+    $_SERVER["HTTP_ACCEPT_CHARSET"] = "";
+  }
 
   /* default to "everything is acceptable", as RFC2616 specifies */
   $acceptLang=(($_SERVER["HTTP_ACCEPT_LANGUAGE"] == '') ? '*' :
     $_SERVER["HTTP_ACCEPT_LANGUAGE"]);
-  $acceptChar=(($_SERVER["HTTP_ACCEPT_CHARSET"] == '') ? '*' :
+  /* Commented out due to problems with IE7, defaulting to the one below... */
+  #$acceptChar=(($_SERVER["HTTP_ACCEPT_CHARSET"] == '') ? '*' :
+  #  $_SERVER["HTTP_ACCEPT_CHARSET"]);
+  $acceptChar=(($_SERVER["HTTP_ACCEPT_CHARSET"] == '') ? 'ISO-8859-1,utf-8;q=0.7,*;q=0.7' :
     $_SERVER["HTTP_ACCEPT_CHARSET"]);
   $alparts=@preg_split("/,/",$acceptLang);
   $acparts=@preg_split("/,/",$acceptChar);
-  
+
   /* Parse the contents of the Accept-Language header.*/
   foreach($alparts as $part) {
     $part=trim($part);
@@ -165,8 +171,8 @@ function al2gt($gettextlangs, $mime)
       $alscores[$noct[0]] = "";
     }
   
-    if(!isset($alscores[$gtcs])){
-      $alscores[$gtcs] = "";
+    if(!isset($acscores[$gtcs])){
+      $acscores[$gtcs] = "";
     }
     $testvals=array(
         array($alscores[$allang], $acscores[$gtcs]),
@@ -191,15 +197,14 @@ function al2gt($gettextlangs, $mime)
 
   /* We must re-parse the gettext-string now, since we may have found it
    * through a "*" qualifier.*/
-  
   $gtparts=@preg_split("/\./",$curgtlang);
   $tmp=strtolower($gtparts[0]);
   $lang=preg_replace("/\_/", "-", $tmp);
-  $charset=$gtparts[1];
-
   header("Content-Language: $lang");
-  header("Content-Type: $mime; charset=$charset");
-
+  if(isset($gtparts[1])){
+    $charset=$gtparts[1];
+    header("Content-Type: $mime; charset=$charset");
+  }
   return $curgtlang;
 }