From 5c948f5d5de4018dae7261b5064d306beee24993 Mon Sep 17 00:00:00 2001 From: Stefan Becker Date: Sun, 22 Feb 2009 12:24:24 +0000 Subject: [PATCH] =?UTF-8?q?"Addressbook=20is=20now=20=20able=20to=20print?= =?UTF-8?q?=20more=20than=20one=20Adresslables=20into=20a=20page.=20This?= =?UTF-8?q?=20is=20needed=20to=20print=20out=20Addreslables=20for=20a=20ma?= =?UTF-8?q?iling.=20New=20Tags=20$$label$$=20and=20$$labelplacement$$=20ad?= =?UTF-8?q?ded.=20Also=20possible=20to=20print=20out=20the=20County=20name?= =?UTF-8?q?,=20if=20it=20is=20not=20your=20own=20contry.=20I=20will=20add?= =?UTF-8?q?=20a=20exsample=20to=20EGroupware=20demo=20page.=20This=20is=20?= =?UTF-8?q?sponsored=20by=20Deutsche=20Kinemathek=20=E2=80=93=20Museum=20f?= =?UTF-8?q?=C3=BCr=20Film=20und=20Fernsehen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit " --- .../inc/class.addressbook_merge.inc.php | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/addressbook/inc/class.addressbook_merge.inc.php b/addressbook/inc/class.addressbook_merge.inc.php index b72504b15d..dadfe45238 100644 --- a/addressbook/inc/class.addressbook_merge.inc.php +++ b/addressbook/inc/class.addressbook_merge.inc.php @@ -205,6 +205,11 @@ class addressbook_merge // extends bo_merge return false; } list($contentstart,$contentrepeat,$contentend) = preg_split('/\$\$pagerepeat\$\$/',$content,-1, PREG_SPLIT_NO_EMPTY); //get differt parts of document, seperatet by Pagerepeat + list($Labelstart,$Labelrepeat,$Labeltend) = preg_split('/\$\$label\$\$/',$contentrepeat,-1, PREG_SPLIT_NO_EMPTY); //get the Lable content + preg_match_all('/\$\$labelplacement\$\$/',$contentrepeat,$countlables, PREG_SPLIT_NO_EMPTY); + $countlables =count($countlables[0])+1; + preg_replace('/\$\$labelplacement\$\$/','',$Labelrepeat,1); + if ($countlables>1) $lableprint = true; if (count($ids) > 1 && !$contentrepeat) { $err = lang('for more then one contact in a document use the tag pagerepeat!'); @@ -214,6 +219,7 @@ class addressbook_merge // extends bo_merge { if ($contentrepeat) $content = $contentrepeat; //content to repeat // generate replacements + if ($lableprint) $content = $Labelrepeat; if (!($replacements = $this->contact_replacements($id))) { $err = lang('Contact not found!'); @@ -239,7 +245,6 @@ class addressbook_merge // extends bo_merge { $content = preg_replace('/\$\$calendar\/[0-9]+\/[a-z_]+\$\$/','',$content); } - $this->replacements = $replacements; if (strpos($content,'$$IF')) { //Example use to use: $$IF n_prefix~Herr~Sehr geehrter~Sehr geehrte$$ @@ -248,6 +253,31 @@ class addressbook_merge // extends bo_merge if ($contentrepeat) $contentrep[$id] = $content; } + + + if ($Labelrepeat) + + { + $countpage=0; + $count=0; + $contentrepeatpages[$countpage] = $Labelstart.$Labeltend; + + foreach ($contentrep as $Label) + { + $count=$count+1; + if ($count % $countlables == 0) + { + $countpage=$countpage+1; + $contentrepeatpages[$countpage] = $Labelstart.$Labeltend; + } + $contentrepeatpages[$countpage] = preg_replace('/\$\$labelplacement\$\$/',$Label,$contentrepeatpages[$countpage],1); + + } + + $contentrepeatpages[$countpage] = preg_replace('/\$\$labelplacement\$\$/','',$contentrepeatpages[$countpage],-1); //clean empty fields + return $contentstart.implode('\\par \\page\\pard\\plain',$contentrepeatpages).$contentend; + } + if ($contentrepeat) { return $contentstart.implode('\\par \\page\\pard\\plain',$contentrep).$contentend; @@ -258,6 +288,8 @@ class addressbook_merge // extends bo_merge function replace_callback($param) { + 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]; return $replace; }