From cd1f03c7619664afc6688b9ba2843b5e57ece81b Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Wed, 9 Mar 2016 21:58:56 +0000 Subject: [PATCH] Add ability to test for blank fields when merging: {{IF~ #fieldname ~ EMPTY ~ Empty ~Not empty}} or {{IF~#fieldname~~Empty~Not empty}} --- etemplate/inc/class.bo_merge.inc.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/etemplate/inc/class.bo_merge.inc.php b/etemplate/inc/class.bo_merge.inc.php index 5318cc114d..306ed55ae5 100644 --- a/etemplate/inc/class.bo_merge.inc.php +++ b/etemplate/inc/class.bo_merge.inc.php @@ -1436,7 +1436,13 @@ 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('/'.preg_quote($param[2], '/').'/',$this->replacements['$$'.$param[1].'$$']) ? $param[3] : $param[4]; + + $pattern = '/'.preg_quote($param[2], '/').'/'; + if (strpos($param[0],'$$IF') === 0 && (trim($param[2]) == "EMPTY" || $param[2] === '')) + { + $pattern = '/^$/'; + } + $replace = preg_match($pattern,$this->replacements['$$'.$param[1].'$$']) ? $param[3] : $param[4]; switch($this->mimetype) { case 'application/vnd.oasis.opendocument.text': // open office