- }
- echo " BGCOLOR=\"$color[0]\">";
- echo "<TR BGCOLOR=\"$color[5]\" ALIGN=\"center\">";
-
- // Print the headers
- for ($i=1; $i <= count($index_order); $i++) {
- switch ($index_order[$i]) {
- case 1: # checkbox
- case 5: # flags
- echo ' <TD WIDTH="1%"><B> </B></TD>';
- break;
-
- case 2: # from
- if ($mailbox == $sent_folder)
- echo ' <TD WIDTH="25%"><B>'. _("To") .'</B>';
- else
- echo ' <TD WIDTH="25%"><B>'. _("From") .'</B>';
- ShowSortButton($sort, $mailbox, 2, 3);
- echo "</TD>\n";
- break;
-
- case 3: # date
- echo ' <TD NOWRAP WIDTH="5%"><B>'. _("Date") .'</B>';
- ShowSortButton($sort, $mailbox, 0, 1);
- echo "</TD>\n";
- break;
-
- case 4: # subject
- echo ' <TD><B>'. _("Subject") .'</B> ';
- ShowSortButton($sort, $mailbox, 4, 5);
- echo "</TD>\n";
- break;
-
- case 6: # size
- echo ' <TD WIDTH="5%"><b>' . _("Size")."</b></TD>\n";
- break;
- }
- }
- echo "</TR>\n";
- }
-
- function ShowSortButton($sort, $mailbox, $Up, $Down) {
- 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;
- }
- 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;
-
- // This code is from Philippe Mingo <mingo@rotedic.com>
-
- ?>
-<script language="JavaScript">
-<!--
-function CheckAll() {
- for (var i = 0; i < document.messageList.elements.length; i++) {
- if( document.messageList.elements[i].name.substr( 0, 3 ) == 'msg') {
- document.messageList.elements[i].checked =
- !(document.messageList.elements[i].checked);
- }
- }
+ }
+ echo " BGCOLOR=\"$color[0]\">".
+ "<TR BGCOLOR=\"$color[5]\" ALIGN=\"center\">";
+
+ /* Print the headers. */
+ for ($i=1; $i <= count($index_order); $i++) {
+ switch ($index_order[$i]) {
+ case 1: /* checkbox */
+ case 5: /* flags */
+ echo ' <TD WIDTH="1%"><B> </B></TD>';
+ break;
+
+ case 2: /* from */
+ if (($mailbox == $sent_folder)
+ || ($mailbox == $draft_folder)) {
+ echo ' <TD WIDTH="25%"><B>'. _("To") .'</B>';
+ } else {
+ echo ' <TD WIDTH="25%"><B>'. _("From") .'</B>';
+ }
+
+ ShowSortButton($sort, $mailbox, 2, 3);
+ echo "</TD>\n";
+ break;
+
+ case 3: /* date */
+ echo ' <TD NOWRAP WIDTH="5%"><B>'. _("Date") .'</B>';
+ ShowSortButton($sort, $mailbox, 0, 1);
+ echo "</TD>\n";
+ break;
+
+ case 4: /* subject */
+ echo ' <TD><B>'. _("Subject") .'</B> ';
+ ShowSortButton($sort, $mailbox, 4, 5);
+ echo "</TD>\n";
+ break;
+
+ case 6: /* size */
+ echo ' <TD WIDTH="5%"><b>' . _("Size")."</b></TD>\n";
+ break;
+ }
+ }
+ echo "</TR>\n";
+}
+
+/*
+ * 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 get_selectall_link($start_msg, $sort) {
+ global $checkall, $PHP_SELF, $what, $where, $mailbox, $javascript_on;
+
+ if ($javascript_on) {
+ $result =
+ '<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" .
+ "//-->\n" .
+ '</script><a href=# onClick="CheckAll();">' . _("Toggle All") . "</a>\n";
+ } else {
+ $result .= "<a href=\"$PHP_SELF?mailbox=" . urlencode($mailbox)
+ . "&startMessage=$start_msg&sort=$sort&checkall=";
+ if (isset($checkall) && $checkall == '1') {
+ $result .= '0';
+ } else {
+ $result .= '1';
+ }
+
+ if (isset($where) && isset($what)) {
+ $result .= '&where=' . urlencode($where)
+ . '&what=' . urlencode($what);
+ }
+
+ $result .= "\">";
+
+ if (isset($checkall) && ($checkall == '1')) {
+ $result .= _("Unselect All");
+ } else {
+ $result .= _("Select All");
+ }
+
+ $result .= "</A>\n";
+ }
+
+ /* Return our final result. */
+ return ($result);
+}
+
+/**
+* This function computes the "Viewing Messages..." string.
+*/
+function get_msgcnt_str($start_msg, $end_msg, $num_msgs) {
+ /* Compute the $msg_cnt_str. */
+ $result = '';
+ if ($start_msg < $end_msg) {
+ $result = sprintf(_("Viewing Messages: <B>%s</B> to <B>%s</B> (%s total)"), $start_msg, $end_msg, $num_msgs);
+ } else if ($start_msg == $end_msg) {
+ $result = sprintf(_("Viewing Message: <B>%s</B> (1 total)"), $start_msg);
+ } else {
+ $result = '<br>';
+ }
+
+ /* Return our result string. */
+ return ($result);
+}
+
+/**
+* This function computes the paginator string.
+*/
+function get_paginator_str
+($urlMailbox, $start_msg, $end_msg, $num_msgs, $show_num, $sort) {
+ global $username, $data_dir, $use_mailbox_cache, $color;
+
+ $nextGroup = $start_msg + $show_num;
+ $prevGroup = $start_msg - $show_num;
+
+ if ($sort == 6) {
+ $use = 0;
+ } else {
+ $use = 1;
+ }
+ $lMore = '';
+ $rMore = '';
+ if (($nextGroup <= $num_msgs) && ($prevGroup >= 0)) {
+ $lMore = "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Previous") . '</A>';
+ $rMore = "<A HREF=\"right_main.php?use_mailbox_cache=$use&&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Next") ."</A>\n";
+ } else if (($nextGroup > $num_msgs) && ($prevGroup >= 0)) {
+ $lMore = "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$prevGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Previous") . '</A>';
+ $rMore = "<FONT COLOR=\"$color[9]\">"._("Next")."</FONT>\n";
+ } else if (($nextGroup <= $num_msgs) && ($prevGroup < 0)) {
+ $lMore = "<FONT COLOR=\"$color[9]\">"._("Previous") . '</FONT>';
+ $rMore = "<A HREF=\"right_main.php?use_mailbox_cache=$use&startMessage=$nextGroup&mailbox=$urlMailbox\" TARGET=\"right\">". _("Next") ."</A>\n";
+ }
+ if ($lMore <> '') {
+ $lMore .= ' | ';
+ }
+ if ($rMore <> '' || $lMore <> '' ) {
+ $rMore = "<A HREF=\"right_main.php?PG_SHOWNUM=9999use_mailbox_cache=$use&startMessage=1&mailbox=$urlMailbox\" TARGET=\"right\">" .
+ _("All") . '</A> | ' . $rMore;
+ }
+ /* Page selector block. Following code computes page links. */
+ $mMore = '';
+ if (getPref($data_dir, $username, 'page_selector')
+ && ($num_msgs > $show_num)) {
+ $j = intval( $num_msgs / $show_num ); // Max pages
+ $k = max( 1, $j / getPref($data_dir, $username, 'page_selector_max', PG_SEL_MAX ) );
+ if ($num_msgs % $show_num <> 0 ) {
+ $j++;
+ }
+ $start_msg = min( $start_msg, $num_msgs );
+ $p = intval( $start_msg / $show_num ) + 1;
+ $i = 1;
+ while( $i < $p ) {
+ $pg = intval( $i );
+ $start = ( ($pg-1) * $show_num ) + 1;
+ $mMore .= "<a href=\"right_main.php?use_mailbox_cache=$use_mailbox_cache&startMessage=$start" .
+ "&mailbox=$urlMailbox\" TARGET=\"right\">$pg</a> ";
+ $i += $k;
+ }
+ $mMore .= "<B>$p</B> ";
+ $i += $k;
+ while( $i <= $j ) {
+ $pg = intval( $i );
+ $start = ( ($pg-1) * $show_num ) + 1;
+ $mMore .= "<a href=\"right_main.php?use_mailbox_cache=$use_mailbox_cache&startMessage=$start"
+ . "&mailbox=$urlMailbox\" TARGET=\"right\">$pg</a> ";
+ $i+=$k;
+ }
+ $mMore .= ' | ';
+ }
+
+ /* Return the resulting string. */
+ if( $lMore . $mMore . $rMore == '' ) {
+ $lMore = ' ';
+ }
+ return ($lMore . $mMore . $rMore);
+}
+
+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) . '...';