2 /***************************************************************************
3 * Copyright (C) 2003-2010 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 class UserSet
extends PlSet
24 public function __construct(PlFilterCondition
&$cond, $orders = null
)
26 parent
::__construct($cond, $orders);
29 protected function buildFilter(PlFilterCondition
&$cond, $orders)
31 return new UserFilter($cond, $orders);
35 class ProfileSet
extends PlSet
37 public function __construct(PlFilterCondition
&$cond, $orders = null
)
39 parent
::__construct($cond, $orders);
42 protected function buildFilter(PlFilterCondition
&$cond, $orders)
44 return new ProfileFilter($cond, $orders);
48 class SearchSet
extends ProfileSet
50 public $advanced = false
;
51 private $score = null
;
52 private $quick = false
;
54 public function __construct($quick = false
, $no_search = false
, PlFilterCondition
$cond = null
)
60 $this->quick
= $quick;
63 $this->conds
= new PFC_And();
64 } else if ($cond instanceof PFC_And
) {
67 $this->conds
= new PFC_And($cond);
77 private function getQuick()
80 Env
::kill('with_soundex');
83 require_once 'ufbuilder.inc.php';
84 $ufb = new UFB_QuickSearch();
86 if (!$ufb->isValid()) {
90 $ufc = $ufb->getUFC();
91 $this->conds
->addChild($ufc);
93 $orders = $ufb->getOrders();
95 if (S
::logged() && Env
::has('nonins')) {
96 $this->conds
= new PFC_And($this->conds
,
97 new PFC_Not(new UFC_Dead()),
98 new PFC_Not(new UFC_Registered())
102 parent
::__construct($this->conds
, $orders);
105 private function getAdvanced()
107 $this->advanced
= true
;
108 require_once 'ufbuilder.inc.php';
109 $ufb = new UFB_AdvancedSearch();
111 if (!$ufb->isValid()) {
115 $this->conds
->addChild($ufb->getUFC());
118 protected function &getFilterResults(PlFilter
&$pf, PlLimit
$limit)
120 return $pf->getProfiles($limit, Profile
::FETCH_MINIFICHES
);
124 class ArraySet
extends ProfileSet
126 public function __construct(array $users)
128 $hruids = User
::getBulkHruid($users, array('User', '_silent_user_callback'));
129 if (is_null($hruids) ||
count($hruids) == 0) {
130 $cond = new PFC_False();
132 $cond = new UFC_Hruid($hruids);
134 parent
::__construct($cond);
138 abstract class ProfileView
extends MultipageView
140 protected function getBoundValue($obj)
142 if ($obj instanceof Profile
) {
143 switch ($this->bound_field
) {
145 $name = $obj->name('%l');
146 return strtoupper($name);
148 return $obj->promo();
156 public function bounds()
158 $order = Env
::v('order', $this->defaultkey
);
160 if (($order == "name") ||
($order == "-name")) {
161 $this->bound_field
= "name";
163 } elseif (($order == "promo") ||
($order == "-promo")) {
164 $this->bound_field
= "promo";
167 if ($order{0} == '-') {
168 $show_bounds = -$show_bounds;
174 class MinificheView
extends ProfileView
176 public function __construct(PlSet
&$set, $data, array $params)
178 require_once 'education.func.inc.php';
180 $this->entriesPerPage
= $globals->search
->per_page
;
181 if (@$params['with_score']) {
182 $this->addSort(new PlViewOrder('score', array(
184 new UFO_ProfileUpdate(true
),
185 new UFO_Promo(UserFilter
::DISPLAY
, true
),
186 new UFO_Name(Profile
::DN_SORT
),
189 $this->addSort(new PlViewOrder(
191 array(new UFO_Name(Profile
::DN_SORT
)),
193 $this->addSort(new PlViewOrder('promo', array(
194 new UFO_Promo(UserFilter
::DISPLAY
, true
),
195 new UFO_Name(Profile
::DN_SORT
),
197 $this->addSort(new PlViewOrder('date_mod', array(
198 new UFO_ProfileUpdate(true
),
199 new UFO_Promo(UserFilter
::DISPLAY
, true
),
200 new UFO_Name(Profile
::DN_SORT
),
201 ), 'dernière modification'));
202 parent
::__construct($set, $data, $params);
205 public function templateName()
207 return 'include/plview.minifiche.tpl';
211 class MentorView
extends ProfileView
213 public function __construct(PlSet
&$set, $data, array $params)
215 $this->entriesPerPage
= 10;
216 $this->addSort(new PlViewOrder('rand', array(new PFO_Random(S
::i('uid'))), 'aléatoirement'));
217 $this->addSort(new PlViewOrder('name', array(new UFO_Name(Profile
::DN_SORT
)), 'nom'));
218 $this->addSort(new PlViewOrder('promo', array(
219 new UFO_Promo(UserFilter
::DISPLAY
, true
),
220 new UFO_Name(Profile
::DN_SORT
),
222 $this->addSort(new PlViewOrder('date_mod', array(
223 new UFO_ProfileUpdate(true
),
224 new UFO_Promo(UserFilter
::DISPLAY
, true
),
225 new UFO_Name(Profile
::DN_SORT
),
226 ), 'dernière modification'));
227 parent
::__construct($set, $data, $params);
230 public function templateName()
232 return 'include/plview.referent.tpl';
236 class TrombiView
extends ProfileView
238 public function __construct(PlSet
&$set, $data, array $params)
240 $this->entriesPerPage
= 24;
241 $this->defaultkey
= 'name';
242 if (@$params['with_score']) {
243 $this->addSort(new PlViewOrder('score', array(
245 new UFO_ProfileUpdate(true
),
246 new UFO_Promo(UserFilter
::DISPLAY
, true
),
247 new UFO_Name(Profile
::DN_SORT
),
250 $set->addCond(new UFC_Photo());
251 $this->addSort(new PlViewOrder('name', array(new UFO_Name(Profile
::DN_SORT
)), 'nom'));
252 $this->addSort(new PlViewOrder('promo', array(
253 new UFO_Promo(UserFilter
::DISPLAY
, true
),
254 new UFO_Name(Profile
::DN_SORT
),
256 parent
::__construct($set, $data, $params);
259 public function templateName()
261 return 'include/plview.trombi.tpl';
264 public function apply(PlPage
&$page)
266 if (!empty($GLOBALS['IS_XNET_SITE'])) {
268 $page->assign('mainsiteurl', 'https://' . $globals->core
->secure_domain
. '/');
270 return parent
::apply($page);
274 class GadgetView
implements PlView
276 public function __construct(PlSet
&$set, $data, array $params)
281 public function apply(PlPage
&$page)
283 $page->assign_by_ref('set', $this->set
->get(new PlLimit(5, 0)));
286 public function args()
292 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: