diff --git a/etemplate/inc/class.bo_merge.inc.php b/etemplate/inc/class.bo_merge.inc.php index 696bcf6d81..45198a4677 100644 --- a/etemplate/inc/class.bo_merge.inc.php +++ b/etemplate/inc/class.bo_merge.inc.php @@ -665,6 +665,20 @@ abstract class bo_merge if (array_key_exists('$$'.$param[4].'$$',$this->replacements)) $param[4] = $this->replacements['$$'.$param[4].'$$']; if (array_key_exists('$$'.$param[3].'$$',$this->replacements)) $param[3] = $this->replacements['$$'.$param[3].'$$']; $replace = preg_match('/'.$param[2].'/',$this->replacements['$$'.$param[1].'$$']) ? $param[3] : $param[4]; + switch($this->mimetype) + { + case 'application/vnd.oasis.opendocument.text': // open office + case 'application/vnd.oasis.opendocument.spreadsheet': + case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': // ms office 2007 + case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': + case 'application/xml': + case 'text/xml': + case 'text/html': + $is_xml = true; + $charset = 'utf-8'; // xml files --> always use utf-8 + break; + } + switch($this->mimetype) { case 'application/rtf': @@ -688,7 +702,9 @@ abstract class bo_merge default: $LF = "\n"; } - + if($is_xml) { + $this->replacements = str_replace(array('&','<','>',"\r","\n"),array('&','<','>','',$LF),$this->replacements); + } if (strpos($param[0],'$$NELF') === 0) { //sets a Pagebreak and value, only if the field has a value if ($this->replacements['$$'.$param[1].'$$'] !='') $replace = $LF.$this->replacements['$$'.$param[1].'$$'];