From f619dedc5aa2020eeffa01e05feacedb043ccb66 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Sat, 22 Oct 2005 10:17:25 -0400
Subject: [PATCH] Patches for 20051021 release

---
 program/include/rcube_shared.inc |   44 ++++++++++++++++++++++++++++++++++++--------
 1 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/program/include/rcube_shared.inc b/program/include/rcube_shared.inc
index 21c3ae8..c0df2e5 100644
--- a/program/include/rcube_shared.inc
+++ b/program/include/rcube_shared.inc
@@ -979,7 +979,7 @@
 // provide details about the client's browser
 function rcube_browser()
   {
-  global $HTTP_USER_AGENT;
+  $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
 
   $bw['ver'] = 0;
   $bw['win'] = stristr($HTTP_USER_AGENT, 'win');
@@ -1032,7 +1032,7 @@
 function rcube_label($attrib)
   {
   global $sess_user_lang, $INSTALL_PATH;
-  static $sa_text_data, $s_language;
+  static $sa_text_data, $s_language, $utf8_decode;
 
   // extract attributes
   if (is_string($attrib))
@@ -1069,6 +1069,12 @@
         $sa_text_data = array_merge($sa_text_data, $labels);
       if (is_array($messages))
         $sa_text_data = array_merge($sa_text_data, $messages);
+      }
+      
+    if (isset($utf8_decoding) && $utf8_decoding==TRUE)
+      {
+      @include_once('lib/utf8.inc');
+      $utf8_decode = TRUE;
       }
       
     $s_language = $sess_user_lang;
@@ -1109,7 +1115,6 @@
   if ($text=='')
     $text = $a_text_item['single'];
 
-
   // replace vars in text
   if (is_array($attrib['vars']))
     {
@@ -1125,6 +1130,11 @@
 $text
 EOF;
 ");
+
+
+  // perform utf-8 decoding
+  if ($utf8_decode && function_exists('utf8ToUnicodeEntities'))
+    $text = utf8ToUnicodeEntities($text);
 
 
   // format output
@@ -1186,12 +1196,11 @@
     if (!$html_encode_arr)
       {
       $html_encode_arr = get_html_translation_table(HTML_ENTITIES);
-      $html_encode_arr["?"] = '&#150;';
       $html_encode_arr[chr(128)] = '&euro;';
       unset($html_encode_arr['?']);
       unset($html_encode_arr['&']);
       }
-    
+
     $ltpos = strpos($str, '<');
     $encode_arr = $html_encode_arr;
 
@@ -1236,7 +1245,7 @@
 
   // encode for javascript use
   if ($enctype=='js')
-    return preg_replace(array("/\r\n/", '/"/', "/'/"), array('\n', '\"', "\'"), strtr($str, $js_rep_table));
+    return preg_replace(array("/\r\n/", '/"/', "/([^\\\])'/"), array('\n', '\"', "$1\'"), strtr($str, $js_rep_table));
 
   // encode for RTF
   if ($enctype=='rtf')
@@ -1251,8 +1260,11 @@
   {
   $charset = strtolower($charset);
   
-  if (strcasecmp($charset, 'utf-8')==0)
-    return utf8_decode($input);
+  if ($charset=='utf-8')
+    {
+    require_once('lib/utf8.inc');
+    return utf8ToUnicodeEntities($input);
+    }
   else if ($charset=="koi8-r")
     return convert_cyr_string($input, 'k', 'w');
   else if ($charset=="iso8859-5")
@@ -1414,4 +1426,20 @@
 
 
 
+function abbrevate_string($str, $maxlength, $place_holder='...')
+  {
+  $length = strlen($str);
+  $first_part_length = floor($maxlength/2) - strlen($place_holder);
+  
+  if ($length > $maxlength)
+    {
+    $second_starting_location = $length - $maxlength + $first_part_length + 1;
+    $str = substr($str, 0, $first_part_length) . $place_holder . substr($str, $second_starting_location, $length);
+    }
+
+  return $str;
+  }
+  
+
+
 ?>
\ No newline at end of file

--
Gitblit v1.9.1