From fd7bef1be8dbdb132da686c071d80ceebef2897c Mon Sep 17 00:00:00 2001
From: "Committo,Ergo:sum" <esj@rezo.net>
Date: Sun, 18 Jul 2004 23:46:40 +0000
Subject: [PATCH] Gestion propre de #POINTS

---
 inc-index-squel.php3 |  4 ++--
 inc-vrac-squel.php3  | 35 +++++++++++++++++++++++++++++++----
 2 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/inc-index-squel.php3 b/inc-index-squel.php3
index 56b36767a5..4254aa665f 100644
--- a/inc-index-squel.php3
+++ b/inc-index-squel.php3
@@ -34,12 +34,12 @@ function index_pile($idb, $nom_champ, &$boucles)
     $t = $table_des_tables[$r];
     if (!$t) $t = $r; // pour les tables non Spip
     // $t est le nom PHP de cette table 
-    spip_log("'$idb' '$r' '$c' '$nom_champ'");
+#    spip_log("'$idb' '$r' '$c' '$nom_champ'");
     $x = $tables_principales[$t];
     if (!$x) 
     {
       include_local("inc-debug-squel.php3");
-      erreur_squelette("Table SQL absente de \$tables_principales dans inc_serialbase", $r, $idb);
+      erreur_squelette(_L("Table SQL absente de \$tables_principales dans inc_serialbase"), $r, $idb);
     }
 
     $a = $x['field'];
diff --git a/inc-vrac-squel.php3 b/inc-vrac-squel.php3
index 3ee796b25a..bc2ed802f6 100644
--- a/inc-vrac-squel.php3
+++ b/inc-vrac-squel.php3
@@ -140,6 +140,37 @@ function calculer_champ_divers($fonctions, $nom_champ, $id_boucle, &$boucles, $i
 #	spip_log("TOTAL_BOUCLE: $id_boucle dans $id_mere");
 		break;
 
+  case 'POINTS':
+	  $n = 0;
+	  $b = $id_boucle;
+	  $code = '';
+	  while ($b != '')
+	    {
+	      if ($s = 	$boucles[$b]->param)
+		{
+		  foreach($s as $v)
+		    {
+		      if (strpos($v,'recherche') !== false)
+			{
+			  $code = '$PileROW[$SP' . (($n==0) ? "" : "-$n") .
+			    '][points]';
+			  $b = '';
+			  break;
+			}
+		      }
+		}
+
+	      $n++;
+	      $b = $boucles[$b]->id_parent;
+	    }
+	  if (!$code) 
+	    {
+	      include_local("inc-debug-squel.php3");
+	      erreur_squelette(_L("Champ #POINTS hors d'une recherche"), '', $idb);
+	    }
+
+		break;
+
   case 'POPULARITE_ABSOLUE':
 		$code = 'ceil(' .
 		  index_pile($id_boucle,  "popularite", $boucles) .
@@ -272,10 +303,6 @@ function calculer_champ_divers($fonctions, $nom_champ, $id_boucle, &$boucles, $i
     return calculer_champ_LOGO($fonctions, $nom_champ, $id_boucle, $boucles, $id_mere);
     break; 
 
-case 'POINTS':
-	$code = '$PileRow[$SP]["points"]';
-	break;
-
   default:
 	  // champ inconnu. Il s'auto-de'note.
 	    $code = "'#$nom_champ'";
-- 
GitLab