Ignore:
Timestamp:
Mar 24, 2010 6:06:23 AM (3 years ago)
Author:
alec
Message:
  • improvements in rcmail_html4inline()
File:
1 edited

Legend:

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

    r3410 r3412  
    939939 
    940940        if ($part->ctype_secondary == 'html') 
    941           $out .= html::div('message-htmlpart', rcmail_html4inline($body, $attrib['id'] . ' div.rcmBody')); 
     941          $out .= html::div('message-htmlpart', rcmail_html4inline($body, $attrib['id'], 'div.rcmBody')); 
    942942        else 
    943943          $out .= html::div('message-part', $body); 
     
    998998 * modify a HTML message that it can be displayed inside a HTML page 
    999999 */ 
    1000 function rcmail_html4inline($body, $container_id) 
     1000function rcmail_html4inline($body, $container_id, $body_id='') 
    10011001  { 
    10021002  $last_style_pos = 0; 
     
    10091009 
    10101010    // replace all css definitions with #container [def] 
    1011     $styles = rcmail_mod_css_styles(substr($body, $pos, $pos2-$pos), $container_id); 
     1011    $styles = rcmail_mod_css_styles(substr($body, $pos, $pos2-$pos), $container_id.($body_id ? ' '.$body_id : '')); 
    10121012 
    10131013    $body = substr($body, 0, $pos) . $styles . substr($body, $pos2); 
     
    10211021  unset($GLOBALS['rcmail_html_container_id']); 
    10221022 
    1023   // add comments arround html and other tags 
    10241023  $out = preg_replace(array( 
     1024      // add comments arround html and other tags 
    10251025      '/(<!DOCTYPE[^>]*>)/i', 
    10261026      '/(<\?xml[^>]*>)/i', 
     
    10281028      '/(<\/?head[^>]*>)/i', 
    10291029      '/(<title[^>]*>.*<\/title>)/Ui', 
    1030       '/(<\/?meta[^>]*>)/i'), 
    1031     '<!--\\1-->', 
     1030      '/(<\/?meta[^>]*>)/i', 
     1031      // quote <? of php and xml files that are specified as text/html 
     1032      '/<\?/', 
     1033      '/\?>/', 
     1034      // replace <body> with <div> 
     1035      '/<body([^>]*)>/i', 
     1036      '/<\/body>/i', 
     1037      ), 
     1038    array( 
     1039      '<!--\\1-->', 
     1040      '<!--\\1-->', 
     1041      '<!--\\1-->', 
     1042      '<!--\\1-->', 
     1043      '<!--\\1-->', 
     1044      '<!--\\1-->', 
     1045      '&lt;?', 
     1046      '?&gt;', 
     1047      '<div class="rcmBody"\\1>', 
     1048      '</div>', 
     1049      ), 
    10321050    $body); 
    10331051 
    1034   $out = preg_replace( 
    1035     array('/<body([^>]*)>/i', '/<\/body>/i'), 
    1036     array('<div class="rcmBody"\\1>', '</div>'), 
    1037     $out); 
    1038  
     1052  // make sure there's 'rcmBody' div, we need it for proper css modification 
     1053  // its name is hardcoded in rcmail_message_body() also 
    10391054  if (!preg_match('/<div class="rcmBody"/', $out)) 
    10401055    $out = '<div class="rcmBody">' . $out . '</div>'; 
    1041  
    1042   // quote <? of php and xml files that are specified as text/html 
    1043   $out = preg_replace(array('/<\?/', '/\?>/'), array('&lt;?', '?&gt;'), $out); 
    10441056 
    10451057  return $out; 
Note: See TracChangeset for help on using the changeset viewer.