improving the display by toggling the editor mode; improving import of html mails after flaw in rev28758

This commit is contained in:
Klaus Leithoff 2009-12-16 10:59:38 +00:00
parent 8efdb97c29
commit 70d74361f3
4 changed files with 14 additions and 10 deletions

View File

@ -239,16 +239,18 @@
function toggleEditor($_composeID, $_content ,$_mode) function toggleEditor($_composeID, $_content ,$_mode)
{ {
if($this->_debug) error_log("ajaxfelamimail::toggleEditor->".$_mode); if($this->_debug) error_log("ajaxfelamimail::toggleEditor->".$_mode.'->'.$_content);
$bocompose = CreateObject('felamimail.bocompose', $_composeID); $bocompose = CreateObject('felamimail.bocompose', $_composeID);
if($_mode == 'simple') { if($_mode == 'simple') {
if($this->_debug) error_log(__METHOD__.$_content); if($this->_debug) error_log(__METHOD__.$_content);
#if (isset($GLOBALS['egw_info']['server']['enabled_spellcheck'])) $_mode = 'egw_simple_spellcheck'; #if (isset($GLOBALS['egw_info']['server']['enabled_spellcheck'])) $_mode = 'egw_simple_spellcheck';
$this->sessionData['mimeType'] = 'html'; $this->sessionData['mimeType'] = 'html';
// convert emailadresses presentet in angle brackets to emailadress only // convert emailadresses presentet in angle brackets to emailadress only
$_content = str_replace(array("\r\n","\n","\r","<br>"),array("<br>","<br>","<br>","\r\n"),$_content);
$bocompose->replaceEmailAdresses($_content); $bocompose->replaceEmailAdresses($_content);
} else { } else {
$this->sessionData['mimeType'] = 'text'; $this->sessionData['mimeType'] = 'text';
$_content = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$_content);
$_content = $bocompose->_getCleanHTML($_content); $_content = $bocompose->_getCleanHTML($_content);
$_content = $bocompose->convertHTMLToText($_content); $_content = $bocompose->convertHTMLToText($_content);
} }

View File

@ -574,19 +574,19 @@
foreach ($headers['TO'] as $mailheader) { foreach ($headers['TO'] as $mailheader) {
$toAddressA[] = ($mailheader['PERSONAL_NAME'] != 'NIL') ? $mailheader['RFC822_EMAIL'] : $mailheader['EMAIL']; $toAddressA[] = ($mailheader['PERSONAL_NAME'] != 'NIL') ? $mailheader['RFC822_EMAIL'] : $mailheader['EMAIL'];
} }
if (count($toAddressA)>0) $toAddress = @htmlspecialchars(lang("to").": ".$bofelamimail->decode_header(implode(', ', $toAddressA)),ENT_QUOTES).($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n"); if (count($toAddressA)>0) $toAddress = @htmlspecialchars(lang("to").": ".$bofelamimail->decode_header(implode(', ', $toAddressA)),ENT_QUOTES).($bodyParts['0']['mimeType'] == 'text/html'?"\r\n<br>":"\r\n");
$ccAddressA = array(); $ccAddressA = array();
$ccAddress = ''; $ccAddress = '';
foreach ($headers['CC'] as $mailheader) { foreach ($headers['CC'] as $mailheader) {
$ccAddressA[] = ($mailheader['PERSONAL_NAME'] != 'NIL') ? $mailheader['RFC822_EMAIL'] : $mailheader['EMAIL']; $ccAddressA[] = ($mailheader['PERSONAL_NAME'] != 'NIL') ? $mailheader['RFC822_EMAIL'] : $mailheader['EMAIL'];
} }
if (count($ccAddressA)>0) $ccAddress = @htmlspecialchars(lang("cc").": ".$bofelamimail->decode_header(implode(', ', $ccAddressA)),ENT_QUOTES).($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n"); if (count($ccAddressA)>0) $ccAddress = @htmlspecialchars(lang("cc").": ".$bofelamimail->decode_header(implode(', ', $ccAddressA)),ENT_QUOTES).($bodyParts['0']['mimeType'] == 'text/html'?"\r\n<br>":"\r\n");
if($bodyParts['0']['mimeType'] == 'text/html') { if($bodyParts['0']['mimeType'] == 'text/html') {
$this->sessionData['body'] = "<br>&nbsp;\r\n<p>".'----------------'.lang("original message").'-----------------<br>'. $this->sessionData['body'] = "<br>&nbsp;\r\n<p>".'----------------'.lang("original message").'-----------------'."\r\n".'<br>'.
@htmlspecialchars(lang("from").": ".$bofelamimail->decode_header($fromAddress),ENT_QUOTES)."<br>". @htmlspecialchars(lang("from").": ".$bofelamimail->decode_header($fromAddress),ENT_QUOTES)."\r\n<br>".
$toAddress.$ccAddress. $toAddress.$ccAddress.
@htmlspecialchars(lang("date").": ".$headers['DATE'],ENT_QUOTES)."<br>". @htmlspecialchars(lang("date").": ".$headers['DATE'],ENT_QUOTES)."\r\n<br>".
'----------------------------------------------------------'."</p>\r\n"; '----------------------------------------------------------'."\r\n</p>";
$this->sessionData['mimeType'] = 'html'; $this->sessionData['mimeType'] = 'html';
$this->sessionData['body'] .= '<blockquote type="cite">'; $this->sessionData['body'] .= '<blockquote type="cite">';

View File

@ -800,8 +800,9 @@
static function getCleanHTML(&$_html, $usepurify = false) static function getCleanHTML(&$_html, $usepurify = false)
{ {
// remove CRLF and TAB as it is of no use in HTML. // remove CRLF and TAB as it is of no use in HTML.
$_html = str_replace("\r\n",' ',$_html); // but they matter in <pre>, so we rather don't
$_html = str_replace("\t",' ',$_html); //$_html = str_replace("\r\n",' ',$_html);
//$_html = str_replace("\t",' ',$_html);
self::replaceTagsCompletley($_html,'style'); // clean out empty or pagewide style definitions / left over tags self::replaceTagsCompletley($_html,'style'); // clean out empty or pagewide style definitions / left over tags
self::replaceTagsCompletley($_html,'head'); // Strip out stuff in head self::replaceTagsCompletley($_html,'head'); // Strip out stuff in head

View File

@ -1037,11 +1037,12 @@ class translation
*/ */
static function replaceEmailAdresses(&$text) static function replaceEmailAdresses(&$text)
{ {
//error_log($text);
// replace emailaddresses eclosed in <> (eg.: <me@you.de>) with the emailaddress only (e.g: me@you.de) // replace emailaddresses eclosed in <> (eg.: <me@you.de>) with the emailaddress only (e.g: me@you.de)
$text = preg_replace("/(<|&lt;)*(([\w\.,-.,_.,0-9.]+)(@)([\w\.,-.,_.,0-9.]+))(>|&gt;)*/ie","'$2 '", $text);
$text = preg_replace("/(<|&lt;a href=\")*(mailto:([\w\.,-.,_.,0-9.]+)(@)([\w\.,-.,_.,0-9.]+))(>|&gt;)*/ie","'$2 '", $text); $text = preg_replace("/(<|&lt;a href=\")*(mailto:([\w\.,-.,_.,0-9.]+)(@)([\w\.,-.,_.,0-9.]+))(>|&gt;)*/ie","'$2 '", $text);
$text = preg_replace('~<a[^>]+href=\"(mailto:)+([^"]+)\"[^>]*>~si','$2 ',$text); $text = preg_replace('~<a[^>]+href=\"(mailto:)+([^"]+)\"[^>]*>~si','$2 ',$text);
$text = preg_replace("/(([\w\.,-.,_.,0-9.]+)(@)([\w\.,-.,_.,0-9.]+))( |\s)*(<\/a>)*( |\s)*(>|&gt;)*/ie","'$1 '", $text); $text = preg_replace("/(([\w\.,-.,_.,0-9.]+)(@)([\w\.,-.,_.,0-9.]+))( |\s)*(<\/a>)*( |\s)*(>|&gt;)*/ie","'$1 '", $text);
$text = preg_replace("/(<|&lt;)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|&gt;)*/ie","'$2 '", $text);
return 1; return 1;
} }