[prev in list] [next in list] [prev in thread] [next in thread] 

List:       squirrelmail-cvs
Subject:    [SM-CVS] CVS: squirrelmail/functions mailbox_display.php,1.345,1.346
From:       Alex Lemaresquier <alex-brainstorm () users ! sourceforge ! net>
Date:       2003-08-30 21:21:36
[Download RAW message or body]

Update of /cvsroot/squirrelmail/squirrelmail/functions
In directory sc8-pr-cvs1:/tmp/cvs-serv15996

Modified Files:
	mailbox_display.php 
Log Message:
Truncate sender taking html entities in account (like Subject)

Index: mailbox_display.php
===================================================================
RCS file: /cvsroot/squirrelmail/squirrelmail/functions/mailbox_display.php,v
retrieving revision 1.345
retrieving revision 1.346
diff -u -w -r1.345 -r1.346
--- mailbox_display.php	30 Aug 2003 19:55:54 -0000	1.345
+++ mailbox_display.php	30 Aug 2003 21:21:34 -0000	1.346
@@ -123,9 +123,8 @@
         $senderAddress = _("To:") . ' ' . $senderAddress;
     }
 
-    if ( $truncate_sender > 0 && strlen($senderName) > $truncate_sender ) {
-       $senderName = substr_replace($senderName, '... ', $truncate_sender);
-    }
+    if ($truncate_sender > 0)
+       $senderName = truncateWithEntities($senderName, $truncate_sender);
 
     echo html_tag( 'tr','','','','VALIGN="top"') . "\n";
 
@@ -1215,23 +1214,12 @@
     return ($result);
 }
 
-function processSubject($subject, $threadlevel = 0) {
-    global $languages, $squirrelmail_language;
-    /* Shouldn't ever happen -- caught too many times in the IMAP functions */
-    if ($subject == '') {
-        return _("(no subject)");
-    }
-
-    $trim_at = SUBJ_TRIM_AT;
-
-    /* if this is threaded, subtract two chars per indentlevel */
-    if($threadlevel > 0 && $threadlevel <= 10) {
-        $trim_at -= (2*$threadlevel);
-    }
-
-    if (strlen($subject) <= $trim_at) {
+function truncateWithEntities($subject, $trim_at)
+{
+    if (($trim_at == 0) || (strlen($subject) <= $trim_at))
         return $subject;
-    }
+
+    global $languages, $squirrelmail_language;
 
     $ent_strlen = $orig_len = strlen($subject);
     $trim_val = $trim_at - 5;
@@ -1240,7 +1228,7 @@
      * see if this is entities-encoded string
      * If so, Iterate through the whole string, find out
      * the real number of characters, and if more
-     * than 55, substr with an updated trim value. 
+     * than $trim_at, substr with an updated trim value. 
      */
     $step = $ent_loc = 0;
     while ( $ent_loc < $trim_val && (($ent_loc = strpos($subject, '&', $ent_offset)) \
!== false) && @@ -1250,7 +1238,7 @@
         ++$step;
     }
     
-    if (($trim_val > 50) && (strlen($subject) > ($trim_val))&& \
(strpos($subject,';',$trim_val) < ($trim_val +6))) { +    if (($trim_val > ($trim_at \
- 5)) && (strlen($subject) > ($trim_val))&& (strpos($subject,';',$trim_val) < \
($trim_val +6))) {  $i = strpos($subject,';',$trim_val);
         if ($i) {
             $trim_val = strpos($subject,';',$trim_val);
@@ -1269,8 +1257,24 @@
     if(strlen($subject) <= $trim_val) {
         return $subject;
     } else {
-        return substr($subject, 0, $trim_val) . '...';
+//      return substr($subject, 0, $trim_val) . '...';
+        return substr_replace($subject, '...', $trim_val);
     }
+}
+
+function processSubject($subject, $threadlevel = 0) {
+    /* Shouldn't ever happen -- caught too many times in the IMAP functions */
+    if ($subject == '') {
+        return _("(no subject)");
+    }
+
+    $trim_at = SUBJ_TRIM_AT;
+
+    /* if this is threaded, subtract two chars per indentlevel */
+    if (($threadlevel > 0) && ($threadlevel <= 10))
+        $trim_at -= (2*$threadlevel);
+
+    return truncateWithEntities($subject, $trim_at);
 }
 
 function getMbxList($imapConnection, $boxes = 0) {



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
--
squirrelmail-cvs mailing list
List Address: squirrelmail-cvs@lists.sourceforge.net
List Info: https://lists.sourceforge.net/lists/listinfo/squirrelmail-cvs
http://squirrelmail.org/cvs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic