From 8467bf0073db31214fb8643e06186c40821d9e1a Mon Sep 17 00:00:00 2001 From: lkehresman Date: Sat, 4 Dec 1999 14:50:25 +0000 Subject: [PATCH] * Word Wrapping works good * 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 | 3 --- functions/mailbox.php | 4 +++- functions/mailbox_display.php | 8 ++++---- functions/page_header.php | 2 +- functions/strings.php | 30 +++++++++++++++--------------- src/compose.php | 17 +++++++++++++++++ src/folders.php | 2 +- src/read_body.php | 12 ++++++++---- 8 files changed, 49 insertions(+), 29 deletions(-) create mode 100644 src/compose.php diff --git a/config/config.php b/config/config.php index 166587e3..87b93b17 100644 --- a/config/config.php +++ b/config/config.php @@ -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; ?> diff --git a/functions/mailbox.php b/functions/mailbox.php index 846e1a60..44ea499d 100644 --- a/functions/mailbox.php +++ b/functions/mailbox.php @@ -266,7 +266,9 @@ $line = str_replace(">", ">", $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(" ", " ", $line); $line = str_replace("\t", "        ", $line); diff --git a/functions/mailbox_display.php b/functions/mailbox_display.php index c82891a0..d039cbc1 100644 --- a/functions/mailbox_display.php +++ b/functions/mailbox_display.php @@ -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 "\n"; @@ -21,7 +21,7 @@ echo " \n"; echo " $senderName\n"; echo "
$dateString
\n"; - echo " $subject\n"; + echo " $subject\n"; } echo "\n"; } @@ -230,10 +230,10 @@ echo "

THIS FOLDER IS EMPTY
 
"; } 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++; } } diff --git a/functions/page_header.php b/functions/page_header.php index d871768e..83f1fc80 100644 --- a/functions/page_header.php +++ b/functions/page_header.php @@ -19,7 +19,7 @@ echo " \n"; echo ""; echo "
"; - echo " Compose  "; + echo " Compose  "; echo " Addresses  "; echo " Folders  "; echo " Options  "; diff --git a/functions/strings.php b/functions/strings.php index 17591047..422c0124 100644 --- a/functions/strings.php +++ b/functions/strings.php @@ -27,22 +27,22 @@ 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] "; + $i++; + $line_len = $line_len + strlen($words[$i])+1; } - $before = substr($line, 0, $pos); - $lastpart = substr($line, $pos+1, strlen($line)); - $newline = $before . "
" . $lastpart; - $numlines++; + if ($i < count($words)) // don't
the last line + $line = "$line
"; + $line_len = strlen($words[$i])+1; } - return $newline; + return $line; } ?> diff --git a/src/compose.php b/src/compose.php new file mode 100644 index 00000000..60c40421 --- /dev/null +++ b/src/compose.php @@ -0,0 +1,17 @@ +\n"; + $imapConnection = loginToImapServer($username, $key, $imapServerAddress); + displayPageHeader($mailbox); + + echo "
\n"; + echo ""; + echo ""; + echo "
"; +?> \ No newline at end of file diff --git a/src/folders.php b/src/folders.php index beccf555..5dea2602 100644 --- a/src/folders.php +++ b/src/folders.php @@ -21,7 +21,7 @@ echo "\n"; echo ""; echo "
Delete Folder
"; - echo "
\n"; + echo "\n"; echo "\n"; - echo " "; - echo "
 
"; + echo "
"; + echo "\n"; + echo " "; + echo " \n"; - echo "
"; + echo " Message List  "; + echo "
"; echo " \n"; echo " \n"; /** subject **/ @@ -52,7 +56,7 @@ echo "

\n"; + echo "

\n"; $i = 0; while ($i < count($body)) { echo "$body[$i]"; -- 2.25.1