diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 24dd771404f..bd82d622e5a 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -402,7 +402,7 @@ class FormMail extends Form $out.= '
| ';
//$out.=' ';
@@ -890,8 +890,7 @@ class FormMail extends Form
$defaultmessage = dol_nl2br($defaultmessage);
}
-
- if (isset($_POST["message"]) && ! $_POST['modelselected']) $defaultmessage=$_POST["message"];
+ if (isset($_POST["message"]) && ! $_POST['modelselected']) $defaultmessage=$_POST["message"];
else
{
$defaultmessage=make_substitutions($defaultmessage,$this->substit);
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index a4b569aae87..397c74b9ed9 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -5370,7 +5370,8 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
if (empty($exclude) || ! in_array('system', $exclude))
{
- $substitutionarray['__(AnyTranslationKey)__']=$outputlangs->trans('TranslationKey');
+ $substitutionarray['__(AnyTranslationKey)__']=$outputlangs->trans('TranslationOfKey');
+ $substitutionarray['__[AnyConstantKey]__']=$outputlangs->trans('ValueOfConstant');
$substitutionarray['__DOL_MAIN_URL_ROOT__']=DOL_MAIN_URL_ROOT;
}
if (empty($exclude) || ! in_array('mycompany', $exclude))
@@ -5605,7 +5606,7 @@ function make_substitutions($text, $substitutionarray, $outputlangs=null)
// Make substitution for language keys
if (is_object($outputlangs))
{
- while (preg_match('/__\(([^\)]*)\)__/', $text, $reg))
+ while (preg_match('/__\(([^\)]+)\)__/', $text, $reg))
{
// If key is __(TranslationKey|langfile)__, then force load of langfile.lang
$tmp=explode('|',$reg[1]);
@@ -5618,6 +5619,17 @@ function make_substitutions($text, $substitutionarray, $outputlangs=null)
}
}
+ // Make substitution for constant keys. Must be after the substitution of translation, so if text of translation contains a constant,
+ // it is also converted.
+ while (preg_match('/__\[([^\]]+)\]__/', $text, $reg))
+ {
+ $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);
+ }
+
// Make substitition for array $substitutionarray
foreach ($substitutionarray as $key => $value)
{
@@ -5650,16 +5662,16 @@ function complete_substitutions_array(&$substitutionarray, $outputlangs, $object
// Add a substitution key for each extrafields, using key __EXTRA_XXX__
// TODO Remove this. Already available into the getCommonSubstitutionArray used to build the substitution array.
- if (is_object($object) && is_array($object->array_options))
+ /*if (is_object($object) && is_array($object->array_options))
{
foreach($object->array_options as $key => $val)
{
$keyshort=preg_replace('/^(options|extra)_/','',$key);
- $substitutionarray['__EXTRA_'.$keyshort.'__']=$val;
+ $substitutionarray['__EXTRAFIELD_'.$keyshort.'__']=$val;
// For backward compatibiliy
$substitutionarray['%EXTRA_'.$keyshort.'%']=$val;
}
- }
+ }*/
// Check if there is external substitution to do, requested by plugins
$dirsubstitutions=array_merge(array(),(array) $conf->modules_parts['substitutions']);
|