[PLUGINS] +set de base
[lhc/web/www.git] / www / plugins / formidable_1_0 / public / formidable_criteres.php
1 <?php
2
3 if (!defined("_ECRIRE_INC_VERSION")) return;
4
5 // {tri_donnee champ}
6 /**
7 * Depuis la boucle FORMULAIRES_REPONSES, trier les résulats en fonction d'un champ
8 * de la table FORMULAIRES_REPONSES_CHAMPS
9 * {tri_selon_donnee}
10 *
11 * @global array $exceptions_des_tables
12 * @param string $idb
13 * @param array $boucles
14 * @param <type> $crit
15 *
16 * Auteurs :
17 * Antoine Pitrou
18 * Cedric Morin
19 * Renato
20 * @ 2005,2006 - Distribue sous licence GNU/GPL
21 */
22
23 function critere_tri_selon_donnee_dist($idb, &$boucles, $crit) { // Garder cette fontion pour compatibilité
24 critere_tri_selon_reponse_dist($idb, $boucles, $crit) ;
25 }
26 function critere_tri_selon_reponse_dist($idb, &$boucles, $crit) {
27
28 $boucle = &$boucles[$idb];
29 $t = $boucle->id_table;
30
31 if ($t=='formulaires_reponses'){
32 $not = $crit->not;
33 $_quoi = calculer_liste($crit->param[0], array(), $boucles, $boucles[$idb]->id_parent);
34 $k = count($boucle->join)+1;
35 $boucle->join[$k]= array($t,'id_formulaires_reponse');
36 $boucle->from["L$k"]= 'spip_formulaires_reponses_champs';
37 $op = array("'='", "'L$k.nom'", "_q(".$_quoi.")");
38 $boucle->where[]= array("'?'","!in_array($_quoi,array('date','id_formulaires_reponse'))",$op,"''");
39 $boucle->order[]= "(in_array($_quoi,array('date','id_formulaires_reponse'))?'$t.'.$_quoi:(strncmp($_quoi,'date_',5)==0?'STR_TO_DATE(L$k.valeur,\'%d/%m/%Y\')':'L$k.valeur'))".($not?".' DESC'":"");
40 }
41 }
42
43 // {recherche_donnee} ou {recherche_donnee susan}
44 // Intégralement pompé et adapté de Forms&Tables
45 function critere_recherche_reponse_dist($idb, &$boucles, $crit) {
46 global $table_des_tables;
47 $boucle = &$boucles[$idb];
48 $t = $boucle->id_table;
49 if ($t=='formulaires_reponses'){
50 if (isset($crit->param[0]))
51 $_quoi = calculer_liste($crit->param[0], array(), $boucles, $boucles[$idb]->id_parent);
52 else
53 $_quoi = '@$Pile[0]["recherche"]';
54
55 $k = count($boucle->join)+1;
56 $boucle->join[$k]= array($t,'id_formulaires_reponse');
57 $boucle->from["L$k"]= 'spip_formulaires_reponses_champs';
58 $op = array("'LIKE'","'L$k.valeur'","_q(strpos($_quoi,'%')===false?'%'.".$_quoi.".'%':$_quoi)");
59 $boucle->where[]= array("'?'",$_quoi,$op,"''");
60 }
61 }
62
63
64 ?>