From 6faa01866d4ce153ec9f8a3895eed3791a4edd23 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Barrois?= Date: Sat, 6 Feb 2010 10:38:20 +0100 Subject: [PATCH] Make emptiness info of UFBs available ; add Mentor-related UFBs MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphaël Barrois --- include/ufbuilder.inc.php | 71 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/include/ufbuilder.inc.php b/include/ufbuilder.inc.php index d299d74..a435cac 100644 --- a/include/ufbuilder.inc.php +++ b/include/ufbuilder.inc.php @@ -73,6 +73,17 @@ class UserFilterBuilder return $this->valid; } + public function isEmpty() + { + $this->buildUFC(); + foreach ($this->fields as $field) { + if (! $field->isEmpty()) { + return false; + } + } + return true; + } + /** Returns the built UFC * @return The UFC, or PFC_False() if an error happened */ @@ -171,6 +182,22 @@ class UFB_AdvancedSearch extends UserFilterBuilder } // }}} +// {{{ class UFB_MentorSearch +class UFB_MentorSearch extends UserFilterBuilder +{ + public function __construct($envprefix = '') + { + $fields = array( + new UFBF_MentorCountry('pays_sel'), + new UFBF_MentorSectorization('sector', '', UFC_Mentor_Sectorization::SECTOR), + new UFBF_MentorSectorization('subSector', '', UFC_Mentor_Sectorization::SUBSECTOR), + new UFBF_MentorExpertise('expertise'), + ); + parent::__construct($fields, $envprefix); + } +} +// }}} + // {{{ class UFB_Field abstract class UFB_Field { @@ -219,6 +246,11 @@ abstract class UFB_Field return true; } + public function isEmpty() + { + return $this->empty; + } + /** Create the UFC associated to the field; won't be called * if the field is "empty" * @param &$ufb UFB to which fields must be added @@ -311,6 +343,7 @@ abstract class UFBF_Index extends UFB_Field if (!$ufb->has($this->envfield)) { $this->empty = true; } + $this->val = $ufb->i($this->envfield); return true; } } @@ -981,4 +1014,42 @@ class UFBF_Networking extends UFBF_Text } } // }}} + +// {{{ class UFBF_MentorCountry +class UFBF_MentorCountry extends UFBF_Index +{ + protected function buildUFC(UserFilterBuilder &$ufb) + { + return new UFC_Mentor_Country($this->val); + } +} +// }}} + +// {{{ class UFBF_MentorSectorization +class UFBF_MentorSectorization extends UFBF_Index +{ + protected $type; + + public function __construct($envfield, $formtext = '', $type = UFC_Mentor_Sectorization::SECTOR) + { + parent::__construct($envfield, $formtext); + $this->type = $type; + } + + protected function buildUFC(UserFilterBuilder &$ufb) + { + return new UFC_Mentor_Sectorization($this->val, $this->type); + } +} +// }}} + +// {{{ class UFBF_MentorExpertise +class UFBF_MentorExpertise extends UFBF_Text +{ + protected function buildUFC(UserFilterBuilder &$ufb) + { + return new UFC_Mentor_Expertise($this->val); + } +} +// }}} ?> -- 2.1.4