X-Git-Url: http://git.cyclocoop.org/?p=velocampus%2Fweb%2Fwww.git;a=blobdiff_plain;f=www%2Fecrire%2Fexec%2Frechercher.php;fp=www%2Fecrire%2Fexec%2Frechercher.php;h=8ff88fe6b345a98180b9ae86629a777fb98fc890;hp=0000000000000000000000000000000000000000;hb=80b4d3e85f78d402ed2e73f8f5d1bf4c19962eed;hpb=aaf970bf4cdaf76689ecc10609048e18d073820c
diff --git a/www/ecrire/exec/rechercher.php b/www/ecrire/exec/rechercher.php
new file mode 100644
index 0000000..8ff88fe
--- /dev/null
+++ b/www/ecrire/exec/rechercher.php
@@ -0,0 +1,137 @@
+ $v)
+ $where[$k] = "'%" . substr(str_replace("%","\%", sql_quote($v)),1,-1) . "%'";
+ $where_titre = ("(titre LIKE " . join(" AND titre LIKE ", $where) . ")");
+ $where_desc = ("(descriptif LIKE " . join(" AND descriptif LIKE ", $where) . ")");
+ $where_id = ("(id_rubrique = " . join(" AND id_rubrique = ", $where) . ")");
+ } else {
+ $where_titre = " 1=2";
+ $where_desc = " 1=2";
+ $where_id = " 1=2";
+ }
+
+ if ($exclus) {
+ include_spip('inc/rubriques');
+ $where_exclus = " AND " . sql_in('id_rubrique', calcul_branche_in($exclus), 'NOT');
+ } else $where_exclus = '';
+
+ $res = sql_select("id_rubrique, id_parent, titre", "spip_rubriques", "$where_id$where_exclus");
+
+ $points = $rub = array();
+
+ while ($row = sql_fetch($res)) {
+ $id_rubrique = $row["id_rubrique"];
+ $rub[$id_rubrique]["titre"] = typo ($row["titre"]);
+ $rub[$id_rubrique]["id_parent"] = $row["id_parent"];
+ $points[$id_rubrique] = $points[$id_rubrique] + 3;
+ }
+ $res = sql_select("id_rubrique, id_parent, titre", "spip_rubriques", "$where_titre$where_exclus");
+
+ while ($row = sql_fetch($res)) {
+ $id_rubrique = $row["id_rubrique"];
+ $rub[$id_rubrique]["titre"] = typo ($row["titre"]);
+ $rub[$id_rubrique]["id_parent"] = $row["id_parent"];
+ if (isset($points[$id_rubrique]))
+ $points[$id_rubrique] += 2;
+ else $points[$id_rubrique] = 0;
+ }
+ $res = sql_select("id_rubrique, id_parent, titre", "spip_rubriques", "$where_desc$where_exclus");
+
+ while ($row = sql_fetch($res)) {
+ $id_rubrique = $row["id_rubrique"];
+ $rub[$id_rubrique]["titre"] = typo ($row["titre"]);
+ $rub[$id_rubrique]["id_parent"] = $row["id_parent"];
+ if (isset($points[$id_rubrique]))
+ $points[$id_rubrique] += 1;
+ else $points[$id_rubrique] = 0;
+ }
+
+ if ($points) {
+ arsort($points);
+ $style = " style='background-image: url(" . chemin_image('secteur-12.gif') . ")'";
+ foreach($rub as $k => $v) {
+ $rub[$k]['atts'] = ($v["id_parent"] ? $style : '')
+ . " class='arial11 petite-rubrique'";
+ }
+ }
+
+ return (proposer_item($points, $rub, $rac, $type, $do));
+}
+
+// Resultat de la recherche interactive demandee par la fonction JS
+// onkey_rechercher qui testera s'il comporte une seule balise au premier niveau
+// car cela qui indique qu'un seul resultat a ete trouve.
+// ==> attention a composer le message d'erreur avec au moins 2 balises
+
+// http://doc.spip.org/@proposer_item
+function proposer_item ($ids, $titles, $rac, $type, $do)
+{
+
+ if (!$ids)
+ return "