* Word Wrapping works good
authorlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 4 Dec 1999 14:50:25 +0000 (14:50 +0000)
committerlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 4 Dec 1999 14:50:25 +0000 (14:50 +0000)
* Added "Message List" link to read_body.php
* beginnings of Compose

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@53 7612ce4b-ef26-0410-bec9-ea0150e637f0

config/config.php
functions/mailbox.php
functions/mailbox_display.php
functions/page_header.php
functions/strings.php
src/compose.php [new file with mode: 0644]
src/folders.php
src/read_body.php

index 166587e..87b93b1 100644 (file)
@@ -51,7 +51,4 @@ $special_folders[1] = $trash_folder;
 $special_folders[2] = "INBOX.Sent";
 $special_folders[3] = "INBOX.Drafts";
 $special_folders[4] = "INBOX.Templates";
-
-/** This is the max chars before a line wrap on plain text messages */
-$wrap_max = 80;
 ?>
index 846e1a6..44ea499 100644 (file)
          $line = str_replace(">", "&gt;", $line);
       }
 
-//      $line = wordWrap($line);
+      $wrap_at = 80; // Make this configurable int the config file some time
+      if (strlen($line) - 2 >= $wrap_at) // -2 because of the ^^ at the beginning
+         $line = wordWrap($line, $wrap_at);
       $line = str_replace(" ", "&nbsp;", $line);
       $line = str_replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", $line);
 
index c82891a..d039cbc 100644 (file)
@@ -8,7 +8,7 @@
     **
     **/
 
-   function printMessageInfo($imapConnection, $t, $i, $from, $subject, $dateString, $answered, $seen, $mailbox) {
+   function printMessageInfo($imapConnection, $t, $i, $from, $subject, $dateString, $answered, $seen, $mailbox, $sort, $startMessage) {
       $senderName = getSenderName($from);
       $urlMailbox = urlencode($mailbox);
       echo "<TR>\n";
@@ -21,7 +21,7 @@
          echo "   <TD><FONT FACE=\"Arial,Helvetica\"><nobr><input type=checkbox name=\"msg[$t]\" value=$i></nobr></FONT></TD>\n";
          echo "   <TD><FONT FACE=\"Arial,Helvetica\">$senderName</FONT></TD>\n";
          echo "   <TD><FONT FACE=\"Arial,Helvetica\"><CENTER>$dateString</CENTER></FONT></TD>\n";
-         echo "   <TD><FONT FACE=\"Arial,Helvetica\"><A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$i\">$subject</A></FONT></TD>\n";
+         echo "   <TD><FONT FACE=\"Arial,Helvetica\"><A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$i&sort=$sort&startMessage=$startMessage\">$subject</A></FONT></TD>\n";
       }
       echo "</TR>\n";
    }
          echo "<TR><TD BGCOLOR=FFFFFF COLSPAN=4><CENTER><BR><B>THIS FOLDER IS EMPTY</B><BR>&nbsp</CENTER></TD></TR>";
       } else if ($startMessage == $endMessage) { // if there's only one message in the box, handle it different.
          $i = $startMessage - 1;
-         printMessageInfo($imapConnection, $t, $msgs[$i]["ID"], $msgs[$i]["FROM"], $msgs[$i]["SUBJECT"], $msgs[$i]["DATE_STRING"], $msgs[$i]["FLAG_ANSWERED"], $msgs[$i]["FLAG_SEEN"], $mailbox);
+         printMessageInfo($imapConnection, $t, $msgs[$i]["ID"], $msgs[$i]["FROM"], $msgs[$i]["SUBJECT"], $msgs[$i]["DATE_STRING"], $msgs[$i]["FLAG_ANSWERED"], $msgs[$i]["FLAG_SEEN"], $mailbox, $sort, $startMessage);
       } else {
          for ($i = $startMessage - 1;$i <= $endMessage - 1; $i++) {
-            printMessageInfo($imapConnection, $t, $msgs[$i]["ID"], $msgs[$i]["FROM"], $msgs[$i]["SUBJECT"], $msgs[$i]["DATE_STRING"], $msgs[$i]["FLAG_ANSWERED"], $msgs[$i]["FLAG_SEEN"], $mailbox);
+            printMessageInfo($imapConnection, $t, $msgs[$i]["ID"], $msgs[$i]["FROM"], $msgs[$i]["SUBJECT"], $msgs[$i]["DATE_STRING"], $msgs[$i]["FLAG_ANSWERED"], $msgs[$i]["FLAG_SEEN"], $mailbox, $sort, $startMessage);
             $t++;
          }
       }
index d871768..83f1fc8 100644 (file)
@@ -19,7 +19,7 @@
       echo "   </TR></TABLE>\n";
       echo "<TABLE BGCOLOR=FFFFFF BORDER=0 COLS=2 WIDTH=100% CELLSPACING=0 CELLPADDING=2><TR>";
       echo "      <TD ALIGN=left WIDTH=70%>";
-      echo "         <FONT FACE=\"Arial,Helvetica\">Compose</FONT>&nbsp&nbsp";
+      echo "         <FONT FACE=\"Arial,Helvetica\"><A HREF=\"compose.php\">Compose</A></FONT>&nbsp&nbsp";
       echo "         <FONT FACE=\"Arial,Helvetica\">Addresses</FONT>&nbsp&nbsp";
       echo "         <FONT FACE=\"Arial,Helvetica\"><A HREF=\"folders.php\">Folders</A></FONT>&nbsp&nbsp";
       echo "         <FONT FACE=\"Arial,Helvetica\">Options</FONT>&nbsp&nbsp";
index 1759104..422c012 100644 (file)
       return strrev($data);
    }
 
-   // Wraps text at $wrap_max characters
-   function wordWrap($line) {
-      $newline = $line;
-      $lastpart = $line;
-      $numlines = 0;
-      $wrap_max = 80;
-      while (strlen($lastpart) > $wrap_max) {
-         $pos = $wrap_max;
-         while ((substr($line, $pos, $pos+1) != " ") && ($pos > 0)) {
-            $pos--;
+   // Wraps text at $wrap characters
+   function wordWrap($passed, $wrap) {
+      $words = explode(" ", trim($passed));
+      $i = 0;
+      $line_len = strlen($words[$i])+1;
+      $line = "";
+      while ($i < count($words)) {
+         while ($line_len < $wrap) {
+            $line = "$line$words[$i]&nbsp;";
+            $i++;
+            $line_len = $line_len + strlen($words[$i])+1;
          }
-         $before = substr($line, 0, $pos);
-         $lastpart = substr($line, $pos+1, strlen($line));
-         $newline = $before . "<BR>" . $lastpart;
-         $numlines++;
+         if ($i < count($words)) // don't <BR> the last line
+            $line = "$line<BR>";
+         $line_len = strlen($words[$i])+1;
       }
-      return $newline;
+      return $line;
    }
 ?>
diff --git a/src/compose.php b/src/compose.php
new file mode 100644 (file)
index 0000000..60c4042
--- /dev/null
@@ -0,0 +1,17 @@
+<?
+   include("../config/config.php");
+   include("../functions/strings.php");
+   include("../functions/page_header.php");
+   include("../functions/imap.php");
+   include("../functions/mailbox.php");
+   include("../functions/date.php");
+
+   echo "<HTML><BODY TEXT=\"#000000\" BGCOLOR=\"#FFFFFF\" LINK=\"#0000EE\" VLINK=\"#0000EE\" ALINK=\"#0000EE\">\n";
+   $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
+   displayPageHeader($mailbox);
+
+   echo "<FORM action=\"mailto:luke@usa.om.org\" METHOD=POST>\n";
+   echo "<TEXTAREA NAME=body ROWS=20 COLS=82></TEXTAREA>";
+   echo "<INPUT TYPE=SUBMIT VALUE=\"Send\">";
+   echo "</FORM>";
+?>
\ No newline at end of file
index beccf55..5dea260 100644 (file)
@@ -21,7 +21,7 @@
    echo "<TABLE WIDTH=70% COLS=1 ALIGN=CENTER>\n";
    echo "<TR><TD BGCOLOR=DCDCDC ALIGN=CENTER><FONT FACE=\"Arial,Helvetica\"><B>Delete Folder</B></FONT></TD></TR>";
    echo "<TR><TD BGCOLOR=FFFFFF ALIGN=CENTER>";
-   echo "<FORM ACTION=folders_delete.php METHOD=POST>\n";
+   echo "<FORM ACTION=folders_delete.php METHOD=SUBMIT>\n";
    echo "<SELECT NAME=mailbox><FONT FACE=\"Arial,Helvetica\">\n";
    for ($i = 0; $i < count($boxesUnformatted); $i++) {
       $use_folder = true;
index b660fef..4f7e458 100644 (file)
 //   $date = getDateString($date);
    $date = $d[0];
    $from_name = getSenderName($f[0]);
+   $urlMailbox = urlencode($mailbox);
 
-   echo "<TABLE COLS=1 WIDTH=95% BORDER=0 ALIGN=CENTER>\n";
-   echo "   <TR><TD BGCOLOR=DCDCDC>&nbsp;</TD></TR>";
-   echo "   <TR><TD BGCOLOR=FFFFFF>";
+   echo "<BR>";
+   echo "<TABLE COLS=1 WIDTH=95% BORDER=0 ALIGN=CENTER CELLPADDING=2>\n";
+   echo "   <TR><TD BGCOLOR=DCDCDC WIDTH=100%>";
+   echo "      <A HREF=\"right_main.php?sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">Message List</A>&nbsp;&nbsp;";
+   echo "   </TD></TR>";
+   echo "   <TR><TD BGCOLOR=FFFFFF WIDTH=100%>";
    echo "   <TABLE COLS=2 WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=2>\n";
    echo "      <TR>\n";
    /** subject **/
@@ -52,7 +56,7 @@
 
    echo "   </TABLE></TD></TR>\n";
 
-   echo "   <TR><TD BGCOLOR=FFFFFF><BR>\n";
+   echo "   <TR><TD BGCOLOR=FFFFFF WIDTH=100%><BR>\n";
    $i = 0;
    while ($i < count($body)) {
       echo "$body[$i]";