From 7e40ee5e4b6aedc4d762b9d4b4a61aa703d64a0b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 25 Nov 2017 23:16:15 +0100 Subject: [PATCH] Fix substitution key for constant ok with php 5.3 --- htdocs/core/lib/functions.lib.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 397c74b9ed9..0e7a5458dff 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5608,13 +5608,13 @@ function make_substitutions($text, $substitutionarray, $outputlangs=null) { while (preg_match('/__\(([^\)]+)\)__/', $text, $reg)) { + $msgishtml = 0; + if (dol_textishtml($text,1)) $msgishtml = 1; + // If key is __(TranslationKey|langfile)__, then force load of langfile.lang $tmp=explode('|',$reg[1]); if (! empty($tmp[1])) $outputlangs->load($tmp[1]); - $msgishtml = 0; - if (dol_textishtml($text,1)) $msgishtml = 1; - $text = preg_replace('/__\('.preg_quote($reg[1], '/').'\)__/', $msgishtml?dol_htmlentitiesbr($outputlangs->transnoentitiesnoconv($reg[1])):$outputlangs->transnoentitiesnoconv($reg[1]), $text); } } @@ -5626,8 +5626,9 @@ function make_substitutions($text, $substitutionarray, $outputlangs=null) $msgishtml = 0; if (dol_textishtml($text,1)) $msgishtml = 1; - $newval=empty($conf->global->$reg[1])?'':$conf->global->$reg[1]; - $text = preg_replace('/__\['.preg_quote($reg[1], '/').'\]__/', $msgishtml?dol_htmlentitiesbr($newval):$newval, $text); + $keyfound = $reg[1]; + $newval=empty($conf->global->$keyfound)?'':$conf->global->$keyfound; + $text = preg_replace('/__\['.preg_quote($keyfound, '/').'\]__/', $msgishtml?dol_htmlentitiesbr($newval):$newval, $text); } // Make substitition for array $substitutionarray