Changeset 3859 in subversion


Ignore:
Timestamp:
Aug 3, 2010 7:46:13 AM (3 years ago)
Author:
alec
Message:
  • Improve displaying of html messages with body's background image
File:
1 edited

Legend:

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

    r3845 r3859  
    988988 
    989989        if ($part->ctype_secondary == 'html') { 
    990           $body = rcmail_html4inline($body, $attrib['id'], 'rcmBody', $color); 
     990          $body = rcmail_html4inline($body, $attrib['id'], 'rcmBody', $attrs); 
    991991          $div_attr = array('class' => 'message-htmlpart'); 
    992           if ($color) 
    993             $div_attr['style'] = 'background-color: '.$color; 
     992          $style = array(); 
     993 
     994          if (!empty($attrs['color'])) 
     995            $style[] = 'background-color: '.$attrs['color']; 
     996          if (!empty($attrs['image'])) 
     997            $style[] = 'background-image: url('.$attrs['image'].')'; 
     998          if (!empty($style)) 
     999            $div_attr['style'] = implode('; ', $style); 
    9941000 
    9951001          $out .= html::div($div_attr, $body); 
     
    10531059 * modify a HTML message that it can be displayed inside a HTML page 
    10541060 */ 
    1055 function rcmail_html4inline($body, $container_id, $body_id='', &$body_color='') 
     1061function rcmail_html4inline($body, $container_id, $body_id='', &$attributes=null) 
    10561062  { 
    10571063  $last_style_pos = 0; 
     
    11061112    $body); 
    11071113 
    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  $attributes = array(); 
     1115 
     1116  // Handle body attributes that doesn't play nicely with div elements 
     1117  if (preg_match('/<div class="' . preg_quote($body_id, '/') . '" ([^>]+)/', $out, $m)) { 
     1118    $attrs = $m[0]; 
     1119    // Get bgcolor, we'll set it as background-color of the message container 
     1120    if (preg_match('/bgcolor=["\']*([a-z0-9#]+)["\']*/', $attrs, $mb)) { 
     1121      $attributes['color'] = $mb[1]; 
     1122      $attrs = preg_replace('/bgcolor=["\']*([a-z0-9#]+)["\']*/', '', $attrs); 
     1123    } 
     1124    // Get background, we'll set it as background-image of the message container 
     1125    if (preg_match('/background=["\']*([^"\'>\s]+)["\']*/', $attrs, $mb)) { 
     1126      $attributes['image'] = $mb[1]; 
     1127      $attrs = preg_replace('/background=["\']*([^"\'>\s]+)["\']*/', '', $attrs); 
     1128    } 
     1129    if (!empty($attributes)) 
     1130      $out = preg_replace('/<div class="' . preg_quote($body_id, '/') . '" [^>]+/', rtrim($attrs), $out, 1); 
    11141131  } 
    11151132  // make sure there's 'rcmBody' div, we need it for proper css modification 
Note: See TracChangeset for help on using the changeset viewer.