diff --git a/inc-arg-squel.php3 b/inc-arg-squel.php3 index 0818fe3cba62dfe5614d28295ea3f49f2fbfc842..bb960e2dcfb9616bc6e2f093d0ad22e31074719d 100644 --- a/inc-arg-squel.php3 +++ b/inc-arg-squel.php3 @@ -95,13 +95,13 @@ function calculer_params($type, $params, $idb, &$boucles) { $boucle->where[] = "$id_table.id_parent='0'"; } else if (ereg("^branche *(\??)", $param, $regs)) { - $c = '".' ."calcul_mysql_in('$id_table.id_rubrique', + $c = "calcul_mysql_in('$id_table.id_rubrique', calcul_branche(" . index_pile($boucle->id_parent, 'id_rubrique', - $boucles) . "), '') . \""; + $boucles) . "), '')"; if (!$regs[1]) - $boucle->where[] = $c ; + $boucle->where[] = "\". $c .\"" ; else - $boucle->where[] = "('\$id_rubrique'='' OR $c)"; + $boucle->where[] = "\".(".index_pile($boucle->id_parent, 'id_rubrique', $boucles)."? $c : 1).\""; } else if ($type == 'hierarchie') { // Hack specifique; cf complement dans calculer_boucle @@ -134,9 +134,6 @@ function calculer_params($type, $params, $idb, &$boucles) { else $val = addslashes($val); - // operateur optionnel {lang?} - $ou_rien = ($match[2]) ? "'$val'='' OR " : ''; - // Traitement general des relations externes if ($s = $tables_relations[$type][$col]) { $col_table = $s; @@ -257,7 +254,7 @@ function calculer_params($type, $params, $idb, &$boucles) { if (!$op) $op = '='; else if ($op == '==') - $op = 'REGEXP '; + $op = 'REGEXP'; if ($col_table) $col = "$col_table.$col"; @@ -280,10 +277,19 @@ function calculer_params($type, $params, $idb, &$boucles) { if (!$vu) { if ($match[4] == '!') - $boucle->where[] = "NOT ($ou_rien$col $op'$val')"; + $where = "NOT ($col $op '$val')"; else - $boucle->where[] = "($ou_rien$col $op'$val')"; + $where = "($col $op '$val')"; + + // operateur optionnel {lang?} + if ($match[2]) { + $champ = index_pile($boucle->id_parent, $match[1], $boucles) ; + $where = "\".($champ ? \"$where\" : 1).\""; + } + + $boucle->where[] = $where; } + } // fin du if sur les restrictions de valeurs // Selection du classement diff --git a/inc-calcul-squel.php3 b/inc-calcul-squel.php3 index a8df1587101c041f11c7e928636067996ea83581..22a96c2615df5683d2caafa065d0817fb594dfac 100644 --- a/inc-calcul-squel.php3 +++ b/inc-calcul-squel.php3 @@ -414,13 +414,15 @@ function calculer_squelette($squelette, $nom, $gram) { foreach($boucles as $id => $boucle) { - $code .= "\n\nfunction $nom" . ereg_replace("-","_",$id) . + $code .= "\n\n// BOUCLE".$id. + "\nfunction $nom" . ereg_replace("-","_",$id) . '(&$Cache, &$Pile, &$doublons, &$Numrows, $SP) {' . $boucle->return . "\n}\n"; } } return $code . ' +// Fonction principale du squelette function ' . $nom . '($Cache, $Pile, $doublons, $Numrows="", $SP=0) { ' . $corps . "\n \$t0 = " . $return . ';