diff --git a/etemplate/inc/class.bo_merge.inc.php b/etemplate/inc/class.bo_merge.inc.php index 8d46a67b32..ab386ef836 100644 --- a/etemplate/inc/class.bo_merge.inc.php +++ b/etemplate/inc/class.bo_merge.inc.php @@ -261,6 +261,15 @@ abstract class bo_merge $err = lang("Document '%1' does not exist or is not readable for you!",$document); return false; } + if ($mimetype == 'application/xml' && + preg_match('/'.preg_quote('').'/',substr($content,0,200),$matches)) + { + $mso_application_progid = $matches[1]; + } + else + { + $mso_application_progid = ''; + } // alternative syntax using double curly brackets (eg. {{cat_id}} instead $$cat_id$$), // agressivly removing all xml-tags eg. Word adds within placeholders $content = preg_replace_callback('/{{[^}]+}}/i',create_function('$p','return \'$$\'.strip_tags(substr($p[0],2,-2)).\'$$\';'),$content); @@ -340,13 +349,13 @@ abstract class bo_merge { for($n = 0; ($row_replacements = ExecMethod2($callback,$plugin,$id,$n)); ++$n) { - $repeats .= $this->replace($repeat,$row_replacements,$mimetype); + $repeats .= $this->replace($repeat,$row_replacements,$mimetype,$mso_application_progid); } } $content = str_replace($match[0],$repeats,$content); } } - $content = $this->replace($content,$replacements,$mimetype); + $content = $this->replace($content,$replacements,$mimetype,$mso_application_progid); if (strpos($content,'$$IF')) { //Example use to use: $$IF n_prefix~Herr~Sehr geehrter~Sehr geehrte$$ @@ -450,9 +459,10 @@ abstract class bo_merge * @param string $content * @param array $replacements name => replacement pairs * @param string $mimetype mimetype of content + * @param string $mso_application_progid='' MS Office 2003: 'Excel.Sheet' or 'Word.Document' * @return string */ - protected function replace($content,array $replacements,$mimetype) + protected function replace($content,array $replacements,$mimetype,$mso_application_progid='') { switch($mimetype) { @@ -498,14 +508,42 @@ abstract class bo_merge // remove all html tags, evtl. included if (strpos($value,'<') !== false) { + // replace
andand CRLF) + $value = str_replace(array("\r","\n",'
','
','