Browse Source

- beautified index order options page
- sort order now saves in prefs every time it is changed
- made click order of sort icons smarter and more user friendly
(easier to get to "no sort" method)
- fixed bug with next/previous when reading a message under "no sort" method

Luke Ehresman 24 years ago
parent
commit
5ff26a9f24
6 changed files with 75 additions and 44 deletions
  1. 1 0
      ChangeLog
  2. 4 0
      src/load_prefs.php
  3. 2 10
      src/options.php
  4. 13 5
      src/options_order.php
  5. 51 28
      src/read_body.php
  6. 4 1
      src/right_main.php

+ 1 - 0
ChangeLog

@@ -1,5 +1,6 @@
 Version 1.0pre1 -- DEVELOPMENT
 ------------------------------
+- Sort method saving now transparent to user, and saves between sessions
 - Now replacing all \n with \r\n before sending the message.
 - Added sorting option for NO sorting.. 10000 times faster!
 - Using <pre> tags for viewing message body instead of <tt> and &nbsp;

+ 4 - 0
src/load_prefs.php

@@ -131,6 +131,10 @@
    $left_refresh = getPref($data_dir, $username, "left_refresh");
    if ($left_refresh == "")
       $left_refresh = false;
+
+   $sort = getPref($data_dir, $username, "sort");
+   if ($sort == "")
+      $sort = 6;
    
    /** Load up the Signature file **/
    if ($use_signature == true) {

+ 2 - 10
src/options.php

@@ -72,12 +72,8 @@
     
       do_hook("options_display_save");
 
-      echo "<center><table width=90% cellpadding=2 cellspacing=0 border=0 bgcolor=\"$color[2]\"><tr><td>";
-      ecHO "<table width=100% cellpadding=5 cellspacing=0 border=0 bgcolor=\"$color[4]\"><tr><td>";
       echo "<br><center><b>"._("Successfully saved display preferences!")."</b><br>";
-      echo "<a href=\"webmail.php?right_frame=options.php\" target=_top>"._("Refresh Page")."</a></center><br>";
-      echo "</td></tr></table>";
-      echo "</td></tr></table></center>";
+      echo "<a href=\"../src/webmail.php\" target=_top>" . _("Refresh Page") . "</a></center><br>";
    } else if ($submit_folder) { 
       # Save folder preferences
       if ($trash != "none") {
@@ -98,12 +94,8 @@
       setPref($data_dir, $username, "unseen_notify", $unseennotify);
       setPref($data_dir, $username, "unseen_type", $unseentype);
       do_hook("options_folders_save");
-      echo "<center><table width=90% cellpadding=2 cellspacing=0 border=0 bgcolor=\"$color[2]\"><tr><td>";
-      ecHO "<table width=100% cellpadding=5 cellspacing=0 border=0 bgcolor=\"$color[4]\"><tr><td>";
       echo "<br><center><b>"._("Successfully saved folder preferences!")."</b><br>";
-      echo "<a href=\"left_main.php\" target=left>"._("Refresh Folders")."</a></center><br>";
-      echo "</td></tr></table>";
-      echo "</td></tr></table></center>";
+      echo "<a href=\"../src/left_main.php\" target=left>" . _("Refresh Folder List") . "</a></center><br>";
    } else {
       do_hook("options_save");
    }

+ 13 - 5
src/options_order.php

@@ -85,31 +85,37 @@
          setPref($data_dir, $username, "order$i", $index_order[$i]);
       }
    }
+   echo "<center>";
+   echo "<table cellspacing=0 cellpadding=0 border=0 width=65%><tr><td>\n";
+   echo _("The index order is the order that the columns are arranged in the message index.  You can add, remove, and move columns around to customize them to fit your needs.");
+   echo "</td></tr></table></center><br>";
 
    if (count($index_order))
    {
+      echo "<center>";
       echo "<table cellspacing=0 cellpadding=0 border=0>\n";
       for ($i=1; $i <= count($index_order); $i++) {
          $tmp = $index_order[$i];
          echo "<tr>";
-         echo "<td><small><a href=\"options_order.php?method=up&num=$i\">up</a></small></td>\n";
+         echo "<td><small><a href=\"options_order.php?method=up&num=$i\">". _("up") ."</a></small></td>\n";
          echo "<td><small>&nbsp;|&nbsp;</small></td>\n";
-         echo "<td><small><a href=\"options_order.php?method=down&num=$i\">down</a></small></td>\n";
+         echo "<td><small><a href=\"options_order.php?method=down&num=$i\">". _("down") . "</a></small></td>\n";
          echo "<td><small>&nbsp;|&nbsp;</small></td>\n";
          echo "<td>";
          // Always show the subject
          if ($tmp != 4)
-            echo "<small><a href=\"options_order.php?method=remove&num=$i\">remove</a></small>";
+            echo "<small><a href=\"options_order.php?method=remove&num=$i\">" . _("remove") . "</a></small>";
          echo "</td>\n";
          echo "<td><small>&nbsp;-&nbsp;</small></td>\n";
          echo "<td>" . $available[$tmp] . "</td>\n";
          echo "</tr>\n";
       }
       echo "</table>\n";
+      echo "</center>";
    }
    
    if (count($index_order) != count($available)) {
-   echo "<form name=f method=post action=options_order.php>";
+   echo "<center><form name=f method=post action=options_order.php>";
    echo "<select name=add>";
    for ($i=1; $i <= count($available); $i++) {
       $found = false;
@@ -125,9 +131,11 @@
    echo "</select>";
    echo "<input type=hidden value=add name=method>";
    echo "<input type=submit value=\""._("Add")."\" name=submit>";
-   echo "</form>";
+   echo "</form></center>";
    }
 
+   echo "<br><center><a href=\"../src/options.php\">" . _("Return to options page") . "</a></center>";
+
 ?>
    </td></tr></table>
 </body></html>

+ 51 - 28
src/read_body.php

@@ -45,19 +45,28 @@
       }
       echo ""._("View message") . "</a></b></center></td></tr></table>\n";
       echo "<table width=99% cellpadding=2 cellspacing=0 border=0 align=center>\n";
-      echo "<tr><td><pre>";
+      echo "<tr><td>";
+
+      echo "<table width=100% cellpadding=0 cellspacing=0 border=0>";
       for ($i=1; $i < count($read)-1; $i++) {
-         $read[$i] = htmlspecialchars($read[$i]);
-         if (substr($read[$i], 0, 1) != "\t" && 
-             substr($read[$i], 0, 1) != " " && 
-             substr($read[$i], 0, 1) != "&" && 
-             trim($read[$i])) {
-            $pre = substr($read[$i], 0, strpos($read[$i], ":"));
-            $read[$i] = str_replace("$pre", "<b>$pre</b>", decodeHeader($read[$i]));
+         $line = htmlspecialchars($read[$i]);
+         if (eregi("^[ |\t]", $line)) {
+            $second = $line;
+            $first = "";
+         } else if (eregi("^([^:|^\s]+):(.+)", $line, $regs)) {
+            $first = $regs[1];
+            $second = $regs[2];
+         } else {
+            $second = trim($line);
+            $first = "";
          }
-         echo "$read[$i]";
+         echo "<tr><td align=right valign=top>";
+         if ($first) echo "<tt><b>$first:</b></tt>";
+         else        echo " ";
+         echo "</td><td valign=top nowrap><tt>$second</tt></td></tr>";
       }
-      echo "</pre></td></tr></table>\n";
+      echo "</table>";
+      echo "</td></tr></table>\n";
       echo "</body></html>";
       sqimap_mailbox_close($imapConnection);
       sqimap_logout($imapConnection);
@@ -69,29 +78,43 @@
 
    // returns the index of the next valid message from the array
    function findNextMessage() {
-      global $msort, $currentArrayIndex, $msgs;
-		for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) { 
-   	   if ($currentArrayIndex == $msgs[$key]["ID"]) {
-				next($msort); 
-				$key = key($msort);
-				if (isset($key)) 
-					return $msgs[$key]["ID"];
-			}
-		}
+      global $msort, $currentArrayIndex, $msgs, $sort;
+
+      if ($sort == 6) {
+         if ($currentArrayIndex != 1) {
+            return $currentArrayIndex - 1;
+         }
+      } else {
+         for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) { 
+            if ($currentArrayIndex == $msgs[$key]["ID"]) {
+               next($msort); 
+               $key = key($msort);
+               if (isset($key)) 
+                  return $msgs[$key]["ID"];
+            }
+         }
+      }
       return -1;
    }
 
    // returns the index of the previous message from the array
    function findPreviousMessage() {
-      global $msort, $currentArrayIndex, $msgs;
-		for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) { 
-   	   if ($currentArrayIndex == $msgs[$key]["ID"]) {
-				prev($msort);
-				$key = key($msort);
-				if (isset($key))
-					return $msgs[$key]["ID"];
-			}
-		}
+      global $msort, $currentArrayIndex, $sort, $msgs, $imapConnection, $mailbox;
+      if ($sort == 6) {
+         $numMessages = sqimap_get_num_messages($imapConnection, $mailbox);
+         if ($currentArrayIndex != $numMessages) {
+            return $currentArrayIndex + 1; 
+         }
+      } else {
+   		for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) { 
+      	   if ($currentArrayIndex == $msgs[$key]["ID"]) {
+   				prev($msort);
+   				$key = key($msort);
+   				if (isset($key))
+   					return $msgs[$key]["ID"];
+   			}
+   		}
+      }   
       return -1;
    }
 

+ 4 - 1
src/right_main.php

@@ -67,11 +67,14 @@
    /** If it was a successful login, lets load their preferences **/
    include("../src/load_prefs.php");
 
+   if (isset($newsort) && $newsort != $sort) {
+      setPref($data_dir, $username, "sort", $newsort);
+   }
+
    // If the page has been loaded without a specific mailbox,
    //   send them to the inbox
    if (!isset($mailbox)) {
       $mailbox = "INBOX";
-      $sort = $newsort = 6;
       $startMessage = 1;
    }