added new Tags for merge

This commit is contained in:
Stefan Becker 2009-09-23 13:00:59 +00:00
parent 7a23ad6e3c
commit 08d4daad55

View File

@ -316,13 +316,24 @@ abstract class bo_merge
$replacements = $GLOBALS['egw']->translation->convert($replacements,$GLOBALS['egw']->translation->charset(),$this->contacts->prefs['csv_charset']);
}
$content = str_replace(array_keys($replacements),array_values($replacements),$content);
if (strpos($content,'$$IF'))
{ //Example use to use: $$IF n_prefix~Herr~Sehr geehrter~Sehr geehrte$$
$this->replacements =& $replacements;
$content = preg_replace_callback('/\$\$IF ([0-9a-z_-]+)~(.*)~(.*)~(.*)\$\$/imU',Array($this,'replace_callback'),$content);
unset($this->replacements);
}
if (strpos($content,'$$NELF'))
{ //Example: $$NEPBR org_unit$$ sets a LF and value of org_unit, only if there is a value
$this->replacements =& $replacements;
$content = preg_replace_callback('/\$\$NELF ([0-9a-z_-]+)\$\$/imU',Array($this,'replace_callback'),$content);
unset($this->replacements);
}
if (strpos($content,'$$NENVLF'))
{ //Example: $$NEPBRNV org_unit$$ sets only a LF if there is a value for org_units, but did not add any value
$this->replacements =& $replacements;
$content = preg_replace_callback('/\$\$NENVLF ([0-9a-z_-]+)\$\$/imU',Array($this,'replace_callback'),$content);
unset($this->replacements);
}
// remove not existing replacements (eg. from calendar array)
if (strpos($content,'$$') !== null)
{
@ -408,6 +419,15 @@ 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];
$LF = '}\par \pard\plain{'; //RTF Only
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].'$$'];
}
if (strpos($param[0],'$$NENVLF') === 0)
{ //sets a Pagebreak without any value, only if the field has a value
if ($this->replacements['$$'.$param[1].'$$'] !='') $replace = $LF;
}
return $replace;
}