X-Git-Url: http://git.cyclocoop.org/?p=ptitvelo%2Fweb%2Fwww.git;a=blobdiff_plain;f=www%2Fecrire%2Fexec%2Frechercher.php;h=3c630ab416212c69be43b184747ad348a2265a8b;hp=e50229a68899c33ba097509473fee4e3ae6f1966;hb=e847eea4a82a7396dd0abf860f9b30d654f38629;hpb=d686c3e22e97dd46ef42bcd0f138c65083f8f232 diff --git a/www/ecrire/exec/rechercher.php b/www/ecrire/exec/rechercher.php index e50229a..3c630ab 100644 --- a/www/ecrire/exec/rechercher.php +++ b/www/ecrire/exec/rechercher.php @@ -1,5 +1,4 @@ $v) - $where[$k] = "'%" . substr(str_replace("%","\%", sql_quote($v)),1,-1) . "%'"; + if ($where){ + foreach ($where as $k => $v){ + $where[$k] = "'%" . substr(str_replace("%", "\%", sql_quote($v,'','string')), 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_id = ("(id_rubrique = " . intval($type) . ")"); + } else { $where_titre = " 1=2"; $where_desc = " 1=2"; $where_id = " 1=2"; } - if ($exclus) { + if ($exclus){ include_spip('inc/rubriques'); $where_exclus = " AND " . sql_in('id_rubrique', calcul_branche_in($exclus), 'NOT'); - } else $where_exclus = ''; + } 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)) { + while ($row = sql_fetch($res)){ $id_rubrique = $row["id_rubrique"]; - $rub[$id_rubrique]["titre"] = typo ($row["titre"]); + $rub[$id_rubrique]["titre"] = typo($row["titre"]); $rub[$id_rubrique]["id_parent"] = $row["id_parent"]; - $points[$id_rubrique] = $points[$id_rubrique] + 3; + $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)) { + while ($row = sql_fetch($res)){ $id_rubrique = $row["id_rubrique"]; - $rub[$id_rubrique]["titre"] = typo ($row["titre"]); + $rub[$id_rubrique]["titre"] = typo($row["titre"]); $rub[$id_rubrique]["id_parent"] = $row["id_parent"]; if (isset($points[$id_rubrique])) - $points[$id_rubrique] += 2; + $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)) { + while ($row = sql_fetch($res)){ $id_rubrique = $row["id_rubrique"]; - $rub[$id_rubrique]["titre"] = typo ($row["titre"]); + $rub[$id_rubrique]["titre"] = typo($row["titre"]); $rub[$id_rubrique]["id_parent"] = $row["id_parent"]; if (isset($points[$id_rubrique])) - $points[$id_rubrique] += 1; + $points[$id_rubrique] += 1; else $points[$id_rubrique] = 0; } - if ($points) { + if ($points){ arsort($points); $style = " style='background-image: url(" . chemin_image('secteur-12.png') . ")'"; - foreach($rub as $k => $v) { + foreach ($rub as $k => $v){ $rub[$k]['atts'] = ($v["id_parent"] ? $style : '') - . " class='petite-rubrique'"; + . " class='petite-rubrique'"; } } @@ -101,35 +99,34 @@ function exec_rechercher_args($id, $type, $exclus, $rac, $do) // ==> 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) -{ +function proposer_item($ids, $titles, $rac, $type, $do){ if (!$ids) return "

" - .spip_htmlentities($type) - ." : "._T('avis_aucun_resultat')."
"; + . spip_htmlentities($type) + . " : " . _T('avis_aucun_resultat') . ""; $ret = ''; $info = generer_url_ecrire('informer', "type=rubrique&rac=$rac&id="); - $onClick = "aff_selection(this.firstChild.title,'$rac". "_selection','$info', event)"; + $onClick = "aff_selection(this.firstChild.title,'$rac" . "_selection','$info', event)"; $ondbClick = "$do(this.firstChild.firstChild.nodeValue,this.firstChild.title,'selection_rubrique', 'id_parent');"; - foreach($ids as $id => $bof) { - + foreach ($ids as $id => $bof){ + $titre = strtr(str_replace("'", "’", str_replace('"', """, textebrut($titles[$id]["titre"]))), "\n\r", " "); $ret .= "
  " - . $titre - . "
"; + . $onClick + . "\"\nondblclick=\"" + . $ondbClick + . $onClick + . " \">  " + . $titre + . ""; } return $ret; }