summaryrefslogtreecommitdiffstats
path: root/system/libraries
diff options
context:
space:
mode:
Diffstat (limited to 'system/libraries')
-rw-r--r--system/libraries/Email.php74
-rw-r--r--system/libraries/Output.php3
2 files changed, 35 insertions, 42 deletions
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index 92f2e73fa..158c82af2 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -321,14 +321,7 @@ class CI_Email {
*/
function message($body)
{
- $body = rtrim(str_replace("\r", "", $body));
-
- if ($this->wordwrap === TRUE AND $this->mailtype != 'html')
- $this->_body = $this->word_wrap($body);
- else
- $this->_body = $body;
-
- $this->_body = stripslashes($this->_body);
+ $this->_body = stripslashes(rtrim(str_replace("\r", "", $body)));
}
// --------------------------------------------------------------------
@@ -758,59 +751,53 @@ class CI_Email {
function word_wrap($str, $chars = '')
{
if ($chars == '')
+ {
$chars = ($this->wrapchars == "") ? "76" : $this->wrapchars;
+ }
- $lines = split("\n", $str);
-
- $output = "";
+ $str = preg_replace("| +|", " ", $str);
- while (list(, $thisline) = each($lines))
+ $str = preg_replace("|(\[url.+\])|", "{unwrap}\\1{/unwrap}", $str);
+
+ $output = "";
+ foreach (split("\n", $str) as $current_line)
{
- if (strlen($thisline) > $chars)
+ if (strlen($current_line) > $chars)
{
$line = "";
-
- $words = split(" ", $thisline);
-
- while(list(, $thisword) = each($words))
+
+ foreach (split(" ", $current_line) as $words)
{
- while((strlen($thisword)) > $chars)
+ while((strlen($words)) > $chars)
{
- if (stristr($thisword, '{unwrap}') !== FALSE OR stristr($thisword, '{/unwrap}') !== FALSE)
+ if (stristr($words, '{unwrap}') !== FALSE OR stristr($words, '{/unwrap}') !== FALSE)
{
break;
}
-
- $cur_pos = 0;
-
- for($i=0; $i < $chars - 1; $i++)
- {
- $output .= $thisword[$i];
- $cur_pos++;
- }
-
- $output .= "\n";
-
- $thisword = substr($thisword, $cur_pos, (strlen($thisword) - $cur_pos));
+
+ $output .= substr($words, 0, $chars-1);
+ $words = substr($words, $chars-1);
+
+ $output .= $this->newline;
}
- if ((strlen($line) + strlen($thisword)) > $chars)
+ if ((strlen($line) + strlen($words)) > $chars)
{
- $output .= $line."\n";
+ $output .= $line.$this->newline;
- $line = $thisword." ";
- }
- else
+ $line = $words." ";
+ }
+ else
{
- $line .= $thisword." ";
+ $line .= $words." ";
}
}
- $output .= $line."\n";
- }
- else
+ $output .= $line.$this->newline;
+ }
+ else
{
- $output .= $thisline."\n";
+ $output .= $current_line.$this->newline;
}
}
@@ -878,6 +865,11 @@ class CI_Email {
*/
function _build_message()
{
+ if ($this->wordwrap === TRUE AND $this->mailtype != 'html')
+ {
+ $this->_body = $this->word_wrap($this->_body);
+ }
+
$this->_set_boundaries();
$this->_write_headers();
diff --git a/system/libraries/Output.php b/system/libraries/Output.php
index 0c2620df7..e53627408 100644
--- a/system/libraries/Output.php
+++ b/system/libraries/Output.php
@@ -201,7 +201,8 @@ class CI_Output {
{
echo $output;
log_message('debug', "Final output sent to browser");
- log_message('debug', "Total execution time: ".$elapsed);
+ log_message('debug', "Total execution time: ".$elapsed);
+ return TRUE;
}
// --------------------------------------------------------------------