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));
$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());
<?php
+require_once("xorg.misc.inc.php");
+
/** classe qui gère les erreurs dans les requêtes des utilisateurs finaux
* passe le message d'erreur au template de page et exécute le template
*/
}
}
+/** classe de champ texte avec soundex (nom par exemple)
+ */
+class StringWithSoundexSField extends StringSField {
+ /** clause WHERE correspondant à un champ de la bdd et à ce champ de formulaire
+ * @param field nom de champ de la bdd concerné par la clause */
+ function get_single_where_statement($field) {
+ return $field.'="'.soundex_fr($this->value).'"';
+ }
+}
+
/** classe de champ de promotion */
class PromoSField extends SField {
/** opérateur de comparaison (<,>,=) de la promo utilisé pour ce champ de formulaire */
<div class="rubrique">
Résultats
</div>
+ {if $with_soundex==0}
+ <a href="{$smarty.server.PHP_SELF}?public_directory={$public_directory}&with_soundex=1&rechercher=1&{$url_args}">
+ Etendre à la recherche par proximité sonore
+ </a>
+ {/if}
<div class="right">
<a href="{$smarty.server.PHP_SELF}?public_directory={$public_directory}">Nouvelle recherche</a>
</div>
{if $perpage<$nb_resultats_total}
<p>
{if $offset!=0}
- <a href="{$smarty.server.PHP_SELF}?public_directory={$public_directory}&rechercher=1&{$url_args}&offset={$offset-$perpage}">
+ <a href="{$smarty.server.PHP_SELF}?public_directory={$public_directory}&with_soundex={$with_soundex}&rechercher=1&{$url_args}&offset={$offset-$perpage}">
Précédent
</a>
{/if}
{section name=offset loop=$offsets}
{if $offset!=$smarty.section.offset.index*$perpage}
- <a href="{$smarty.server.PHP_SELF}?public_directory={$public_directory}&rechercher=1&{$url_args}&offset={$smarty.section.offset.index*$perpage}">
+ <a href="{$smarty.server.PHP_SELF}?public_directory={$public_directory}&with_soundex={$with_soundex}&rechercher=1&{$url_args}&offset={$smarty.section.offset.index*$perpage}">
{$smarty.section.offset.index+1}
</a>
{else}
{/section}
{if $offset<$nb_resultats_total-$perpage}
- <a href="{$smarty.server.PHP_SELF}?public_directory={$public_directory}&rechercher=1&{$url_args}&offset={$offset+$perpage}">
+ <a href="{$smarty.server.PHP_SELF}?public_directory={$public_directory}&with_soundex={$with_soundex}&rechercher=1&{$url_args}&offset={$offset+$perpage}">
Suivant
</a>