From: x2000bedo Date: Thu, 5 Aug 2004 23:17:17 +0000 (+0000) Subject: Ajout de l'option de recherche par proximité sonore X-Git-Tag: xorg/old~1770 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=f1af0588603aedf55eef85093ad59c65b3ea3bde;p=platal.git Ajout de l'option de recherche par proximité sonore Sous forme d'extension des résultats si on n'est pas satisfait => on satisfait à la fois JMY et tous les utilisateurs qui sont gênés par la quantité de résultats générés par la proximité sonore --- diff --git a/htdocs/search.php b/htdocs/search.php index c3732f1..ed7b965 100644 --- a/htdocs/search.php +++ b/htdocs/search.php @@ -12,8 +12,17 @@ $page->assign('public_directory',$public_directory); if (array_key_exists('rechercher', $_REQUEST)) { $page->assign('formulaire',0); - $nameField = new StringSField('name',array('u.nom','u.epouse','i.nom'),'i.nom'); - $firstnameField = new StringSField('firstname',array('u.prenom','i.prenom'),'i.prenom'); + $with_soundex = ((isset($_REQUEST['with_soundex']) && $_REQUEST['with_soundex']==1)); + + if ($with_soundex) { + $nameField = new StringWithSoundexSField('name',array('u.nom_soundex','u.epouse_soundex','i.nom_soundex'),'i.nom'); + $firstnameField = new StringWithSoundexSField('firstname',array('u.prenom_soundex','i.prenom_soundex'),'i.prenom'); + } + else { + $nameField = new StringSField('name',array('u.nom','u.epouse','i.nom'),'i.nom'); + $firstnameField = new StringSField('firstname',array('u.prenom','i.prenom'),'i.prenom'); + $with_soundex = ($nameField->length()==0 && $firstnameField->length()==0)?(-1):0; + } $promo1Field = new PromoSField('promo1','egal1',array('u.promo','i.promo'),'i.promo'); $promo2Field = new PromoSField('promo2','egal2',array('u.promo','i.promo'),'i.promo'); $fields = new SFieldGroup(true,array($nameField,$firstnameField,$promo1Field,$promo2Field)); @@ -52,6 +61,7 @@ if (array_key_exists('rechercher', $_REQUEST)) { $nbpages = ($page->get_template_vars('nb_resultats_total')-1)/$globals->search_results_per_page; $page->assign('offsets',range(0,$nbpages)); $page->assign('url_args',$fields->get_url()); + $page->assign('with_soundex',$with_soundex); $page->assign('offset',$offset->value); $page->assign('perpage',$globals->search_results_per_page); $page->assign('is_admin',has_perms()); diff --git a/include/search.classes.inc.php b/include/search.classes.inc.php index 49f188f..ee83b5a 100644 --- a/include/search.classes.inc.php +++ b/include/search.classes.inc.php @@ -1,4 +1,6 @@ value).'"'; + } +} + /** classe de champ de promotion */ class PromoSField extends SField { /** opérateur de comparaison (<,>,=) de la promo utilisé pour ce champ de formulaire */ diff --git a/templates/search.tpl b/templates/search.tpl index f92a06c..444fc05 100644 --- a/templates/search.tpl +++ b/templates/search.tpl @@ -3,6 +3,11 @@
Résultats
+ {if $with_soundex==0} + + Etendre à la recherche par proximité sonore + + {/if}
Nouvelle recherche
@@ -22,14 +27,14 @@ {if $perpage<$nb_resultats_total}

{if $offset!=0} - + Précédent   {/if} {section name=offset loop=$offsets} {if $offset!=$smarty.section.offset.index*$perpage} - + {$smarty.section.offset.index+1} {else} @@ -38,7 +43,7 @@   {/section} {if $offset<$nb_resultats_total-$perpage} - + Suivant