Changeset 1751 in subversion


Ignore:
Timestamp:
Sep 6, 2008 12:41:43 PM (5 years ago)
Author:
thomasb
Message:

Don't wrap worwarded text; better wrap reply message text

Location:
trunk/roundcubemail/program/steps/mail
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/steps/mail/compose.inc

    r1747 r1751  
    3333  { 
    3434    @unlink($_SESSION['compose']['attachments'][$id]['path']); 
    35     $_SESSION['compose']['attachments'][$id] = NULL; 
     35    unset($_SESSION['compose']['attachments'][$id]); 
    3636    $OUTPUT->command('remove_from_attachment_list', "rcmfile$id"); 
    3737    $OUTPUT->send(); 
     
    479479  { 
    480480    // soft-wrap message first 
    481     $body = wordwrap($body, 75); 
     481    $body = rcmail_wrap_quoted($body, 75); 
    482482   
    483483    // split body into single lines 
     
    527527  if (!$bodyIsHtml) 
    528528  { 
    529     // soft-wrap message first 
    530     $body = wordwrap($body, 80); 
    531  
    532529    $prefix = sprintf("\n\n\n-------- Original Message --------\nSubject: %s\nDate: %s\nFrom: %s\nTo: %s\n\n", 
    533530      $MESSAGE->subject, 
  • trunk/roundcubemail/program/steps/mail/func.inc

    r1739 r1751  
    643643  $convert_replaces[] = "rcmail_str_replacement('<a href=\"mailto:\\1\" onclick=\"return ".JS_OBJECT_NAME.".command(\'compose\',\'\\1\',this)\">\\1</a>', \$replace_strings)"; 
    644644   
    645 //    if ($part->ctype_parameters['format'] != 'flowed') 
    646 //      $body = wordwrap(trim($body), 80); 
    647  
    648645  // search for patterns like links and e-mail addresses 
    649646  $body = preg_replace($convert_patterns, $convert_replaces, $body); 
     
    10141011 
    10151012 
     1013/** 
     1014 * Wrap text to a given number of characters per line 
     1015 * but respect the mail quotation of replies messages (>) 
     1016 * 
     1017 * @param string Text to wrap 
     1018 * @param int The line width 
     1019 * @return string The wrapped text 
     1020 */ 
     1021function rcmail_wrap_quoted($text, $max = 76) 
     1022{ 
     1023  // Rebuild the message body with a maximum of $max chars, while keeping quoted message. 
     1024  $lines = preg_split('/\r?\n/', trim($text)); 
     1025  $out = ''; 
     1026 
     1027  foreach ($lines as $line) { 
     1028    if (strlen($line) > $max) { 
     1029      if (preg_match('/^([>\s]+)/', $line, $regs)) { 
     1030        $length = strlen($regs[0]); 
     1031        $prefix = substr($line, 0, $length); 
     1032 
     1033        // Remove '> ' from the line, then wordwrap() the line 
     1034        $line = wordwrap(substr($line, $length), $max - $length); 
     1035 
     1036        // Rebuild the line with '> ' at the beginning of each 'subline' 
     1037        $newline = ''; 
     1038        foreach (explode("\n", $line) as $l) { 
     1039          $newline .= $prefix . $l . "\n"; 
     1040        } 
     1041 
     1042        // Remove the righest newline char 
     1043        $line = rtrim($newline); 
     1044      } 
     1045      else { 
     1046        $line = wordwrap($line, $max); 
     1047      } 
     1048    } 
     1049 
     1050    // Append the line 
     1051    $out .= $line . "\n"; 
     1052  } 
     1053   
     1054  return $out; 
     1055} 
     1056 
     1057 
    10161058function rcmail_message_part_controls() 
    10171059  { 
Note: See TracChangeset for help on using the changeset viewer.