From 3381d45ef674884897efddb1c87a0aa2b777214f Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Sun, 24 Sep 2006 15:47:48 -0400
Subject: [PATCH] Updated Hungarian,Estonian and Traditional Chinese localization

---
 program/steps/mail/func.inc |  120 +++++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 83 insertions(+), 37 deletions(-)

diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 58da0ca..bfddb5a 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -611,7 +611,7 @@
 
 function rcmail_quota_display($attrib)
   {
-  global $IMAP, $OUTPUT, $JS_OBJECT_NAME;
+  global $IMAP, $OUTPUT, $JS_OBJECT_NAME, $COMM_PATH;
 
   if (!$attrib['id'])
     $attrib['id'] = 'rcmquotadisplay';
@@ -620,11 +620,33 @@
 
   // allow the following attributes to be added to the <span> tag
   $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id'));
-  
+
   if (!$IMAP->get_capability('QUOTA'))
     $quota_text = rcube_label('unknown');
-  else if (!($quota_text = $IMAP->get_quota()))
+  else if ($quota = $IMAP->get_quota())
+    {
+    $quota_text = sprintf("%s / %s (%.0f%%)",
+                          show_bytes($quota["used"] * 1024),
+                          show_bytes($quota["total"] * 1024),
+                          $quota["percent"]);
+
+    // show quota as image (by Brett Patterson)
+    if ($attrib['display'] == 'image' && function_exists('imagegif'))
+      {
+      $attrib += array('width' => 100, 'height' => 14);
+      $quota_text = sprintf('<img src="%s&amp;_action=quotaimg&amp;u=%s&amp;q=%d&amp;w=%d&amp;h=%d" width="%d" height="%d" alt="%s" title="%s / %s" />',
+                            $COMM_PATH,
+                            $quota['used'], $quota['total'],
+                            $attrib['width'], $attrib['height'],
+                            $attrib['width'], $attrib['height'],
+                            $quota_text,
+                            show_bytes($quota["used"] * 1024),
+                            show_bytes($quota["total"] * 1024));
+      }
+    }
+  else
     $quota_text = rcube_label('unlimited');
+    
 
   $out = '<span' . $attrib_str . '>';
   $out .= $quota_text;
@@ -667,7 +689,7 @@
   global $IMAP, $REMOTE_OBJECTS, $JS_OBJECT_NAME;
   
   $body = is_array($part->replaces) ? strtr($part->body, $part->replaces) : $part->body;
-  
+
   // text/html
   if ($part->ctype_secondary=='html')
     {
@@ -1061,11 +1083,11 @@
         {
         if (empty($part->ctype_parameters) || empty($part->ctype_parameters['charset']))
           $$part->ctype_parameters['charset'] = $MESSAGE['headers']->charset;
-         
+
         // fetch part if not available
         if (!isset($part->body))
           $part->body = $IMAP->get_message_part($MESSAGE['UID'], $part->mime_id, $part);
-        
+
         $body = rcmail_print_body($part, $safe_mode);
         $out .= '<div class="message-part">';
         
@@ -1165,13 +1187,13 @@
                             '/(<\/?meta[^>]*>)/i'),
                       '<!--\\1-->',
                       $body);
-                      
+
   $out = preg_replace(array('/(<body[^>]*>)/i',
                             '/(<\/body>)/i'),
                       array('<div class="rcmBody">',
                             '</div>'),
                       $out);
-  
+
   return $out;
   }
 
@@ -1217,15 +1239,65 @@
   }
 
 
+function rcmail_has_html_part($message_parts)
+{
+   if (!is_array($message_parts))
+      return FALSE;
 
-// return first text part of a message
-function rcmail_first_text_part($message_struct)
+   // check all message parts
+   foreach ($message_parts as $pid => $part)
+   {
+      $mimetype = strtolower($part->ctype_primary.'/'.$part->ctype_secondary);
+      if ($mimetype=='text/html')
+      {
+         return TRUE;
+      }
+   }
+    
+   return FALSE;
+}
+
+// return first HTML part of a message
+function rcmail_first_html_part($message_struct)
   {
   global $IMAP;
 
   if (!is_array($message_struct['parts']))
     return FALSE;
     
+  $html_part = NULL;
+
+  // check all message parts
+  foreach ($message_struct['parts'] as $pid => $part)
+    {
+    $mimetype = strtolower($part->ctype_primary.'/'.$part->ctype_secondary);
+    if ($mimetype=='text/html')
+      {
+      $html_part = $IMAP->get_message_part($message_struct['UID'], $pid, $part);
+      }
+    }
+
+  if ($html_part)
+    {
+    // remove special chars encoding
+    //$trans = array_flip(get_html_translation_table(HTML_ENTITIES));
+    //$html_part = strtr($html_part, $trans);
+
+    return $html_part;
+    }
+
+  return FALSE;
+}
+
+
+// return first text part of a message
+function rcmail_first_text_part($message_struct)
+  {
+  global $IMAP;
+
+  if (empty($message_struct['parts']))
+    return $message_struct['UID'] ? $IMAP->get_body($message_struct['UID']) : false;
+
   // check all message parts
   foreach ($message_struct['parts'] as $pid => $part)
     {
@@ -1362,42 +1434,16 @@
   }
 
 
-// create temp dir for attachments
-function rcmail_create_compose_tempdir()
-  {
-  global $CONFIG;
-  
-  if ($_SESSION['compose']['temp_dir'])
-    return $_SESSION['compose']['temp_dir'];
-  
-  if (!empty($CONFIG['temp_dir']))
-    $temp_dir = $CONFIG['temp_dir'].(!eregi('\/$', $CONFIG['temp_dir']) ? '/' : '').$_SESSION['compose']['id'];
-
-  // create temp-dir for uploaded attachments
-  if (!empty($CONFIG['temp_dir']) && is_writeable($CONFIG['temp_dir']))
-    {
-    mkdir($temp_dir);
-    $_SESSION['compose']['temp_dir'] = $temp_dir;
-    }
-
-  return $_SESSION['compose']['temp_dir'];
-  }
-
-
 // clear message composing settings
 function rcmail_compose_cleanup()
   {
   if (!isset($_SESSION['compose']))
     return;
-  
+
   // remove attachment files from temp dir
   if (is_array($_SESSION['compose']['attachments']))
     foreach ($_SESSION['compose']['attachments'] as $attachment)
       @unlink($attachment['path']);
-
-  // kill temp dir
-  if ($_SESSION['compose']['temp_dir'])
-    @rmdir($_SESSION['compose']['temp_dir']);
   
   unset($_SESSION['compose']);
   }

--
Gitblit v1.9.1