Ignore:
Timestamp:
Jul 30, 2010 12:58:27 PM (3 years ago)
Author:
alec
Message:
  • Fix bgcolor attribute of message body handling
File:
1 edited

Legend:

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

    r3840 r3845  
    987987        $body = rcmail_print_body($part, array('safe' => $safe_mode, 'plain' => !$CONFIG['prefer_html'])); 
    988988 
    989         if ($part->ctype_secondary == 'html') 
    990           $out .= html::div('message-htmlpart', rcmail_html4inline($body, $attrib['id'], 'div.rcmBody')); 
     989        if ($part->ctype_secondary == 'html') { 
     990          $body = rcmail_html4inline($body, $attrib['id'], 'rcmBody', $color); 
     991          $div_attr = array('class' => 'message-htmlpart'); 
     992          if ($color) 
     993            $div_attr['style'] = 'background-color: '.$color; 
     994 
     995          $out .= html::div($div_attr, $body); 
     996        } 
    991997        else 
    992998          $out .= html::div('message-part', $body); 
     
    10471053 * modify a HTML message that it can be displayed inside a HTML page 
    10481054 */ 
    1049 function rcmail_html4inline($body, $container_id, $body_id='') 
     1055function rcmail_html4inline($body, $container_id, $body_id='', &$body_color='') 
    10501056  { 
    10511057  $last_style_pos = 0; 
     
    10581064 
    10591065    // replace all css definitions with #container [def] 
    1060     $styles = rcmail_mod_css_styles(substr($body, $pos, $pos2-$pos), $container_id.($body_id ? ' '.$body_id : '')); 
     1066    $styles = rcmail_mod_css_styles(substr($body, $pos, $pos2-$pos), 
     1067      $container_id.($body_id ? ' div.'.$body_id : '')); 
    10611068 
    10621069    $body = substr($body, 0, $pos) . $styles . substr($body, $pos2); 
     
    10941101      '<?', 
    10951102      '?>', 
    1096       '<div class="rcmBody"\\1>', 
     1103      '<div class="'.$body_id.'"\\1>', 
    10971104      '</div>', 
    10981105      ), 
    10991106    $body); 
    11001107 
     1108  // Get rcmBody's bgcolor attribute, we'll set the color to the body container 
     1109  // as background-color, bgcolor doesn't work with a div 
     1110  if (preg_match('/<div class="' . preg_quote($body_id, '/') . '" ([^>]+)>/', $out, $m)) { 
     1111    if (preg_match('/bgcolor=["\']*([a-z0-9#]+)["\']*/', $m[0], $mb)) { 
     1112      $body_color = $mb[1]; 
     1113    } 
     1114  } 
    11011115  // make sure there's 'rcmBody' div, we need it for proper css modification 
    11021116  // its name is hardcoded in rcmail_message_body() also 
    1103   if (!preg_match('/<div class="rcmBody"/', $out)) 
    1104     $out = '<div class="rcmBody">' . $out . '</div>'; 
     1117  else 
     1118    $out = '<div class="' . $body_id . '">' . $out . '</div>'; 
    11051119 
    11061120  return $out; 
Note: See TracChangeset for help on using the changeset viewer.