From ac17630a8671efd1b7e4f67979268140f9b3eb6e Mon Sep 17 00:00:00 2001 From: Fil <fil@rezo.net> Date: Sun, 25 Jul 2004 09:50:26 +0000 Subject: [PATCH] =?UTF-8?q?optimisation=20et=20r=C3=A9paration=20des=20cri?= =?UTF-8?q?t=C3=A8res=20optionnels=20{branche=3F}=20{lang=3F}=20etc.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc-arg-squel.php3 | 26 ++++++++++++++++---------- inc-calcul-squel.php3 | 4 +++- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/inc-arg-squel.php3 b/inc-arg-squel.php3 index 0818fe3cba..bb960e2dcf 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 a8df158710..22a96c2615 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 . '; -- GitLab