3 if (!defined('_ECRIRE_INC_VERSION')) {
9 * Depuis la boucle FORMULAIRES_REPONSES, trier les résulats en fonction d'un champ
10 * de la table FORMULAIRES_REPONSES_CHAMPS
13 * @global array $exceptions_des_tables
15 * @param array $boucles
22 * @ 2005,2006 - Distribue sous licence GNU/GPL
25 function critere_tri_selon_donnee_dist($idb, &$boucles, $crit) {
26 // Garder cette fontion pour compatibilité
27 critere_tri_selon_reponse_dist($idb, $boucles, $crit) ;
29 function critere_tri_selon_reponse_dist($idb, &$boucles, $crit) {
31 $boucle = &$boucles[$idb];
32 $t = $boucle->id_table
;
34 if ($t=='formulaires_reponses') {
36 $_quoi = calculer_liste($crit->param
[0], array(), $boucles, $boucles[$idb]->id_parent
);
37 $k = count($boucle->join
)+
1;
38 $boucle->join
[$k]= array($t,'id_formulaires_reponse');
39 $boucle->from
["L$k"]= 'spip_formulaires_reponses_champs';
40 $op = array("'='", "'L$k.nom'", "sql_quote(".$_quoi.")");
41 $boucle->where
[]= array("'?'","!in_array($_quoi,array('date','id_formulaires_reponse'))",$op,"''");
42 $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'":"");
46 // {recherche_donnee} ou {recherche_donnee susan}
47 // Intégralement pompé et adapté de Forms&Tables
48 function critere_recherche_reponse_dist($idb, &$boucles, $crit) {
49 global $table_des_tables;
50 $boucle = &$boucles[$idb];
51 $t = $boucle->id_table
;
52 if ($t=='formulaires_reponses') {
53 if (isset($crit->param
[0])) {
54 $_quoi = calculer_liste($crit->param
[0], array(), $boucles, $boucles[$idb]->id_parent
);
56 $_quoi = '@$Pile[0]["recherche"]';
59 $k = count($boucle->join
)+
1;
60 $boucle->join
[$k]= array($t,'id_formulaires_reponse');
61 $boucle->from
["L$k"]= 'spip_formulaires_reponses_champs';
62 $op = array("'LIKE'","'L$k.valeur'","sql_quote(strpos($_quoi,'%')===false?'%'.".$_quoi.".'%':$_quoi)");
63 $boucle->where
[]= array("'?'",$_quoi,$op,"''");