From 1d3648321e2636332b731eb7d3f5b281bcf3aa00 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Barrois?= Date: Sun, 10 Oct 2010 20:52:19 +0200 Subject: [PATCH] Replace field for 'networking type' in advanced search (Closes #1251) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Use a list of options instead. Special valued: -1 => Any, 0 => empty Fix UserFilterBuilderFields as well. Signed-off-by: Raphaël Barrois --- include/ufbuilder.inc.php | 7 ++++++- modules/search.php | 6 ++++++ templates/search/adv.form.tpl | 10 ++++++---- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/include/ufbuilder.inc.php b/include/ufbuilder.inc.php index 40c5a74..a28a10a 100644 --- a/include/ufbuilder.inc.php +++ b/include/ufbuilder.inc.php @@ -268,7 +268,7 @@ abstract class UFB_Field return false; } - if (!$this->empty) { + if (!$this->isEmpty()) { $ufc = $this->buildUFC($ufb); if ($ufc != null) { $ufb->addCond($ufc); @@ -1010,6 +1010,11 @@ class UFBF_Networking extends UFBF_Text } } + public function isEmpty() + { + return parent::isEmpty() || $this->nwtype == 0; + } + public function buildUFC(UserFilterBuilder &$ufb) { return new UFC_Networking($this->nwtype, $this->val); diff --git a/modules/search.php b/modules/search.php index 505e5ee..06c729a 100644 --- a/modules/search.php +++ b/modules/search.php @@ -155,6 +155,12 @@ class SearchModule extends PLModule $page->assign('advanced',1); $page->addJsLink('jquery.autocomplete.js'); + $networks = DirEnum::getOptions(DirEnum::NETWORKS); + $networks[-1] = 'Tous types'; + $networks[0] = '-'; + ksort($networks); + $page->assign('networking_types', $networks); + if (!Env::has('rechercher') && $model != 'geoloc') { $this->form_prepare(); } else { diff --git a/templates/search/adv.form.tpl b/templates/search/adv.form.tpl index a9e56a5..ee730a4 100644 --- a/templates/search/adv.form.tpl +++ b/templates/search/adv.form.tpl @@ -205,7 +205,7 @@ }); }); /** Regexps to wipe out from search queries */ -var default_form_values = [ /&woman=0(&|$)/, /&subscriber=0(&|$)/, /&alive=0(&|$)/, /&egal[12]=[^&]*&promo[12]=(&|$)/g, /&[^&=]+=(&|$)/g ]; +var default_form_values = [ /&woman=0(&|$)/, /&subscriber=0(&|$)/, /&alive=0(&|$)/, /&egal[12]=[^&]*&promo[12]=(&|$)/g, /&networking_type=0(&|$)/, /&[^&=]+=(&|$)/g ]; /** Uses javascript to clean form from all empty fields */ function cleanForm(f) { var query = $(f).formSerialize(); @@ -462,9 +462,11 @@ function cleanForm(f) { - - - {icon name="table" title="Tous les types d'adresse"} + -- 2.1.4