mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-25 17:33:49 +01:00
replace original message header with fieldset in html and convert it to plain as before
This commit is contained in:
parent
5791ef0117
commit
c4e0989bf9
@ -273,7 +273,7 @@ class Html
|
||||
chr(161),
|
||||
chr(162),
|
||||
chr(163),
|
||||
'(C)',//chr(169),// copyrighgt
|
||||
'(C)',//chr(169),// copyright
|
||||
'(R)',//chr(174),// registered
|
||||
'(TM)',// trade
|
||||
"'",
|
||||
@ -282,6 +282,16 @@ class Html
|
||||
);
|
||||
$_html = preg_replace($Rules, $Replace, $_html);
|
||||
|
||||
// replace fieldset with legend used for original message header
|
||||
$_html = preg_replace_callback('#<fieldset[^>]*>\s*<legend>(.*)</legend>\s*(.*)\s*</fieldset>#sm',
|
||||
static function($matches)
|
||||
{
|
||||
$len_legend = strlen($legend = $matches[1]);
|
||||
$content = preg_replace('/<([^@> ]+@[^> ]+)>/', '#lower#than#$1#greater#than#', $matches[2]);
|
||||
return "<br>".str_repeat('-', (64-$len_legend-2)>>1).' '.$legend.' '.str_repeat('-', (64-$len_legend-2+1)>>1)."<br>".
|
||||
$content.str_repeat('-', 64)."<br>";
|
||||
}, $_html);
|
||||
|
||||
// removing carriage return linefeeds, preserve those enclosed in <pre> </pre> tags
|
||||
if ($stripcrl === true )
|
||||
{
|
||||
@ -584,4 +594,4 @@ class Html
|
||||
//error_log(__METHOD__.__LINE__.array2string($html2ret));
|
||||
return $html2ret;
|
||||
}
|
||||
}
|
||||
}
|
@ -2261,7 +2261,7 @@ class mail_compose
|
||||
//_debug_array($bodyParts);
|
||||
$styles = Mail::getStyles($bodyParts);
|
||||
|
||||
$fromAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$headers['FROM']));
|
||||
$fromAddress = implode(', ', $headers['FROM']);
|
||||
|
||||
$toAddressA = array();
|
||||
$toAddress = '';
|
||||
@ -2270,8 +2270,8 @@ class mail_compose
|
||||
}
|
||||
if (count($toAddressA)>0)
|
||||
{
|
||||
$toAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$toAddressA));
|
||||
$toAddress = @htmlspecialchars(lang("to")).": ".$toAddress.($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n");
|
||||
$toAddress = implode(', ', $toAddressA);
|
||||
$toAddress = htmlspecialchars(lang("to").": ".$toAddress).($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n");
|
||||
}
|
||||
$ccAddressA = array();
|
||||
$ccAddress = '';
|
||||
@ -2280,15 +2280,18 @@ class mail_compose
|
||||
}
|
||||
if (count($ccAddressA)>0)
|
||||
{
|
||||
$ccAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$ccAddressA));
|
||||
$ccAddress = @htmlspecialchars(lang("cc")).": ".$ccAddress.($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n");
|
||||
$ccAddress = implode(', ', $ccAddressA);
|
||||
$ccAddress = htmlspecialchars(lang("cc").": ".$ccAddress).($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n");
|
||||
}
|
||||
if($bodyParts['0']['mimeType'] == 'text/html') {
|
||||
$this->sessionData['body'] = "<br>"."<div>".'----------------'.lang("original message").'-----------------'."".'<br>'.
|
||||
@htmlspecialchars(lang("from")).": ".$fromAddress."<br>".
|
||||
$toAddress.$ccAddress.
|
||||
@htmlspecialchars(lang("date").": ".Mail::_strtotime($headers['DATE'],'r',true),ENT_QUOTES | ENT_IGNORE,Mail::$displayCharset, false)."<br>".
|
||||
'----------------------------------------------------------'."</div>";
|
||||
// create original message header in users preferred font and -size
|
||||
$this->sessionData['body'] = self::wrapBlockWithPreferredFont(
|
||||
htmlspecialchars(lang("from").": ".$fromAddress)."<br>".
|
||||
$toAddress.$ccAddress.
|
||||
htmlspecialchars(lang("date").": ".Mail::_strtotime($headers['DATE'],'r',true),ENT_QUOTES | ENT_IGNORE, Mail::$displayCharset, false),
|
||||
lang("original message"), 'originalMessage');
|
||||
|
||||
if($bodyParts['0']['mimeType'] == 'text/html')
|
||||
{
|
||||
$this->sessionData['mimeType'] = 'html';
|
||||
if (!empty($styles)) $this->sessionData['body'] .= $styles;
|
||||
$this->sessionData['body'] .= '<blockquote type="cite">';
|
||||
@ -2314,14 +2317,12 @@ class mail_compose
|
||||
|
||||
$this->sessionData['body'] .= '</blockquote><br>';
|
||||
$this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'html');
|
||||
} else {
|
||||
//$this->sessionData['body'] = @htmlspecialchars(lang("on")." ".$headers['DATE']." ".$mail_bo->decode_header($fromAddress), ENT_QUOTES) . " ".lang("wrote").":\r\n";
|
||||
// take care the way the ReplyHeader is created here, is used later on in uicompose::compose, in case you force replys to be HTML (prefs)
|
||||
$this->sessionData['body'] = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n".
|
||||
@htmlspecialchars(lang("from")).": ".$fromAddress."\r\n".
|
||||
$toAddress.$ccAddress.
|
||||
@htmlspecialchars(lang("date").": ".Mail::_strtotime($headers['DATE'],'r',true), ENT_QUOTES | ENT_IGNORE,Mail::$displayCharset, false)."\r\n".
|
||||
'-------------------------------------------------'."\r\n \r\n ";
|
||||
}
|
||||
else
|
||||
{
|
||||
// convert original message header to plain-text
|
||||
$this->sessionData['body'] = self::convertHTMLToText($this->sessionData['body'], true, false, true);
|
||||
|
||||
$this->sessionData['mimeType'] = 'plain';
|
||||
foreach($bodyParts as $i => &$bodyPart)
|
||||
{
|
||||
@ -2368,11 +2369,30 @@ class mail_compose
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap html block in given tag with preferred font and -size set
|
||||
*
|
||||
* @param string $content
|
||||
* @param string $legend
|
||||
* @param ?string $class
|
||||
* @return string
|
||||
*/
|
||||
static function wrapBlockWithPreferredFont($content, $legend, $class=null)
|
||||
{
|
||||
$options = ' style="border: 2px solid silver; border-left: none; border-right: none;'.
|
||||
'font-family: '.($GLOBALS['egw_info']['user']['preferences']['common']['rtf_font'] ?? 'arial, helvetica, sans-serif').
|
||||
'; font-size: '.($GLOBALS['egw_info']['user']['preferences']['common']['rtf_size'] ?? '10').'pt"';
|
||||
|
||||
if (!empty($class)) $options .= ' class="'.htmlspecialchars($class).'"';
|
||||
|
||||
return Api\Html::fieldset($content, $legend, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* HTML cleanup
|
||||
*
|
||||
* @param type $_body message
|
||||
* @param type $_useTidy = false, if true tidy extention will be loaded and tidy will try to clean body message
|
||||
* @param type $_useTidy = false, if true tidy extension will be loaded and tidy will try to clean body message
|
||||
* since the tidy causes segmentation fault ATM, we set the default to false.
|
||||
* @return type
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user