diff --git a/ecrire/inc/indexation.php b/ecrire/inc/indexation.php index e325cd48be705e2b669f95d4e132bb17cf4df300..ca50582ec492756a50def1959090ca4bf8ac4ce6 100644 --- a/ecrire/inc/indexation.php +++ b/ecrire/inc/indexation.php @@ -885,6 +885,12 @@ function requete_hash ($rech) { function prepare_recherche($recherche, $primary = 'id_article', $id_table='articles',$nom_table='spip_articles', $cond=false) { static $cache = array(); static $fcache = array(); + + // si recherche n'est pas dans le contexte, on va prendre en globals + // ca permet de faire des inclure simple. + if (!isset($recherche) AND isset($GLOBALS['recherche'])) + $recherche = $GLOBALS['recherche']; + // traiter le cas {recherche?} if ($cond AND !strlen($recherche)) return array("''" /* as points */, /* where */ '1'); diff --git a/ecrire/public/balises.php b/ecrire/public/balises.php index a3a7007a7749e0fd7e3755eff1f41a86ca5c736c..710e7523332ebaa7d414e743c541be97ad019d47 100644 --- a/ecrire/public/balises.php +++ b/ecrire/public/balises.php @@ -347,10 +347,7 @@ function balise_TOTAL_BOUCLE_dist($p) { // Si on est hors d'une boucle {recherche}, ne pas "prendre" cette balise // http://doc.spip.org/@balise_POINTS_dist function balise_POINTS_dist($p) { - if ($p->boucles[$p->nom_boucle ? $p->nom_boucle : $p->id_boucle]->hash) - return rindex_pile($p, 'points', 'recherche'); - else - return NULL; + return rindex_pile($p, 'points', 'recherche'); } // http://doc.spip.org/@balise_POPULARITE_ABSOLUE_dist diff --git a/ecrire/public/criteres.php b/ecrire/public/criteres.php index 089e58d1fb24b40641114f26fdab524e13e13144..b00bc629368538440ed54f17630386c570438ccc 100644 --- a/ecrire/public/criteres.php +++ b/ecrire/public/criteres.php @@ -130,7 +130,7 @@ function critere_fragment_dist($idb, &$boucles, $crit) { } -// {recherche} +// {recherche} ou {recherche susan} // http://www.spip.net/@recherche // http://doc.spip.org/@critere_recherche_dist function critere_recherche_dist($idb, &$boucles, $crit) { @@ -140,10 +140,15 @@ function critere_recherche_dist($idb, &$boucles, $crit) { if (in_array($t,$table_des_tables)) $t = "spip_$t"; + if (isset($crit->param[0])) + $quoi = calculer_liste($crit->param[0], array(), $boucles, $boucles[$idb]->id_parent); + else + $quoi = '$Pile[0]["recherche"]'; + // Ne pas executer la requete en cas de hash vide $boucle->hash = ' // RECHERCHE - list($rech_select, $rech_where) = prepare_recherche($GLOBALS["recherche"], "'.$boucle->primary.'", "'.$boucle->id_table.'", "'.$t.'", "'.$crit->cond.'"); + list($rech_select, $rech_where) = prepare_recherche('.$quoi.', "'.$boucle->primary.'", "'.$boucle->id_table.'", "'.$t.'", "'.$crit->cond.'"); '; // Sauf si le critere est conditionnel {recherche ?} @@ -701,7 +706,7 @@ function calculer_critere_infixe($idb, &$boucles, $crit) { else if (($col == 'id_secteur')&& ($type == 'forums')) { $table = critere_secteur_forum($idb, $boucles, $val, $crit); } - + // Cas particulier : expressions de date else if ($table_date[$type] AND preg_match(",^((age|jour|mois|annee)_relatif|date|mois|annee|jour|heure|age)(_[a-z]+)?$,", diff --git a/ecrire/public/references.php b/ecrire/public/references.php index 225bdefd6d844b343ff24f7fd34b5338b4379374..a123fa54676da28c4be3e794b597a0d8cee146d0 100644 --- a/ecrire/public/references.php +++ b/ecrire/public/references.php @@ -546,25 +546,22 @@ function rindex_pile($p, $champ, $motif) $b = $p->id_boucle; $p->code = ''; while ($b != '') { - if ($s = $p->boucles[$b]->param) { - foreach($s as $v) { - if (strpos($v[1][0]->texte,$motif) !== false) { - $p->code = '$Pile[$SP' . (($n==0) ? "" : "-$n") . - "]['$champ']"; - $b = ''; - break; + foreach($p->boucles[$b]->criteres as $critere) { + if ($critere->op == $motif) { + $p->code = '$Pile[$SP' . (($n==0) ? "" : "-$n") . + "]['$champ']"; + $b = ''; + break 2; + } } - } - } - $n++; - $b = $p->boucles[$b]->id_parent; - } - if (!$p->code) { - erreur_squelette(_T('zbug_champ_hors_motif', - array('champ' => '#' . strtoupper($champ), - 'motif' => $motif) - ), $p->id_boucle); + $n++; + $b = $p->boucles[$b]->id_parent; } + + // si on est hors d'une boucle de {recherche}, cette balise est vide + if (!$p->code) + $p->code = "''"; + $p->interdire_scripts = false; return $p; }