Skip to content
Extraits de code Groupes Projets
Valider 92c4e991 rédigé par Fil's avatar Fil
Parcourir les fichiers

Correction $meta

Introduction d'un moteur de rech en texte integral dans la page recherche.php3
(en deuxième rideau).
Pour que la recherche s'applique aux auteurs, il manque une fonction afficher_auteurs() du type de afficher_articles()... à suivre.
parent 730e2417
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -68,8 +68,8 @@ if ($changer_config == 'oui') {
'activer_syndic',
'visiter_sites'
);
while (list(,$meta) = each($liste_meta))
if ($$meta) ecrire_meta($meta, $$meta);
while (list(,$i) = each($liste_meta))
if ($$i) ecrire_meta($i, $$i);
ecrire_metas();
if ($purger_skel) {
......
......@@ -256,4 +256,45 @@ function creer_liste_indexation() {
}
}
// cree la requete pour une recherche en txt integral
function requete_txt_integral($objet, $hash_recherche) {
if ($objet == 'syndic') {
$table = "spip_".$objet;
$index_table = "spip_index_".$objet;
} else {
$table = "spip_".$objet."s";
$index_table = "spip_index_".$objet."s";
}
$id_objet = "id_".$objet;
return "SELECT objet.*, SUM(idx.points) AS points
FROM $table AS objet, $index_table AS idx
WHERE objet.$id_objet = idx.$id_objet
AND idx.hash IN ($hash_recherche)
GROUP BY objet.$id_objet
ORDER BY points DESC
LIMIT 0,10";
}
// decode la chaine recherchee et la traduit en hash
function requete_hash ($rech) {
$s = nettoyer_chaine_indexation(urldecode($rech));
$regs = separateurs_indexation()." ";
$s = split("[$regs]+", $s);
while (list(, $val) = each($s))
if (strlen($val) > 3)
$dico[] = "dico LIKE \"$val%\"";
if ($dico) {
$query2 = "SELECT HEX(hash) AS hx FROM spip_index_dico WHERE ".join(" OR ", $dico);
$result2 = spip_query($query2);
while ($row2 = mysql_fetch_array($result2))
$h[] = "0x".$row2["hx"];
}
if ($h)
$hash_recherche = join(",", $h);
else
$hash_recherche = "0";
return $hash_recherche;
}
?>
\ No newline at end of file
......@@ -11,9 +11,14 @@ debut_gauche();
debut_droite();
if ($rech) $recherche = '';
echo "<FONT FACE='Verdana,Arial,Helvetica,sans-serif'><B>R&eacute;sultats de la recherche :</B><BR>";
echo "<FONT SIZE=5 COLOR='$couleur_foncee'><B>".typo($recherche)."</B></FONT><BR>";
echo "<FONT SIZE=2>(recherche sur les titres des articles et br&egrave;ves, ou sur leur num&eacute;ro)</FONT></FONT><P>";
echo "<FONT SIZE=5 COLOR='$couleur_foncee'><B>".typo($recherche.$rech)."</B></FONT><BR>";
if ($recherche)
echo "<FONT SIZE=2>(recherche sur les titres des articles et br&egrave;ves, ou sur leur num&eacute;ro)</FONT></FONT><P>";
else
echo "<FONT SIZE=2>(recherche en texte int&eacute;gral)</FONT></FONT><P>";
$query_articles = "SELECT spip_articles.id_article, surtitre, titre, soustitre, descriptif, chapo, date, visites, id_rubrique, statut FROM spip_articles WHERE";
$query_breves = "SELECT * FROM spip_breves WHERE ";
......@@ -23,24 +28,51 @@ if (ereg("^[0-9]+$", $recherche)) {
$query_breves .= " (id_breve = $recherche) OR ";
}
$recherche = split("[[:space:]]+", addslashes($recherche));
if ($recherche) {
$where = " (titre LIKE '%".join("%' AND titre LIKE '%", $recherche)."%') ";
}
else {
$rech2 = split("[[:space:]]+", addslashes($recherche));
if ($rech2)
$where = " (titre LIKE '%".join("%' AND titre LIKE '%", $rech2)."%') ";
else
$where = " 1=2";
}
$query_articles .= " $where ORDER BY maj DESC";
$query_breves .= " $where ORDER BY maj DESC LIMIT 0,10";
$nb_articles = afficher_articles("Articles trouv&eacute;s", $query_articles);
$nb_breves = afficher_breves("Br&egrave;ves trouv&eacute;es", $query_breves);
if (!$nb_articles AND !$nb_breves) {
if ($rech) // texte integral
{
include_ecrire ('inc_index.php3');
$hash_recherche = requete_hash ($rech);
$query_articles = requete_txt_integral('article', $hash_recherche);
$query_breves = requete_txt_integral('breve', $hash_recherche);
$query_rubriques = requete_txt_integral('rubrique', $hash_recherche);
// $query_auteurs = requete_txt_integral('auteur', $hash_recherche);
$query_sites = requete_txt_integral('syndic', $hash_recherche);
}
if ($query_articles)
$nba = afficher_articles ("Articles trouv&eacute;s", $query_articles);
if ($query_breves)
$nbb = afficher_breves ("Br&egrave;ves trouv&eacute;es", $query_breves);
if ($query_rubriques)
$nbr = afficher_rubriques ("Rubriques trouv&eacute;es", $query_rubriques);
// if ($query_sites)
// $nbt = afficher_auteurs ("Auteurs trouv&eacute;s", $query_auteurs);
if ($query_sites)
$nbs = afficher_sites ("Sites trouv&eacute;s", $query_sites);
if (!$nba AND !$nbb AND !$nbr AND !$nbt AND !$nbs) {
echo "<FONT FACE='Verdana,Arial,Helvetica,sans-serif'>Aucun r&eacute;sultat.</FONT><P>";
}
if (lire_meta('activer_moteur') == 'oui') {
debut_cadre_relief();
echo "<form action='recherche.php3' method='get'>";
echo "<p>Recherche en texte int&eacute;gral :<br>";
echo "<input type='text' name='rech' value='$recherche$rech'>";
echo "</form>";
fin_cadre_relief();
}
echo "<p>";
fin_page();
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter