From 4f4a49357b8b3461aa58fd07c2c86cc04f774954 Mon Sep 17 00:00:00 2001 From: x2000bedo Date: Tue, 12 Oct 2004 22:16:16 +0000 Subject: [PATCH] Proposed by MadCoder - Closes FS #93 --- htdocs/advanced_search.php | 4 ++-- htdocs/search.php | 4 ++-- include/search.classes.inc.php | 19 ++++++++++++++++++- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/htdocs/advanced_search.php b/htdocs/advanced_search.php index 66ef7db..995ad43 100644 --- a/htdocs/advanced_search.php +++ b/htdocs/advanced_search.php @@ -18,7 +18,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: advanced_search.php,v 1.13 2004-10-12 21:51:58 x2000bedo Exp $ + $Id: advanced_search.php,v 1.14 2004-10-12 22:16:16 x2000bedo Exp $ ***************************************************************************/ require("auto.prepend.inc.php"); @@ -67,7 +67,7 @@ else { $nameField = new RefWithSoundexSField('name',array('rn.nom1_soundex','rn.nom2_soundex','rn.nom3_soundex'),'recherche_soundex','rn','u.matricule = rn.matricule'); $firstnameField = new RefWithSoundexSField('firstname',array('rp.prenom1_soundex','rp.prenom2_soundex'),'recherche_soundex','rp','u.matricule = rp.matricule'); } else { - $nameField = new StringSField('name',array('u.nom','u.epouse'),''); + $nameField = new NameSField('name',array('u.nom','u.epouse'),''); $firstnameField = new StringSField('firstname',array('u.prenom'),''); } $promo1Field = new PromoSField('promo1','egal1',array('u.promo'),''); diff --git a/htdocs/search.php b/htdocs/search.php index dc1f526..5cd1117 100644 --- a/htdocs/search.php +++ b/htdocs/search.php @@ -18,7 +18,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: search.php,v 1.24 2004-10-12 21:51:58 x2000bedo Exp $ + $Id: search.php,v 1.25 2004-10-12 22:16:16 x2000bedo Exp $ ***************************************************************************/ require("auto.prepend.inc.php"); @@ -45,7 +45,7 @@ if (array_key_exists('rechercher', $_REQUEST)) { StringWithSoundexSField('firstname',array('r.prenom1_soundex','r.prenom2_soundex'),''); } else { - $nameField = new StringSField('name',array('r.nom1','r.nom2','r.nom3'),'r.nom1'); + $nameField = new NameSField('name',array('r.nom1','r.nom2','r.nom3'),'r.nom1'); $firstnameField = new StringSField('firstname',array('r.prenom1','r.prenom2'),'r.prenom1'); $with_soundex = ($nameField->length()==0 && $firstnameField->length()==0)?(-1):0; } diff --git a/include/search.classes.inc.php b/include/search.classes.inc.php index 0e81221..6641577 100644 --- a/include/search.classes.inc.php +++ b/include/search.classes.inc.php @@ -18,7 +18,7 @@ * Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * *************************************************************************** - $Id: search.classes.inc.php,v 1.18 2004-10-12 22:00:15 x2000habouzit Exp $ + $Id: search.classes.inc.php,v 1.19 2004-10-12 22:16:19 x2000bedo Exp $ ***************************************************************************/ require_once("xorg.misc.inc.php"); @@ -249,6 +249,23 @@ class StringSField extends SField { } } +/** classe pour les noms : on cherche en plus du like 'foo%' le like '% foo' (particules) ++*/ +class NameSField extends StringSField { + function get_single_where_statement($field) { + $regexp = str_replace('-',' ',$this->value); + $regexp = str_replace('*','%',$regexp); + return "$field LIKE '$regexp%' OR $field LIKE '% $regexp%'"; + } + + function get_order_statement() { + if ($this->value!='' && $this->fieldResultName!='') + return $this->fieldResultName.' NOT LIKE "'.$this->value.'"'; + else + return false; + } +} + /** classe de champ texte avec soundex (nom par exemple) */ class StringWithSoundexSField extends StringSField { -- 2.1.4