From 5cd2b962ea318714470084bc980159b25c5d01f7 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 27 Oct 2010 09:34:42 +0000 Subject: [PATCH] split merge taking a path as argument in second method merge_string taking the document as string --- etemplate/inc/class.bo_merge.inc.php | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/etemplate/inc/class.bo_merge.inc.php b/etemplate/inc/class.bo_merge.inc.php index b85961cd8b..73f3c32bbd 100644 --- a/etemplate/inc/class.bo_merge.inc.php +++ b/etemplate/inc/class.bo_merge.inc.php @@ -261,6 +261,27 @@ abstract class bo_merge $err = lang("Document '%1' does not exist or is not readable for you!",$document); return false; } + // fix application/msword mimetype for rtf files + if ($mimetype == 'application/msword' && strtolower(substr($document,-4)) == '.rtf') + { + $mimetype = 'application/rtf'; + } + return $this->merge_string($content,$ids,$err,$mimetype,$fix); + } + + /** + * Merges a given document with contact data + * + * @param string $content + * @param array $ids array with contact id(s) + * @param string &$err error-message on error + * @param string $mimetype mimetype of complete document, eg. text/*, application/vnd.oasis.opendocument.text, application/rtf + * @param array $fix=null regular expression => replacement pairs eg. to fix garbled placeholders + * @param string $document=null path/url of document, if applicable + * @return string|boolean merged document or false on error + */ + public function &merge_string($content,$ids,&$err,$mimetype,array $fix=null) + { if ($mimetype == 'application/xml' && preg_match('/'.preg_quote('').'/',substr($content,0,200),$matches)) { @@ -413,8 +434,6 @@ abstract class bo_merge switch($mimetype) { - case 'application/msword': - if (strtolower(substr($document,-4)) != '.rtf') break; // no binary word documents case 'application/rtf': case 'text/rtf': return $contentstart.implode('\\par \\page\\pard\\plain',$contentrepeatpages).$contentend; @@ -434,8 +453,6 @@ abstract class bo_merge { switch($mimetype) { - case 'application/msword': - if (strtolower(substr($document,-4)) != '.rtf') break; // no binary word documents case 'application/rtf': case 'text/rtf': return $contentstart.implode('\\par \\page\\pard\\plain',$contentrep).$contentend;