private $score = null;
private $quick = false;
- public function __construct($quick = false, $no_search = false, PlFilterCondition $cond = null)
+ public function __construct($quick = false, PlFilterCondition $cond = null)
{
if ($no_search) {
return;
$this->quick = $quick;
if (is_null($cond)) {
- $this->conds = new PFC_And();
+ $conds = new PFC_And();
} else if ($cond instanceof PFC_And) {
- $this->conds = $cond;
+ $conds = $cond;
} else {
- $this->conds = new PFC_And($cond);
+ $conds = new PFC_And($cond);
}
if ($quick) {
- $this->getQuick();
+ $this->getQuick($conds);
} else {
- $this->getAdvanced();
+ $this->getAdvanced($conds);
}
}
- private function getQuick()
+ /** Sets up the conditions for a Quick Search
+ * @param $conds Additional conds (as a PFC_And)
+ */
+ private function getQuick($conds)
{
if (!S::logged()) {
Env::kill('with_soundex');
}
$ufc = $ufb->getUFC();
- $this->conds->addChild($ufc);
+ $conds->addChild($ufc);
$orders = $ufb->getOrders();
if (S::logged() && Env::has('nonins')) {
- $this->conds = new PFC_And($this->conds,
+ $conds = new PFC_And($conds,
new PFC_Not(new UFC_Dead()),
new PFC_Not(new UFC_Registered())
);
}
- parent::__construct($this->conds, $orders);
+ parent::__construct($conds, $orders);
}
- private function getAdvanced()
+ /** Sets up the conditions for an Advanced Search
+ * @param $conds Additional conds (as a PFC_And)
+ */
+ private function getAdvanced($conds)
{
$this->advanced = true;
require_once 'ufbuilder.inc.php';
return;
}
- $this->conds->addChild($ufb->getUFC());
+ $ufc = $ufb->getUFC();
+ $conds->addChild($ufc);
+
+ $orders = $ufb->getOrders();
+
+ parent::__construct($conds, $orders);
}
protected function &getFilterResults(PlFilter &$pf, PlLimit $limit)
}
}
+/** Simple set based on an array of User objects
+ */
class ArraySet extends ProfileSet
{
public function __construct(array $users)
}
}
+/** A multipage view for profiles
+ * Allows the display of bounds when sorting by name or promo.
+ */
abstract class ProfileView extends MultipageView
{
protected function getBoundValue($obj)
}
}
+/** An extended multipage view for profiles, as minifiches.
+ * Allows to sort by:
+ * - score (for a search query)
+ * - name
+ * - promo
+ * - latest modification
+ *
+ * Paramaters for this view are:
+ * - with_score: whether to allow ordering by score (set only for a quick search)
+ * - starts_with: show only names beginning with the given letter
+ */
class MinificheView extends ProfileView
{
- public function __construct(PlSet &$set, $data, array $params)
+ public function __construct(PlSet &$set, array $params)
{
- require_once 'education.func.inc.php';
global $globals;
$this->entriesPerPage = $globals->search->per_page;
if (@$params['with_score']) {
new UFO_Promo(UserFilter::DISPLAY, true),
new UFO_Name(Profile::DN_SORT),
), 'dernière modification'));
- parent::__construct($set, $data, $params);
+ parent::__construct($set, $params);
+ }
+
+ public function apply(PlPage &$page)
+ {
+ if (array_key_exists('starts_with', $this->params)
+ && $this->params['starts_with'] != ""
+ && $this->params['starts_with'] != null) {
+
+ $this->set->addCond(
+ new UFC_Name(Profile::LASTNAME,
+ $this->params['starts_with'], UFC_Name::PREFIX)
+ );
+ }
+ return parent::apply($page);
}
public function templateName()
class MentorView extends ProfileView
{
- public function __construct(PlSet &$set, $data, array $params)
+ public function __construct(PlSet &$set, array $params)
{
$this->entriesPerPage = 10;
$this->addSort(new PlViewOrder('rand', array(new PFO_Random(S::i('uid'))), 'aléatoirement'));
new UFO_Promo(UserFilter::DISPLAY, true),
new UFO_Name(Profile::DN_SORT),
), 'dernière modification'));
- parent::__construct($set, $data, $params);
+ parent::__construct($set, $params);
}
public function templateName()
class TrombiView extends ProfileView
{
- public function __construct(PlSet &$set, $data, array $params)
+ public function __construct(PlSet &$set, array $params)
{
$this->entriesPerPage = 24;
$this->defaultkey = 'name';
new UFO_Promo(UserFilter::DISPLAY, true),
new UFO_Name(Profile::DN_SORT),
), 'promotion'));
- parent::__construct($set, $data, $params);
+ parent::__construct($set, $params);
}
public function templateName()
class GadgetView implements PlView
{
- public function __construct(PlSet &$set, $data, array $params)
+ public function __construct(PlSet &$set, array $params)
{
$this->set =& $set;
}
Platal::page()->assign('formulaire',1);
}
- function handler_quick(&$page, $action = null, $subaction = null)
+ /**
+ * $model: The way of presenting the results: minifiche, trombi, geoloc.
+ * $byletter: Show only names beginning with this letter
+ */
+ function handler_quick(&$page, $model = null, $byletter = null)
{
global $globals;
- if (Env::has('quick') || $action == 'geoloc') {
+ if (Env::has('quick') || $model == 'geoloc') {
$quick = Env::t('quick');
if (S::logged() && !Env::has('page')) {
S::logger()->log('search', 'quick=' . $quick);
$page->assign('formulaire', 0);
require_once 'userset.inc.php';
- $view = new SearchSet(true, $action == 'geoloc' && substr($subaction, -3) == 'swf');
- $view->addMod('minifiche', 'Mini-fiches', true, array('with_score' => true));
+ $view = new SearchSet(true);
+ $view->addMod('minifiche', 'Mini-fiches', true, array('with_score' => true, 'starts_with' => $byletter));
if (S::logged() && !Env::i('nonins')) {
$view->addMod('trombi', 'Trombinoscope', false, array('with_promo' => true, 'with_score' => true));
// TODO: Reactivate when the new map is completed.
// $view->addMod('geoloc', 'Planisphère', false, array('with_annu' => 'search/adv'));
}
- $view->apply('search', $page, $action, $subaction);
+ $view->apply('search', $page, $model);
$nb_tot = $view->count();
$page->assign('search_results_nb', $nb_tot);
- if ($subaction) {
- return;
- }
if (!S::logged() && $nb_tot > $globals->search->public_max) {
$page->trigError('Votre recherche a généré trop de résultats pour un affichage public.');
} elseif ($nb_tot > $globals->search->private_max) {
$page->setTitle('Annuaire');
}
- function handler_advanced(&$page, $action = null, $subaction = null)
+ /** $model is the way of presenting the results: minifiche, trombi, geoloc.
+ */
+ function handler_advanced(&$page, $model = null, $byletter = null)
{
global $globals;
require_once 'geocoding.inc.php';
$page->assign('advanced',1);
$page->addJsLink('jquery.autocomplete.js');
- if (!Env::has('rechercher') && $action != 'geoloc') {
+ if (!Env::has('rechercher') && $model != 'geoloc') {
$this->form_prepare();
} else {
if (!Env::has('page')) {
}
require_once 'userset.inc.php';
- $view = new SearchSet(false, $action == 'geoloc' && substr($subaction, -3) == 'swf');
- $view->addMod('minifiche', 'Mini-fiches', true);
+ $view = new SearchSet(false);
+ $view->addMod('minifiche', 'Mini-fiches', true, array('starts_with' => $byletter));
$view->addMod('trombi', 'Trombinoscope', false, array('with_promo' => true));
// TODO: Reactivate when the new map is completed.
// $view->addMod('geoloc', 'Planisphère', false, array('with_annu' => 'search/adv'));
- $view->apply('search/adv', $page, $action, $subaction);
+ $view->apply('search/adv', $page, $model);
- if ($subaction) {
- return;
- }
$nb_tot = $view->count();
if ($nb_tot > $globals->search->private_max) {
$this->form_prepare();
}
}
- $page->changeTpl('search/index.tpl', $action == 'mini' ? SIMPLE : SKINNED);
+ $page->changeTpl('search/index.tpl', $model == 'mini' ? SIMPLE : SKINNED);
$page->addJsLink('ajax.js');
$page->assign('public_directory',0);
}