diff --git a/ecrire/req/sqlite_fonctions.php b/ecrire/req/sqlite_fonctions.php index a109d2f71f47ed5b77ab45d157157fe73353890a..7d807f4e00d7b667c224c029fb1b756554d9f6ec 100644 --- a/ecrire/req/sqlite_fonctions.php +++ b/ecrire/req/sqlite_fonctions.php @@ -206,9 +206,23 @@ function _sqlite_func_preg_replace($quoi, $cherche, $remplace) { * @return string, l'extrait trouve. **/ function _sqlite_func_extraire_multi($quoi, $lang) { - $cherche = "<multi>.*[\[]" . $lang . "[\]]([^\[]*).*</multi>"; - $return = preg_replace('%'.$cherche.'%sS', '$1', $quoi); - return $return; + if (!defined('_EXTRAIRE_MULTI')) + include_spip('inc/filtres'); + if (!function_exists('approcher_langue')) + include_spip('inc/lang'); + if (preg_match_all(_EXTRAIRE_MULTI, $quoi, $regs, PREG_SET_ORDER)) { + foreach ($regs as $reg) { + // chercher la version de la langue courante + $trads = extraire_trads($reg[1]); + if ($l = approcher_langue($trads, $lang)) { + $trad = $trads[$l]; + } else { + $trad = reset($trads); + } + $quoi = str_replace($reg[0], $trad, $quoi); + } + } + return $quoi; }