Changeset 868deb5 in github


Ignore:
Timestamp:
Oct 6, 2010 1:15:38 PM (3 years ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
7f89041
Parents:
ace511a
Message:
  • Make htmleditor option behaviour consistent, add option to use HTML on reply to HTML message (#1485840)
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • CHANGELOG

    race511a r868deb5  
    2020- Improve tabs to fixed width and add tabs in identities info (#1486974) 
    2121- Add unique index on users.username+users.mail_host 
     22- Make htmleditor option more consistent and add option to use HTML on reply to HTML message (#1485840) 
    2223 
    2324RELEASE 0.4.2 
  • config/main.inc.php.dist

    r6c6bb09 r868deb5  
    480480 
    481481// compose html formatted messages by default 
    482 $rcmail_config['htmleditor'] = false; 
     482// 0 - never, 1 - always, 2 - on reply to HTML message only  
     483$rcmail_config['htmleditor'] = 0; 
    483484 
    484485// show pretty dates as standard 
  • installer/config.php

    r6c6bb09 r868deb5  
    1515  'prefer_html' => 1, 
    1616  'preview_pane' => 1, 
    17   'htmleditor' => 1, 
    1817  'debug_level' => 1, 
    1918); 
     
    544543<dt class="propname">htmleditor <span class="userconf">*</span></dt> 
    545544<dd> 
    546 <?php 
    547  
    548 $check_htmlcomp = new html_checkbox(array('name' => '_htmleditor', 'id' => "cfghtmlcompose", 'value' => 1)); 
    549 echo $check_htmlcomp->show(intval($RCI->getprop('htmleditor'))); 
    550  
    551 ?> 
    552 <label for="cfghtmlcompose">Compose HTML formatted messages</label><br /> 
     545<label for="cfghtmlcompose">Compose HTML formatted messages</label> 
     546<?php 
     547 
     548$select_htmlcomp = new html_select(array('name' => '_htmleditor', 'id' => "cfghtmlcompose")); 
     549$select_htmlcomp->add('never', 0); 
     550$select_htmlcomp->add('always', 1); 
     551$select_htmlcomp->add('on reply to HTML message only', 2); 
     552echo $select_htmlcomp->show(intval($RCI->getprop('htmleditor'))); 
     553 
     554?> 
    553555</dd> 
    554556 
  • program/include/rcube_message.php

    r103ddcde r868deb5  
    215215     * Return the first text part of this message 
    216216     * 
     217     * @param rcube_message_part $part Reference to the part if found 
    217218     * @return string Plain text message/part content 
    218219     */ 
    219     function first_text_part() 
     220    function first_text_part(&$part=null) 
    220221    { 
    221222        // no message structure, return complete body 
     
    223224            return $this->body; 
    224225 
    225         $out = null; 
    226  
    227226        // check all message parts 
    228227        foreach ($this->mime_parts as $mime_id => $part) { 
     
    230229 
    231230            if ($mimetype == 'text/plain') { 
    232                 $out = $this->imap->get_message_part($this->uid, $mime_id, $part); 
    233  
    234                 // re-format format=flowed content 
    235                 if ($part->ctype_secondary == 'plain' && $part->ctype_parameters['format'] == 'flowed') 
    236                     $out = self::unfold_flowed($out); 
    237                 break; 
     231                return $this->imap->get_message_part($this->uid, $mime_id, $part); 
    238232            } 
    239233            else if ($mimetype == 'text/html') { 
     
    246240                // create instance of html2text class 
    247241                $txt = new html2text($out); 
    248                 $out = $txt->get_text(); 
    249             } 
    250         } 
    251  
    252         return $out; 
     242                return $txt->get_text(); 
     243            } 
     244        } 
     245 
     246        $part = null; 
     247        return null; 
    253248    } 
    254249 
  • program/steps/mail/compose.inc

    re25a357 r868deb5  
    359359  } 
    360360 
    361  
    362361  if ($fname && $field_type) 
    363362  { 
     
    492491 
    493492 
     493function rcmail_compose_editor_mode() 
     494{ 
     495  global $RCMAIL, $MESSAGE, $compose_mode; 
     496  static $useHtml; 
     497 
     498  if ($useHtml !== null) 
     499    return $useHtml; 
     500 
     501  $html_editor = intval($RCMAIL->config->get('htmleditor')); 
     502 
     503  if ($compose_mode == RCUBE_COMPOSE_DRAFT || $compose_mode == RCUBE_COMPOSE_EDIT) { 
     504    $useHtml = $MESSAGE->has_html_part(); 
     505  } 
     506  else if ($compose_mode == RCUBE_COMPOSE_REPLY) { 
     507    $useHtml = ($html_editor == 1 || ($html_editor == 2 && $MESSAGE->has_html_part())); 
     508  } 
     509  else { // RCUBE_COMPOSE_FORWARD or NEW 
     510    $useHtml = ($html_editor == 1); 
     511  } 
     512 
     513  return $useHtml; 
     514} 
     515 
     516 
    494517function rcmail_prepare_message_body() 
    495518{ 
    496   global $RCMAIL, $CONFIG, $MESSAGE, $compose_mode, $LINE_LENGTH, $HTML_MODE; 
    497  
    498   if ($CONFIG['htmleditor'] || (($compose_mode == RCUBE_COMPOSE_DRAFT || $compose_mode == RCUBE_COMPOSE_EDIT) && $MESSAGE->has_html_part())) 
    499     $isHtml = true; 
    500   else 
    501     $isHtml = false; 
    502  
    503   $body = ''; 
     519  global $RCMAIL, $MESSAGE, $compose_mode, $LINE_LENGTH, $HTML_MODE; 
    504520 
    505521  // use posted message body 
    506   if (!empty($_POST['_message'])) 
    507   { 
     522  if (!empty($_POST['_message'])) { 
    508523    $body = get_input_value('_message', RCUBE_INPUT_POST, true); 
    509   } 
    510   else if ($_SESSION['compose']['param']['body']) 
    511   { 
     524    $isHtml = (bool) get_input_value('_is_html', RCUBE_INPUT_POST); 
     525  } 
     526  else if ($_SESSION['compose']['param']['body']) { 
    512527    $body = $_SESSION['compose']['param']['body']; 
    513528    $isHtml = false; 
    514529  } 
    515   else if ($compose_mode) 
    516   { 
     530  // reply/edit/draft/forward 
     531  else if ($compose_mode) { 
    517532    $has_html_part = $MESSAGE->has_html_part(); 
    518     if (($isHtml || $compose_mode == RCUBE_COMPOSE_DRAFT) && $has_html_part) 
    519     { 
    520       $body = $MESSAGE->first_html_part(); 
    521       $isHtml = true; 
    522     } 
    523     else if ($has_html_part) 
    524     { 
    525       // use html part if it has been used for message (pre)viewing 
    526       // decrease line length for quoting 
    527       $len = $compose_mode == RCUBE_COMPOSE_REPLY ? $LINE_LENGTH-2 : $LINE_LENGTH; 
    528       $txt = new html2text($MESSAGE->first_html_part(), false, true, $len); 
    529       $body = $txt->get_text(); 
    530       $isHtml = false; 
    531     } 
    532     else 
    533     { 
    534       $body = $MESSAGE->first_text_part(); 
    535       $isHtml = false; 
     533    $isHtml = rcmail_compose_editor_mode(); 
     534 
     535    if ($isHtml) { 
     536      if ($has_html_part) { 
     537        $body = $MESSAGE->first_html_part(); 
     538      } 
     539      else { 
     540        $body = rcmail_plain_body($MESSAGE->first_text_part()); 
     541        if ($body) 
     542          $body = '<pre>' . $body . '</pre>'; 
     543      } 
     544    } 
     545    else { 
     546      if ($has_html_part) { 
     547        // use html part if it has been used for message (pre)viewing 
     548        // decrease line length for quoting 
     549        $len = $compose_mode == RCUBE_COMPOSE_REPLY ? $LINE_LENGTH-2 : $LINE_LENGTH; 
     550        $txt = new html2text($MESSAGE->first_html_part(), false, true, $len); 
     551        $body = $txt->get_text(); 
     552      } 
     553      else { 
     554        $body = $MESSAGE->first_text_part($part); 
     555        if ($body && $part && $part->ctype_secondary == 'plain' 
     556            && $part->ctype_parameters['format'] == 'flowed' 
     557        ) { 
     558          $body = rcube_message::unfold_flowed($body); 
     559        } 
     560      } 
    536561    } 
    537562 
     
    545570    else if ($compose_mode == RCUBE_COMPOSE_DRAFT || $compose_mode == RCUBE_COMPOSE_EDIT) 
    546571      $body = rcmail_create_draft_body($body, $isHtml); 
     572  } 
     573  else { // new message 
     574    $isHtml = rcmail_compose_editor_mode(); 
    547575  } 
    548576 
     
    11521180 
    11531181  // determine whether HTML or plain text should be checked 
    1154   if ($compose_mode) 
    1155     $useHtml = (($CONFIG['htmleditor'] || $compose_mode == RCUBE_COMPOSE_DRAFT || $compose_mode == RCUBE_COMPOSE_EDIT) 
    1156         && $MESSAGE->has_html_part()); 
    1157   else 
    1158     $useHtml = $CONFIG['htmleditor'] ? true : false; 
     1182  $useHtml = rcmail_compose_editor_mode(); 
    11591183 
    11601184  if (empty($attrib['editorid'])) 
     
    11731197  return $select->show($useHtml ? 'html' : 'plain'); 
    11741198 
    1175   foreach ($choices as $value => $text) 
    1176   { 
     1199  foreach ($choices as $value => $text) { 
    11771200    $attrib['id'] = '_' . $value; 
    11781201    $attrib['value'] = $value; 
  • program/steps/settings/func.inc

    r6c6bb09 r868deb5  
    467467    if (!isset($no_override['htmleditor'])) { 
    468468      $field_id = 'rcmfd_htmleditor'; 
    469       $input_htmleditor = new html_checkbox(array('name' => '_htmleditor', 'id' => $field_id, 'value' => 1)); 
     469      $select_htmleditor = new html_select(array('name' => '_htmleditor', 'id' => $field_id)); 
     470      $select_htmleditor->add(rcube_label('never'), 0); 
     471      $select_htmleditor->add(rcube_label('always'), 1); 
     472      $select_htmleditor->add(rcube_label('htmlonreply'), 2); 
    470473 
    471474      $blocks['main']['options']['htmleditor'] = array( 
    472475        'title' => html::label($field_id, Q(rcube_label('htmleditor'))), 
    473         'content' => $input_htmleditor->show($config['htmleditor']?1:0), 
     476        'content' => $select_htmleditor->show(intval($config['htmleditor'])), 
    474477      ); 
    475478    } 
  • program/steps/settings/save_prefs.inc

    rb3660bb r868deb5  
    5959    ); 
    6060 
    61  
    6261  break; 
    6362  case 'compose': 
    6463    $a_user_prefs = array( 
    65       'htmleditor'         => isset($_POST['_htmleditor']) ? TRUE : FALSE, 
     64      'htmleditor'         => intval($_POST['_htmleditor']), 
    6665      'draft_autosave'     => isset($_POST['_draft_autosave']) ? intval($_POST['_draft_autosave']) : 0, 
    6766      'mime_param_folding' => isset($_POST['_mime_param_folding']) ? intval($_POST['_mime_param_folding']) : 0, 
Note: See TracChangeset for help on using the changeset viewer.