5 * Copyright (c) 1999-2001 The Squirrelmail Development Team
6 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 * This contains functions that display mailbox information, such as the
9 * table row that has sender, date, subject, etc...
14 if (defined('mailbox_display_php'))
16 define('mailbox_display_php', true);
18 define('PG_SEL_MAX', 10); /* Default value for page_selector_max. */
20 function printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $start_msg, $where, $what) {
22 global $color, $msgs, $msort;
23 global $sent_folder, $draft_folder;
24 global $default_use_priority;
25 global $message_highlight_list;
28 $color_string = $color[4];
29 if ($GLOBALS['alt_index_colors']) {
30 if (!isset($GLOBALS["row_count"])) {
31 $GLOBALS["row_count"] = 0;
33 $GLOBALS["row_count"]++
;
34 if ($GLOBALS["row_count"] %
2) {
35 if (!isset($color[12])) $color[12] = '#EAEAEA';
36 $color_string = $color[12];
41 $senderName = htmlentities(sqimap_find_displayable_name($msg['FROM']));
42 if( $mailbox == _("None") ) {
43 // $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
44 $boxes = sqimap_mailbox_list($imapConnection);
45 // sqimap_logout($imapConnection);
46 $mailbox = $boxes[0]['unformatted'];
49 $urlMailbox = urlencode($mailbox);
50 $subject = processSubject($msg['SUBJECT']);
53 if (isset($msg['FLAG_FLAGGED']) && ($msg['FLAG_FLAGGED'] == true)) {
54 $flag = "<font color=$color[2]>";
55 $flag_end = '</font>';
60 if (!isset($msg['FLAG_SEEN']) ||
($msg['FLAG_SEEN'] == false)) {
68 if (($mailbox == $sent_folder) ||
($mailbox == $draft_folder)) {
76 if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED']) {
77 $fontstr = "<font color=\"$color[9]\">";
78 $fontstr_end = '</font>';
84 for ($i=0; $i < count($message_highlight_list); $i++
) {
85 if (trim($message_highlight_list[$i]['value']) != '') {
86 if ($message_highlight_list[$i]['match_type'] == 'to_cc') {
87 if (strpos('^^'.strtolower($msg['TO']), strtolower($message_highlight_list[$i]['value'])) ||
strpos('^^'.strtolower($msg['CC']), strtolower($message_highlight_list[$i]['value']))) {
88 $hlt_color = $message_highlight_list[$i]['color'];
91 } else if (strpos('^^'.strtolower($msg[strtoupper($message_highlight_list[$i]['match_type'])]),strtolower($message_highlight_list[$i]['value']))) {
92 $hlt_color = $message_highlight_list[$i]['color'];
98 if (!isset($hlt_color)) {
99 $hlt_color = $color_string;
102 if ($where && $what) {
103 $search_stuff = '&where='.urlencode($where).'&what='.urlencode($what);
106 $checked = ($checkall == 1 ?
' checked' : '');
108 for ($i=1; $i <= count($index_order); $i++
) {
109 switch ($index_order[$i]) {
110 case 1: /* checkbox */
111 echo " <td bgcolor=$hlt_color align=center><input type=checkbox name=\"msg[$t]\" value=".$msg["ID"]."$checked></TD>\n";
114 echo " <td bgcolor=$hlt_color>$italic$bold$flag$fontstr$senderName$fontstr_end$flag_end$bold_end$italic_end</td>\n";
117 echo " <td nowrap bgcolor=$hlt_color><center>$bold$flag$fontstr".$msg["DATE_STRING"]."$fontstr_end$flag_end$bold_end</center></td>\n";
119 case 4: /* subject */
120 echo " <td bgcolor=$hlt_color>$bold";
121 if (! isset($search_stuff)) { $search_stuff = ''; }
122 echo "<a href=\"read_body.php?mailbox=$urlMailbox&passed_id=".$msg["ID"]."&startMessage=$start_msg&show_more=0$search_stuff\"";
123 do_hook("subject_link");
125 if ($subject != $msg['SUBJECT']) {
126 $title = get_html_translation_table(HTML_SPECIALCHARS
);
127 $title = array_flip($title);
128 $title = strtr($msg['SUBJECT'], $title);
129 $title = str_replace('"', "''", $title);
130 echo " title=\"$title\"";
132 echo ">$flag$subject$flag_end</a>$bold_end</td>\n";
136 echo " <td bgcolor=$hlt_color align=center nowrap><b><small>\n";
137 if (isset($msg['FLAG_ANSWERED']) &&
138 $msg['FLAG_ANSWERED'] == true) {
142 if ($msg['TYPE0'] == 'multipart') {
146 if ($default_use_priority) {
147 if (ereg('(1|2)',substr($msg['PRIORITY'],0,1))) {
148 echo "<font color=$color[1]>!</font>\n";
151 if (ereg('(5)',substr($msg['PRIORITY'],0,1))) {
152 echo "<font color=$color[8]>?</font>\n";
156 if (isset($msg['FLAG_DELETED']) && $msg['FLAG_DELETED']) {
157 echo "<font color=\"$color[1]\">D</font>\n";
161 if (!$stuff) echo " \n";
162 echo "</small></b></td>\n";
165 echo " <td bgcolor=$hlt_color>$bold$fontstr".show_readable_size($msg['SIZE'])."$fontstr_end$bold_end</td>\n";
173 * This function loops through a group of messages in the mailbox
174 * and shows them to the user.
176 function showMessagesForMailbox
177 ($imapConnection, $mailbox, $num_msgs, $start_msg,
178 $sort, $color,$show_num, $use_cache) {
179 global $msgs, $msort;
180 global $sent_folder, $draft_folder;
181 global $message_highlight_list;
182 global $auto_expunge;
184 /* If autoexpunge is turned on, then do it now. */
185 if ($auto_expunge == true) {
186 sqimap_mailbox_expunge($imapConnection, $mailbox, false);
188 sqimap_mailbox_select($imapConnection, $mailbox);
190 $issent = (($mailbox == $sent_folder) ||
($mailbox == $draft_folder));
192 /* If it is sorted... */
193 if ($num_msgs >= 1) {
195 $id = range(1, $num_msgs);
197 // if it's not sorted
198 if ($start_msg +
($show_num - 1) < $num_msgs) {
199 $end_msg = $start_msg +
($show_num-1);
201 $end_msg = $num_msgs;
204 if ($end_msg < $start_msg) {
205 $start_msg = $start_msg - $show_num;
206 if ($start_msg < 1) {
211 $real_startMessage = $num_msgs - $start_msg +
1;
212 $real_endMessage = $num_msgs - $start_msg - $show_num +
2;
213 if ($real_endMessage <= 0) {
214 $real_endMessage = 1;
216 $id = array_reverse(range($real_endMessage, $real_startMessage));
219 $msgs_list = sqimap_get_small_header_list($imapConnection, $id, $issent);
220 $flags = sqimap_get_flags_list($imapConnection, $id, $issent);
221 foreach ($msgs_list as $hdr) {
222 $from[] = $hdr->from
;
223 $date[] = $hdr->date
;
224 $subject[] = $hdr->subject
;
226 $priority[] = $hdr->priority
;
228 $size[] = $hdr->size
;
229 $type[] = $hdr->type0
;
235 $end = $start_msg +
$show_num - 1;
236 if ($num_msgs < $show_num) {
237 $end_loop = $num_msgs;
238 } else if ($end > $num_msgs) {
239 $end_loop = $num_msgs - $start_msg +
1;
241 $end_loop = $show_num;
248 while ($j < $end_loop) {
249 if (isset($date[$j])) {
250 $date[$j] = ereg_replace(' ', ' ', $date[$j]);
251 $tmpdate = explode(' ', trim($date[$j]));
253 $tmpdate = $date = array("","","","","","");
256 $messages[$j]['TIME_STAMP'] = getTimeStamp($tmpdate);
257 $messages[$j]['DATE_STRING'] = getDateString($messages[$j]['TIME_STAMP']);
258 $messages[$j]['ID'] = $id[$j];
259 $messages[$j]['FROM'] = decodeHeader($from[$j]);
260 $messages[$j]['FROM-SORT'] = strtolower(sqimap_find_displayable_name(decodeHeader($from[$j])));
261 $messages[$j]['SUBJECT'] = decodeHeader($subject[$j]);
262 $messages[$j]['SUBJECT-SORT'] = strtolower(decodeHeader($subject[$j]));
263 $messages[$j]['TO'] = decodeHeader($to[$j]);
264 $messages[$j]['PRIORITY'] = $priority[$j];
265 $messages[$j]['CC'] = $cc[$j];
266 $messages[$j]['SIZE'] = $size[$j];
267 $messages[$j]['TYPE0'] = $type[$j];
269 # fix SUBJECT-SORT to remove Re:
270 $re_abbr = # Add more here!
271 'vedr|sv|' . # Danish
274 if (eregi( "^($re_abbr):[ ]*(.*)$", $messages[$j]['SUBJECT-SORT'], $regs))
275 $messages[$j]['SUBJECT-SORT'] = $regs[2];
278 while ($num < count($flags[$j])) {
279 if ($flags[$j][$num] == 'Deleted') {
280 $messages[$j]['FLAG_DELETED'] = true;
281 } else if ($flags[$j][$num] == 'Answered') {
282 $messages[$j]['FLAG_ANSWERED'] = true;
283 } else if ($flags[$j][$num] == 'Seen') {
284 $messages[$j]['FLAG_SEEN'] = true;
285 } else if ($flags[$j][$num] == 'Flagged') {
286 $messages[$j]['FLAG_FLAGGED'] = true;
293 /* Only ignore messages flagged as deleted if we are using a
294 * trash folder or auto_expunge */
295 if (((isset($move_to_trash) && $move_to_trash)
296 ||
(isset($auto_expunge) && $auto_expunge)) && $sort != 6) {
298 /** Find and remove the ones that are deleted */
302 while ($j < $num_msgs) {
303 if (isset($messages[$j]['FLAG_DELETED']) && $messages[$j]['FLAG_DELETED'] == true) {
307 $msgs[$i] = $messages[$j];
314 if (!isset($messages)) {
321 // There's gotta be messages in the array for it to sort them.
322 if ($num_msgs > 0 && ! $use_cache) {
323 /** 0 = Date (up) 4 = Subject (up)
324 ** 1 = Date (dn) 5 = Subject (dn)
328 session_unregister("msgs");
329 if (($sort == 0) ||
($sort == 1))
330 $msort = array_cleave ($msgs, 'TIME_STAMP');
331 elseif (($sort == 2) ||
($sort == 3))
332 $msort = array_cleave ($msgs, 'FROM-SORT');
333 elseif (($sort == 4) ||
($sort == 5))
334 $msort = array_cleave ($msgs, 'SUBJECT-SORT');
345 session_register('msort');
347 displayMessageArray($imapConnection, $num_msgs, $start_msg, $msgs, $msort, $mailbox, $sort, $color,$show_num);
348 session_register('msgs');
351 /******************************************************************/
352 /* Generic function to convert the msgs array into an HTML table. */
353 /******************************************************************/
354 function displayMessageArray($imapConnection, $num_msgs, $start_msg, &$msgs, $msort, $mailbox, $sort, $color, $show_num) {
355 global $folder_prefix, $sent_folder;
356 global $imapServerAddress, $data_dir, $username, $use_mailbox_cache;
357 global $index_order, $real_endMessage, $real_startMessage, $checkall;
359 /* If cache isn't already set, do it now. */
360 if (!session_is_registered('msgs')) { session_register('msgs'); }
361 if (!session_is_registered('msort')) { session_register('msort'); }
363 if ($start_msg +
($show_num - 1) < $num_msgs) {
364 $end_msg = $start_msg +
($show_num-1);
366 $end_msg = $num_msgs;
369 if ($end_msg < $start_msg) {
370 $start_msg = $start_msg - $show_num;
371 if ($start_msg < 1) { $start_msg = 1; }
374 $urlMailbox = urlencode($mailbox);
376 do_hook('mailbox_index_before');
378 $msg_cnt_str = get_msgcnt_str($start_msg, $end_msg, $num_msgs);
379 $paginator_str = get_paginator_str($urlMailbox, $start_msg, $end_msg, $num_msgs, $show_num, $sort);
385 mail_message_listing_beginning
387 "move_messages.php?msg=$msg&mailbox=$urlMailbox&startMessage=$start_msg",
388 $mailbox, $sort, $msg_cnt_str, $paginator_str, $start_msg);
390 $groupNum = $start_msg %
($show_num - 1);
391 $real_startMessage = $start_msg;
393 if ($end_msg - $start_msg < $show_num - 1) {
394 $end_msg = $end_msg - $start_msg +
1;
396 } else if ($start_msg > $show_num) {
397 $end_msg = $show_num;
401 $endVar = $end_msg +
1;
403 /* Loop through and display the info for each message. */
404 $t = 0; // $t is used for the checkbox number
405 if ($num_msgs == 0) { // if there's no messages in this folder
406 echo "<TR><TD BGCOLOR=\"$color[4]\" COLSPAN=" . count($index_order) . ">\n";
407 echo " <CENTER><BR><B>". _("THIS FOLDER IS EMPTY") ."</B><BR> </CENTER>\n";
409 } else if ($start_msg == $end_msg) {
410 /* If there's only one message in the box, handle it differently. */
423 } while (isset ($key) && ($k < $i));
424 printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $real_startMessage, 0, 0);
434 } while (isset ($key) && ($k < $i));
437 printMessageInfo($imapConnection, $t, $i, $key, $mailbox, $sort, $real_startMessage, 0, 0);
442 } while ($i && $i < $endVar);
446 echo "<table bgcolor=\"$color[9]\" width=100% border=0 cellpadding=1 cellspacing=1>" .
447 "<tr BGCOLOR=\"$color[4]\">" .
448 "<table width=100% BGCOLOR=\"$color[4]\" border=0 cellpadding=1 cellspacing=0><tr><td>$paginator_str</td>".
449 "<td align=right>$msg_cnt_str</td></tr></table>".
452 /** End of message-list table */
454 do_hook('mailbox_index_after');
455 echo "</TABLE></FORM>\n";
459 * Displays the standard message list header. To finish the table,
460 * you need to do a "</table></table>";
462 * $moveURL is the URL to submit the delete/move form to
463 * $mailbox is the current mailbox
464 * $sort is the current sorting method (-1 for no sorting available [searches])
465 * $Message is a message that is centered on top of the list
466 * $More is a second line that is left aligned
468 function mail_message_listing_beginning
469 ($imapConnection, $moveURL, $mailbox = '', $sort = -1,
470 $msg_cnt_str = '', $paginator = '', $start_msg = 1) {
471 global $color, $index_order, $auto_expunge, $move_to_trash;
472 global $checkall, $sent_folder, $draft_folder;
473 $urlMailbox = urlencode($mailbox);
475 /****************************************************
476 * This is the beginning of the message list table. *
477 * It wraps around all messages *
478 ****************************************************/
479 echo "<TABLE WIDTH=\"100%\" BORDER=\"0\" CELLPADDING=\"1\" CELLSPACING=\"0\">\n";
481 echo "<TR BGCOLOR=\"$color[0]\"><TD>";
482 echo " <TABLE BGCOLOR=\"$color[4]\" width=\"100%\" CELLPADDING=\"2\" CELLSPACING=\"0\" BORDER=\"0\"><TR>\n";
483 echo " <TD ALIGN=LEFT>$paginator</TD>\n";
484 echo ' <TD ALIGN=CENTER>' . get_selectall_link($start_msg, $sort) . "</TD>\n";
485 echo " <TD ALIGN=RIGHT>$msg_cnt_str</TD>\n";
486 echo " </TR></TABLE>\n";
489 /** The delete and move options */
490 echo "<TR><TD BGCOLOR=\"$color[0]\">";
492 echo "\n<FORM name=messageList method=post action=\"$moveURL\">\n";
493 echo "<TABLE BGCOLOR=\"$color[0]\" COLS=2 BORDER=0 cellpadding=0 cellspacing=0 width=100%>\n";
496 " <TD ALIGN=LEFT VALIGN=CENTER NOWRAP>\n" .
497 ' <SMALL> ' . _("Move selected to:") . "</SMALL>\n" .
499 " <TD ALIGN=RIGHT NOWRAP>\n" .
500 ' <SMALL> ' . _("Transform Selected Messages") . ": </SMALL><BR>\n" .
504 " <TD ALIGN=LEFT VALIGN=CENTER NOWRAP>\n" .
505 ' <SMALL> <TT><SELECT NAME="targetMailbox">';
507 $boxes = sqimap_mailbox_list($imapConnection);
508 for ($i = 0; $i < count($boxes); $i++
) {
509 if (!in_array("noselect", $boxes[$i]['flags'])) {
510 $box = $boxes[$i]['unformatted'];
511 $box2 = str_replace(' ', ' ', $boxes[$i]['formatted']);
512 echo " <OPTION VALUE=\"$box\">$box2</option>\n";
515 echo ' </SELECT></TT></SMALL>';
516 echo " <SMALL><INPUT TYPE=SUBMIT NAME=\"moveButton\" VALUE=\"" . _("Move") . "\"></SMALL>\n";
518 echo " <TD ALIGN=RIGHT NOWRAP> \n";
519 if (!$auto_expunge) {
520 echo ' <INPUT TYPE=SUBMIT NAME="expungeButton" VALUE="'. _("Expunge") .'"> '. _("mailbox") ." \n";
522 echo " <INPUT TYPE=SUBMIT NAME=\"markRead\" VALUE=\"". _("Read")."\">\n";
523 echo " <INPUT TYPE=SUBMIT NAME=\"markUnread\" VALUE=\"". _("Unread")."\">\n";
524 echo " <INPUT TYPE=SUBMIT VALUE=\"". _("Delete") . "\"> \n";
528 do_hook('mailbox_form_before');
531 echo "<TR><TD BGCOLOR=\"$color[0]\">";
532 echo "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=";
533 if ($GLOBALS['alt_index_colors']) {
538 echo " BGCOLOR=\"$color[0]\">";
539 echo "<TR BGCOLOR=\"$color[5]\" ALIGN=\"center\">";
541 /* Print the headers. */
542 for ($i=1; $i <= count($index_order); $i++
) {
543 switch ($index_order[$i]) {
544 case 1: /* checkbox */
546 echo ' <TD WIDTH="1%"><B> </B></TD>';
550 if (($mailbox == $sent_folder)
551 ||
($mailbox == $draft_folder)) {
552 echo ' <TD WIDTH="25%"><B>'. _("To") .'</B>';
554 echo ' <TD WIDTH="25%"><B>'. _("From") .'</B>';
557 ShowSortButton($sort, $mailbox, 2, 3);
562 echo ' <TD NOWRAP WIDTH="5%"><B>'. _("Date") .'</B>';
563 ShowSortButton($sort, $mailbox, 0, 1);
567 case 4: /* subject */
568 echo ' <TD><B>'. _("Subject") .'</B> ';
569 ShowSortButton($sort, $mailbox, 4, 5);
574 echo ' <TD WIDTH="5%"><b>' . _("Size")."</b></TD>\n";
581 /*******************************************************************/
582 /* This function shows the sort button. Isn't this a good comment? */
583 /*******************************************************************/
584 function ShowSortButton($sort, $mailbox, $Up, $Down) {
585 /* Figure out which image we want to use. */
586 if ($sort != $Up && $sort != $Down) {
587 $img = 'sort_none.gif';
589 } elseif ($sort == $Up) {
590 $img = 'up_pointer.gif';
593 $img = 'down_pointer.gif';
597 /* Now that we have everything figured out, show the actual button. */
598 echo ' <a href="right_main.php?newsort=' . $which .
599 '&startMessage=1&mailbox=' . urlencode($mailbox) .
600 '"><IMG SRC="../images/' . $img .
601 '" BORDER=0 WIDTH=12 HEIGHT=10></a>';
604 function get_selectall_link($start_msg, $sort) {
605 global $checkall, $PHP_SELF, $what, $where, $mailbox;
608 ' <script language="JavaScript">' .
610 "function CheckAll() {\n" .
611 " for (var i = 0; i < document.messageList.elements.length; i++) {\n" .
612 " if( document.messageList.elements[i].type == 'checkbox' ) {\n" .
613 " document.messageList.elements[i].checked = !(document.messageList.elements[i].checked);\n".
617 'window.document.write(\'<a href=# onClick="CheckAll();">' . _("Toggle All") . "</a>');\n" .
619 "</script>\n<noscript>\n";
621 $result .= "<a href=\"$PHP_SELF?mailbox=" . urlencode($mailbox)
622 . "&startMessage=$start_msg&sort=$sort&checkall=";
623 if (isset($checkall) && $checkall == '1') {
629 if (isset($where) && isset($what)) {
630 $result .= '&where=' . urlencode($where) . '&what=' . urlencode($what);
635 if (isset($checkall) && ($checkall == '1')) {
636 $result .= _("Unselect All");
638 $result .= _("Select All");
641 $result .= "</A>\n</noscript>\n";
643 /* Return our final result. */
648 * This function computes the "Viewing Messages..." string.
650 function get_msgcnt_str($start_msg, $end_msg, $num_msgs) {
651 /* Compute the $msg_cnt_str. */
653 if ($start_msg < $end_msg) {
654 $result = sprintf(_("Viewing Messages: <B>%s</B> to <B>%s</B> (%s total)"), $start_msg, $end_msg, $num_msgs);
655 } else if ($start_msg == $end_msg) {
656 $result = sprintf(_("Viewing Message: <B>%s</B> (1 total)"), $start_msg);
661 /* Return our result string. */
666 * This function computes the paginator string.
668 function get_paginator_str
669 ($urlMailbox, $start_msg, $end_msg, $num_msgs, $show_num, $sort) {
670 global $username, $data_dir, $use_mailbox_cache;
672 $nextGroup = $start_msg +
$show_num;
673 $prevGroup = $start_msg - $show_num;
682 if (($nextGroup <= $num_msgs) && ($prevGroup >= 0)) {
683 $lMore = "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Previous") . '</A>';
684 $rMore = "<A HREF=\"right_main.php?use_mailbox_cache=$use&&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Next") ."</A>\n";
685 } else if (($nextGroup > $num_msgs) && ($prevGroup >= 0)) {
686 $lMore = "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Previous") . '</A>';
687 $rMore = "<FONT COLOR=\"$color[9]\">"._("Next")."</FONT>\n";
688 } else if (($nextGroup <= $num_msgs) && ($prevGroup < 0)) {
689 $lMore = "<FONT COLOR=\"$color[9]\">"._("Previous") . '</FONT>';
690 $rMore = "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Next") ."</A>\n";
696 /* Page selector block. Following code computes page links. */
698 if (!getPref($data_dir, $username, 'page_selector')
699 && ($num_msgs > $show_num)) {
700 $j = intval( $num_msgs / $show_num ); // Max pages
701 $k = max( 1, $j / getPref($data_dir, $username, 'page_selector_max', PG_SEL_MAX
) );
702 if ($num_msgs %
$show_num <> 0 ) {
705 $start_msgs = min( $start_msgs, $num_msgs );
706 $p = intval( $start_msg / $show_num ) +
1;
710 $start = ( ($pg-1) * $show_num ) +
1;
711 $mMore .= "<a href=\"right_main.php?use_mailbox_cache=$use_mailbox_cache&startMessage=$start" .
712 "&mailbox=$urlMailbox\" TARGET=\"right\">$pg</a> ";
715 $mMore .= "<B>$p</B> ";
719 $start = ( ($pg-1) * $show_num ) +
1;
720 $mMore .= "<a href=\"right_main.php?use_mailbox_cache=$use_mailbox_cache&startMessage=$start"
721 . "&mailbox=$urlMailbox\" TARGET=\"right\">$pg</a> ";
724 $mMore .= ' | ';
727 /* Return the resulting string. */
728 return ($lMore . $mMore . $rMore);
731 function processSubject($subject) {
732 // Shouldn't ever happen -- caught too many times in the IMAP functions
734 return _("(no subject)");
736 if (strlen($subject) <= 55)
739 $ent_strlen=strlen($subject);
742 // see if this is entities-encoded string
743 // If so, Iterate through the whole string, find out
744 // the real number of characters, and if more
745 // than 55, substr with an updated trim value.
746 while (($ent_loc = strpos($subject, '&', $ent_offset)) !== false &&
747 ($ent_loc_end = strpos($subject, ';', $ent_loc)) !== false)
749 $trim_val +
= ($ent_loc_end-$ent_loc)+
1;
750 $ent_strlen -= $ent_loc_end-$ent_loc;
751 $ent_offset = $ent_loc_end+
1;
754 if ($ent_strlen <= 55)
757 return substr($subject, 0, $trim_val) . '...';