Code

Added new function to get available languages.
[gosa.git] / include / functions.inc
index 8867c0674c83c66ac1ee415c1c58361748d8799a..ab5f5db9d9559d7c97daae9e5727480e6da31204 100644 (file)
@@ -189,6 +189,9 @@ function get_browser_language()
   if (preg_match('/zh/', $lang)){
     return ("zh_CN");
   }
+  if (preg_match('/sv/', $lang)){
+    return ("sv_SE");
+  }
 
   return (strtolower($lang)."_".strtoupper($lang));
 }
@@ -1711,7 +1714,7 @@ function gen_uids($rule, $attributes)
 
     if ($rule[$pos] == "}" ){
       $variables[$pos]= expand_id($part, $attributes);
-      $stripped.= "\{$pos}";
+      $stripped.= "{".$pos."}";
       $trigger= false;
       continue;
     }
@@ -2467,6 +2470,9 @@ function prepare4mailbody($string)
                 "/</",
                 "/>/",
                 "/\?/",
+                "/\&/",
+                "/\(/",
+                "/\)/",
                 "/\"/");
   
   $to = array(  
@@ -2481,6 +2487,9 @@ function prepare4mailbody($string)
                 "%3C",
                 "%3E",
                 "%3F",
+                "%38",
+                "%28",
+                "%29",
                 "%22");
 
   $string = preg_replace($from,$to,$string);
@@ -2518,5 +2527,36 @@ function mac2company($mac)
 }
 
 
+function get_languages($languages_in_own_language = FALSE)
+{
+  $tmp = array(
+        "de_DE" => "German",
+        "fr_FR" => "French",
+        "it_IT" => "Italian",
+        "es_ES" => "Spanish",
+        "en_EN" => "English",
+        "nl_NL" => "Dutch",
+        "pl_PL" => "Polish",
+        "sv_SE" => "Swedish",
+        "zh_CN" => "Chinese",
+        "ru_RU" => "Russian");
+
+  $ret = array();
+  if($languages_in_own_language){
+    $old_lang = setlocale(LC_ALL, 0);
+    foreach($tmp as $key => $name){
+      $lang = $key.".UTF-8";
+      setlocale(LC_ALL, $lang);
+      $ret[$key] = _($name);
+    }
+    setlocale(LC_ALL, $old_lang);
+  }else{
+    foreach($tmp as $key => $name){
+      $ret[$key] = _($name);
+    }
+  }
+  return($ret);
+}
+
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>