$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 = " . intval($type) . ")"); if ($exclus) { include_spip('inc/rubriques'); $where_exclus = " AND " . sql_in('id_rubrique', calcul_branche_in($exclus), 'NOT'); } else { $where_exclus = ''; } foreach (array( 3 => $where_titre, 2 => $where_desc, 1 => $where_id, ) as $point => $recherche) { $res = sql_select("id_rubrique, id_parent, titre", "spip_rubriques", "$recherche$where_exclus"); while ($row = sql_fetch($res)) { $id_rubrique = $row["id_rubrique"]; if (!isset($rub[$id_rubrique])) { $rub[$id_rubrique] = array(); } $rub[$id_rubrique]["titre"] = typo($row["titre"]); $rub[$id_rubrique]["id_parent"] = $row["id_parent"]; if (!isset($points[$id_rubrique])) { $points[$id_rubrique] = 0; } $points[$id_rubrique] = $points[$id_rubrique] + $point; } } } if ($points) { arsort($points); $style = " style='background-image: url(" . chemin_image('secteur-12.png') . ")'"; foreach ($rub as $k => $v) { $rub[$k]['atts'] = ($v["id_parent"] ? $style : '') . " class='petite-rubrique'"; } } return (proposer_item($points, $rub, $rac, $type, $do)); } /** * Résultat de la recherche intéractive demandée par la fonction JS * `onkey_rechercher` * * @note * `onkey_rechercher()` testera s'il comporte une seule balise au premier niveau * car cela qui indique qu'un seul résultat a été trouvé. * * Attention donc à composer le message d'erreur avec au moins 2 balises. * * @param array $ids * @param array|string $titles * @param string|bool $rac * @param string $type * @param string $do * @return string **/ function proposer_item($ids, $titles, $rac, $type, $do) { if (!$ids) { return "

" . 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)"; $ondbClick = "$do(this.firstChild.firstChild.nodeValue,this.firstChild.title,'selection_rubrique', 'id_parent');"; foreach ($ids as $id => $bof) { $titre = strtr(str_replace("'", "’", str_replace('"', """, textebrut($titles[$id]["titre"]))), "\n\r", " "); $ret .= "
  " . $titre . "
"; } return $ret; }