pending commit, finished during MQ/S download ...
[platal.git] / include / search / classes.inc.php
CommitLineData
0337d704 1<?php
2/***************************************************************************
50a40a33 3 * Copyright (C) 2003-2006 Polytechnique.org *
0337d704 4 * http://opensource.polytechnique.org/ *
5 * *
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. *
10 * *
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. *
15 * *
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 *
18 * Foundation, Inc., *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
21
22require_once("xorg.misc.inc.php");
23
24// {{{ Global variables used for the search Queries
25
26$globals->search->result_fields = '
27 u.user_id, u.promo, u.matricule, u.matricule_ax,
28 if(u.nom_usage=\'\', u.nom, u.nom_usage) AS NomSortKey,
29 u.nom_usage,u.date,
30 u.deces!=0 AS dcd,u.deces,
31 u.perms IN (\'admin\',\'user\') AS inscrit,
32 u.perms != \'pending\' AS wasinscrit,
33 FIND_IN_SET(\'femme\', u.flags) AS sexe,
34 a.alias AS forlife,
35 ad0.text AS app0text, ad0.url AS app0url, ai0.type AS app0type,
36 ad1.text AS app1text, ad1.url AS app1url, ai1.type AS app1type,
37 es.label AS secteur, ef.fonction_fr AS fonction,
38 IF(n.nat=\'\',n.pays,n.nat) AS nat, n.a2 AS iso3166,';
39// hide private information if not logged
cab08090 40if (S::logged())
0337d704 41 $globals->search->result_fields .='
42 q.profile_web AS web,
43 q.profile_mobile AS mobile,
44 q.profile_freetext AS freetext,
45 adr.city, gp.pays AS countrytxt, gr.name AS region,
46 e.entreprise,';
47else
48 $globals->search->result_fields .="
49 IF(q.profile_web_pub='public', q.profile_web, '') AS web,
50 IF(q.profile_mobile_pub='public', q.profile_mobile, '') AS mobile,
51 IF(q.profile_freetext_pub='public', q.profile_freetext, '') AS freetext,
52 IF(adr.pub='public', adr.city, '') AS city,
53 IF(adr.pub='public', gp.pays, '') AS countrytxt,
54 IF(adr.pub='public', gr.name, '') AS region,
55 IF(e.pub='public', e.entreprise, '') AS entreprise,";
56$globals->search->result_where_statement = '
57 LEFT JOIN applis_ins AS ai0 ON (u.user_id = ai0.uid AND ai0.ordre = 0)
58 LEFT JOIN applis_def AS ad0 ON (ad0.id = ai0.aid)
59 LEFT JOIN applis_ins AS ai1 ON (u.user_id = ai1.uid AND ai1.ordre = 1)
60 LEFT JOIN applis_def AS ad1 ON (ad1.id = ai1.aid)
61 LEFT JOIN entreprises AS e ON (e.entrid = 0 AND e.uid = u.user_id)
62 LEFT JOIN emploi_secteur AS es ON (e.secteur = es.id)
63 LEFT JOIN fonctions_def AS ef ON (e.fonction = ef.id)
64 LEFT JOIN geoloc_pays AS n ON (u.nationalite = n.a2)
65 LEFT JOIN adresses AS adr ON (u.user_id = adr.uid AND FIND_IN_SET(\'active\',adr.statut))
66 LEFT JOIN geoloc_pays AS gp ON (adr.country = gp.a2)
67 LEFT JOIN geoloc_region AS gr ON (adr.country = gr.a2 AND adr.region = gr.region)';
68
69// }}}
70// {{{ function display_lines()
71
72/**
73 * This function is a heuristic that approximatively tells
74 * how many lines of output the contact list will use.
75 */
76function display_lines($text)
77{
78 $n = 0;
79 $tokens = Array('<tr>', '<div class="nom">');
80 foreach ($tokens as $t) {
81 $i = -1;
82 while ( ($i = strpos($text,$t,$i+1))!==false) { $n++; }
83 }
84 return $n;
85}
86
87// }}}
88// {{{ class ThrowError
89
90/** handle errors for end-users queries
91 * assign the error message and runs the templates
92 *
93 * @author Jean-Sebastien Bedo
94 */
95class ThrowError
96{
97 /** constuctor
98 * @param $explain string the error (in natural language)
99 */
100 function ThrowError($explain)
101 {
102 global $page;
103 $page->trig_run('Erreur : '.$explain);
104 }
105}
106
107// }}}
108// {{{ class SField [Base class]
109
110/** classe de base représentant un champ de recherche
111 * (correspond à un champ du formulaire mais peut être à plusieurs champs de la bdd)
112 * interface étendue pour chaque type de champ particulier
113 */
114class SField
115{
116 // {{{ properties
117
118 /** le nom du champ dans le formulaire HTML */
119 var $fieldFormName;
120 /** champs de la bdd correspondant à ce champ sous forme d'un tableau */
121 var $fieldDbName;
122 /** champ résultat dans la requête MySQL correspondant à ce champ
123 * (alias utilisé pour la clause ORDER BY) */
124 var $fieldResultName;
125 /** valeur du champ instanciée par l'utilisateur */
126 var $value;
127
128 // }}}
129 // {{{ constructor
130
131 /** constructeur
132 * (récupère la requête de l'utilisateur pour ce champ) */
133 function SField($_fieldFormName, $_fieldDbName='', $_fieldResultName='')
134 {
135 $this->fieldFormName = $_fieldFormName;
136 $this->fieldDbName = $_fieldDbName;
137 $this->fieldResultName = $_fieldResultName;
138 $this->get_request();
139 }
140
141 // }}}
142 // {{{ function get_request()
143
144 /** récupérer la requête de l'utilisateur
145 * on met une chaîne vide si le champ n'a pas été complété */
146 function get_request()
147 {
148 $this->value = trim(Env::get($this->fieldFormName));
149 }
150
151 // }}}
152 // {{{ function get_where_statement()
153
154 /** récupérer la clause correspondant au champ dans la clause WHERE de la requête
155 * on parcourt l'ensemble des champs de la bdd de $fieldDbName et on associe
156 * à chacun d'entre eux une clause spécifique
157 * la clause totale et la disjonction de ces clauses spécifiques */
158 function get_where_statement()
159 {
160 if ($this->value=='') {
161 return false;
162 }
163 $res = implode(' OR ', array_filter(array_map(array($this, 'get_single_where_statement'), $this->fieldDbName)));
164 return empty($res) ? '' : "($res)";
165 }
166
167 // }}}
168 // {{{ function get_order_statement()
169
170 /** récupérer la clause correspondant au champ dans la clause ORDER BY de la requête
171 * utilisé par exemple pour placer d'abord le nom égal à la requête avant les approximations */
172 function get_order_statement()
173 {
174 return false;
175 }
176
177 // }}}
178 // {{{ function get_select_statement()
179
180 function get_select_statement()
181 {
182 return false;
183 }
184
185 // }}}
186 // {{{ function get_url()
187
188 /** récupérer le bout d'URL correspondant aux paramètres permettant d'imiter une requête d'un
189 * utilisateur assignant la valeur $this->value à ce champ */
190 function get_url()
191 {
192 if (empty($this->value)) {
193 return false;
194 } else {
195 return $this->fieldFormName.'='.urlencode($this->value);
196 }
197 }
198
199 // }}}
200}
201
202// }}}
203// {{{ class QuickSearch [Google Like]
204
205class QuickSearch extends SField
206{
207 // {{{ properties
208
209 /** stores tokens */
210 var $strings;
211 /** stores numerical ranges */
212 var $ranges;
213
214 // }}}
215 // {{{ constructor
216
217 function QuickSearch($_fieldFormName)
218 {
219 $this->fieldFormName = $_fieldFormName;
220 $this->get_request();
221 if (preg_match(":[\]\[{}~/§_`|%$^=+]|\*\*:", $this->value)) {
222 new ThrowError('Un champ contient un caractère interdit rendant la recherche impossible.');
223 }
224 }
225
226 // }}}
227 // {{{ function isempty()
228
229 function isempty()
230 {
231 return empty($this->strings) && empty($this->ranges);
232 }
233
234 // }}}
235 // {{{ function get_request()
236
237 function get_request()
238 {
239 parent::get_request();
240 $s = replace_accent(trim($this->value));
241 $s = preg_replace('!\d+!', ' ', $s);
242 $s = str_replace('*','%',$s);
243 $this->strings = preg_split("![^a-zA-Z%]+!",$s, -1, PREG_SPLIT_NO_EMPTY);
244
245 $s = trim($this->value);
246 $s = preg_replace('! *- *!', '-', $s);
247 $s = preg_replace('!([<>]) *!', ' \1', $s);
248 $s = preg_replace('![^0-9\-><]!', ' ', $s);
249 $s = preg_replace('![<>\-] !', '', $s);
250 $ranges = preg_split('! +!', $s, -1, PREG_SPLIT_NO_EMPTY);
251 $this->ranges=Array();
252 foreach ($ranges as $r) {
253 if (preg_match('!^([<>]\d{4}|\d{4}(-\d{4})?)$!', $r)) $this->ranges[] = $r;
254 }
255 }
256
257 // }}}
258 // {{{ function get_where_statement()
259
260 function get_where_statement()
261 {
262 $where = Array();
263 foreach ($this->strings as $i => $s) {
264 $t = str_replace('*', '%', $s).'%';
265 $t = str_replace('%%', '%', $t);
266 $where[] = "sn$i.token LIKE '$t'";
267 }
268
269 $wherep = Array();
270 foreach ($this->ranges as $r) {
271 if (preg_match('!^\d{4}$!', $r)) {
272 $wherep[] = "u.promo=$r";
273 } elseif (preg_match('!^(\d{4})-(\d{4})$!', $r, $matches)) {
274 $p1=min(intval($matches[1]), intval($matches[2]));
275 $p2=max(intval($matches[1]), intval($matches[2]));
276 $wherep[] = "(u.promo>=$p1 AND u.promo<=$p2)";
277 } elseif (preg_match('!^<(\d{4})!', $r, $matches)) {
278 $wherep[] = "u.promo<={$matches[1]}";
279 } elseif (preg_match('!^>(\d{4})!', $r, $matches)) {
280 $wherep[] = "u.promo>={$matches[1]}";
281 }
282 }
283 if (!empty($wherep)) {
284 $where[] = '('.join(' OR ',$wherep).')';
285 }
286 return join(" AND ", $where);
287 }
288
289 // }}}
290 // {{{ get_select_statement
291 function get_select_statement()
292 {
293 $join = "";
294 foreach ($this->strings as $i => $s) {
295 $join .= "INNER JOIN search_name AS sn$i ON (u.user_id = sn$i.uid)\n";
296 }
297 return $join;
298 }
299 // }}}
300 // {{{ function get_order_statement()
301
302 function get_order_statement()
303 {
304 return false;
305 }
306
307 // }}}
308 // {{{ function get_score_statement
309
310 function get_score_statement()
311 {
312 $sum = array('0');
313 foreach ($this->strings as $i => $s) {
314 $sum[] .= "SUM(sn$i.score + IF('$s'=sn$i.token,5,0))";
315 }
316 return join('+', $sum).' AS score';
317 }
318
319 // }}}
320}
321
322// }}}
323// {{{ class NumericSField [Integer fields]
324
325/** classe de champ numérique entier (offset par exemple)
326 */
327class NumericSField extends SField
328{
329 // {{{ constructor
330
331 /** constructeur
332 * (récupère la requête de l'utilisateur pour ce champ) */
333 function NumericSField($_fieldFormName)
334 {
335 $this->fieldFormName = $_fieldFormName;
336 $this->get_request();
337 }
338
339 // }}}
340 // {{{ function get_request()
341
342 /** récupère la requête de l'utilisateur et échoue s'il ne s'agit pas d'un entier */
343 function get_request()
344 {
345 parent::get_request();
346 if (empty($this->value)) {
347 $this->value = 0;
348 }
349 if (!preg_match("/^[0-9]+$/", $this->value)) {
350 new ThrowError('Un champ numérique contient des caractères alphanumériques.');
351 }
352 }
353
354 // }}}
355}
356
357// }}}
358// {{{ class RefSField [ ??? ]
359
360class RefSField extends SField
361{
362 // {{{ properties
363
364 var $refTable;
365 var $refAlias;
366 var $refCondition;
367 var $exact = true;
368
369 // }}}
370 // {{{ constructor
371
372 function RefSField($_fieldFormName, $_fieldDbName='', $_refTable, $_refAlias, $_refCondition, $_exact=true)
373 {
374 $this->fieldFormName = $_fieldFormName;
375 $this->fieldDbName = $_fieldDbName;
376 $this->refTable = $_refTable;
377 $this->refAlias = $_refAlias;
378 $this->refCondition = $_refCondition;
379 $this->exact = $_exact;
380 $this->get_request();
381 }
382
383 // }}}
384 // {{{ function get_request()
385
386 function get_request() {
387 parent::get_request();
388 if ($this->value=='00' || $this->value=='0') {
389 $this->value='';
390 }
391 }
392
393 // }}}
394 // {{{ function too_large()
395
396 function too_large()
397 {
398 return ($this->value=='');
399 }
400
401 // }}}
402 // {{{ function compare()
403
404 function compare()
405 {
406 $val = addslashes($this->value);
407 return $this->exact ? "='$val'" : " LIKE '%$val%'";
408 }
409
410 // }}}
411 // {{{ function get_single_match_statement()
412
413 function get_single_match_statement($field)
414 {
415 return $field.$this->compare();
416 }
417
418 // }}}
419 // {{{ function get_single_where_statement()
420
421 function get_single_where_statement($field)
422 {
423 return $this->refTable=='' ? $this->get_single_match_statement($field) : false;
424 }
425
426 // }}}
427 // {{{ function get_select_statement()
428
429 function get_select_statement()
430 {
431 if ($this->value=='' || $this->refTable=='') {
432 return false;
433 }
434 $res = implode(' OR ', array_filter(array_map(array($this, 'get_single_match_statement'), $this->fieldDbName)));
435 return "INNER JOIN {$this->refTable} AS {$this->refAlias} ON ({$this->refCondition} AND ($res) )";
436 }
437
438 // }}}
439}
440
441// }}}
56670b6a 442
443// {{{ class RefSFieldMultipleTable
444class MapSField extends RefSField
445{
446 var $mapId;
447
448 function MapSField($_fieldFormName, $_fieldDbName='', $_refTable, $_refAlias, $_refCondition, $_mapId=false)
449 {
350e6926 450 if ($_mapId === false)
451 $this->mapId = Env::get($_fieldFormName, '');
452 else
453 $this->mapId = $_mapId;
454 $this->RefSField($_fieldFormName, $_fieldDbName, $_refTable, $_refAlias, $_refCondition, true, false);
56670b6a 455 }
456 function get_select_statement()
457 {
350e6926 458 if ($this->mapId === '') return false;
56670b6a 459 $res = implode(' OR ', array_filter(array_map(array($this, 'get_single_match_statement'), $this->fieldDbName)));
460 foreach ($this->refTable as $i => $refT)
461 $last = $i;
462 $inner = "";
463 foreach ($this->refTable as $i => $refT)
464 $inner .= " INNER JOIN {$refT} AS {$this->refAlias[$i]} ON ({$this->refCondition[$i]} ".(($i == $last)?"AND ($res) ":"").")";
465 return $inner;
466 }
467 function get_request()
468 {
350e6926 469 $this->value = $this->mapId;
56670b6a 470 }
471}
472
0337d704 473// {{{ class RefWithSoundexSField [ ??? ]
474
475class RefWithSoundexSField extends RefSField
476{
477 // {{{ function compare()
478
479 function compare()
480 {
481 return "='".soundex_fr($this->value)."'";
482 }
483
484 // }}}
485}
486
487// }}}
488// {{{ class StringSField [String fields]
489
490/** classe de champ texte (nom par exemple)
491 */
492class StringSField extends SField
493{
494 // {{{ function get_request()
495
496 /** récupère la requête de l'utilisateur et échoue si la chaîne contient des caractères
497 * interdits */
498 function get_request()
499 {
500 parent::get_request();
501 if (preg_match(":[\]\[<>{}~/§_`|%$^=+]|\*\*:", $this->value)) {
502 new ThrowError('Un champ contient un caractère interdit rendant la recherche impossible.');
503 }
504 }
505
506 // }}}
507 // {{{ function length()
508
509 /** donne la longueur de la requête de l'utilisateur
510 * (au sens strict i.e. pas d'* ni d'espace ou de trait d'union -> les contraintes réellement
511 * imposées par l'utilisateur) */
512 function length()
513 {
514 global $lc_accent,$uc_accent;
515 return strlen($this->value) - strlen(ereg_replace('[a-z'.$lc_accent.$uc_accent.']', '', strtolower($this->value)));
516 }
517
518 // }}}
519 // {{{ function too_large()
520
521 function too_large()
522 {
523 return ($this->length()<2);
524 }
525
526 // }}}
527 // {{{ function get_single_where_statement()
528
529 /** clause WHERE correspondant à un champ de la bdd et à ce champ de formulaire
530 * @param field nom de champ de la bdd concerné par la clause */
531 function get_single_where_statement($field)
532 {
533 $regexp = strtr(addslashes($this->value), '-*', '_%');
534 return "$field LIKE '$regexp%'";
535 }
536
537 // }}}
538 // {{{ function get_order_statement()
539
540 /** clause ORDER BY correspondant à ce champ de formulaire */
541 function get_order_statement()
542 {
543 if ($this->value!='' && $this->fieldResultName!='') {
544 return "{$this->fieldResultName}!='".addslashes($this->value)."'";
545 } else {
546 return false;
547 }
548 }
549
550 // }}}
551}
552
553// }}}
554// {{{ class NameSField [Names : serach 'n%' + '% b']
555
556/** classe pour les noms : on cherche en plus du like 'foo%' le like '% foo' (particules)
557+*/
558class NameSField extends StringSField
559{
560 // {{{ function get_single_where_statement()
561
562 function get_single_where_statement($field)
563 {
564 $regexp = strtr(addslashes($this->value), '-*', '_%');
565 return "$field LIKE '$regexp%' OR $field LIKE '% $regexp%' OR $field LIKE '%-$regexp%'";
566 }
567
568 // }}}
569 // {{{ function get_order_statement()
570
571 function get_order_statement()
572 {
573 if ($this->value!='' && $this->fieldResultName!='') {
574 return "{$this->fieldResultName} NOT LIKE '".addslashes($this->value)."'";
575 } else {
576 return false;
577 }
578 }
579
580 // }}}
581}
582
583// }}}
584// {{{ class StringWithSoundexSField [Strings + soundex]
585
586/** classe de champ texte avec soundex (nom par exemple)
587 */
588class StringWithSoundexSField extends StringSField
589{
590 // {{{ function get_single_where_statement()
591
592 /** clause WHERE correspondant à un champ de la bdd et à ce champ de formulaire
593 * @param field nom de champ de la bdd concerné par la clause */
594 function get_single_where_statement($field) {
595 return $field.'="'.soundex_fr($this->value).'"';
596 }
597
598 // }}}
599}
600
601// }}}
602// {{{ class PromoSField [Prom field]
603
604/** classe de champ de promotion */
605class PromoSField extends SField
606{
607 // {{{ properties
608
609 /** opérateur de comparaison (<,>,=) de la promo utilisé pour ce champ de formulaire */
610 var $compareField;
611
612 // }}}
613 // {{{ constructor
614
615 /** constructeur
616 * compareField est un champ de formulaire très simple qui ne sert qu'à la construction de la
617 * clause WHERE de la promo */
618 function PromoSField($_fieldFormName, $_compareFieldFormName, $_fieldDbName, $_fieldResultName)
619 {
620 parent::SField($_fieldFormName, $_fieldDbName, $_fieldResultName);
621 $this->compareField = new SField($_compareFieldFormName);
622 }
623
624 // }}}
625 // {{{ function get_request()
626
627 /** récupère la requête utilisateur et échoue si le champ du formulaire ne représente pas une
628 * promotion (nombre à 4 chiffres) */
629 function get_request()
630 {
631 parent::get_request();
632 if (preg_match('/^[0-9]{2}$/', $this->value)){
633 $this->value = intval($this->value) + 1900;
634 }
635 if (!(empty($this->value) or preg_match('/^[0-9]{4}$/', $this->value))) {
636 new ThrowError('La promotion est une année à quatre chiffres.');
637 }
638 }
639
640 // }}}
641 // {{{ function is_a_single_promo()
642
643 /** teste si la requête est de la forme =promotion -> contrainte forte imposée -> elle suffit
644 * pour autoriser un affichage des résultats alors que <promotion est insuffisant */
645 function is_a_single_promo()
646 {
647 return ($this->compareField->value=='=' && $this->value!='');
648 }
649
650 // }}}
651 // {{{ function too_large()
652
653 function too_large()
654 {
655 return !$this->is_a_single_promo();
656 }
657
658 // }}}
659 // {{{ function get_single_where_statement()
660
661 /** clause WHERE correspondant à ce champ */
662 function get_single_where_statement($field)
663 {
664 return $field.$this->compareField->value.$this->value;
665 }
666
667 // }}}
668 // {{{ function get_url()
669
670 /** récupérer le bout d'URL correspondant aux paramètres permettant d'imiter une requête
671 * d'un utilisateur assignant la valeur $this->value à ce champ et assignant l'opérateur de
672 * comparaison adéquat */
673 function get_url()
674 {
675 if (!($u=parent::get_url())) {
676 return false;
677 }
678 return $u.'&amp;'.$this->compareField->get_url();
679 }
680
681 // }}}
682}
683
684// }}}
685// {{{ class SFieldGroup [Group fields]
686
687/** classe groupant des champs de formulaire de recherche */
688class SFieldGroup
689{
690 // {{{ properties
691
692 /** tableau des classes correspondant aux champs groupés */
693 var $fields;
694 /** type de groupe : ET ou OU */
695 var $and;
696
697 // }}}
698 // {{{ constuctor
699
700 /** constructeur */
701 function SFieldGroup($_and, $_fields)
702 {
703 $this->fields = $_fields;
704 $this->and = $_and;
705 }
706
707 // }}}
708 // {{{ function too_large()
709
710 function too_large()
711 {
712 $b = true;
713 for ($i=0; $b && $i<count($this->fields); $i++) {
714 $b &= $this->fields[$i]->too_large();
715 }
716 return $b;
717 }
718
719 // }}}
720 // {{{ function field_get_select()
721
722 function field_get_select($f)
723 {
724 return $f->get_select_statement();
725 }
726
727 // }}}
728 // {{{ function field_get_where()
729
730 /** récupérer la clause WHERE d'un objet champ de recherche */
731 function field_get_where($f)
732 {
733 return $f->get_where_statement();
734 }
735
736 // }}}
737 // {{{ function field_get_order()
738
739 /** récupérer la clause ORDER BY d'un objet champ de recherche */
740 function field_get_order($f)
741 {
742 return $f->get_order_statement();
743 }
744
745 // }}}
746 // {{{ function field_get_url()
747
748 /** récupérer le bout d'URL correspondant à un objet champ de recherche */
749 function field_get_url($f)
750 {
751 return $f->get_url();
752 }
753
754 // }}}
755 // {{{ function get_select_statement()
756
757 function get_select_statement()
758 {
759 return implode(' ', array_filter(array_map(array($this, 'field_get_select'), $this->fields)));
760 }
761
762 // }}}
763 // {{{ function get_where_statement()
764
765 /** récupérer la clause WHERE du groupe de champs = conjonction (ET) ou disjonction (OU) de
766 * clauses des champs élémentaires */
767 function get_where_statement()
768 {
769 $joinText = $this->and ? ' AND ' : ' OR ';
770 $res = implode($joinText, array_filter(array_map(array($this, 'field_get_where'), $this->fields)));
771 return $res == '' ? '' : "($res)";
772 }
773
774 // }}}
775 // {{{ function get_order_statement()
776
777 /** récupérer la clause ORDER BY du groupe de champs = conjonction (ET) ou disjonction (OU) de
778 * clauses des champs élémentaires */
779 function get_order_statement()
780 {
781 $order = array_filter(array_map(array($this, 'field_get_order'), $this->fields));
782 return count($order)>0 ? implode(',', $order) : false;
783 }
784
785 // }}}
786 // {{{ function get_url()
787
788 /** récupérer le bout d'URL correspondant à ce groupe de champs = concaténation des bouts d'URL
789 * des champs élémentaires */
790 function get_url($others=Array())
791 {
792 $url = array_filter(array_map(array($this, 'field_get_url'), $this->fields));
793 foreach ($url as $key=>$val) {
794 if (empty($val)) {
795 unset($url[$key]);
796 }
797 }
798 foreach ($others as $key=>$val) {
799 if (!empty($val)) {
800 $url[] = "$key=$val";
801 }
802 }
803 return count($url)>0 ? implode('&amp;', $url) : false;
804 }
805
806 // }}}
807}
808
809// }}}
810
56670b6a 811// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
0337d704 812?>