mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-23 13:41:01 +01:00
improve convertHTMLToText, for toggle editor and mail2infolog process; better control of insert Signature at Top. Only insert the signature, when the compose window is opened the first time (compose/reply/forward), dont do it if sending failes, and the compose window is refreshed (in general when mySigID is set)
This commit is contained in:
parent
574ff9a59a
commit
57c63c6c29
@ -49,7 +49,7 @@
|
|||||||
|
|
||||||
function addACL($_accountName, $_aclData)
|
function addACL($_accountName, $_aclData)
|
||||||
{
|
{
|
||||||
if($this->_debug) error_log("ajaxfelamimail::addACL");
|
if($this->_debug) error_log("ajaxfelamimail::addACL for ".$_accountName."->".array2string($_aclData));
|
||||||
$response = new xajaxResponse();
|
$response = new xajaxResponse();
|
||||||
|
|
||||||
if(!empty($_accountName)) {
|
if(!empty($_accountName)) {
|
||||||
@ -252,7 +252,15 @@
|
|||||||
$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);
|
if (stripos($_content,'<pre>')!==false)
|
||||||
|
{
|
||||||
|
$contentArr = html::splithtmlByPRE($_content);
|
||||||
|
foreach ($contentArr as $k =>&$elem)
|
||||||
|
{
|
||||||
|
if (stripos($elem,'<pre>')!==false) $elem = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$elem);
|
||||||
|
}
|
||||||
|
$_content = implode('',$contentArr);
|
||||||
|
}
|
||||||
$_content = $bocompose->_getCleanHTML($_content);
|
$_content = $bocompose->_getCleanHTML($_content);
|
||||||
$_content = $bocompose->convertHTMLToText($_content);
|
$_content = $bocompose->convertHTMLToText($_content);
|
||||||
}
|
}
|
||||||
|
@ -634,7 +634,7 @@
|
|||||||
$numberOfChars = strspn(trim($value), ">");
|
$numberOfChars = strspn(trim($value), ">");
|
||||||
$appendString = str_repeat('>', $numberOfChars + 1);
|
$appendString = str_repeat('>', $numberOfChars + 1);
|
||||||
|
|
||||||
$bodyAppend = $this->bofelamimail->wordwrap($value, 76-strlen("\r\n$appendString "), "\r\n$appendString ");
|
$bodyAppend = $this->bofelamimail->wordwrap($value, 76-strlen("\r\n$appendString "), "\r\n$appendString ",'>');
|
||||||
|
|
||||||
if($bodyAppend[0] == '>') {
|
if($bodyAppend[0] == '>') {
|
||||||
$bodyAppend = '>'. $bodyAppend;
|
$bodyAppend = '>'. $bodyAppend;
|
||||||
|
@ -2795,7 +2795,7 @@
|
|||||||
return $userACL;
|
return $userACL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function wordwrap($str, $cols, $cut)
|
static function wordwrap($str, $cols, $cut, $dontbreaklinesstartingwith=false)
|
||||||
{
|
{
|
||||||
$lines = explode("\n", $str);
|
$lines = explode("\n", $str);
|
||||||
$newStr = '';
|
$newStr = '';
|
||||||
@ -2805,7 +2805,15 @@
|
|||||||
//$line = str_replace("\t"," ",$line);
|
//$line = str_replace("\t"," ",$line);
|
||||||
//$newStr .= wordwrap($line, $cols, $cut);
|
//$newStr .= wordwrap($line, $cols, $cut);
|
||||||
$allowedLength = $cols-strlen($cut);
|
$allowedLength = $cols-strlen($cut);
|
||||||
if (strlen($line) > $allowedLength) {
|
if (strlen($line) > $allowedLength &&
|
||||||
|
($dontbreaklinesstartingwith==false ||
|
||||||
|
($dontbreaklinesstartingwith &&
|
||||||
|
strlen($dontbreaklinesstartingwith)>=1 &&
|
||||||
|
substr($line,0,strlen($dontbreaklinesstartingwith)) != $dontbreaklinesstartingwith
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{
|
||||||
$s=explode(" ", $line);
|
$s=explode(" ", $line);
|
||||||
$line = "";
|
$line = "";
|
||||||
$linecnt = 0;
|
$linecnt = 0;
|
||||||
|
@ -32,6 +32,7 @@ class bosieve
|
|||||||
$bopreferences = CreateObject('felamimail.bopreferences',$_restoreSession);
|
$bopreferences = CreateObject('felamimail.bopreferences',$_restoreSession);
|
||||||
$mailPreferences = $bopreferences->getPreferences();
|
$mailPreferences = $bopreferences->getPreferences();
|
||||||
$icServer = $mailPreferences->getIncomingServer(0);
|
$icServer = $mailPreferences->getIncomingServer(0);
|
||||||
|
if ($this->debug) error_log(__CLASS__.'::'.__METHOD__.'->LoginName:'.$icServer->loginName);
|
||||||
$icServer->setVacationUser($icServer->loginName,$_vacation['scriptName'],$_vacation);
|
$icServer->setVacationUser($icServer->loginName,$_vacation['scriptName'],$_vacation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,8 +64,6 @@
|
|||||||
|
|
||||||
$this->rowColor[0] = $GLOBALS['egw_info']["theme"]["bg01"];
|
$this->rowColor[0] = $GLOBALS['egw_info']["theme"]["bg01"];
|
||||||
$this->rowColor[1] = $GLOBALS['egw_info']["theme"]["bg02"];
|
$this->rowColor[1] = $GLOBALS['egw_info']["theme"]["bg02"];
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function unhtmlentities ($string)
|
function unhtmlentities ($string)
|
||||||
@ -440,7 +438,10 @@
|
|||||||
$disableRuler = true;
|
$disableRuler = true;
|
||||||
}
|
}
|
||||||
$insertSigOnTop = false;
|
$insertSigOnTop = false;
|
||||||
if (isset($this->bocompose->preferencesArray['insertSignatureAtTopOfMessage']) && $this->bocompose->preferencesArray['insertSignatureAtTopOfMessage'])
|
if (isset($this->bocompose->preferencesArray['insertSignatureAtTopOfMessage']) &&
|
||||||
|
$this->bocompose->preferencesArray['insertSignatureAtTopOfMessage'] &&
|
||||||
|
!(isset($_POST['mySigID']) && !empty($_POST['mySigID']))
|
||||||
|
)
|
||||||
{
|
{
|
||||||
$insertSigOnTop = true;
|
$insertSigOnTop = true;
|
||||||
if($sessionData['mimeType'] == 'html') {
|
if($sessionData['mimeType'] == 'html') {
|
||||||
@ -453,7 +454,6 @@
|
|||||||
$sigText = bofelamimail::merge($signature->fm_signature,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')));
|
$sigText = bofelamimail::merge($signature->fm_signature,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')));
|
||||||
$sessionData['body'] = $before.($sessionData['mimeType'] == 'html'?$sigText:$this->bocompose->convertHTMLToText($sigText)).$inbetween.$sessionData['body'];
|
$sessionData['body'] = $before.($sessionData['mimeType'] == 'html'?$sigText:$this->bocompose->convertHTMLToText($sigText)).$inbetween.$sessionData['body'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// prepare body
|
// prepare body
|
||||||
if($sessionData['mimeType'] == 'html') {
|
if($sessionData['mimeType'] == 'html') {
|
||||||
$mode = 'simple';
|
$mode = 'simple';
|
||||||
|
@ -1665,6 +1665,7 @@ class infolog_ui
|
|||||||
|
|
||||||
if ($bodyParts[$i]['mimeType'] == 'text/html') {
|
if ($bodyParts[$i]['mimeType'] == 'text/html') {
|
||||||
// convert HTML to text, as we dont want HTML in infologs
|
// convert HTML to text, as we dont want HTML in infologs
|
||||||
|
$newBody = html::purify($newBody);
|
||||||
$newBody = $bofelamimail->convertHTMLToText($newBody,true);
|
$newBody = $bofelamimail->convertHTMLToText($newBody,true);
|
||||||
$bofelamimail->getCleanHTML($newBody); // new Body passed by reference
|
$bofelamimail->getCleanHTML($newBody); // new Body passed by reference
|
||||||
$message .= $newBody;
|
$message .= $newBody;
|
||||||
|
@ -1531,5 +1531,30 @@ class html
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* split html by PRE tag, return array with all content pre-sections isolated in array elements
|
||||||
|
* @author Leithoff, Klaus
|
||||||
|
* @param string html
|
||||||
|
* @return mixed array of parts or unaffected html
|
||||||
|
*/
|
||||||
|
static function splithtmlByPRE($html)
|
||||||
|
{
|
||||||
|
if (($pos = stripos($html,'<pre>')) === false)
|
||||||
|
{
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
$html2ret[] = substr($html,0,$pos);
|
||||||
|
while ($pos!==false)
|
||||||
|
{
|
||||||
|
$endofpre = stripos($html,'</pre>',$pos);
|
||||||
|
$length = $endofpre-$pos+6;
|
||||||
|
$html2ret[] = substr($html,$pos,$length);
|
||||||
|
$pos = stripos($html,'<pre>', $endofpre+6);
|
||||||
|
$html2ret[] = ($pos ? substr($html,$endofpre+6,$pos-($endofpre+6)): substr($html,$endofpre+6));
|
||||||
|
//$pos=false;
|
||||||
|
}
|
||||||
|
return $html2ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
html::_init_static();
|
html::_init_static();
|
||||||
|
@ -1139,6 +1139,7 @@ class translation
|
|||||||
'@&(pound|#163);@i', // Pound
|
'@&(pound|#163);@i', // Pound
|
||||||
'@&(copy|#169);@i', // Copyright
|
'@&(copy|#169);@i', // Copyright
|
||||||
'@&(reg|#174);@i', // Registered
|
'@&(reg|#174);@i', // Registered
|
||||||
|
'@'@i', // singleQuote
|
||||||
);
|
);
|
||||||
$Replace = array ('',
|
$Replace = array ('',
|
||||||
'"',
|
'"',
|
||||||
@ -1151,11 +1152,26 @@ class translation
|
|||||||
chr(163),
|
chr(163),
|
||||||
chr(169),
|
chr(169),
|
||||||
chr(174),
|
chr(174),
|
||||||
|
"'",
|
||||||
);
|
);
|
||||||
$_html = preg_replace($Rules, $Replace, $_html);
|
$_html = preg_replace($Rules, $Replace, $_html);
|
||||||
|
|
||||||
// removing carriage return linefeeds
|
// removing carriage return linefeeds, preserve those enclosed in <pre> </pre> tags
|
||||||
if ($stripcrl === true ) $_html = preg_replace('@(\r\n)@i',' ',$_html);
|
if ($stripcrl === true )
|
||||||
|
{
|
||||||
|
if (stripos($_html,'<pre>')!==false)
|
||||||
|
{
|
||||||
|
$contentArr = html::splithtmlByPRE($_html);
|
||||||
|
foreach ($contentArr as $k =>&$elem)
|
||||||
|
{
|
||||||
|
if (stripos($elem,'<pre>')===false)
|
||||||
|
{
|
||||||
|
$elem = preg_replace('@(\r\n)@i',' ',$elem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$_html = implode('',$contentArr);
|
||||||
|
}
|
||||||
|
}
|
||||||
$tags = array (
|
$tags = array (
|
||||||
0 => '~<h[123][^>]*>\r*\n*~si',
|
0 => '~<h[123][^>]*>\r*\n*~si',
|
||||||
1 => '~<h[456][^>]*>\r*\n*~si',
|
1 => '~<h[456][^>]*>\r*\n*~si',
|
||||||
@ -1168,6 +1184,9 @@ class translation
|
|||||||
8 => '~<div[^>]*>\r*\n*~si',
|
8 => '~<div[^>]*>\r*\n*~si',
|
||||||
9 => '~<hr[^>]*>\r*\n*~si',
|
9 => '~<hr[^>]*>\r*\n*~si',
|
||||||
10 => '/<blockquote type="cite">/',
|
10 => '/<blockquote type="cite">/',
|
||||||
|
11 => '/<blockquote>/',
|
||||||
|
12 => '~</blockquote>~si',
|
||||||
|
13 => '~<blockquote[^>]*>~si',
|
||||||
);
|
);
|
||||||
$Replace = array (
|
$Replace = array (
|
||||||
0 => "\r\n",
|
0 => "\r\n",
|
||||||
@ -1181,6 +1200,9 @@ class translation
|
|||||||
8 => "\r\n",
|
8 => "\r\n",
|
||||||
9 => "\r\n__________________________________________________\r\n",
|
9 => "\r\n__________________________________________________\r\n",
|
||||||
10 => '#blockquote#type#cite#',
|
10 => '#blockquote#type#cite#',
|
||||||
|
11 => '#blockquote#type#cite#',
|
||||||
|
12 => '#blockquote#end#cite#',
|
||||||
|
13 => '#blockquote#type#cite#',
|
||||||
);
|
);
|
||||||
$_html = preg_replace($tags,$Replace,$_html);
|
$_html = preg_replace($tags,$Replace,$_html);
|
||||||
$_html = preg_replace('~</t(d|h)>\s*<t(d|h)[^>]*>~si',' - ',$_html);
|
$_html = preg_replace('~</t(d|h)>\s*<t(d|h)[^>]*>~si',' - ',$_html);
|
||||||
@ -1200,7 +1222,7 @@ class translation
|
|||||||
#$_html = preg_replace('~^\s+~m','',$_html);
|
#$_html = preg_replace('~^\s+~m','',$_html);
|
||||||
#$_html = preg_replace('~\s+$~m','',$_html);
|
#$_html = preg_replace('~\s+$~m','',$_html);
|
||||||
// restoring the preserved blockquote
|
// restoring the preserved blockquote
|
||||||
$_html = preg_replace('~#blockquote#type#cite#~s','<blockquote type="cite">',$_html);
|
//$_html = str_replace('#blockquote#type#cite#','<blockquote type="cite">',$_html);
|
||||||
|
|
||||||
|
|
||||||
$_html = html_entity_decode($_html, ENT_COMPAT, $displayCharset);
|
$_html = html_entity_decode($_html, ENT_COMPAT, $displayCharset);
|
||||||
@ -1214,14 +1236,15 @@ class translation
|
|||||||
$indent = 0;
|
$indent = 0;
|
||||||
$indentString = '';
|
$indentString = '';
|
||||||
|
|
||||||
$quoteParts = preg_split('/<blockquote type="cite">/', $_html, -1, PREG_SPLIT_OFFSET_CAPTURE);
|
//$quoteParts = preg_split('/<blockquote type="cite">/', $_html, -1, PREG_SPLIT_OFFSET_CAPTURE);
|
||||||
|
$quoteParts = preg_split('/#blockquote#type#cite#/', $_html, -1, PREG_SPLIT_OFFSET_CAPTURE);
|
||||||
foreach($quoteParts as $quotePart) {
|
foreach($quoteParts as $quotePart) {
|
||||||
if($quotePart[1] > 0) {
|
if($quotePart[1] > 0) {
|
||||||
$indent++;
|
$indent++;
|
||||||
$indentString .= '>';
|
$indentString .= '>';
|
||||||
}
|
}
|
||||||
$quoteParts2 = preg_split('/<\/blockquote>/', $quotePart[0], -1, PREG_SPLIT_OFFSET_CAPTURE);
|
//$quoteParts2 = preg_split('/<\/blockquote>/', $quotePart[0], -1, PREG_SPLIT_OFFSET_CAPTURE);
|
||||||
|
$quoteParts2 = preg_split('/#blockquote#end#cite#/', $quotePart[0], -1, PREG_SPLIT_OFFSET_CAPTURE);
|
||||||
|
|
||||||
foreach($quoteParts2 as $quotePart2) {
|
foreach($quoteParts2 as $quotePart2) {
|
||||||
if($quotePart2[1] > 0) {
|
if($quotePart2[1] > 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user