From d6959298807c2de35915355359cbdf02031bf112 Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Fri, 22 Feb 2013 10:59:31 +0000 Subject: [PATCH] use monospace fontstyle for plaintext edit; preserve whitespace (horizontal AND vertical) if mail is plaintext (not containing any html) --- felamimail/templates/default/app.css | 5 +++++ felamimail/templates/jerryr/app.css | 5 +++++ phpgwapi/inc/class.translation.inc.php | 18 +++++++++++------- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/felamimail/templates/default/app.css b/felamimail/templates/default/app.css index 2b01e3d2d9..ad45b716aa 100644 --- a/felamimail/templates/default/app.css +++ b/felamimail/templates/default/app.css @@ -1,3 +1,8 @@ +textarea +{ + font-family: monospace, sans-serif; +} + th.activetab { color:#000000; diff --git a/felamimail/templates/jerryr/app.css b/felamimail/templates/jerryr/app.css index 9652c7544c..302c63e038 100644 --- a/felamimail/templates/jerryr/app.css +++ b/felamimail/templates/jerryr/app.css @@ -1,3 +1,8 @@ +textarea +{ + font-family: monospace, sans-serif; +} + .fmToggle { background-color:#f6efe0; diff --git a/phpgwapi/inc/class.translation.inc.php b/phpgwapi/inc/class.translation.inc.php index 06b7b5744b..a57cdf23c9 100644 --- a/phpgwapi/inc/class.translation.inc.php +++ b/phpgwapi/inc/class.translation.inc.php @@ -1018,6 +1018,14 @@ class translation */ static function convertHTMLToText($_html,$displayCharset=false,$stripcrl=false,$stripalltags=true) { + // assume input isHTML, but test the input anyway, because, + // if it is not, we may not want to strip whitespace + $isHTML = true; + if (strlen(strip_tags($_html)) == strlen($_html)) + { + $isHTML = false; + // return $_html; // maybe we should not proceed at all + } if ($displayCharset === false) $displayCharset = self::$system_charset; //error_log(__METHOD__.$_html); #print '
'; @@ -1122,7 +1130,7 @@ class translation $_html = preg_replace('~]+href=\"([^"]+)\"[^>]*>(.*)~si','[$2 -> $1]',$_html); // reducing double \r\n to single ones, dont mess with pre sections - if ($stripcrl === true ) + if ($stripcrl === true && $isHTML) { if (stripos($_html,'
')!==false)
 			{
@@ -1160,18 +1168,14 @@ class translation
 			$_html = preg_replace('~<[^>^@]+>~s','',$_html);
 			//$_html = strip_tags($_html, '');
 		}
-		// reducing spaces
-		$_html = preg_replace('~ +~s',' ',$_html);
-		// we dont reduce whitespace at the start or the end of the line, since its used for structuring the document
-		#$_html = preg_replace('~^\s+~m','',$_html);
-		#$_html = preg_replace('~\s+$~m','',$_html);
+		// reducing spaces (not for input that was plain text from the beginning)
+		if ($isHTML) $_html = preg_replace('~ +~s',' ',$_html);
 		// restoring ampersands
 		$_html = str_replace('#amper#sand#','&',$_html);
 		//error_log(__METHOD__.__LINE__.' Charset:'.$displayCharset.' -> '.$_html);
 		$_html = html_entity_decode($_html, ENT_COMPAT, $displayCharset);
 		//error_log(__METHOD__.__LINE__.' Charset:'.$displayCharset.' After html_entity_decode: -> '.$_html);
 		//self::replaceEmailAdresses($_html);
-		#error_log($text);
 		$pos = strpos($_html, 'blockquote');
 		//error_log("convert HTML2Text: $_html");
 		if($pos === false) {