X-Git-Url: http://git.cyclocoop.org/?p=lhc%2Fweb%2Fwww.git;a=blobdiff_plain;f=www%2Fecrire%2Finc%2Frechercher.php;h=28bcbc309c6f1fcdd42dd8673629d45142d314eb;hp=858137f8165071201cb7a58b364a1250e25e093c;hb=122c920eb07e3f665789f8734965b576e6c25515;hpb=226942065cd4f604eb464addf45a065c9e5bc916 diff --git a/www/ecrire/inc/rechercher.php b/www/ecrire/inc/rechercher.php index 858137f8..28bcbc30 100644 --- a/www/ecrire/inc/rechercher.php +++ b/www/ecrire/inc/rechercher.php @@ -3,7 +3,7 @@ /***************************************************************************\ * SPIP, Systeme de publication pour l'internet * * * - * Copyright (c) 2001-2012 * + * Copyright (c) 2001-2014 * * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * * * * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * @@ -70,9 +70,21 @@ function expression_recherche($recherche, $options) { } else{ // s'il y a plusieurs mots il faut les chercher tous : oblige REGEXP + // sauf ceux de moins de 4 lettres (on supprime ainsi 'le', 'les', 'un', + // 'une', 'des' ...) if (preg_match(",\s+,".$u, $recherche)){ $is_preg = true; - $recherche = preg_replace(',\s+,'.$u, '|', $recherche); + $recherche_inter = '|'; + $recherche_mots = explode(' ', $recherche); + $min_long = defined('_RECHERCHE_MIN_CAR') ? _RECHERCHE_MIN_CAR : 4; + foreach ($recherche_mots as $mot) { + if (strlen($mot) >= $min_long) { + $recherche_inter .= $mot.' '; + } + } + // mais on cherche quand même l'expression complète, même si elle + // comporte des mots de moins de quatre lettres + $recherche = rtrim($recherche.preg_replace(',\s+,'.$u, '|', $recherche_inter), '|'); } $preg = '/'.str_replace('/', '\\/', $recherche).'/' . $options['preg_flags'];