From 134388db115125b2dbb673ea28198859f60973aa Mon Sep 17 00:00:00 2001 From: "Pierre Habouzit (MadCoder" Date: Fri, 3 Dec 2004 10:14:52 +0000 Subject: [PATCH] =?utf8?q?better=20heuristic.=20now=20we=20find=20=ABt=20x?= =?utf8?q?=20m=BB=20or=20=ABf=20x=20m=BB=20in=20the=20first=20place?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-22 --- htdocs/search.php | 2 +- include/search.classes.inc.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/search.php b/htdocs/search.php index 871e2a4..c3fd7e5 100644 --- a/htdocs/search.php +++ b/htdocs/search.php @@ -54,7 +54,7 @@ if (isset($_REQUEST['quick'])) { LEFT JOIN watch_nonins AS w ON (w.ni_id=u.user_id AND w.uid='.((array_key_exists('uid',$_SESSION))?$_SESSION['uid']:0).') '.$globals->search->result_where_statement.' WHERE '.$fields->get_where_statement().' - HAVING mark>0 + HAVING mark>=10 ORDER BY '.(logged() && !empty($_REQUEST['mod_date_sort']) ? 'date DESC,' :'') .implode(',',array_filter(array($fields->get_order_statement(), 'u.promo DESC, NomSortKey, prenom'))).' LIMIT '.$offset->value.','.$globals->search->per_page; diff --git a/include/search.classes.inc.php b/include/search.classes.inc.php index 2e2889d..2208eed 100644 --- a/include/search.classes.inc.php +++ b/include/search.classes.inc.php @@ -278,11 +278,13 @@ class QuickSearch extends SField function get_mark_statement() { if (empty($this->strings)) { - return "1 AS mark"; + return "10 AS mark"; } $order = "0"; foreach ($this->strings as $s) { - $order .= " + (u.nom='$s' OR u.epouse='$s')*100 + (u.prenom='$s')*10 + (u.nom LIKE '$s%' OR u.epouse LIKE '$s%')"; + $order .= " + ( (u.nom='$s' OR u.epouse='$s') + (CONCAT(' ',u.nom,' ',u.epouse,' ') RLIKE '[ \\-]{$s}[ \\-]') )*100 + + ( u.nom LIKE '$s%' OR u.epouse LIKE '$s%' )*10 + + ( u.prenom LIKE '$s%' OR u.prenom LIKE '% $s%' OR u.prenom LIKE '%-$s%' )"; } return $order.' AS mark'; } -- 2.1.4