3 if (!defined("_ECRIRE_INC_VERSION")) return;
7 * Depuis la boucle FORMULAIRES_REPONSES, trier les résulats en fonction d'un champ
8 * de la table FORMULAIRES_REPONSES_CHAMPS
11 * @global array $exceptions_des_tables
13 * @param array $boucles
20 * @ 2005,2006 - Distribue sous licence GNU/GPL
23 function critere_tri_selon_donnee_dist($idb, &$boucles, $crit) { // Garder cette fontion pour compatibilité
24 critere_tri_selon_reponse_dist($idb, $boucles, $crit) ;
26 function critere_tri_selon_reponse_dist($idb, &$boucles, $crit) {
28 $boucle = &$boucles[$idb];
29 $t = $boucle->id_table
;
31 if ($t=='formulaires_reponses'){
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'":"");
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
);
53 $_quoi = '@$Pile[0]["recherche"]';
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,"''");