Add option to not indent quoted text on top-posting reply (#5105)

by setting reply_mode = 2
pull/5589/merge
Aleksander Machniak 7 years ago
parent 6ad4ebe431
commit fe2f553688

@ -1,6 +1,7 @@
CHANGELOG Roundcube Webmail
===========================
- Add option to not indent quoted text on top-posting reply (#5105)
- Removed global $CONFIG variable
- Password: Automatic virtualmin domain setting, removed password_virtualmin_format option (#5759)
- Support AUTHENTICATE LOGIN for IMAP connections (#5563)

@ -1150,6 +1150,7 @@ $config['autoexpand_threads'] = 0;
// -1 - don't cite the original message
// 0 - place cursor below the original message
// 1 - place cursor above original message (top posting)
// 2 - place cursor above original message (top posting), but do not indent the quote
$config['reply_mode'] = 0;
// When replying strip original signature from message

@ -530,6 +530,7 @@ $labels['signatureoptions'] = 'Signature Options';
$labels['whenreplying'] = 'When replying';
$labels['replyempty'] = 'do not quote the original message';
$labels['replytopposting'] = 'start new message above the quote';
$labels['replytoppostingnoindent'] = 'start new message above the quote (no indentation)';
$labels['replybottomposting'] = 'start new message below the quote';
$labels['replyremovesignature'] = 'When replying remove original signature from message';
$labels['autoaddsignature'] = 'Automatically add signature';

@ -1039,14 +1039,26 @@ function rcmail_create_reply_body($body, $bodyIsHtml)
{
global $RCMAIL, $MESSAGE, $LINE_LENGTH;
$prefix = rcmail_get_reply_header($MESSAGE);
$reply_mode = intval($RCMAIL->config->get('reply_mode'));
$reply_mode = (int) $RCMAIL->config->get('reply_mode');
$reply_indent = $reply_mode != 2;
// In top-posting without quoting it's better to use multi-line header
if ($reply_mode == 2) {
$prefix = rcmail_get_forward_header($MESSAGE, $bodyIsHtml, false);
}
else {
$prefix = rcmail_get_reply_header($MESSAGE);
if ($bodyIsHtml) {
$prefix = '<p>' . rcube::Q($prefix) . '</p>';
}
else {
$prefix .= "\n";
}
}
if (!$bodyIsHtml) {
// soft-wrap and quote message text
$body = rcmail_wrap_and_quote($body, $LINE_LENGTH);
$prefix .= "\n";
$body = rcmail_wrap_and_quote($body, $LINE_LENGTH, $reply_indent);
if ($reply_mode > 0) { // top-posting
$prefix = "\n\n\n" . $prefix;
@ -1064,16 +1076,22 @@ function rcmail_create_reply_body($body, $bodyIsHtml)
// clean up html tags
$body = rcmail_wash_html($body, array('safe' => $MESSAGE->is_safe), $cid_map);
// build reply (quote content)
$prefix = '<p>' . rcube::Q($prefix) . "</p>\n";
$prefix .= '<blockquote>';
$suffix = '';
if ($reply_mode > 0) { // top-posting
if ($reply_indent) {
$prefix .= '<blockquote>';
$suffix .= '</blockquote>';
}
if ($reply_mode == 2) {
// top-posting, no indent
}
else if ($reply_mode > 0) {
// top-posting
$prefix = '<br>' . $prefix;
$suffix = '</blockquote>';
}
else {
$suffix = '</blockquote><p><br/></p>';
$suffix .= '<p><br/></p>';
}
}
@ -1103,32 +1121,44 @@ function rcmail_create_forward_body($body, $bodyIsHtml)
$cid_map = rcmail_write_compose_attachments($MESSAGE, $bodyIsHtml);
}
$date = $RCMAIL->format_date($MESSAGE->headers->date, $RCMAIL->config->get('date_long'));
if (!$bodyIsHtml) {
$body = trim($body, "\r\n");
}
else {
// set is_safe flag (we need this for html body washing)
rcmail_check_safe($MESSAGE);
// clean up html tags
$body = rcmail_wash_html($body, array('safe' => $MESSAGE->is_safe), $cid_map);
}
return rcmail_get_forward_header($MESSAGE, $bodyIsHtml) . $body;
}
function rcmail_get_forward_header($message, $bodyIsHtml = false, $extended = true)
{
global $RCMAIL;
$date = $RCMAIL->format_date($message->headers->date, $RCMAIL->config->get('date_long'));
if (!$bodyIsHtml) {
$prefix = "\n\n\n-------- " . $RCMAIL->gettext('originalmessage') . " --------\n";
$prefix .= $RCMAIL->gettext('subject') . ': ' . $MESSAGE->subject . "\n";
$prefix .= $RCMAIL->gettext('subject') . ': ' . $message->subject . "\n";
$prefix .= $RCMAIL->gettext('date') . ': ' . $date . "\n";
$prefix .= $RCMAIL->gettext('from') . ': ' . $MESSAGE->get_header('from') . "\n";
$prefix .= $RCMAIL->gettext('to') . ': ' . $MESSAGE->get_header('to') . "\n";
$prefix .= $RCMAIL->gettext('from') . ': ' . $message->get_header('from') . "\n";
$prefix .= $RCMAIL->gettext('to') . ': ' . $message->get_header('to') . "\n";
if ($cc = $MESSAGE->headers->get('cc')) {
if ($extended && ($cc = $message->headers->get('cc'))) {
$prefix .= $RCMAIL->gettext('cc') . ': ' . $cc . "\n";
}
if (($replyto = $MESSAGE->headers->get('reply-to')) && $replyto != $MESSAGE->get_header('from')) {
if ($extended && ($replyto = $message->headers->get('reply-to')) && $replyto != $message->get_header('from')) {
$prefix .= $RCMAIL->gettext('replyto') . ': ' . $replyto . "\n";
}
$prefix .= "\n";
$body = trim($body, "\r\n");
}
else {
// set is_safe flag (we need this for html body washing)
rcmail_check_safe($MESSAGE);
// clean up html tags
$body = rcmail_wash_html($body, array('safe' => $MESSAGE->is_safe), $cid_map);
$prefix = sprintf(
"<br /><p>-------- " . $RCMAIL->gettext('originalmessage') . " --------</p>" .
"<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tbody>" .
@ -1136,26 +1166,27 @@ function rcmail_create_forward_body($body, $bodyIsHtml)
"<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">%s: </th><td>%s</td></tr>" .
"<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">%s: </th><td>%s</td></tr>" .
"<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">%s: </th><td>%s</td></tr>",
$RCMAIL->gettext('subject'), rcube::Q($MESSAGE->subject),
$RCMAIL->gettext('subject'), rcube::Q($message->subject),
$RCMAIL->gettext('date'), rcube::Q($date),
$RCMAIL->gettext('from'), rcube::Q($MESSAGE->get_header('from'), 'replace'),
$RCMAIL->gettext('to'), rcube::Q($MESSAGE->get_header('to'), 'replace'));
$RCMAIL->gettext('from'), rcube::Q($message->get_header('from'), 'replace'),
$RCMAIL->gettext('to'), rcube::Q($message->get_header('to'), 'replace'));
if ($cc = $MESSAGE->headers->get('cc'))
if ($extended && ($cc = $message->headers->get('cc'))) {
$prefix .= sprintf("<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">%s: </th><td>%s</td></tr>",
$RCMAIL->gettext('cc'), rcube::Q($cc, 'replace'));
}
if (($replyto = $MESSAGE->headers->get('reply-to')) && $replyto != $MESSAGE->get_header('from'))
if ($extended && ($replyto = $message->headers->get('reply-to')) && $replyto != $message->get_header('from')) {
$prefix .= sprintf("<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">%s: </th><td>%s</td></tr>",
$RCMAIL->gettext('replyto'), rcube::Q($replyto, 'replace'));
}
$prefix .= "</tbody></table><br>";
}
return $prefix . $body;
return $prefix;
}
function rcmail_create_draft_body($body, $bodyIsHtml)
{
global $MESSAGE, $COMPOSE;

@ -1774,9 +1774,10 @@ function rcmail_address_string($input, $max=null, $linked=false, $addicon=null,
*
* @param string Text to wrap
* @param int The line width
* @param bool Enable quote indentation
* @return string The wrapped text
*/
function rcmail_wrap_and_quote($text, $length = 72)
function rcmail_wrap_and_quote($text, $length = 72, $quote = true)
{
// Rebuild the message body with a maximum of $max chars, while keeping quoted message.
$max = max(75, $length + 8);
@ -1786,18 +1787,28 @@ function rcmail_wrap_and_quote($text, $length = 72)
foreach ($lines as $line) {
// don't wrap already quoted lines
if ($line[0] == '>') {
$line = '>' . rtrim($line);
$line = rtrim($line);
if ($quote) {
$line = '>' . $line;
}
}
else if (mb_strlen($line) > $max) {
// wrap lines above the length limit, but skip these
// special lines with links list created by rcube_html2text
else if (mb_strlen($line) > $max && !preg_match('|^\[[0-9]+\] https?://\S+$|', $line)) {
$newline = '';
foreach (explode("\n", rcube_mime::wordwrap($line, $length - 2)) as $l) {
$newline .= strlen($l) ? "> $l\n" : ">\n";
if ($quote) {
$newline .= strlen($l) ? "> $l\n" : ">\n";
}
else {
$newline .= "$l\n";
}
}
$line = rtrim($newline);
}
else {
else if ($quote) {
$line = '> ' . $line;
}

@ -773,6 +773,7 @@ function rcmail_user_prefs($current = null)
$select->add($RCMAIL->gettext('replyempty'), -1);
$select->add($RCMAIL->gettext('replybottomposting'), 0);
$select->add($RCMAIL->gettext('replytopposting'), 1);
$select->add($RCMAIL->gettext('replytoppostingnoindent'), 2);
$blocks['main']['options']['reply_mode'] = array(
'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('whenreplying'))),

Loading…
Cancel
Save