diff --git a/ecrire/inc/utils.php b/ecrire/inc/utils.php index 9f86eb67674c4f96283a0c2604a9d9348f246ceb..44090e2e3039bb3e7e06473740a7bf65b5acf398 100644 --- a/ecrire/inc/utils.php +++ b/ecrire/inc/utils.php @@ -822,10 +822,19 @@ function _T($texte, $args = array(), $options = array()) { */ function _L($text, $args = array(), $options = array()) { $f = $text; + $defaut_options = array( + 'class' => null, + 'sanitize' => true, + ); + // support de l'ancien argument $class if ($options and is_string($options)) { - // support de l'ancien argument $class $options = array('class' => $options); + } elseif (is_array($options)) { + $options += $defaut_options; + } else { + $options = $defaut_options; } + if (is_array($args)) { if (!function_exists('interdire_scripts')) { include_spip('inc/texte'); @@ -834,11 +843,11 @@ function _L($text, $args = array(), $options = array()) { include_spip('inc/texte_mini'); } foreach ($args as $name => $value) { - if (!isset($options['sanitize']) or $options['sanitize']) { + if ($options['sanitize']) { $value = echapper_html_suspect($value); $value = interdire_scripts($value, -1); } - if (isset($options['class']) and $options['class']) { + if (!empty($options['class'])) { $value = "<span class='".$options['class']."'>$value</span>"; } $t = str_replace("@$name@", $value, $text); @@ -854,7 +863,7 @@ function _L($text, $args = array(), $options = array()) { } } - if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and (!isset($options['class']) or !$options['class'])) { + if (($GLOBALS['test_i18n'] or (_request('var_mode') == 'traduction')) and is_null($options['class'])) { return "<span class=debug-traduction-erreur>$text</span>"; } else { return $text;