From da4c66e8aed8a6deb1e1a2cefe5a5323f309a50a Mon Sep 17 00:00:00 2001 From: philippe_mingo Date: Sat, 23 Mar 2002 16:43:06 +0000 Subject: [PATCH] Optimizarion: Translatetext is a mime.php specific function. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2627 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/mime.php | 55 +++++++++++++++++++++++++++++++++++++++++++ functions/strings.php | 50 --------------------------------------- 2 files changed, 55 insertions(+), 50 deletions(-) diff --git a/functions/mime.php b/functions/mime.php index d19d6e0d..14b3eae2 100644 --- a/functions/mime.php +++ b/functions/mime.php @@ -600,6 +600,61 @@ function findDisplayEntityHTML ($message) { return 0; } +/* + * translateText + * Extracted from strings.php 23/03/2002 + */ + +function translateText(&$body, $wrap_at, $charset) { + global $where, $what; /* from searching */ + global $color; /* color theme */ + + require_once('../functions/url_parser.php'); + + $body_ary = explode("\n", $body); + $PriorQuotes = 0; + for ($i=0; $i < count($body_ary); $i++) { + $line = $body_ary[$i]; + if (strlen($line) - 2 >= $wrap_at) { + sqWordWrap($line, $wrap_at); + } + $line = charset_decode($charset, $line); + $line = str_replace("\t", ' ', $line); + + parseUrl ($line); + + $Quotes = 0; + $pos = 0; + $j = strlen( $line ); + + while ( $pos < $j ) { + if ($line[$pos] == ' ') { + $pos ++; + } else if (strpos($line, '>', $pos) === $pos) { + $pos += 4; + $Quotes ++; + } else { + break; + } + } + + if ($Quotes > 1) { + if (! isset($color[14])) { + $color[14] = '#FF0000'; + } + $line = '' . $line . ''; + } elseif ($Quotes) { + if (! isset($color[13])) { + $color[13] = '#800000'; + } + $line = '' . $line . ''; + } + + $body_ary[$i] = $line; + } + $body = '
' . implode("\n", $body_ary) . '
'; +} + /* This returns a parsed string called $body. That string can then be displayed as the actual message in the HTML. It contains everything needed, including HTML Tags, Attachments at the diff --git a/functions/strings.php b/functions/strings.php index 9277354a..ac70ae62 100644 --- a/functions/strings.php +++ b/functions/strings.php @@ -72,56 +72,6 @@ function getLineOfAddrs($array) { return( $to_line ); } -function translateText(&$body, $wrap_at, $charset) { - global $where, $what; /* from searching */ - global $color; /* color theme */ - - require_once('../functions/url_parser.php'); - - $body_ary = explode("\n", $body); - $PriorQuotes = 0; - for ($i=0; $i < count($body_ary); $i++) { - $line = $body_ary[$i]; - if (strlen($line) - 2 >= $wrap_at) { - sqWordWrap($line, $wrap_at); - } - $line = charset_decode($charset, $line); - $line = str_replace("\t", ' ', $line); - - parseUrl ($line); - - $Quotes = 0; - $pos = 0; - $j = strlen( $line ); - - while ( $pos < $j ) { - if ($line[$pos] == ' ') { - $pos ++; - } else if (strpos($line, '>', $pos) === $pos) { - $pos += 4; - $Quotes ++; - } else { - break; - } - } - - if ($Quotes > 1) { - if (! isset($color[14])) { - $color[14] = '#FF0000'; - } - $line = '' . $line . ''; - } elseif ($Quotes) { - if (! isset($color[13])) { - $color[13] = '#800000'; - } - $line = '' . $line . ''; - } - - $body_ary[$i] = $line; - } - $body = '
' . implode("\n", $body_ary) . '
'; -} - function find_mailbox_name ($mailbox) { if (ereg(" *\"([^\r\n\"]*)\"[ \r\n]*$", $mailbox, $regs)) return $regs[1]; -- 2.25.1