Author Topic: Making HTML the Default Reply Editor  (Read 3920 times)

Offline NosferatusCoffin

  • Newbie
  • *
  • Posts: 1
Making HTML the Default Reply Editor
« on: June 16, 2008, 10:17:44 PM »
Hello,

I am working on a rather perplexing issue.

I cannot seem to set HTML to be the default editor when replying to an email. When composing a message, the HTML editor kicks in just fine. This is only an issue when replying to or forwarding a message.

This fix should reside in the portion of code in /programs/steps/mail/compose.inc

Quote
function rcmail_editor_selector($attrib)
{
  global $CONFIG, $MESSAGE, $compose_mode;

  $choices = array(
    'html'  => 'htmltoggle',
    'plain' => 'plaintoggle'
  );

  // determine whether HTML or plain text should be checked
  if ($CONFIG['htmleditor'])
    $useHtml = true;
  else
    $useHtml = false;

  if ($compose_mode == RCUBE_COMPOSE_REPLY ||
      $compose_mode == RCUBE_COMPOSE_FORWARD ||
      $compose_mode == RCUBE_COMPOSE_DRAFT)
  {
    $hasHtml = rcmail_has_html_part($MESSAGE['parts']);
    $useHtml = ($hasHtml && $CONFIG['htmleditor']);
  }

  $selector = '';
 
  $attrib['name'] = '_editorSelect';
  $attrib['onchange'] = 'return rcmail_toggle_editor(this)';
  foreach ($choices as $value => $text)
  {
    $checked = '';
    if ((($value == 'html') && $useHtml) ||
        (($value != 'html') && !$useHtml))
      $attrib['checked'] = 'true';
    else
      unset($attrib['checked']);

    $attrib['id'] = '_' . $value;
    $rb = new radiobutton($attrib);
    $selector .= sprintf("%s",
                         $rb->show($value),
                         $attrib['id'],
                         rcube_label($text));
  }

  return $selector;
}

I have tried to toggle the values to switch the "checked" value from Plain Text (the default) to HTML with no luck, since this is the function which generates the "checked" value for those radio buttons. Frankly, I am stumped at this point any help would be appreciated.

BTW, in the main config file, editing is set for HTML:

// prefer displaying HTML messages
$rcmail_config['prefer_html'] = TRUE;

// compose html formatted messages by default
$rcmail_config['htmleditor'] = TRUE;

I am using RC Version: 0.1.1

Thanks.

Offline allisterf

  • Newbie
  • *
  • Posts: 1
Making HTML the Default Reply Editor
« Reply #1 on: July 24, 2008, 04:23:16 AM »
Well, I followed your trail on this as I also was looking to find a way to kickstart the html editor as default. I found the folowing in the compose.inc file:
// compose reply-body
  else if ($compose_mode == RCUBE_COMPOSE_REPLY)
    {
    $hasHtml = rcmail_has_html_part($MESSAGE['parts']);
    if ($hasHtml && $CONFIG['htmleditor'])
      {
      $body = rcmail_first_html_part($MESSAGE);
      $isHtml = true;
      }
    else
      {
      $body = rcmail_first_text_part($MESSAGE);
      $isHtml = true;
      }

    $body = rcmail_create_reply_body($body, $isHtml);
    }

As above, I set both states of $isHtml to = true (the second was originally set to =false).
So  it seemed to work - at least at first few attempts.
However - I am doing this with little real understanding of how this really works!

If you understand it, can you let me know.  :)
allister


Quote from: NosferatusCoffin;12604
Hello,

I am working on a rather perplexing issue.

I cannot seem to set HTML to be the default editor when replying to an email. When composing a message, the HTML editor kicks in just fine. This is only an issue when replying to or forwarding a message.

This fix should reside in the portion of code in /programs/steps/mail/compose.inc



I have tried to toggle the values to switch the "checked" value from Plain Text (the default) to HTML with no luck, since this is the function which generates the "checked" value for those radio buttons. Frankly, I am stumped at this point any help would be appreciated.

BTW, in the main config file, editing is set for HTML:

// prefer displaying HTML messages
$rcmail_config['prefer_html'] = TRUE;

// compose html formatted messages by default
$rcmail_config['htmleditor'] = TRUE;

I am using RC Version: 0.1.1

Thanks.