+
+ /*******************************************************************/
+ /* This function shows the sort button. Isn't this a good comment? */
+ /*******************************************************************/
+ function ShowSortButton($sort, $mailbox, $Up, $Down) {
+ /* Figure out which image we want to use. */
+ if ($sort != $Up && $sort != $Down) {
+ $img = 'sort_none.gif';
+ $which = $Up;
+ } elseif ($sort == $Up) {
+ $img = 'up_pointer.gif';
+ $which = $Down;
+ } else {
+ $img = 'down_pointer.gif';
+ $which = 6;
+ }
+
+ /* Now that we have everything figured out, show the actual button. */
+ echo ' <a href="right_main.php?newsort=' . $which .
+ '&startMessage=1&mailbox=' . urlencode($mailbox) .
+ '"><IMG SRC="../images/' . $img .
+ '" BORDER=0 WIDTH=12 HEIGHT=10></a>';
+ }
+
+ function ShowSelectAllLink($startMessage, $sort) {
+ global $checkall, $PHP_SELF, $what, $where, $mailbox;
+
+ echo ' <script language="JavaScript">' .
+ "\n<!-- \n" .
+ "function CheckAll() {\n" .
+ " for (var i = 0; i < document.messageList.elements.length; i++) {\n" .
+ " if( document.messageList.elements[i].type == 'checkbox' ) {\n" .
+ " document.messageList.elements[i].checked = !(document.messageList.elements[i].checked);\n".
+ " }\n" .
+ " }\n" .
+ "}\n" .
+ 'window.document.write(\'<a href=# onClick="CheckAll();">' . _("Toggle All") . "</a>');\n" .
+ "//-->\n" .
+ "</script>\n<noscript>\n";
+
+ echo "<a href=\"$PHP_SELF?mailbox=" . urlencode($mailbox) .
+ "&startMessage=$startMessage&sort=$sort&checkall=";
+ if (isset($checkall) && $checkall == '1')
+ echo '0';
+ else
+ echo '1';
+ if (isset($where) && isset($what))
+ echo '&where=' . urlencode($where) . '&what=' . urlencode($what);
+ echo "\">";
+ if (isset($checkall) && $checkall == '1')
+ echo _("Unselect All");
+ else
+ echo _("Select All");
+
+ echo "</A>\n</noscript>\n";
+ }
+
+ function processSubject($subject)
+ {
+ // Shouldn't ever happen -- caught too many times in the IMAP functions
+ if ($subject == '')
+ return _("(no subject)");
+
+ if (strlen($subject) <= 55)
+ return $subject;
+
+ $ent_strlen=strlen($subject);
+ $trim_val=50;
+ $ent_offset=0;
+ // 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.
+ while (($ent_loc = strpos($subject, '&', $ent_offset)) !== false &&
+ ($ent_loc_end = strpos($subject, ';', $ent_loc)) !== false)
+ {
+ $trim_val += ($ent_loc_end-$ent_loc)+1;
+ $ent_strlen -= $ent_loc_end-$ent_loc;
+ $ent_offset = $ent_loc_end+1;
+ }
+
+ if ($ent_strlen <= 55)
+ return $subject;
+
+ return substr($subject, 0, $trim_val) . '...';
+ }
+