mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-02-22 13:53:14 +08:00
Fix Email rendering issue (#1233)
This commit is contained in:
parent
d79fe8757e
commit
aecb0b2500
1 changed files with 52 additions and 2 deletions
|
@ -75,7 +75,7 @@ class HtmlUtils
|
|||
@$oDom->loadHTML('<'.'?xml version="1.0" encoding="utf-8"?'.'>'.
|
||||
'<html '.$sHtmlAttrs.'><head>'.
|
||||
'<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>'.
|
||||
'<body '.$sBodyAttrs.'><div data-wrp="rainloop">'.\MailSo\Base\Utils::Utf8Clear($sText).'</div></body></html>');
|
||||
'<body '.$sBodyAttrs.'>'.\MailSo\Base\Utils::Utf8Clear($sText).'</body></html>');
|
||||
|
||||
@$oDom->normalizeDocument();
|
||||
|
||||
|
@ -156,7 +156,7 @@ class HtmlUtils
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function GetTextFromDom($oDom, $bWrapByFakeHtmlAndBodyDiv = true)
|
||||
public static function GetTextFromDom_($oDom, $bWrapByFakeHtmlAndBodyDiv = true)
|
||||
{
|
||||
$sResult = '';
|
||||
|
||||
|
@ -209,6 +209,56 @@ class HtmlUtils
|
|||
return $sResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DOMDocument $oDom
|
||||
* @param bool $bWrapByFakeHtmlAndBodyDiv = true
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function GetTextFromDom($oDom, $bWrapByFakeHtmlAndBodyDiv = true)
|
||||
{
|
||||
$sResult = '';
|
||||
|
||||
$oHtml = $oDom->getElementsByTagName('html')->item(0);
|
||||
$oBody = $oDom->getElementsByTagName('body')->item(0);
|
||||
|
||||
foreach ($oBody->childNodes as $oChild)
|
||||
{
|
||||
$sResult .= $oDom->saveHTML($oChild);
|
||||
}
|
||||
|
||||
if ($bWrapByFakeHtmlAndBodyDiv)
|
||||
{
|
||||
$aHtmlAttrs = \MailSo\Base\HtmlUtils::GetElementAttributesAsArray($oHtml);
|
||||
$aBodylAttrs = \MailSo\Base\HtmlUtils::GetElementAttributesAsArray($oBody);
|
||||
|
||||
$oWrapHtml = $oDom->createElement('div');
|
||||
$oWrapHtml->setAttribute('data-x-div-type', 'html');
|
||||
foreach ($aHtmlAttrs as $sKey => $sValue)
|
||||
{
|
||||
$oWrapHtml->setAttribute($sKey, $sValue);
|
||||
}
|
||||
|
||||
$oWrapDom = $oDom->createElement('div', 'xxx');
|
||||
$oWrapDom->setAttribute('data-x-div-type', 'body');
|
||||
foreach ($aBodylAttrs as $sKey => $sValue)
|
||||
{
|
||||
$oWrapDom->setAttribute($sKey, $sValue);
|
||||
}
|
||||
|
||||
$oWrapHtml->appendChild($oWrapDom);
|
||||
|
||||
$sWrp = $oDom->saveHTML($oWrapHtml);
|
||||
|
||||
$sResult = \str_replace('xxx', $sResult, $sWrp);
|
||||
}
|
||||
|
||||
$sResult = \str_replace(\MailSo\Base\HtmlUtils::$KOS, ':', $sResult);
|
||||
$sResult = \MailSo\Base\Utils::StripSpaces($sResult);
|
||||
|
||||
return $sResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sHtml
|
||||
* @param string $sHtmlAttrs = ''
|
||||
|
|
Loading…
Reference in a new issue