3 * Plugin Agenda 4 pour Spip 3.0
7 * Auteurs : cf paquet.xml
10 if (!defined("_ECRIRE_INC_VERSION")) return;
14 * Filtres&criteres deprecies/obsoletes
19 * {agendafull ..} variante etendue du crietre agenda du core
20 * qui accepte une date de debut et une date de fin
22 * {agendafull date_debut, date_fin, jour, #ENV{annee}, #ENV{mois}, #ENV{jour}}
23 * {agendafull date_debut, date_fin, semaine, #ENV{annee}, #ENV{mois}, #ENV{jour}}
24 * {agendafull date_debut, date_fin, mois, #ENV{annee}, #ENV{mois}}
25 * {agendafull date_debut, date_fin, periode, #ENV{annee}, #ENV{mois}, #ENV{jour},
26 * #ENV{annee_fin}, #ENV{mois_fin}, #ENV{jour_fin}}
29 * @param object $boucles
32 function critere_agendafull_dist($idb, &$boucles, $crit)
34 $params = $crit->param
;
36 if (count($params) < 1)
37 erreur_squelette(_T('zbug_info_erreur_squelette'),
38 "{agenda ?} BOUCLE$idb");
40 $parent = $boucles[$idb]->id_parent
;
42 // les valeurs $date et $type doivent etre connus a la compilation
43 // autrement dit ne pas etre des champs
45 $date_deb = array_shift($params);
46 $date_deb = $date_deb[0]->texte
;
48 $date_fin = array_shift($params);
49 $date_fin = $date_fin[0]->texte
;
51 $type = array_shift($params);
52 $type = $type[0]->texte
;
54 $annee = $params ?
array_shift($params) : "";
55 $annee = "\n" . 'sprintf("%04d", ($x = ' .
56 calculer_liste($annee, array(), $boucles, $parent) .
57 ') ? $x : date("Y"))';
59 $mois = $params ?
array_shift($params) : "";
60 $mois = "\n" . 'sprintf("%02d", ($x = ' .
61 calculer_liste($mois, array(), $boucles, $parent) .
62 ') ? $x : date("m"))';
64 $jour = $params ?
array_shift($params) : "";
65 $jour = "\n" . 'sprintf("%02d", ($x = ' .
66 calculer_liste($jour, array(), $boucles, $parent) .
67 ') ? $x : date("d"))';
69 $annee2 = $params ?
array_shift($params) : "";
70 $annee2 = "\n" . 'sprintf("%04d", ($x = ' .
71 calculer_liste($annee2, array(), $boucles, $parent) .
72 ') ? $x : date("Y"))';
74 $mois2 = $params ?
array_shift($params) : "";
75 $mois2 = "\n" . 'sprintf("%02d", ($x = ' .
76 calculer_liste($mois2, array(), $boucles, $parent) .
77 ') ? $x : date("m"))';
79 $jour2 = $params ?
array_shift($params) : "";
80 $jour2 = "\n" . 'sprintf("%02d", ($x = ' .
81 calculer_liste($jour2, array(), $boucles, $parent) .
82 ') ? $x : date("d"))';
84 $boucle = &$boucles[$idb];
85 $date = $boucle->id_table
. ".$date";
87 $quote_end = ",'".$boucle->sql_serveur
."','text'";
90 $boucle->where
[]= array("'AND'",
91 array("'<='", "'DATE_FORMAT($date_deb, \'%Y%m%d\')'",("sql_quote($annee . $mois . $jour$quote_end)")),
92 array("'>='", "'DATE_FORMAT($date_fin, \'%Y%m%d\')'",("sql_quote($annee . $mois . $jour$quote_end)")));
93 elseif ($type == 'mois')
94 $boucle->where
[]= array("'AND'",
95 array("'<='", "'DATE_FORMAT($date_deb, \'%Y%m\')'",("sql_quote($annee . $mois$quote_end)")),
96 array("'>='", "'DATE_FORMAT($date_fin, \'%Y%m\')'",("sql_quote($annee . $mois$quote_end)")));
97 elseif ($type == 'semaine')
98 $boucle->where
[]= array("'AND'",
100 "'DATE_FORMAT($date_fin, \'%Y%m%d\')'",
101 ("date_debut_semaine($annee, $mois, $jour)")),
103 "'DATE_FORMAT($date_deb, \'%Y%m%d\')'",
104 ("date_fin_semaine($annee, $mois, $jour)")));
105 elseif (count($crit->param
) > 3)
106 $boucle->where
[]= array("'AND'",
108 "'DATE_FORMAT($date_fin, \'%Y%m%d\')'",
109 ("sql_quote($annee . $mois . $jour$quote_end)")),
110 array("'<='", "'DATE_FORMAT($date_deb, \'%Y%m%d\')'", ("sql_quote($annee2 . $mois2 . $jour2$quote_end)")));
111 // sinon on prend tout
116 * Afficher de facon textuelle les dates de debut et fin en fonction des cas
117 * - Le lundi 20 fevrier a 18h
118 * - Le 20 fevrier de 18h a 20h
119 * - Du 20 au 23 fevrier
120 * - du 20 fevrier au 30 mars
121 * - du 20 fevrier 2007 au 30 mars 2008
122 * $horaire='oui' permet d'afficher l'horaire, toute autre valeur n'indique que le jour
123 * $forme peut contenir abbr (afficher le nom des jours en abbrege) et ou hcal (generer une date au format hcal)
125 * @param string $date_debut
126 * @param string $date_fin
127 * @param string $horaire
128 * @param string $forme
131 function agenda_affdate_debut_fin($date_debut, $date_fin, $horaire = 'oui', $forme=''){
133 if (strpos($forme,'abbr')!==false) $abbr = 'abbr';
134 $affdate = "affdate_jourcourt";
135 if (strpos($forme,'annee')!==false) $affdate = 'affdate';
137 $dtstart = $dtend = $dtabbr = "";
138 if (strpos($forme,'hcal')!==false) {
139 $dtstart = "<abbr class='dtstart' title='".date_iso($date_debut)."'>";
140 $dtend = "<abbr class='dtend' title='".date_iso($date_fin)."'>";
144 $date_debut = strtotime($date_debut);
145 $date_fin = strtotime($date_fin);
146 $d = date("Y-m-d", $date_debut);
147 $f = date("Y-m-d", $date_fin);
148 $h = $horaire=='oui';
149 $hd = date("H:i",$date_debut);
150 $hf = date("H:i",$date_fin);
151 $au = " " . strtolower(_T('agenda:evenement_date_au'));
152 $du = _T('agenda:evenement_date_du') . " ";
156 $s = ucfirst(nom_jour($d,$abbr))." ".$affdate($d);
159 $s = "$dtstart$s$dtabbr";
160 if ($h AND $hd!=$hf) $s .= "-$dtend$hf$dtabbr";
162 else if ((date("Y-m",$date_debut))==date("Y-m",$date_fin))
163 { // meme annee et mois, jours differents
165 $s = $du . $dtstart . affdate_jourcourt($d) . " $hd" . $dtabbr;
166 $s .= $au . $dtend . $affdate($f);
167 if ($hd!=$hf) $s .= " $hf";
171 $s = $du . $dtstart . jour($d) . $dtabbr;
172 $s .= $au . $dtend . $affdate($f) . $dtabbr;
175 else if ((date("Y",$date_debut))==date("Y",$date_fin))
176 { // meme annee, mois et jours differents
177 $s = $du . $dtstart . affdate_jourcourt($d);
178 if ($h) $s .= " $hd";
179 $s .= $dtabbr . $au . $dtend . $affdate($f);
180 if ($h) $s .= " $hf";
185 $s = $du . $dtstart . affdate($d);
187 $s .= " ".date("(H:i)",$date_debut);
188 $s .= $dtabbr . $au . $dtend. affdate($f);
190 $s .= " ".date("(H:i)",$date_fin);
193 return unicode2charset(charset2unicode($s,'AUTO'));