Update of /home/spip-cvs/spip
In directory alan:/tmp/cvs-serv23586
Modified Files:
inc-criteres.php3
Log Message:
analyser chaque item dans le critere IN 1 #ID_ARTICLE etc (Paolo)
Index: inc-criteres.php3
RCS file: /home/spip-cvs/spip/inc-criteres.php3,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- inc-criteres.php3 8 Sep 2004 12:10:55 -0000 1.7
+++ inc-criteres.php3 9 Sep 2004 10:24:31 -0000 1.8
@@ -381,6 +381,7 @@
// Restriction de valeurs (implicite ou explicite)
else if (eregi('^([a-z_]+\(?[a-z_]*\)?) *(\??)((!?)(<=?|>=?|==?|IN) *"?([^<>=!"]*))?"?$', $param, $match)) {
+ $op = $match[5];
// Variable comparee
$col = $match[1];
$fct = '';
@@ -392,10 +393,25 @@
$col_table = $id_table;
// Valeur de comparaison
if ($match[3]) {
- $val = calculer_param_dynamique($match[6], $boucles, $idb);
- // erreur
- if (is_array($val)) return $val;
-
+ if (strtoupper($op) != 'IN') {
+ $val = calculer_param_dynamique($match[6], $boucles, $idb);
+ if (is_array($val)) return $val;
+ }
+ else {
+ // traitement special des valeurs textuelles
+ ereg("^ *\(?(.*[^)])\)? *$",$match[6], $val2);
+ spip_log($match[6] . ' ' . $val2[1]);
+ $val2 = split(" *, *", $val2[1]);
+ foreach ($val2 as $v) {
+ $v = calculer_param_dynamique($v, $boucles, $idb);
+ if (is_array($v)) return $v;
+ if (strpos('"0123456789',$v[0]) !== false)
+ $val3[] = $v;
+ else
+ $val3[] = "'$v'";
+ }
+ $val = join(',', $val3);
+ }
}
else {
@@ -532,22 +548,13 @@
$boucle->plat = true;
// Operateur de comparaison
- $op = $match[5];
+
if (!$op)
$op = '=';
else if ($op == '==')
$op = 'REGEXP';
else if (strtoupper($op) == 'IN') {
// traitement special des valeurs textuelles
- $val2 = split(",", $val);
- foreach ($val2 as $v) {
- $v = trim($v);
- if (ereg("^[0-9]+$",$v))
- $val3[] = $v;
- else
- $val3[] = "'$v'";
- }
- $val = join(',', $val3);
$where = "$col IN ($val)";
if ($match[4] == '!') {
$where = "NOT ($where)";