From e9838f486a08335635aa8514f584484941ed5aa4 Mon Sep 17 00:00:00 2001
From: denisb <denisb@a-working-class-hero-is-something-to.be>
Date: Thu, 19 Sep 2013 06:17:07 +0000
Subject: [PATCH] =?UTF-8?q?compiler,=20decompiler,=20phraser=5Fhtml=20:.?=
 =?UTF-8?q?=20compl=C3=A9ment=20et=20am=C3=A9lioration=20de=20r20415=20;?=
 =?UTF-8?q?=20il=20est=20d=C3=A9sormais=20possible=20de=20d=C3=A9finir=20d?=
 =?UTF-8?q?ynamiquement,=20depuis=20un=20squelette,=20le=20nom=20du=20modu?=
 =?UTF-8?q?le=20de=20langue.=20=20report=20de=20r20775=20(esj)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 ecrire/public/compiler.php     | 20 ++++++++++++++++----
 ecrire/public/decompiler.php   |  5 +----
 ecrire/public/phraser_html.php |  2 +-
 3 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/ecrire/public/compiler.php b/ecrire/public/compiler.php
index 875d1e5b63..e5ceebb03b 100644
--- a/ecrire/public/compiler.php
+++ b/ecrire/public/compiler.php
@@ -924,15 +924,27 @@ function compile_cas($tableau, $descr, &$boucles, $id_boucle) {
 
 		case 'idiome':
 			$l = array();
-			$cpl = '';
+			$code = '';
 			foreach ($p->arg as $k => $v) {
 				$_v = calculer_liste($v, $descr, $boucles, $id_boucle);
 				if ($k)
 					$l[] = _q($k) . ' => ' . $_v;
-				else $cpl = " . $_v";
+				else $code = $_v;
 			}
-			$l = !$l ? '' : (", array(".implode(",\n",$l).")");
-			$code = "_T('" . $p->module . ":" . $p->nom_champ . "'$cpl$l)";
+			// Si le module n'est pas fourni, l'expliciter sauf si calculé
+			if ($p->module) {
+				$m = $p->module .':'.$p->nom_champ;
+			} elseif ($p->nom_champ) {
+				$m = MODULES_IDIOMES .':'.$p->nom_champ;
+			} else  {
+				$m = '';
+			}
+
+			$code = (!$code ? "'$m'" :
+						($m ? "'$m' . $code" :
+							("(strpos(\$x=$code, ':') ? \$x : ('" . MODULES_IDIOMES . ":' . \$x))")))
+					. (!$l ? '' : (", array(" . implode(",\n", $l) . ")"));
+			$code = "_T($code)";
 			if ($p->param) {
 				$p->id_boucle = $id_boucle;
 				$p->boucles = &$boucles;
diff --git a/ecrire/public/decompiler.php b/ecrire/public/decompiler.php
index 09af880ba4..de52ce5f17 100644
--- a/ecrire/public/decompiler.php
+++ b/ecrire/public/decompiler.php
@@ -71,9 +71,6 @@ function decompiler_polyglotte($struct, $fmt='', $prof=0)
 
 function decompiler_idiome($struct, $fmt='', $prof=0)
 {
-	$module = ($struct->module == MODULES_IDIOMES)? ''
-	  : $struct->module;
-
 	$args = array();
 	foreach ($struct->arg as $k => $v) {
 		$args[$k]= public_decompiler($v, $fmt, $prof);
@@ -82,7 +79,7 @@ function decompiler_idiome($struct, $fmt='', $prof=0)
 	$filtres =  decompiler_liste($struct->param, $fmt, $prof);
 
 	$f = 'format_idiome_' . $fmt;
-	return $f($struct->nom_champ, $module, $args, $filtres, $prof);
+	return $f($struct->nom_champ, $struct->module, $args, $filtres, $prof);
 }
 
 function decompiler_champ($struct, $fmt='', $prof=0)
diff --git a/ecrire/public/phraser_html.php b/ecrire/public/phraser_html.php
index 846fa2262d..fd2cf81207 100644
--- a/ecrire/public/phraser_html.php
+++ b/ecrire/public/phraser_html.php
@@ -157,7 +157,7 @@ function phraser_idiomes($texte,$ligne,$result) {
 		}
 		$champ->arg = $args;
 		$champ->nom_champ = strtolower($match[3]);
-		$champ->module = $match[2] ? $match[2] : MODULES_IDIOMES;
+		$champ->module = $match[2];
 		// pas d'imbrication pour les filtres sur langue
 		phraser_args(@$match[7], ":", '', array(), $champ);
 		$result[] = $champ;
-- 
GitLab