|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/***************************************************************************\ |
|
4
|
|
|
* SPIP, Systeme de publication pour l'internet * |
|
5
|
|
|
* * |
|
6
|
|
|
* Copyright (c) 2001-2016 * |
|
7
|
|
|
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * |
|
8
|
|
|
* * |
|
9
|
|
|
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. * |
|
10
|
|
|
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
|
11
|
|
|
\***************************************************************************/ |
|
12
|
|
|
|
|
13
|
|
|
if (!defined('_ECRIRE_INC_VERSION')) return; |
|
14
|
|
|
|
|
15
|
|
|
include_spip('inc/layer'); |
|
16
|
|
|
include_spip('inc/texte'); // inclut inc_filtre |
|
17
|
|
|
|
|
18
|
|
|
/// @file |
|
19
|
|
|
/// Typographie generale des calendriers de 3 type: jour/semaine/mois(ou plus) |
|
20
|
|
|
|
|
21
|
|
|
/// Notes: pour toutes les fonctions ayant parmi leurs parametres |
|
22
|
|
|
/// annee, mois, jour, echelle, partie_cal, script, ancre |
|
23
|
|
|
/// ceux-ci apparaissent TOUJOURS dans cet ordre |
|
24
|
|
|
|
|
25
|
|
|
define('DEFAUT_D_ECHELLE',120); # 1 pixel = 2 minutes |
|
26
|
|
|
define('DEFAUT_DECALE', 4); # marge gauche en EM |
|
27
|
|
|
define('DEFAUT_TAILLE_HEURE', 0.7); # marge gauche en EM |
|
28
|
|
|
|
|
29
|
|
|
define('DEFAUT_PARTIE_M', "matin"); |
|
30
|
|
|
define('DEFAUT_PARTIE_S', "soir"); |
|
31
|
|
|
define('DEFAUT_PARTIE_T', "tout"); |
|
32
|
|
|
define('DEFAUT_PARTIE_R', "sansheure"); |
|
33
|
|
|
define('DEFAUT_PARTIE', DEFAUT_PARTIE_R); |
|
34
|
|
|
|
|
35
|
|
|
$GLOBALS['calendrier_partie'] = array( |
|
36
|
|
|
DEFAUT_PARTIE_S => array('debut' => 12, 'fin' => 23), |
|
37
|
|
|
DEFAUT_PARTIE_M => array('debut' => 4, 'fin' => 15), |
|
38
|
|
|
DEFAUT_PARTIE_T => array('debut' => 7, 'fin' => 21) |
|
39
|
|
|
); |
|
40
|
|
|
/// |
|
41
|
|
|
///Utilitaires sans html ni sql |
|
42
|
|
|
/// |
|
43
|
|
|
|
|
44
|
|
|
/// Utilitaire de separation script / ancre |
|
45
|
|
|
/// et de retrait des arguments a remplacer |
|
46
|
|
|
/// (a mon avis cette fonction ne sert a rien, puisque parametre_url() |
|
47
|
|
|
/// sait remplacer les arguments au bon endroit -- Fil) |
|
48
|
|
|
/// Pas si simple: certains param ne sont pas remplaces |
|
49
|
|
|
/// et doivent reprendre leur valeur par defaut -- esj. |
|
50
|
|
|
/// http://doc.spip.org/@calendrier_retire_args_ancre |
|
51
|
|
|
function calendrier_retire_args_ancre($script) |
|
52
|
|
|
{ |
|
53
|
|
|
|
|
54
|
|
|
if (preg_match(',^(.*)#([\w-]+)$,',$script, $m)) { |
|
55
|
|
|
$script = $m[1]; |
|
56
|
|
|
$ancre = $m[2]; |
|
57
|
|
|
} else { $ancre = ''; } |
|
58
|
|
|
|
|
59
|
|
|
foreach(array('echelle','jour','mois','annee', 'type', 'partie_cal', 'bonjour') as $arg) { |
|
60
|
|
|
$script = preg_replace("/([?&])$arg=[^&]*&/",'\1', $script); |
|
61
|
|
|
$script = preg_replace("/([?&])$arg=[^&]*$/",'\1', $script); |
|
62
|
|
|
} |
|
63
|
|
|
if (in_array(substr($script,-1),array('&','?'))) $script = substr($script,0,-1); |
|
64
|
|
|
return array(quote_amp($script), $ancre); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/// construit un bout de Query-String en eliminant le superflu |
|
68
|
|
|
|
|
69
|
|
|
function calendrier_retire_defaults($echelle, $partie_cal) |
|
70
|
|
|
{ |
|
71
|
|
|
if (!$echelle) $echelle = DEFAUT_D_ECHELLE; |
|
72
|
|
|
|
|
73
|
|
|
return (($echelle != DEFAUT_D_ECHELLE) ? "&echelle=$echelle" : '') |
|
74
|
|
|
. (($partie_cal != DEFAUT_PARTIE) ? "&partie_cal=$partie_cal" : ''); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/// tous les liens de navigations sont issus de cette fonction |
|
78
|
|
|
/// on peut definir generer_url_date et un htacces pour simplifier les URL |
|
79
|
|
|
|
|
80
|
|
|
// http://doc.spip.org/@calendrier_args_date |
|
81
|
|
|
function calendrier_args_date($script, $annee, $mois, $jour, $type, $finurl) { |
|
82
|
|
|
if (function_exists('generer_url_date')) |
|
83
|
|
|
return generer_url_date($script, $annee, $mois, $jour, $type, $finurl); |
|
84
|
|
|
|
|
85
|
|
|
$script = parametre_url($script, 'annee', sprintf("%04d", $annee)); |
|
86
|
|
|
$script = parametre_url($script, 'mois', sprintf("%02d", $mois)); |
|
87
|
|
|
$script = parametre_url($script, 'jour', sprintf("%02d", $jour)); |
|
88
|
|
|
$script = parametre_url($script, 'type', $type); |
|
89
|
|
|
return $script . $finurl; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
function calendrier_args_time($time, $script, $type, $fin='') |
|
93
|
|
|
{ |
|
94
|
|
|
if (!is_numeric($time)) $time = strtotime($time); |
|
95
|
|
|
$jour = date("d",$time); |
|
96
|
|
|
$mois = date("m",$time); |
|
97
|
|
|
$annee = date("Y",$time); |
|
98
|
|
|
|
|
99
|
|
|
return calendrier_args_date($script, $annee, $mois, $jour, $type, $fin); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/// utilise la precedente pour produire une balise A avec tous les accessoires |
|
103
|
|
|
|
|
104
|
|
|
// http://doc.spip.org/@calendrier_href |
|
105
|
|
|
function calendrier_href($script, $annee, $mois, $jour, $type, $fin, $ancre, $img, $titre, $class='', $alt='', $clic='', $style='', $evt='') |
|
106
|
|
|
{ |
|
107
|
|
|
static $moi = NULL; |
|
108
|
|
|
// pas d'Ajax pour l'espace public pour le moment ou si indispo |
|
109
|
|
|
// sinon preparer la RegExp qui l'empeche aussi pour la page elle-meme |
|
110
|
|
|
if ($moi === NULL) { |
|
111
|
|
|
$moi = (test_espace_prive() AND (_SPIP_AJAX === 1 )) |
|
112
|
|
|
? ("/exec=" . _request('exec') .'$/') |
|
113
|
|
|
: ''; |
|
114
|
|
|
} |
|
115
|
|
|
$d = mktime (1,1,1, $mois, $jour, $annee); |
|
116
|
|
|
$url = calendrier_args_time($d, $script, $type, $fin) . ($ancre ? "#$ancre" : ''); |
|
117
|
|
|
$c = ($class ? " class=\"$class\"" : ''); |
|
118
|
|
|
|
|
119
|
|
|
if ($img) $clic = http_img_pack($img, ($alt ? $alt : $titre), $c); |
|
120
|
|
|
|
|
121
|
|
|
if ($moi AND preg_match($moi, $script)) |
|
122
|
|
|
$evt .= "\nonclick=" . ajax_action_declencheur($h,$ancre); |
|
|
|
|
|
|
123
|
|
|
return http_href($url, PtoBR($clic), attribut_html($titre), $style, $class, $evt); |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
/// Fabrique une balise A, avec tous les attributs possibles |
|
127
|
|
|
/// attention au cas ou la href est du Javascript avec des "'" |
|
128
|
|
|
/// pour un href conforme au validateur W3C, faire & --> & avant |
|
129
|
|
|
|
|
130
|
|
|
// http://doc.spip.org/@http_href |
|
131
|
|
|
function http_href($href, $clic, $title='', $style='', $class='', $evt='') { |
|
132
|
|
|
if ($style) $evt .= " style='$style'"; |
|
133
|
|
|
$r = lien_ou_expose($href, $clic, false, $class, $title, 'nofollow', $evt); |
|
134
|
|
|
return str_replace('<a href=', "<a\nhref=", $r); |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
/// prend une heure de debut et de fin, ainsi qu'une echelle (seconde/pixel) |
|
138
|
|
|
/// et retourne un tableau compose |
|
139
|
|
|
/// - taille d'une heure |
|
140
|
|
|
/// - taille d'une journee |
|
141
|
|
|
/// - taille de la fonte |
|
142
|
|
|
/// - taille de la marge |
|
143
|
|
|
|
|
144
|
|
|
// http://doc.spip.org/@calendrier_echelle |
|
145
|
|
|
function calendrier_echelle($debut, $fin, $echelle) |
|
146
|
|
|
{ |
|
147
|
|
|
if ($echelle==0) $echelle = DEFAUT_D_ECHELLE; |
|
148
|
|
|
if ($fin <= $debut) $fin = $debut +1; |
|
149
|
|
|
|
|
150
|
|
|
$duree = $fin - $debut; |
|
151
|
|
|
$dimheure = floor(3600 / $echelle); |
|
152
|
|
|
return array($dimheure, |
|
153
|
|
|
(($duree+2) * $dimheure), |
|
154
|
|
|
floor(14 / (1+($echelle/240))), |
|
155
|
|
|
floor(240 / $echelle)); |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
/// Calcule le "top" d'une heure |
|
159
|
|
|
|
|
160
|
|
|
// http://doc.spip.org/@calendrier_top |
|
161
|
|
|
function calendrier_top ($heure, $debut, $fin, $dimheure, $dimjour) { |
|
|
|
|
|
|
162
|
|
|
|
|
163
|
|
|
$h_heure = substr($heure, 0, strpos($heure, ":")); |
|
164
|
|
|
$m_heure = substr($heure, strpos($heure,":") + 1, strlen($heure)); |
|
165
|
|
|
$heure100 = $h_heure + ($m_heure/60); |
|
166
|
|
|
|
|
167
|
|
|
if ($heure100 < $debut) $heure100 = ($heure100 / $debut) + $debut - 1; |
|
168
|
|
|
if ($heure100 > $fin) $heure100 = (($heure100-$fin) / (24 - $fin)) + $fin; |
|
169
|
|
|
|
|
170
|
|
|
$top = floor(($heure100 - $debut + 1) * $dimheure); |
|
171
|
|
|
|
|
172
|
|
|
return $top; |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
|
/// Calcule la hauteur entre deux heures |
|
176
|
|
|
// http://doc.spip.org/@calendrier_height |
|
177
|
|
|
function calendrier_height ($heure, $heurefin, $debut, $fin, $dimheure, $dimjour) { |
|
178
|
|
|
|
|
179
|
|
|
$height = calendrier_top ($heurefin, $debut, $fin, $dimheure, $dimjour) |
|
180
|
|
|
- calendrier_top ($heure, $debut, $fin, $dimheure, $dimjour); |
|
181
|
|
|
|
|
182
|
|
|
$padding = floor(($dimheure / 3600) * 240); |
|
183
|
|
|
$height = $height - (2* $padding + 2); // pour padding interieur |
|
184
|
|
|
|
|
185
|
|
|
if ($height < ($dimheure/4)) $height = floor($dimheure/4); // eviter paves totalement ecrases |
|
186
|
|
|
|
|
187
|
|
|
return $height; |
|
188
|
|
|
} |
|
189
|
|
|
|
|
190
|
|
|
/// |
|
191
|
|
|
/// init: calcul generique des evenements a partir des tables SQL |
|
192
|
|
|
/// |
|
193
|
|
|
|
|
194
|
|
|
// http://doc.spip.org/@http_calendrier_init |
|
195
|
|
|
function http_calendrier_init($time='', $type='mois', $echelle='', $partie_cal='', $script='', $evt=null) |
|
196
|
|
|
{ |
|
197
|
|
|
if (is_array($time)) { |
|
198
|
|
|
list($j,$m,$a) = $time; |
|
199
|
|
|
if ($j+$m+$a) $time = @mktime(0,0,0, $m, $j, $a); |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
|
|
if (!is_numeric($time)) $time = time(); |
|
203
|
|
|
|
|
204
|
|
|
$jour = date("d",$time); |
|
205
|
|
|
$mois = date("m",$time); |
|
206
|
|
|
$annee = date("Y",$time); |
|
207
|
|
|
if (!$echelle = intval($echelle)) $echelle = DEFAUT_D_ECHELLE; |
|
208
|
|
|
if (!is_string($type) OR !preg_match('/^\w+$/', $type)) $type ='mois'; |
|
209
|
|
|
if (!is_string($partie_cal) OR !preg_match('/^\w+$/', $partie_cal)) |
|
210
|
|
|
$partie_cal = DEFAUT_PARTIE; |
|
211
|
|
|
list($script, $ancre) = |
|
212
|
|
|
calendrier_retire_args_ancre($script); |
|
213
|
|
|
if (is_null($evt)) { |
|
214
|
|
|
$g = 'quete_calendrier_' . $type; |
|
215
|
|
|
$evt = quete_calendrier_interval($g($annee,$mois, $jour)); |
|
216
|
|
|
quete_calendrier_interval_articles("'$annee-$mois-00'", "'$annee-$mois-1'", $evt[0]); |
|
217
|
|
|
// si on veut les forums, decommenter |
|
218
|
|
|
# quete_calendrier_interval_forums($g($annee,$mois,$jour), $evt[0]); |
|
219
|
|
|
} |
|
220
|
|
|
|
|
221
|
|
|
$f = 'http_calendrier_' . $type; |
|
222
|
|
|
if (!function_exists($f)) $f = 'http_calendrier_mois'; |
|
223
|
|
|
return $f($annee, $mois, $jour, $echelle, $partie_cal, $script, $ancre, $evt); |
|
224
|
|
|
} |
|
225
|
|
|
|
|
226
|
|
|
/// affichage d'un calendrier de mois, avec son bandeau de navigation |
|
227
|
|
|
|
|
228
|
|
|
|
|
229
|
|
|
// http://doc.spip.org/@http_calendrier_mois |
|
230
|
|
|
function http_calendrier_mois($annee, $mois, $jour, $echelle, $partie_cal, $script, $ancre, $evt) |
|
|
|
|
|
|
231
|
|
|
{ |
|
232
|
|
|
global $spip_ecran; |
|
233
|
|
|
if (!isset($spip_ecran)) $spip_ecran = isset($_COOKIE['spip_ecran']) ? $_COOKIE['spip_ecran'] : "large"; |
|
234
|
|
|
|
|
235
|
|
|
if (is_array($evt)) { |
|
236
|
|
|
|
|
237
|
|
|
list($sansduree, $evenements, $premier_jour, $dernier_jour) = $evt; |
|
238
|
|
|
if (!$premier_jour) $premier_jour = '01'; |
|
239
|
|
|
if (!$dernier_jour) |
|
240
|
|
|
{ |
|
241
|
|
|
$dernier_jour = 31; |
|
242
|
|
|
while (!(checkdate($mois,$dernier_jour,$annee))) $dernier_jour--; |
|
243
|
|
|
} |
|
244
|
|
View Code Duplication |
if ($sansduree) |
|
|
|
|
|
|
245
|
|
|
foreach($sansduree as $d => $r) |
|
246
|
|
|
$evenements[$d] = !$evenements[$d] ? $r : array_merge($evenements[$d], $r); |
|
247
|
|
|
$evt = |
|
248
|
|
|
http_calendrier_mois_noms() . |
|
249
|
|
|
http_calendrier_mois_sept($annee, $mois, $premier_jour, $dernier_jour,$evenements, $script, calendrier_retire_defaults($echelle, $partie_cal), $ancre) ; |
|
250
|
|
|
} else { |
|
251
|
|
|
$evt = "<tr><td>$evt</td></tr>"; |
|
252
|
|
|
$premier_jour = '01'; |
|
253
|
|
|
$dernier_jour = '31'; |
|
254
|
|
|
} |
|
255
|
|
|
|
|
256
|
|
|
$id = ($ancre ? $ancre : 'agenda') . "-nav"; |
|
257
|
|
|
|
|
258
|
|
|
return |
|
259
|
|
|
"<div><div id='$id'></div>" . |
|
260
|
|
|
"<table class='calendrier calendrier-$spip_ecran'>" . |
|
261
|
|
|
http_calendrier_mois_navigation($annee, $mois, $premier_jour, $dernier_jour, $echelle, $partie_cal, $script, $ancre) . |
|
262
|
|
|
$evt . |
|
263
|
|
|
'</table>' . |
|
264
|
|
|
http_calendrier_sans_date($annee, $mois, $evenements) . |
|
|
|
|
|
|
265
|
|
|
(!test_espace_prive() ? "" : http_calendrier_aide_mess()) . |
|
266
|
|
|
"</div>"; |
|
267
|
|
|
} |
|
268
|
|
|
|
|
269
|
|
|
/// si la periore a plus de 31 jours, c'est du genre trimestre, semestre etc |
|
270
|
|
|
/// pas de navigation suivant/precedent alors |
|
271
|
|
|
|
|
272
|
|
|
// http://doc.spip.org/@http_calendrier_mois_navigation |
|
273
|
|
|
function http_calendrier_mois_navigation($annee, $mois, $premier_jour, $dernier_jour, $echelle, $partie_cal, $script, $ancre){ |
|
274
|
|
|
if ($dernier_jour > 31) { |
|
275
|
|
|
$prec = $suiv = ''; |
|
276
|
|
|
$periode = affdate_mois_annee(date("Y-m-d", mktime(1,1,1,$mois,$premier_jour,$annee))) . ' - '. affdate_mois_annee(date("Y-m-d", mktime(1,1,1,$mois,$dernier_jour,$annee))); |
|
277
|
|
|
} else { |
|
278
|
|
|
|
|
279
|
|
|
$mois_suiv=$mois+1; |
|
280
|
|
|
$annee_suiv=$annee; |
|
281
|
|
|
$mois_prec=$mois-1; |
|
282
|
|
|
$annee_prec=$annee; |
|
283
|
|
|
if ($mois==1){ |
|
284
|
|
|
$mois_prec=12; |
|
285
|
|
|
$annee_prec=$annee-1; |
|
286
|
|
|
} |
|
287
|
|
|
else if ($mois==12){$mois_suiv=1; $annee_suiv=$annee+1;} |
|
288
|
|
|
$prec = array($annee_prec, $mois_prec, 1, "mois"); |
|
289
|
|
|
$suiv = array($annee_suiv, $mois_suiv, 1, "mois"); |
|
290
|
|
|
$periode = affdate_mois_annee("$annee-$mois-1"); |
|
291
|
|
|
} |
|
292
|
|
|
return |
|
293
|
|
|
http_calendrier_navigation($annee, |
|
294
|
|
|
$mois, |
|
295
|
|
|
1, |
|
296
|
|
|
$echelle, |
|
297
|
|
|
$partie_cal, |
|
298
|
|
|
$periode, |
|
299
|
|
|
$script, |
|
300
|
|
|
$prec, |
|
301
|
|
|
$suiv, |
|
302
|
|
|
'mois', |
|
303
|
|
|
$ancre); |
|
304
|
|
|
|
|
305
|
|
|
} |
|
306
|
|
|
|
|
307
|
|
|
// http://doc.spip.org/@http_calendrier_mois_noms |
|
308
|
|
|
function http_calendrier_mois_noms(){ |
|
309
|
|
|
|
|
310
|
|
|
$bandeau =""; |
|
311
|
|
|
for ($j=1; $j<8;$j++){ |
|
312
|
|
|
$bandeau .= |
|
313
|
|
|
"\n<th>" . |
|
314
|
|
|
_T('date_jour_' . (($j%7)+1)) . |
|
315
|
|
|
"</th>"; |
|
316
|
|
|
} |
|
317
|
|
|
return "\n<tr>$bandeau</tr>"; |
|
318
|
|
|
} |
|
319
|
|
|
|
|
320
|
|
|
/// dispose les lignes d'un calendrier de 7 colonnes (les jours) |
|
321
|
|
|
/// chaque case est garnie avec les evenements du jour figurant dans $evenements |
|
322
|
|
|
|
|
323
|
|
|
// http://doc.spip.org/@http_calendrier_mois_sept |
|
324
|
|
|
function http_calendrier_mois_sept($annee, $mois, $premier_jour, $dernier_jour,$evenements, $script, $finurl, $ancre='') |
|
325
|
|
|
{ |
|
326
|
|
|
global $spip_lang_left, $spip_lang_right; |
|
327
|
|
|
|
|
328
|
|
|
// affichage du debut de semaine hors periode |
|
329
|
|
|
$init = ''; |
|
330
|
|
|
$debut = date("w",mktime(1,1,1,$mois,$premier_jour,$annee)); |
|
331
|
|
|
|
|
332
|
|
|
for ($i=$debut ? $debut : 7;$i>1;$i--) |
|
333
|
|
|
{$init .= "\n<td></td>";} |
|
334
|
|
|
|
|
335
|
|
|
$total = ''; |
|
336
|
|
|
$ligne = ''; |
|
337
|
|
|
$today=date("Ymd"); |
|
338
|
|
|
for ($j=$premier_jour; $j<=$dernier_jour; $j++){ |
|
339
|
|
|
$nom = mktime(1,1,1,$mois,$j,$annee); |
|
340
|
|
|
$jour = date("d",$nom); |
|
341
|
|
|
$jour_semaine = date("w",$nom); |
|
342
|
|
|
$mois_en_cours = date("m",$nom); |
|
343
|
|
|
$annee_en_cours = date("Y",$nom); |
|
344
|
|
|
$amj = date("Y",$nom) . $mois_en_cours . $jour; |
|
345
|
|
|
$couleur_texte = "black"; |
|
346
|
|
|
$fond = ""; |
|
347
|
|
|
|
|
348
|
|
|
if ($jour_semaine == 0) $fond = 'jour_dimanche '; |
|
349
|
|
|
else if ($jour_semaine==1) |
|
350
|
|
|
{ |
|
351
|
|
|
if ($ligne||$init) |
|
352
|
|
|
$total .= "\n<tr>$init$ligne</tr>"; |
|
353
|
|
|
$ligne = $init = ''; |
|
354
|
|
|
} |
|
355
|
|
|
|
|
356
|
|
|
if ($amj == $today) { |
|
357
|
|
|
$couleur_texte = "red"; |
|
358
|
|
|
$fond = "jour_encours "; |
|
359
|
|
|
} |
|
360
|
|
|
|
|
361
|
|
|
$res = (test_espace_prive() ? |
|
362
|
|
|
(calendrier_href($script,$annee_en_cours, $mois_en_cours, $jour, "jour", $finurl, $ancre, '', $jour, 'calendrier-helvetica16', '', $jour, "color: $couleur_texte") . |
|
363
|
|
|
http_calendrier_ics_message($annee_en_cours, $mois_en_cours, $jour, false)): |
|
364
|
|
|
http_calendrier_mois_clics($annee_en_cours, $mois_en_cours, $jour, $script, $finurl, $ancre)); |
|
365
|
|
|
|
|
366
|
|
|
if ($evts = $evenements[$amj]) { |
|
367
|
|
|
foreach ($evts as $evenement) |
|
368
|
|
|
{ |
|
369
|
|
|
$res .= isset($evenement['DTSTART']) ? |
|
370
|
|
|
http_calendrier_avec_heure($evenement, $amj) : |
|
371
|
|
|
http_calendrier_sans_heure($evenement); |
|
372
|
|
|
} |
|
373
|
|
|
} |
|
374
|
|
|
$fond .= $ligne ? "bordure_$spip_lang_right" :'bordure_double'; |
|
375
|
|
|
$d = sprintf('D%4d-%02d-%02d', $annee_en_cours,$mois_en_cours,$jour); |
|
376
|
|
|
$ligne .= "\n<td id='$d' class='$fond'>$res</td>"; |
|
377
|
|
|
} |
|
378
|
|
|
return $total . ($ligne ? "\n<tr>$ligne</tr>" : ''); |
|
379
|
|
|
} |
|
380
|
|
|
|
|
381
|
|
|
/// Appelle la fonction precedente en sachant que ca produira 1 TD/TR unique. |
|
382
|
|
|
/// retourne le contenu du TD |
|
383
|
|
|
|
|
384
|
|
|
function http_calendrier_sept_un($annee, $mois, $jour,$evenements, $script, $finurl, $ancre='', $class='', $att='') |
|
|
|
|
|
|
385
|
|
|
{ |
|
386
|
|
|
$res = http_calendrier_mois_sept($annee, $mois, $jour, $jour,$evenements, $script, $finurl, $ancre); |
|
387
|
|
|
preg_match(',^\s*<tr>\s*<td[^>]*>(.*?)</td>\s*</tr>\s*$,s', $res, $m); |
|
388
|
|
|
|
|
389
|
|
|
return $m[1]; |
|
390
|
|
|
} |
|
391
|
|
|
|
|
392
|
|
|
/// typo pour l'espace public |
|
393
|
|
|
// http://doc.spip.org/@http_calendrier_mois_clics |
|
394
|
|
|
function http_calendrier_mois_clics($annee, $mois, $jour, $script, $finurl, $ancre) |
|
395
|
|
|
{ |
|
396
|
|
|
$d = mktime(0,0,0,$mois, $jour, $annee); |
|
397
|
|
|
$semaine = date("W", $d); |
|
398
|
|
|
|
|
399
|
|
|
$semaine = calendrier_href($script,$annee, $mois, $jour, "semaine", $finurl, $ancre,'', |
|
400
|
|
|
(_T('date_semaines') . ": $semaine"), |
|
401
|
|
|
'','', $semaine); |
|
402
|
|
|
|
|
403
|
|
|
$jour = calendrier_href($script,$annee, $mois, $jour, "jour", $finurl, $ancre, '', |
|
404
|
|
|
(_T('date_jour_'. (1+date('w',$d))) . |
|
405
|
|
|
" $jour " . |
|
406
|
|
|
_T('date_mois_'.(0+$mois))), |
|
407
|
|
|
'', '', |
|
408
|
|
|
"$jour/$mois"); |
|
409
|
|
|
|
|
410
|
|
|
return "$jour$semaine"; |
|
411
|
|
|
} |
|
412
|
|
|
|
|
413
|
|
|
/// dispose les evenements d'une semaine |
|
414
|
|
|
|
|
415
|
|
|
// http://doc.spip.org/@http_calendrier_semaine |
|
416
|
|
|
function http_calendrier_semaine($annee, $mois, $jour, $echelle, $partie_cal, $script, $ancre, $evt) |
|
417
|
|
|
{ |
|
418
|
|
|
global $spip_ecran; |
|
419
|
|
|
if (!isset($spip_ecran)) $spip_ecran = isset($_COOKIE['spip_ecran']) ? $_COOKIE['spip_ecran'] : "large"; |
|
420
|
|
|
|
|
421
|
|
|
$finurl = calendrier_retire_defaults($echelle, $partie_cal); |
|
422
|
|
|
$init = date("w",mktime(1,1,1,$mois,$jour,$annee)); |
|
423
|
|
|
$init = $jour+1-($init ? $init : 7); |
|
424
|
|
|
$sd = ''; |
|
425
|
|
|
|
|
426
|
|
|
if (is_array($evt)) { |
|
427
|
|
|
if ($partie_cal!= DEFAUT_PARTIE_R) { |
|
428
|
|
|
$sd = http_calendrier_sans_date($annee, $mois, $evt[0]); |
|
429
|
|
|
$evt = http_calendrier_semaine_sept($annee, $mois, $init, $echelle, $partie_cal, $evt); |
|
430
|
|
|
} else { |
|
431
|
|
|
list($sansduree, $evenements, , ) = $evt; |
|
432
|
|
View Code Duplication |
if ($sansduree) |
|
|
|
|
|
|
433
|
|
|
foreach($sansduree as $d => $r) |
|
434
|
|
|
$evenements[$d] = !$evenements[$d] ? $r : array_merge($evenements[$d], $r); |
|
435
|
|
|
$evt = http_calendrier_mois_sept($annee, $mois, $init, $init+ 6, $evenements, $script, $finurl, $ancre); |
|
436
|
|
|
} |
|
437
|
|
|
} else $evt = "<tr><td >$evt</td></tr>"; |
|
438
|
|
|
|
|
439
|
|
|
$id = ($ancre ? $ancre : 'agenda') . "-nav"; |
|
440
|
|
|
|
|
441
|
|
|
return |
|
442
|
|
|
"<div><div id='$id'></div>" . |
|
443
|
|
|
"<table class='calendrier calendrier-$spip_ecran'>" . |
|
444
|
|
|
http_calendrier_semaine_navigation($annee, $mois, $init, $echelle, $partie_cal, $script, $ancre) . |
|
445
|
|
|
http_calendrier_semaine_noms($annee, $mois, $init, $script, $finurl, $ancre) . |
|
446
|
|
|
$evt . |
|
447
|
|
|
"</table>" . |
|
448
|
|
|
$sd . |
|
449
|
|
|
(!test_espace_prive() ? "" : http_calendrier_aide_mess()) . |
|
450
|
|
|
"</div>"; |
|
451
|
|
|
} |
|
452
|
|
|
|
|
453
|
|
|
// http://doc.spip.org/@http_calendrier_semaine_navigation |
|
454
|
|
|
function http_calendrier_semaine_navigation($annee, $mois, $jour, $echelle, $partie_cal, $script, $ancre){ |
|
455
|
|
|
|
|
456
|
|
|
$fin = mktime (1,1,1,$mois, $jour+6, $annee); |
|
457
|
|
|
$fjour = date("d",$fin); |
|
458
|
|
|
$fmois = date("m",$fin); |
|
459
|
|
|
$fannee = date("Y",$fin); |
|
460
|
|
|
$fin = date("Y-m-d", $fin); |
|
461
|
|
|
$debut = mktime (1,1,1,$mois, $jour, $annee); |
|
462
|
|
|
$djour = date("d",$debut)+0; |
|
463
|
|
|
$dmois = date("m",$debut); |
|
464
|
|
|
$dannee = date("Y",$debut); |
|
465
|
|
|
$debut = date("Y-m-d", $debut); |
|
466
|
|
|
$periode = (($dannee != $fannee) ? |
|
467
|
|
|
(affdate($debut)." - ".affdate($fin)) : |
|
468
|
|
|
(($dmois == $fmois) ? |
|
469
|
|
|
($djour ." - ".affdate_jourcourt($fin)) : |
|
470
|
|
|
(affdate_jourcourt($debut)." - ".affdate_jourcourt($fin)))); |
|
471
|
|
|
|
|
472
|
|
|
return |
|
473
|
|
|
http_calendrier_navigation($annee, |
|
474
|
|
|
$mois, |
|
475
|
|
|
$jour, |
|
476
|
|
|
$echelle, |
|
477
|
|
|
$partie_cal, |
|
478
|
|
|
$periode, |
|
479
|
|
|
$script, |
|
480
|
|
|
array($dannee, $dmois, ($djour-7), "semaine"), |
|
481
|
|
|
array($fannee, $fmois, ($fjour+1), "semaine"), |
|
482
|
|
|
'semaine', |
|
483
|
|
|
$ancre); |
|
484
|
|
|
} |
|
485
|
|
|
|
|
486
|
|
|
// http://doc.spip.org/@http_calendrier_semaine_noms |
|
487
|
|
|
function http_calendrier_semaine_noms($annee, $mois, $jour, $script, $finurl, $ancre){ |
|
488
|
|
|
|
|
489
|
|
|
$bandeau = ''; |
|
490
|
|
|
|
|
491
|
|
|
for ($j=$jour; $j<$jour+7;$j++){ |
|
492
|
|
|
$nom = mktime(0,0,0,$mois,$j,$annee); |
|
493
|
|
|
$num = intval(date("d", $nom)) ; |
|
494
|
|
|
$numois = date("m",$nom); |
|
495
|
|
|
$nomjour = _T('date_jour_'. (1+date('w',$nom))); |
|
496
|
|
|
$clic = ($nomjour . " " . $num . (($num == 1) ? 'er' : '') . |
|
497
|
|
|
($ancre ? ('/' . $numois) : '')); |
|
498
|
|
|
$bandeau .= |
|
499
|
|
|
"\n\t<th>" . |
|
500
|
|
|
calendrier_href($script, date("Y",$nom), $numois, $num, 'jour', $finurl, $ancre, '', $clic, '', '', $clic) . |
|
501
|
|
|
"</th>"; |
|
502
|
|
|
} |
|
503
|
|
|
return "\n<tr>$bandeau</tr>"; |
|
504
|
|
|
} |
|
505
|
|
|
|
|
506
|
|
|
// http://doc.spip.org/@http_calendrier_semaine_sept |
|
507
|
|
|
function http_calendrier_semaine_sept($annee, $mois, $jour, $echelle, $partie_cal, $evt) |
|
508
|
|
|
{ |
|
509
|
|
|
global $spip_ecran, $spip_lang_left; |
|
510
|
|
|
|
|
511
|
|
|
$largeur = ($spip_ecran == "large") ? 80 : 60; |
|
512
|
|
|
|
|
513
|
|
|
$today=date("Ymd"); |
|
514
|
|
|
$total = ''; |
|
515
|
|
|
|
|
516
|
|
|
for ($j=$jour; $j<$jour+7;$j++){ |
|
517
|
|
|
$d = mktime(0,0,0,$mois, $j, $annee); |
|
518
|
|
|
$v = http_calendrier_ics($annee, $mois, $j, $echelle, $partie_cal, $largeur, $evt, '', ( (date("w",$d)==0 && test_espace_prive()) ? |
|
519
|
|
|
" jour_dimanche" : |
|
520
|
|
|
((date("Ymd", $d) == $today) ? |
|
521
|
|
|
" jour_encours" : |
|
522
|
|
|
" jour_gris") ) ) ; |
|
523
|
|
|
$d = sprintf('D%4d-%02d-%02d', $annee,$mois,$j); |
|
524
|
|
|
$total .= "\n<td id='$d'>$v</td>"; |
|
525
|
|
|
} |
|
526
|
|
|
return "\n<tr class='heure'>$total</tr>"; |
|
527
|
|
|
} |
|
528
|
|
|
|
|
529
|
|
|
|
|
530
|
|
|
// http://doc.spip.org/@http_calendrier_jour |
|
531
|
|
|
function http_calendrier_jour($annee, $mois, $jour, $echelle, $partie_cal, $script, $ancre, $evt){ |
|
532
|
|
|
global $spip_ecran; |
|
533
|
|
|
if (!isset($spip_ecran)) $spip_ecran = isset($_COOKIE['spip_ecran']) ? $_COOKIE['spip_ecran'] : "large"; |
|
534
|
|
|
|
|
535
|
|
|
$id = ($ancre ? $ancre : 'agenda') . "-nav"; |
|
536
|
|
|
|
|
537
|
|
|
return |
|
538
|
|
|
"<div><div id='$id'></div>" . |
|
539
|
|
|
"<table class='calendrier calendrier-$spip_ecran'>" . |
|
540
|
|
|
http_calendrier_navigation($annee, $mois, $jour, $echelle, $partie_cal, |
|
541
|
|
|
(nom_jour("$annee-$mois-$jour") . " " . |
|
542
|
|
|
affdate_jourcourt("$annee-$mois-$jour")), |
|
543
|
|
|
$script, |
|
544
|
|
|
array($annee, $mois, ($jour-1), "jour"), |
|
545
|
|
|
array($annee, $mois, ($jour+1), "jour"), |
|
546
|
|
|
'jour', |
|
547
|
|
|
$ancre) . |
|
548
|
|
|
(!is_array($evt) ? ("<tr><td>$evt</td></tr>") : |
|
549
|
|
|
(http_calendrier_jour_noms($annee, $mois, $jour, $echelle, $partie_cal, $script, $ancre) . |
|
550
|
|
|
http_calendrier_jour_sept($annee, $mois, $jour, $echelle, $partie_cal, $script, $ancre, $evt))) . |
|
551
|
|
|
"</table>" . |
|
552
|
|
|
"</div>"; |
|
553
|
|
|
} |
|
554
|
|
|
|
|
555
|
|
|
// http://doc.spip.org/@http_calendrier_jour_noms |
|
556
|
|
|
function http_calendrier_jour_noms($annee, $mois, $jour, $echelle, $partie_cal, $script, $ancre){ |
|
557
|
|
|
|
|
558
|
|
|
global $spip_ecran; |
|
559
|
|
|
|
|
560
|
|
|
if (!test_espace_prive()) return ''; |
|
561
|
|
|
|
|
562
|
|
|
$finurl = calendrier_retire_defaults($echelle, $partie_cal); |
|
563
|
|
|
|
|
564
|
|
|
if ($spip_ecran != "large") { |
|
565
|
|
|
$c = ''; |
|
566
|
|
|
} else { $c = http_calendrier_ics_titre($annee,$mois,$jour-1,$script, $finurl, $ancre); |
|
567
|
|
|
} |
|
568
|
|
|
return |
|
569
|
|
|
"\n<tr class='calendrier-titre-jour'><th>$c</th><th></th><th>" . |
|
570
|
|
|
("\n<div class='calendrier-titre'>" . |
|
571
|
|
|
http_calendrier_ics_message($annee, $mois, $jour, true) . |
|
572
|
|
|
'</div>') . |
|
573
|
|
|
"</th><th></th><th>" . |
|
574
|
|
|
http_calendrier_ics_titre($annee,$mois,$jour+1,$script, $finurl, $ancre) . |
|
575
|
|
|
"</th></tr>"; |
|
576
|
|
|
} |
|
577
|
|
|
|
|
578
|
|
|
// http://doc.spip.org/@http_calendrier_jour_sept |
|
579
|
|
|
function http_calendrier_jour_sept($annee, $mois, $jour, $echelle, $partie_cal, $script, $ancre, $evt){ |
|
580
|
|
|
global $spip_ecran; |
|
581
|
|
|
|
|
582
|
|
|
$gauche = (test_espace_prive() AND ($spip_ecran == "large")); |
|
583
|
|
|
|
|
584
|
|
|
if ($partie_cal!= DEFAUT_PARTIE_R) { |
|
585
|
|
|
$gauche = !$gauche ? '' : http_calendrier_ics($annee, $mois, $jour-1, $echelle, $partie_cal, 0, $evt); |
|
586
|
|
|
$mil = http_calendrier_ics($annee, $mois, $jour, $echelle, $partie_cal, 300, $evt); |
|
587
|
|
|
$droite = (!test_espace_prive() ? '': |
|
588
|
|
|
http_calendrier_ics($annee, $mois, $jour+1, $echelle, $partie_cal, 0, $evt)); |
|
589
|
|
|
} else { |
|
590
|
|
|
list($sansduree, $evenements, $premier_jour, $dernier_jour) = $evt; |
|
|
|
|
|
|
591
|
|
|
|
|
592
|
|
View Code Duplication |
if ($sansduree) |
|
|
|
|
|
|
593
|
|
|
foreach($sansduree as $d => $r) |
|
594
|
|
|
$evenements[$d] = !$evenements[$d] ? $r : array_merge($evenements[$d], $r); |
|
595
|
|
|
$gauche = (!$gauche ? "" : |
|
596
|
|
|
http_calendrier_sept_un($annee, $mois, $jour-1, $evenements, $script, '', $ancre) |
|
597
|
|
|
); |
|
598
|
|
|
$mil = http_calendrier_sept_un($annee, $mois, $jour, $evenements, $script, '', $ancre); |
|
599
|
|
|
$droite = (!test_espace_prive() ? "" :http_calendrier_sept_un($annee, $mois, $jour+1,$evenements, $script, '', $ancre)); |
|
600
|
|
|
} |
|
601
|
|
|
$d = sprintf('D%4d-%02d-%02d', $annee,$mois,$jour); |
|
602
|
|
|
if (!test_espace_prive()) |
|
603
|
|
|
return "<tr class='calendrier-3jours'><td id='$d' colspan='5'>$mil</td></tr>"; |
|
604
|
|
|
$gauche = !$gauche ? "<td colspan='3' id='$d'>" : "<td>$gauche</td><td></td><td id='$d'>"; |
|
605
|
|
|
return "<tr class='calendrier-3jours'>$gauche$mil</td><td></td><td>$droite</td></tr>"; |
|
606
|
|
|
} |
|
607
|
|
|
|
|
608
|
|
|
|
|
609
|
|
|
/// Conversion d'un tableau de champ ics en des balises div positionnees |
|
610
|
|
|
/// Le champ categories indique la Classe de CSS a prendre |
|
611
|
|
|
/// $echelle est le nombre de secondes representees par 1 pixel |
|
612
|
|
|
/// $partie_cal donne l'intervalle des heures affichee |
|
613
|
|
|
/// a travers la globale calendrier_partie ou sous la forme D_F |
|
614
|
|
|
|
|
615
|
|
|
// http://doc.spip.org/@http_calendrier_ics |
|
616
|
|
|
function http_calendrier_ics($annee, $mois, $jour, $echelle, $partie_cal, $largeur, $evt, $style='', $class='') { |
|
617
|
|
|
global $spip_lang_left; |
|
618
|
|
|
|
|
619
|
|
|
if (is_array($GLOBALS['calendrier_partie'][$partie_cal])) { |
|
620
|
|
|
$debut = $GLOBALS['calendrier_partie'][$partie_cal]['debut']; |
|
621
|
|
|
$fin = $GLOBALS['calendrier_partie'][$partie_cal]['fin']; |
|
622
|
|
|
} elseif (preg_match('/^(\d+)\D(\d+)$/', $partie_cal, $m)) |
|
623
|
|
|
list(,$debut, $fin) = $m; |
|
624
|
|
|
else { |
|
625
|
|
|
$debut = 7; |
|
626
|
|
|
$fin =21; |
|
627
|
|
|
} |
|
628
|
|
|
|
|
629
|
|
|
if ($echelle==0) $echelle = DEFAUT_D_ECHELLE; |
|
630
|
|
|
|
|
631
|
|
|
list($dimheure, $dimjour, $fontsize, $padding) = |
|
632
|
|
|
calendrier_echelle($debut, $fin, $echelle); |
|
633
|
|
|
$size = sprintf("%0.2f", DEFAUT_TAILLE_HEURE+(10/$echelle)); |
|
634
|
|
|
$style .= "height:${dimjour}px;font-size:${size}em;"; |
|
635
|
|
|
$date = date("Ymd", mktime(0,0,0,$mois, $jour, $annee)); |
|
636
|
|
|
|
|
637
|
|
|
$avecheure = !isset($evt[1][$date]) ? '' : http_calendrier_ics_div($evt[1][$date], $date, $debut, $fin, $dimheure, $dimjour, $echelle, $largeur, $padding); |
|
638
|
|
|
|
|
639
|
|
|
$sansheure = !isset($evt[0][$date]) ? '' : http_calendrier_ics_trois($evt[0][$date], $largeur, $dimjour, $fontsize, ''); |
|
640
|
|
|
|
|
641
|
|
|
|
|
642
|
|
|
return |
|
643
|
|
|
"\n<div class='calendrier-jour$class' style='$style'>" . |
|
644
|
|
|
http_calendrier_ics_grille($debut, $fin, $dimheure, $dimjour, $echelle) . |
|
645
|
|
|
$avecheure . |
|
646
|
|
|
"\n</div>" . |
|
647
|
|
|
$sansheure; |
|
648
|
|
|
} |
|
649
|
|
|
|
|
650
|
|
|
function http_calendrier_ics_div($evts, $date, $debut, $fin, $dimheure, $dimjour, $echelle, $largeur, $padding) |
|
651
|
|
|
{ |
|
652
|
|
|
global $spip_lang_left; |
|
653
|
|
|
$total = ''; |
|
654
|
|
|
$tous = 1 + count($evts); |
|
655
|
|
|
$i = $bas_prec = 0; |
|
656
|
|
|
|
|
657
|
|
|
foreach($evts as $evenement) { |
|
658
|
|
|
|
|
659
|
|
|
$d = $evenement['DTSTART']; |
|
660
|
|
|
$e = $evenement['DTEND']; |
|
661
|
|
|
$d_jour = substr($d,0,8); |
|
662
|
|
|
$e_jour = $e ? substr($e,0,8) : $d_jour; |
|
663
|
|
|
$debut_avant = false; |
|
664
|
|
|
$fin_apres = false; |
|
665
|
|
|
|
|
666
|
|
|
if ($d_jour > $date OR $e_jour < $date) continue; |
|
667
|
|
|
|
|
668
|
|
|
$i++; |
|
669
|
|
|
|
|
670
|
|
|
// Verifier si debut est jour precedent |
|
671
|
|
|
if (substr($d,0,8) < $date) |
|
672
|
|
|
{ |
|
673
|
|
|
$heure_debut = 0; $minutes_debut = 0; |
|
674
|
|
|
$debut_avant = true; |
|
675
|
|
|
$radius_top = ""; |
|
|
|
|
|
|
676
|
|
|
} |
|
677
|
|
|
else |
|
678
|
|
|
{ |
|
679
|
|
|
$heure_debut = substr($d,-6,2); |
|
680
|
|
|
$minutes_debut = substr($d,-4,2); |
|
681
|
|
|
} |
|
682
|
|
|
|
|
683
|
|
|
if (!$e) |
|
684
|
|
|
{ |
|
685
|
|
|
$heure_fin = $heure_debut ; |
|
686
|
|
|
$minutes_fin = $minutes_debut ; |
|
687
|
|
|
$bordure = "border-bottom: dashed 2px"; |
|
688
|
|
|
} |
|
689
|
|
|
else |
|
690
|
|
|
{ |
|
691
|
|
|
$bordure = ""; |
|
692
|
|
|
if (substr($e,0,8) > $date) |
|
693
|
|
|
{ |
|
694
|
|
|
$heure_fin = 23; $minutes_fin = 59; |
|
695
|
|
|
$fin_apres = true; |
|
696
|
|
|
$radius_bottom = ""; |
|
|
|
|
|
|
697
|
|
|
} |
|
698
|
|
|
else |
|
699
|
|
|
{ |
|
700
|
|
|
$heure_fin = substr($e,-6,2); |
|
701
|
|
|
$minutes_fin = substr($e,-4,2); |
|
702
|
|
|
} |
|
703
|
|
|
} |
|
704
|
|
|
|
|
705
|
|
|
$opacity = ($debut_avant && $fin_apres) ? "calendrier-opacity60" : ""; |
|
|
|
|
|
|
706
|
|
|
|
|
707
|
|
|
$haut = calendrier_top ("$heure_debut:$minutes_debut", $debut, $fin, $dimheure, $dimjour); |
|
708
|
|
|
$bas = !$e ? $haut :calendrier_top ("$heure_fin:$minutes_fin", $debut, $fin, $dimheure, $dimjour); |
|
709
|
|
|
$hauteur = calendrier_height ("$heure_debut:$minutes_debut", "$heure_fin:$minutes_fin", $debut, $fin, $dimheure, $dimjour); |
|
710
|
|
|
|
|
711
|
|
|
if ($bas_prec >= $haut) $decale += 1; |
|
|
|
|
|
|
712
|
|
|
else $decale = DEFAUT_DECALE - |
|
713
|
|
|
(($echelle >= DEFAUT_D_ECHELLE) ? 0 : 1); |
|
714
|
|
|
if ($bas > $bas_prec) $bas_prec = $bas; |
|
715
|
|
|
|
|
716
|
|
|
$colors = $evenement['CATEGORIES']; |
|
717
|
|
|
$url = isset($evenement['URL']) ? $evenement['URL'] : ''; |
|
718
|
|
|
$desc = PtoBR(propre($evenement['DESCRIPTION'])); |
|
719
|
|
|
$perso = construire_personne_ics($evenement['ATTENDEE']); |
|
720
|
|
|
$lieu = isset($evenement['LOCATION']) ? $evenement['LOCATION'] : ''; |
|
721
|
|
|
$sum = typo($evenement['SUMMARY']); |
|
722
|
|
|
if (!$sum) { $sum = $desc; $desc = '';} |
|
723
|
|
|
if (!$sum) { $sum = $lieu; $lieu = '';} |
|
724
|
|
|
if (!$sum) { $sum = textebrut($perso);} |
|
725
|
|
|
if ($sum) { |
|
726
|
|
|
if ($url) |
|
727
|
|
|
$sum = http_href(quote_amp($url), $sum, attribut_html($desc), '', "calendrier-summary calendrier-url $colors"); |
|
728
|
|
|
else $sum = "<span class='calendrier-summary'>$sum</span>"; |
|
729
|
|
|
} |
|
730
|
|
|
|
|
731
|
|
|
if (($largeur > 90) && $desc) |
|
732
|
|
|
$sum .= "\n<br /><span class='calendrier-noir'>$desc</span>"; |
|
733
|
|
|
if ($lieu) |
|
734
|
|
|
$sum .= "\n<span class='calendrier-location'>$lieu</span>"; |
|
735
|
|
|
if ($perso AND $perso != $sum) |
|
736
|
|
|
$sum .= "\n<span class='calendrier-attendee $colors'>$perso</span>"; |
|
737
|
|
|
$sum = pipeline('agenda_rendu_evenement',array('args'=>array('evenement'=>$evenement,'type'=>'ics'),'data'=>$sum)); |
|
738
|
|
|
|
|
739
|
|
|
$width = $largeur - ($padding<<1) - DEFAUT_DECALE; |
|
740
|
|
|
$fontsize = sprintf("%0.2f", 1+(10/$echelle)); |
|
741
|
|
|
$style = "z-index:${i};${spip_lang_left}:${decale}em;top:${haut}px;height:${hauteur}px;width:${width}px;font-size:${fontsize}em;padding:${padding}px;$bordure"; |
|
742
|
|
|
$total .= "\n<div class='$colors calendrier-evt' style='$style' |
|
743
|
|
|
onmouseover=\"this.style.zIndex=" . $tous . "\" |
|
744
|
|
|
onmouseout=\"this.style.zIndex=" . $i . "\">" . |
|
745
|
|
|
$sum . |
|
746
|
|
|
"</div>"; |
|
747
|
|
|
} |
|
748
|
|
|
return $total; |
|
749
|
|
|
} |
|
750
|
|
|
|
|
751
|
|
|
/// Affiche une grille horaire |
|
752
|
|
|
/// Selon l'echelle demandee, on affiche heure, 1/2 heure 1/4 heure, 5minutes. |
|
753
|
|
|
|
|
754
|
|
|
// http://doc.spip.org/@http_calendrier_ics_grille |
|
755
|
|
|
function http_calendrier_ics_grille($debut, $fin, $dimheure, $dimjour, $echelle) |
|
756
|
|
|
{ |
|
757
|
|
|
global $spip_lang_left, $spip_lang_right; |
|
758
|
|
|
$size = floor(14 / (1+($echelle/240))); |
|
759
|
|
|
$slice = floor($dimheure/(2*$size)); |
|
760
|
|
|
if ($slice%2) $slice --; |
|
761
|
|
|
if (!$slice) $slice = 1; |
|
762
|
|
|
|
|
763
|
|
|
$total = ''; |
|
764
|
|
|
for ($i = $debut; $i < $fin; $i++) { |
|
765
|
|
|
$k = "$i:00"; |
|
766
|
|
|
$n = calendrier_top ($k, $debut, $fin, $dimheure, $dimjour); |
|
767
|
|
|
$total .= "\n<span style='$spip_lang_left:0;top:${n}px;'>$k</span>"; |
|
768
|
|
|
for ($j=1; $j < $slice; $j++) |
|
769
|
|
|
{ |
|
770
|
|
|
$k = $i .':' . sprintf("%02d",floor(($j*60)/$slice)); |
|
771
|
|
|
$n = calendrier_top ($k, $debut, $fin, $dimheure, $dimjour); |
|
772
|
|
|
$total .= "\n<span class='calendrier-jour-m' style='$spip_lang_left:0;top:${n}px;'>$k</span>"; |
|
773
|
|
|
} |
|
774
|
|
|
} |
|
775
|
|
|
|
|
776
|
|
|
$n = calendrier_top ("$fin:00", $debut, $fin, $dimheure, $dimjour); |
|
777
|
|
|
|
|
778
|
|
|
$c = ($dimjour - $size - 2); |
|
779
|
|
|
|
|
780
|
|
|
return "\n<span style='border:0;$spip_lang_left:0;top:2px;'>0:00</span>" . |
|
781
|
|
|
$total . |
|
782
|
|
|
"\n<span style='$spip_lang_left:0;top:${n}px;'>$fin:00</span>" . |
|
783
|
|
|
"\n<span style='border:0;$spip_lang_left:0;top:${c}px;'>23:59</span>"; |
|
784
|
|
|
} |
|
785
|
|
|
|
|
786
|
|
|
/// si la largeur le permet, les evenements sans duree, |
|
787
|
|
|
/// se placent a cote des autres, sinon en dessous |
|
788
|
|
|
|
|
789
|
|
|
// http://doc.spip.org/@http_calendrier_ics_trois |
|
790
|
|
|
function http_calendrier_ics_trois($evt, $largeur, $dimjour, $echelle, $border) |
|
|
|
|
|
|
791
|
|
|
{ |
|
792
|
|
|
global $spip_lang_left; |
|
793
|
|
|
|
|
794
|
|
|
$types = array(); |
|
795
|
|
|
foreach($evt as $v) |
|
796
|
|
|
$types[isset($v['DESCRIPTION']) ? 'info_articles' : |
|
797
|
|
|
(isset($v['DTSTART']) ? 'info_liens_syndiques_3' : |
|
798
|
|
|
'info_breves_02')][] = $v; |
|
799
|
|
|
$res = ''; |
|
800
|
|
|
foreach ($types as $k => $v) { |
|
801
|
|
|
$res2 = ''; |
|
802
|
|
|
foreach ($v as $evenement) { |
|
803
|
|
|
$res2 .= http_calendrier_sans_heure($evenement); |
|
804
|
|
|
} |
|
805
|
|
|
$res .= "\n<div class='calendrier-verdana calendrier-titre'>". |
|
806
|
|
|
_T($k) . |
|
807
|
|
|
"</div>" . |
|
808
|
|
|
$res2; |
|
809
|
|
|
} |
|
810
|
|
|
$size = floor(14 / (1+($echelle/240))); |
|
811
|
|
|
if ($largeur > 90) { |
|
812
|
|
|
$largeur += (5*$size); |
|
813
|
|
|
$pos = "-$dimjour"; |
|
814
|
|
|
} else { $largeur = (3*$size); $pos= 0; } |
|
815
|
|
|
|
|
816
|
|
|
return "\n<div style='position: relative; z-index: 2; top: ${pos}px; margin-$spip_lang_left: " . $largeur . "px'>$res</div>"; |
|
817
|
|
|
} |
|
818
|
|
|
|
|
819
|
|
|
// http://doc.spip.org/@http_calendrier_ics_titre |
|
820
|
|
|
function http_calendrier_ics_titre($annee, $mois, $jour,$script, $finurl='', $ancre='') |
|
821
|
|
|
{ |
|
822
|
|
|
$date = mktime(0,0,0,$mois, $jour, $annee); |
|
823
|
|
|
$jour = date("d",$date); |
|
824
|
|
|
$mois = date("m",$date); |
|
825
|
|
|
$annee = date("Y",$date); |
|
826
|
|
|
$nom = affdate_jourcourt("$annee-$mois-$jour"); |
|
827
|
|
|
return "<div class='calendrier-arial10 calendrier-titre'>" . |
|
828
|
|
|
calendrier_href($script, $annee, $mois, $jour, 'jour', $finurl, $ancre, '', $nom, 'calendrier-noir','',$nom) . |
|
829
|
|
|
"</div>"; |
|
830
|
|
|
} |
|
831
|
|
|
|
|
832
|
|
|
|
|
833
|
|
|
// http://doc.spip.org/@http_calendrier_sans_date |
|
834
|
|
|
function http_calendrier_sans_date($annee, $mois, $evenements) |
|
835
|
|
|
{ |
|
836
|
|
|
$r = $evenements[0+($annee . $mois . "00")]; |
|
837
|
|
|
if (!$r) return ""; |
|
838
|
|
|
$res = "\n<div class='calendrier-arial10 calendrier-titre'>". |
|
839
|
|
|
_T('info_mois_courant'). |
|
840
|
|
|
"</div>"; |
|
841
|
|
|
foreach ($r as $evenement) $res .= http_calendrier_sans_heure($evenement); |
|
842
|
|
|
return $res; |
|
843
|
|
|
} |
|
844
|
|
|
|
|
845
|
|
|
|
|
846
|
|
|
// http://doc.spip.org/@http_calendrier_sans_heure |
|
847
|
|
|
function http_calendrier_sans_heure($ev) |
|
848
|
|
|
{ |
|
849
|
|
|
$desc = PtoBR(propre($ev['DESCRIPTION'])); |
|
850
|
|
|
$sum = typo($ev['SUMMARY']); |
|
851
|
|
|
if (!$sum) $sum = $desc; |
|
852
|
|
|
$i = isset($ev['DESCRIPTION']) ? 11 : 9; // 11: article; 9:autre |
|
853
|
|
|
if ($ev['URL']) |
|
854
|
|
|
$sum = http_href(quote_amp($ev['URL']), $sum, attribut_html($desc)); |
|
855
|
|
|
$sum = pipeline('agenda_rendu_evenement',array('args'=>array('evenement'=>$ev,'type'=>'sans_heure'),'data'=>$sum)); |
|
856
|
|
|
return "\n<div class='calendrier-arial$i calendrier-evenement'>" . |
|
857
|
|
|
"<span class='" . $ev['CATEGORIES'] . "'> </span> $sum</div>"; |
|
858
|
|
|
} |
|
859
|
|
|
|
|
860
|
|
|
// http://doc.spip.org/@http_calendrier_avec_heure |
|
861
|
|
|
function http_calendrier_avec_heure($evenement, $amj) |
|
862
|
|
|
{ |
|
863
|
|
|
$jour_debut = substr($evenement['DTSTART'], 0,8); |
|
864
|
|
|
$jour_fin = substr($evenement['DTEND'], 0, 8); |
|
865
|
|
|
if ($jour_fin <= 0) $jour_fin = $jour_debut; |
|
866
|
|
|
if (($jour_debut <= 0) OR ($jour_debut > $amj) OR ($jour_fin < $amj)) |
|
867
|
|
|
return ""; |
|
868
|
|
|
|
|
869
|
|
|
$desc = PtoBR(propre($evenement['DESCRIPTION'])); |
|
870
|
|
|
$sum = $evenement['SUMMARY']; |
|
871
|
|
|
$u = $GLOBALS['meta']['pcre_u']; |
|
|
|
|
|
|
872
|
|
|
$sum = typo($sum); |
|
873
|
|
|
if (!$sum) $sum = $desc; |
|
874
|
|
|
if ($lieu = $evenement['LOCATION']) |
|
875
|
|
|
$sum .= '<br />' . $lieu; |
|
876
|
|
|
if ($perso = construire_personne_ics($evenement['ATTENDEE'])) |
|
877
|
|
|
$sum .= '<br />' . $perso; |
|
878
|
|
|
if ($evenement['URL']) |
|
879
|
|
|
$sum = http_href(quote_amp($evenement['URL']), $sum, attribut_html($desc), 'border: 0'); |
|
880
|
|
|
|
|
881
|
|
|
$sum = pipeline('agenda_rendu_evenement',array('args'=>array('evenement'=>$evenement,'type'=>'avec_heure'),'data'=>$sum)); |
|
882
|
|
|
$deb_h = substr($evenement['DTSTART'],-6,2); |
|
883
|
|
|
$deb_m = substr($evenement['DTSTART'],-4,2); |
|
884
|
|
|
$fin_h = substr($evenement['DTEND'],-6,2); |
|
885
|
|
|
$fin_m = substr($evenement['DTEND'],-4,2); |
|
886
|
|
|
$opacity = $evenement['CATEGORIES']; |
|
887
|
|
|
|
|
888
|
|
|
if ($amj != $jour_debut AND $amj != $jour_fin) { |
|
889
|
|
|
$opacity .= ' calendrier-opacity'; |
|
890
|
|
|
} else { |
|
891
|
|
|
if ($deb_h >0 OR $deb_m > 0) { |
|
892
|
|
|
if ((($deb_h > 0) OR ($deb_m > 0)) AND $amj == $jour_debut) |
|
893
|
|
|
{ $deb = $deb_h . ':' . $deb_m;} |
|
894
|
|
|
else { |
|
895
|
|
|
$deb = '...'; |
|
896
|
|
|
} |
|
897
|
|
|
if ((($fin_h > 0) OR ($fin_m > 0)) AND $amj == $jour_fin) |
|
898
|
|
|
{ $fin = $fin_h . ':' . $fin_m;} |
|
899
|
|
|
else { |
|
900
|
|
|
$fin = '...'; |
|
901
|
|
|
} |
|
902
|
|
|
$sum = "<div style='font-weight: bold;'>$deb-$fin</div>$sum"; |
|
903
|
|
|
} |
|
904
|
|
|
} |
|
905
|
|
|
return "\n<div class='calendrier-arial10 calendrier-evenement $opacity'>$sum\n</div>\n"; |
|
906
|
|
|
} |
|
907
|
|
|
|
|
908
|
|
|
/// Gestion du champ ATTENDEE. |
|
909
|
|
|
/// On admet un ID ou un mail, ou un tableau de ces choses. |
|
910
|
|
|
/// Si c'est un ID, on va chercher le mail dans la table des auteurs, |
|
911
|
|
|
/// a defaut le nom. |
|
912
|
|
|
/// Dans les deux cas, si on a bien un mail, on place le pseudo-protocole mailto |
|
913
|
|
|
|
|
914
|
|
|
function construire_personne_ics($personnes) |
|
915
|
|
|
{ |
|
916
|
|
|
$r = is_array($personnes) ? $personnes : array($personnes); |
|
917
|
|
|
foreach ($r as $k => $p) { |
|
918
|
|
|
if (!is_numeric($p)) { |
|
919
|
|
|
$mail = email_valide($p); |
|
920
|
|
|
if (preg_match('/^[^@]+/', $mail, $m)) |
|
921
|
|
|
$r[$k] = preg_replace('/[.]/', ' ', $m[0]); |
|
922
|
|
|
} else { |
|
923
|
|
|
$m = sql_fetsel("email, nom", 'spip_auteurs', "id_auteur=$p"); |
|
924
|
|
|
if ($m) { |
|
925
|
|
|
$mail = $m['email']; |
|
926
|
|
|
$r[$k] = $m['nom'] ? $m['nom'] : ($mail ? $mail : $p); |
|
927
|
|
|
} |
|
928
|
|
|
} |
|
929
|
|
|
if ($mail) |
|
930
|
|
|
$r[$k] = "<a href='mailto:$mail'>" . $r[$k] . "</a>"; |
|
|
|
|
|
|
931
|
|
|
} |
|
932
|
|
|
return join(' ', $r); |
|
933
|
|
|
} |
|
934
|
|
|
|
|
935
|
|
|
/// fabrique un agenda sur 3 mois. |
|
936
|
|
|
/// fonction appelee par le filtre agenda_affiche du squelette agenda_trimestre, |
|
937
|
|
|
/// lui-meme issu d'un Ajax construit par la fonction http_calendrier_navigation, |
|
938
|
|
|
/// qui fournit via $self la query-string de l'appel anterieur. |
|
939
|
|
|
/// Celle-ci est vide sur les squelettes agenda std cependant. |
|
940
|
|
|
|
|
941
|
|
|
function http_calendrier_trimestre($annee, $mois, $jour, $echelle, $partie_cal, $self, $ancre, $evt) |
|
|
|
|
|
|
942
|
|
|
{ |
|
943
|
|
|
global $spip_lang_right, $spip_lang_left, $spip_ecran; |
|
944
|
|
|
if (!isset($spip_ecran)) $spip_ecran = isset($_COOKIE['spip_ecran']) ? $_COOKIE['spip_ecran'] : "large"; |
|
945
|
|
|
|
|
946
|
|
|
$script = preg_match('/\bscript=(\w+)/', $self, $m) ? $m[1]:''; |
|
947
|
|
|
|
|
948
|
|
|
$script = (preg_match('/\bprive=(.)/', $self, $m) ? $m[1] : 0) |
|
949
|
|
|
? generer_url_ecrire($script) : generer_url_public($script); |
|
950
|
|
|
|
|
951
|
|
|
$fin = preg_replace('/^.*[?]page=agenda_trimestre/', '', $self) |
|
952
|
|
|
. calendrier_retire_defaults($echelle, $partie_cal); |
|
953
|
|
|
|
|
954
|
|
|
$res = "\n<tr><td colspan='3' style='text-align:$spip_lang_left;'>"; |
|
955
|
|
|
|
|
956
|
|
|
$annee_avant = $annee - 1; |
|
957
|
|
|
$annee_apres = $annee + 1; |
|
958
|
|
|
|
|
959
|
|
View Code Duplication |
for ($i=$mois; $i < 13; $i++) { |
|
|
|
|
|
|
960
|
|
|
$nom = nom_mois("$annee_avant-$i-1"); |
|
961
|
|
|
$res .= calendrier_href($script,$annee_avant, $i, 1, "mois", $fin, $ancre,'', ($nom . ' ' . $annee_avant), 'calendrier-annee','', $nom) ; |
|
962
|
|
|
} |
|
963
|
|
View Code Duplication |
for ($i=1; $i < $mois - 1; $i++) { |
|
|
|
|
|
|
964
|
|
|
$nom = nom_mois("$annee-$i-1"); |
|
965
|
|
|
$res .= calendrier_href($script,$annee, $i, 1, "mois", $fin, $ancre,'',($nom . ' ' . $annee),'calendrier-annee','', $nom); |
|
966
|
|
|
} |
|
967
|
|
|
|
|
968
|
|
|
$script .= $fin ; // http_calendrier_agenda devrait avoir cet arg en + |
|
969
|
|
|
|
|
970
|
|
|
$res .= "</td></tr>" |
|
971
|
|
|
. "\n<tr><td class='calendrier-tripleagenda'>" |
|
972
|
|
|
. http_calendrier_agenda($annee, $mois-1, $jour, $mois, $annee, $GLOBALS['afficher_bandeau_calendrier_semaine'], $script,$ancre) |
|
973
|
|
|
. "</td>\n<td class='calendrier-tripleagenda'>" |
|
974
|
|
|
. http_calendrier_agenda($annee, $mois, $jour, $mois, $annee, $GLOBALS['afficher_bandeau_calendrier_semaine'], $script,$ancre) |
|
975
|
|
|
. "</td>\n<td class='calendrier-tripleagenda'>" |
|
976
|
|
|
. http_calendrier_agenda($annee, $mois+1, $jour, $mois, $annee, $GLOBALS['afficher_bandeau_calendrier_semaine'], $script,$ancre) |
|
977
|
|
|
. "</td>" |
|
978
|
|
|
. "</tr>" |
|
979
|
|
|
. "\n<tr><td colspan='3' style='text-align:$spip_lang_right;'>"; |
|
980
|
|
|
|
|
981
|
|
View Code Duplication |
for ($i=$mois+2; $i <= 12; $i++) { |
|
|
|
|
|
|
982
|
|
|
$nom = nom_mois("$annee-$i-1"); |
|
983
|
|
|
$res .= calendrier_href($script, $annee, $i, 1, "mois", $fin, $ancre,'',$nom . ' ' . $annee, 'calendrier-annee','', $nom); |
|
984
|
|
|
} |
|
985
|
|
View Code Duplication |
for ($i=1; $i < $mois+1; $i++) { |
|
|
|
|
|
|
986
|
|
|
$nom = nom_mois("$annee_apres-$i-1"); |
|
987
|
|
|
$res .= calendrier_href($script, $annee_apres, $i, 1, "mois", $fin, $ancre,'',$nom . ' ' . $annee_apres, 'calendrier-annee','',$nom); |
|
988
|
|
|
} |
|
989
|
|
|
$res .= "</td></tr>"; |
|
990
|
|
|
|
|
991
|
|
|
$id = ($ancre ? $ancre : 'agenda') . "-nav"; |
|
992
|
|
|
|
|
993
|
|
|
return |
|
994
|
|
|
"<div><div id='$id'></div>" . |
|
995
|
|
|
"<table class='calendrier-cadreagenda calendrier-$spip_ecran' |
|
996
|
|
|
onmouseover=\"$('#$id').show();\" |
|
997
|
|
|
onmouseout=\"$('#$id').hide();\">$res</table>" . |
|
998
|
|
|
"</div>"; |
|
999
|
|
|
} |
|
1000
|
|
|
|
|
1001
|
|
|
/// Bandeau superieur d'un calendrier selon son $type (jour/mois/annee): |
|
1002
|
|
|
/// 2(+1) icones vers les 2 autres types, a la meme date $jour $mois $annee |
|
1003
|
|
|
/// 2 icones de loupes pour zoom sur la meme date et le meme type |
|
1004
|
|
|
/// 4 icones de selection de demi-journees, idem |
|
1005
|
|
|
/// 2 fleches appelant le $script sur les periodes $pred/$suiv avec une $ancre |
|
1006
|
|
|
/// 1 icone pour amener sur aujourd'hui au clic, et donner un triple agenda au survol |
|
1007
|
|
|
/// et le $nom du calendrier |
|
1008
|
|
|
|
|
1009
|
|
|
// http://doc.spip.org/@http_calendrier_navigation |
|
1010
|
|
|
function http_calendrier_navigation($annee, $mois, $jour, $echelle, $partie_cal, $nom, $script, $args_pred, $args_suiv, $type, $ancre) |
|
1011
|
|
|
{ |
|
1012
|
|
|
global $spip_lang_right, $spip_lang_left; |
|
1013
|
|
|
|
|
1014
|
|
|
if (!$echelle) $echelle = DEFAUT_D_ECHELLE; |
|
1015
|
|
|
$arg_echelle = ($echelle != DEFAUT_D_ECHELLE) ? "&echelle=$echelle" : ''; |
|
1016
|
|
|
$arg_partie = ($partie_cal != DEFAUT_PARTIE) ? "&partie_cal=$partie_cal" : ''; |
|
1017
|
|
|
|
|
1018
|
|
View Code Duplication |
if ($args_pred) { |
|
|
|
|
|
|
1019
|
|
|
list($a, $m, $j, $t) = $args_pred; |
|
1020
|
|
|
$args_pred = calendrier_href($script, $a, $m, $j, $t, "$arg_echelle$arg_partie", $ancre, |
|
1021
|
|
|
"fleche-$spip_lang_left.png", |
|
1022
|
|
|
_T('precedent'), |
|
1023
|
|
|
'calendrier-png', |
|
1024
|
|
|
'<<<'); |
|
1025
|
|
|
} |
|
1026
|
|
|
|
|
1027
|
|
View Code Duplication |
if ($args_suiv) { |
|
|
|
|
|
|
1028
|
|
|
list($a, $m, $j, $t) = $args_suiv; |
|
1029
|
|
|
$args_suiv = calendrier_href($script, $a, $m, $j, $t, "$arg_echelle$arg_partie", $ancre, |
|
1030
|
|
|
"fleche-$spip_lang_right.png", |
|
1031
|
|
|
_T('suivant'), |
|
1032
|
|
|
'calendrier-png', |
|
1033
|
|
|
'>>>'); |
|
1034
|
|
|
} |
|
1035
|
|
|
|
|
1036
|
|
|
$today = getdate(time()); |
|
1037
|
|
|
$jour_today = $today["mday"]; |
|
1038
|
|
|
$mois_today = $today["mon"]; |
|
1039
|
|
|
$annee_today = $today["year"]; |
|
1040
|
|
|
|
|
1041
|
|
|
if (preg_match('/[?&;](exec=(\w+)(&(amp;)?)?)/', $script, $regs)) { |
|
1042
|
|
|
$page = $regs[2]; $prive = 1; $raz = $regs[1]; |
|
1043
|
|
|
} elseif (preg_match('/[?&;](page=(\w+)(&(amp;)?)?)/', $script, $regs)) { |
|
1044
|
|
|
$page = $regs[2]; $prive = 0; $raz = $regs[1]; |
|
1045
|
|
|
} else $page = $prive = $raz = ''; |
|
1046
|
|
|
|
|
1047
|
|
|
$href = generer_url_public('agenda_trimestre', substr(str_replace($raz, '', $script), strpos($script, '?')+1)); |
|
1048
|
|
|
$href = parametre_url($href, 'script', $page); |
|
1049
|
|
|
$href = parametre_url($href, 'prive', $prive); |
|
1050
|
|
|
$href = parametre_url($href, 'ancre', $ancre); |
|
1051
|
|
|
|
|
1052
|
|
|
$href = calendrier_args_date($href, $annee, $mois, $jour, '', "$arg_echelle" . ((DEFAUT_PARTIE == DEFAUT_PARTIE_R) ? '' : ("&partie_cal=" . DEFAUT_PARTIE_R))); |
|
1053
|
|
|
|
|
1054
|
|
|
$id = ($ancre ? $ancre : 'agenda') . "-nav"; |
|
1055
|
|
|
$onmouseover = "if (!this.trimestre)\n{this.trimestre=!charger_node_url('$href', document.getElementById('$id'));}\n;$('#$id').css('visibility','visible').show();"; |
|
1056
|
|
|
|
|
1057
|
|
|
return |
|
1058
|
|
|
"\n<caption>" |
|
1059
|
|
|
. "\n<span style='float: $spip_lang_left;'>" |
|
1060
|
|
|
. calendrier_href($script,$annee_today, $mois_today, $jour_today, $type, "$arg_echelle$arg_partie", $ancre, |
|
1061
|
|
|
"cal-today.gif", |
|
1062
|
|
|
_T("ecrire:info_aujourdhui"), |
|
1063
|
|
|
(($annee == $annee_today && $mois == $mois_today && (($type == 'mois') || ($jour == $jour_today))) |
|
1064
|
|
|
? "calendrier-opacity" : ""), |
|
1065
|
|
|
'','','', |
|
1066
|
|
|
("\nonmouseover=\"$onmouseover\"" )) |
|
1067
|
|
|
. " " |
|
1068
|
|
|
. $args_pred |
|
1069
|
|
|
. $args_suiv |
|
1070
|
|
|
. " " |
|
1071
|
|
|
. $nom |
|
1072
|
|
|
. (!test_espace_prive() ? '' : aide("messcalen")) |
|
1073
|
|
|
. "</span>" |
|
1074
|
|
|
. " \n" // Sans "nbsp" Safari (5.1) n'affiche aucun des 2 span !! |
|
1075
|
|
|
. "<span style='float: $spip_lang_right;'>" |
|
1076
|
|
|
. (($type == "mois") ? '' : |
|
1077
|
|
|
calendrier_navigation_heures($annee, $mois, $jour, $echelle, $partie_cal, $script, $type, $ancre)) |
|
1078
|
|
|
. calendrier_navigation_type($annee, $mois, $jour, "$arg_echelle$arg_partie", $script, $type) |
|
1079
|
|
|
. "</span></caption>"; |
|
1080
|
|
|
} |
|
1081
|
|
|
|
|
1082
|
|
|
/// Bloc de navigation pour zoom sur les heures |
|
1083
|
|
|
|
|
1084
|
|
|
function calendrier_navigation_heures($annee, $mois, $jour, $echelle, $partie_cal, $script, $type, $ancre) |
|
1085
|
|
|
{ |
|
1086
|
|
|
return |
|
1087
|
|
|
calendrier_href($script, $annee, $mois, $jour, $type, calendrier_retire_defaults($echelle, DEFAUT_PARTIE_R), $ancre, |
|
1088
|
|
|
"sans-heure.gif", |
|
1089
|
|
|
_T('sans_heure'), |
|
1090
|
|
|
"calendrier-png" . |
|
1091
|
|
|
(($partie_cal == DEFAUT_PARTIE_R) ? " calendrier-opacity" : "")) |
|
1092
|
|
|
. calendrier_href($script, $annee, $mois, $jour, $type, calendrier_retire_defaults($echelle, DEFAUT_PARTIE_T), $ancre, |
|
1093
|
|
|
"heures-tout.png", |
|
1094
|
|
|
_T('cal_jour_entier'), |
|
1095
|
|
|
"calendrier-png" . |
|
1096
|
|
|
(($partie_cal == DEFAUT_PARTIE_T) ? " calendrier-opacity" : "")) |
|
1097
|
|
|
. calendrier_href($script, $annee, $mois, $jour, $type, calendrier_retire_defaults($echelle, DEFAUT_PARTIE_M), $ancre, |
|
1098
|
|
|
"heures-am.png", |
|
1099
|
|
|
_T('cal_matin'), |
|
1100
|
|
|
"calendrier-png" . |
|
1101
|
|
|
(($partie_cal == DEFAUT_PARTIE_M) ? " calendrier-opacity" : "")) |
|
1102
|
|
|
|
|
1103
|
|
|
. calendrier_href($script, $annee, $mois, $jour, $type, calendrier_retire_defaults($echelle, DEFAUT_PARTIE_S), $ancre, |
|
1104
|
|
|
"heures-pm.png", |
|
1105
|
|
|
_T('cal_apresmidi'), |
|
1106
|
|
|
"calendrier-png" . |
|
1107
|
|
|
(($partie_cal == DEFAUT_PARTIE_S) ? " calendrier-opacity" : "")) |
|
1108
|
|
|
. " " |
|
1109
|
|
|
. calendrier_href($script, $annee, $mois, $jour, $type, calendrier_retire_defaults(floor($echelle * 1.5), $partie_cal), |
|
1110
|
|
|
$ancre, |
|
1111
|
|
|
"loupe-moins.gif", |
|
1112
|
|
|
_T('info_zoom'). '-') |
|
1113
|
|
|
. calendrier_href($script, $annee, $mois, $jour, $type, calendrier_retire_defaults(floor($echelle / 1.5), $partie_cal), |
|
1114
|
|
|
$ancre, |
|
1115
|
|
|
"loupe-plus.gif", |
|
1116
|
|
|
_T('info_zoom'). '+') |
|
1117
|
|
|
; |
|
1118
|
|
|
|
|
1119
|
|
|
} |
|
1120
|
|
|
|
|
1121
|
|
|
/// Bloc de navigation sur le type mois/semaine/jour |
|
1122
|
|
|
|
|
1123
|
|
|
function calendrier_navigation_type($annee, $mois, $jour, $finurl, $script, $type) |
|
|
|
|
|
|
1124
|
|
|
{ |
|
1125
|
|
|
return |
|
1126
|
|
|
calendrier_href($script,$annee, $mois, $jour, "jour", "$arg_echelle$arg_partie", $ancre,"cal-jour.gif", |
|
|
|
|
|
|
1127
|
|
|
_T('cal_par_jour'), |
|
1128
|
|
|
(($type == 'jour') ? " calendrier-opacity" : '')) |
|
1129
|
|
|
|
|
1130
|
|
|
. calendrier_href($script,$annee, $mois, $jour, "semaine", "$arg_echelle$arg_partie", $ancre, "cal-semaine.gif", |
|
1131
|
|
|
_T('cal_par_semaine'), |
|
1132
|
|
|
(($type == 'semaine') ? " calendrier-opacity" : "" )) |
|
1133
|
|
|
|
|
1134
|
|
|
. calendrier_href($script,$annee, $mois, $jour, "mois", "$arg_echelle$arg_partie", $ancre,"cal-mois.gif", |
|
1135
|
|
|
_T('cal_par_mois'), |
|
1136
|
|
|
(($type == 'mois') ? "calendrier-opacity" : "" )); |
|
1137
|
|
|
} |
|
1138
|
|
|
|
|
1139
|
|
|
|
|
1140
|
|
|
/// agenda mensuel |
|
1141
|
|
|
|
|
1142
|
|
|
// http://doc.spip.org/@http_calendrier_agenda |
|
1143
|
|
|
function http_calendrier_agenda ($annee, $mois, $jour_ved, $mois_ved, $annee_ved, $semaine = false, $script='', $ancre='', $evt='') { |
|
1144
|
|
|
|
|
1145
|
|
|
if (!$script) $script = $GLOBALS['PHP_SELF'] ; |
|
1146
|
|
|
|
|
1147
|
|
|
if (!$mois) {$mois = 12; $annee--;} |
|
1148
|
|
|
elseif ($mois==13) {$mois = 1; $annee++;} |
|
1149
|
|
|
if (!$evt) $evt = quete_calendrier_agenda($annee, $mois); |
|
1150
|
|
|
$nom = affdate_mois_annee("$annee-$mois-1"); |
|
1151
|
|
|
return |
|
1152
|
|
|
"<div class='calendrier-titre calendrier-arial10'>" . |
|
1153
|
|
|
calendrier_href($script, $annee, $mois, 1, 'mois', '', $ancre,'', $nom,'','', $nom,'color: black;') . |
|
1154
|
|
|
"<table width='100%'>" . |
|
1155
|
|
|
http_calendrier_agenda_rv ($annee, $mois, $evt, |
|
1156
|
|
|
'calendrier_href', $script, $ancre, |
|
1157
|
|
|
$jour_ved, $mois_ved, $annee_ved, |
|
1158
|
|
|
$semaine) . |
|
1159
|
|
|
"</table>" . |
|
1160
|
|
|
"</div>"; |
|
1161
|
|
|
} |
|
1162
|
|
|
|
|
1163
|
|
|
/// typographie un mois sous forme d'un tableau de 7 colonnes |
|
1164
|
|
|
|
|
1165
|
|
|
// http://doc.spip.org/@http_calendrier_agenda_rv |
|
1166
|
|
|
function http_calendrier_agenda_rv ($annee, $mois, $les_rv, $fclic, |
|
1167
|
|
|
$script='', $ancre='', |
|
1168
|
|
|
$jour_ved='', $mois_ved='', $annee_ved='', |
|
1169
|
|
|
$semaine='') { |
|
1170
|
|
|
global $spip_lang_left, $spip_lang_right; |
|
1171
|
|
|
|
|
1172
|
|
|
// Former une date correcte (par exemple: $mois=13; $annee=2003) |
|
1173
|
|
|
$date_test = date("Y-m-d", mktime(0,0,0,$mois, 1, $annee)); |
|
1174
|
|
|
$mois = mois($date_test); |
|
1175
|
|
|
$annee = annee($date_test); |
|
1176
|
|
|
if ($semaine) |
|
1177
|
|
|
{ |
|
1178
|
|
|
$jour_semaine_valide = date("w",mktime(1,1,1,$mois_ved,$jour_ved,$annee_ved)); |
|
1179
|
|
|
if ($jour_semaine_valide==0) $jour_semaine_valide=7; |
|
1180
|
|
|
$debut = mktime(1,1,1,$mois_ved,$jour_ved-$jour_semaine_valide+1,$annee_ved); |
|
1181
|
|
|
$fin = mktime(1,1,1,$mois_ved,$jour_ved-$jour_semaine_valide+7,$annee_ved); |
|
1182
|
|
|
} else { $debut = $fin = '';} |
|
1183
|
|
|
|
|
1184
|
|
|
$today=getdate(time()); |
|
1185
|
|
|
$jour_today = $today["mday"]; |
|
1186
|
|
|
$cemois = ($mois == $today["mon"] AND $annee == $today["year"]); |
|
1187
|
|
|
|
|
1188
|
|
|
$total = ''; |
|
1189
|
|
|
$ligne = ''; |
|
1190
|
|
|
$jour_semaine = date("w", mktime(1,1,1,$mois,1,$annee)); |
|
1191
|
|
|
if ($jour_semaine==0) $jour_semaine=7; |
|
1192
|
|
|
for ($i=1;$i<$jour_semaine;$i++) $ligne .= "\n<td></td>"; |
|
1193
|
|
|
for ($j=1; (checkdate($mois,$j,$annee)); $j++) { |
|
1194
|
|
|
$class = 'calendrier-agenda-abb11'; |
|
1195
|
|
|
$nom = mktime(1,1,1,$mois,$j,$annee); |
|
1196
|
|
|
$jour_semaine = date("w",$nom); |
|
1197
|
|
|
$title = "$j-$mois-$annee"; |
|
1198
|
|
|
if ($jour_semaine==0) $jour_semaine=7; |
|
1199
|
|
|
|
|
1200
|
|
|
if ($j == $jour_ved AND $mois == $mois_ved AND $annee == $annee_ved) { |
|
1201
|
|
|
|
|
1202
|
|
|
$type = 'jour'; |
|
1203
|
|
|
} else if ($semaine AND $nom >= $debut AND $nom <= $fin) { |
|
1204
|
|
|
$class .= |
|
1205
|
|
|
(($jour_semaine==1) ? " calendrier-$spip_lang_left" : |
|
1206
|
|
|
(($jour_semaine==7) ? " calendrier-$spip_lang_right" : |
|
1207
|
|
|
'')); |
|
1208
|
|
|
$type = ($semaine ? 'semaine' : 'jour') ; |
|
1209
|
|
|
} else { |
|
1210
|
|
|
if ($j == $jour_today AND $cemois) { |
|
1211
|
|
|
$toile = ' jour_encours'; |
|
1212
|
|
|
} else { |
|
1213
|
|
|
if ($jour_semaine == 7) { |
|
1214
|
|
|
$toile = " jour_dimanche"; |
|
1215
|
|
|
} else { |
|
1216
|
|
|
$toile = ' jour_gris'; |
|
1217
|
|
|
} |
|
1218
|
|
|
if (isset($les_rv[$j])) { |
|
1219
|
|
|
$toile = " jour_pris$toile"; |
|
1220
|
|
|
$title = textebrut($les_rv[$j]['SUMMARY']); |
|
1221
|
|
|
} |
|
1222
|
|
|
} |
|
1223
|
|
|
$class .= $toile; |
|
1224
|
|
|
$type = ($semaine ? 'semaine' : 'jour') ; |
|
1225
|
|
|
} |
|
1226
|
|
|
$corps = $fclic($script, $annee, $mois, $j,$type, '', $ancre,'', $title ,'','', $j); |
|
1227
|
|
|
$ligne .= "\n<td class='$class'>$corps</td>"; |
|
1228
|
|
|
if ($jour_semaine==7) |
|
1229
|
|
|
{ |
|
1230
|
|
|
if ($ligne) $total .= "\n<tr>$ligne</tr>"; |
|
1231
|
|
|
$ligne = ''; |
|
1232
|
|
|
} |
|
1233
|
|
|
} |
|
1234
|
|
|
return $total . (!$ligne ? '' : "\n<tr>$ligne</tr>"); |
|
1235
|
|
|
} |
|
1236
|
|
|
|
|
1237
|
|
|
|
|
1238
|
|
|
|
|
1239
|
|
|
/// Fonctions pour la messagerie, la page d'accueil et les gadgets |
|
1240
|
|
|
|
|
1241
|
|
|
// http://doc.spip.org/@http_calendrier_messages |
|
1242
|
|
|
function http_calendrier_messages($annee='', $mois='', $jour='', $heures='', $partie_cal='', $echelle='') |
|
1243
|
|
|
{ |
|
1244
|
|
|
$evtm = quete_calendrier_agenda($annee, $mois); |
|
1245
|
|
|
if ($evtm OR !$heures) |
|
1246
|
|
|
$evtm = http_calendrier_agenda($annee, $mois, $jour, $mois, $annee, false, generer_url_ecrire('calendrier'), '', $evtm); |
|
1247
|
|
|
else $evtm= ''; |
|
1248
|
|
|
|
|
1249
|
|
|
$evtt = http_calendrier_rv(quete_calendrier_taches_annonces(),"annonces") |
|
1250
|
|
|
. http_calendrier_rv(quete_calendrier_taches_pb(),"pb") |
|
1251
|
|
|
. http_calendrier_rv(quete_calendrier_taches_rv(), "rv"); |
|
1252
|
|
|
|
|
1253
|
|
|
$evtr= ''; |
|
1254
|
|
|
if ($heures) { |
|
1255
|
|
|
$date = date("$annee-$mois-$jour"); |
|
1256
|
|
|
$datef = "'$date $heures'"; |
|
1257
|
|
|
if ($heures = quete_calendrier_interval_rv("'$date'", $datef)) |
|
1258
|
|
|
$evtr = http_calendrier_ics_titre($annee,$mois,$jour,generer_url_ecrire('calendrier')) . http_calendrier_ics($annee, $mois, $jour, $echelle, $partie_cal, 90, array('', $heures), '', ' calendrier-msg'); |
|
1259
|
|
|
} |
|
1260
|
|
|
return array($evtm, $evtt, $evtr); |
|
1261
|
|
|
} |
|
1262
|
|
|
|
|
1263
|
|
|
// http://doc.spip.org/@http_calendrier_rv |
|
1264
|
|
|
function http_calendrier_rv($messages, $type) { |
|
1265
|
|
|
|
|
1266
|
|
|
$total = $date_rv = ''; |
|
1267
|
|
|
if (!$messages) return $total; |
|
1268
|
|
|
$connect_quand = $GLOBALS['visiteur_session']['quand']; |
|
1269
|
|
|
|
|
1270
|
|
|
foreach ($messages as $row) { |
|
1271
|
|
|
$rv = ($row['location'] == 'oui'); |
|
1272
|
|
|
$date = $row['dtstart']; |
|
1273
|
|
|
$date_fin = $row['dtend']; |
|
1274
|
|
|
if ($row['category']=="pb") $bouton = "pense-bete"; |
|
1275
|
|
|
else if ($row['category']=="affich") $bouton = "annonce"; |
|
1276
|
|
|
else $bouton = "message"; |
|
1277
|
|
|
|
|
1278
|
|
|
if ($rv) { |
|
1279
|
|
|
$date_jour = affdate_jourcourt($date); |
|
1280
|
|
|
$total .= "<tr><td colspan='2'>" . |
|
1281
|
|
|
(($date_jour == $date_rv) ? '' : |
|
1282
|
|
|
"\n<div class='calendrier-arial11'><b>$date_jour</b></div>") . |
|
1283
|
|
|
"</td></tr>"; |
|
1284
|
|
|
$date_rv = $date_jour; |
|
1285
|
|
|
$rv = |
|
1286
|
|
|
((affdate($date) == affdate($date_fin)) ? |
|
1287
|
|
|
("\n<div class='calendrier-arial9 fond-agenda'>" |
|
1288
|
|
|
. heures($date).":".minutes($date)."<br />" |
|
1289
|
|
|
. heures($date_fin).":".minutes($date_fin)."</div>") : |
|
1290
|
|
|
( "\n<div class='calendrier-arial9 fond-agenda' style='text-align: center;'>" |
|
1291
|
|
|
. heures($date).":".minutes($date)."<br />...</div>" )); |
|
1292
|
|
|
} |
|
1293
|
|
|
|
|
1294
|
|
|
$c = (strtotime($date) <= $connect_quand) ? '' : " color: red;"; |
|
1295
|
|
|
$total .= "<tr><td style='width: 24px' valign='middle'>" . |
|
1296
|
|
|
http_href($row['url'], |
|
1297
|
|
|
($rv ? |
|
1298
|
|
|
http_img_pack("rv.gif", 'rv', |
|
1299
|
|
|
http_style_background($bouton . '.gif', "no-repeat;")) : |
|
1300
|
|
|
http_img_pack($bouton.".gif", $bouton, ""))) . |
|
1301
|
|
|
"</td>\n" . |
|
1302
|
|
|
"<td valign='middle'><div style='font-weight: bold;$c'>" . |
|
1303
|
|
|
$rv . |
|
1304
|
|
|
http_href($row['url'], typo($row['summary']), '', '', 'calendrier-verdana') . |
|
1305
|
|
|
"</div></td></tr>"; |
|
1306
|
|
|
} |
|
1307
|
|
|
|
|
1308
|
|
|
if ($type == 'annonces') { |
|
1309
|
|
|
$titre = _T('info_annonces_generales'); |
|
1310
|
|
|
} |
|
1311
|
|
|
else if ($type == 'pb') { |
|
1312
|
|
|
$titre = _T('infos_vos_pense_bete'); |
|
1313
|
|
|
} |
|
1314
|
|
|
else if ($type == 'rv') { |
|
1315
|
|
|
$titre = _T('info_vos_rendez_vous'); |
|
1316
|
|
|
} |
|
1317
|
|
|
|
|
1318
|
|
|
return |
|
1319
|
|
|
debut_cadre_enfonce("", true, "", $titre) . |
|
|
|
|
|
|
1320
|
|
|
"\n<table>" . |
|
1321
|
|
|
$total . |
|
1322
|
|
|
"</table>" . |
|
1323
|
|
|
fin_cadre_enfonce(true); |
|
1324
|
|
|
} |
|
1325
|
|
|
|
|
1326
|
|
|
// http://doc.spip.org/@calendrier_categories |
|
1327
|
|
|
function calendrier_categories($table, $num, $objet) |
|
1328
|
|
|
{ |
|
1329
|
|
|
if (function_exists('generer_calendrier_class')) |
|
1330
|
|
|
return generer_calendrier_class($table, $num, $objet); |
|
1331
|
|
|
else { |
|
1332
|
|
|
// cf agenda.css |
|
1333
|
|
|
$num= sql_getfetsel((($objet != 'id_breve') ? 'id_secteur' : 'id_rubrique') . " AS id", $table, "$objet=$num"); |
|
1334
|
|
|
|
|
1335
|
|
|
return 'calendrier-couleur' . (($num%14)+1); |
|
1336
|
|
|
} |
|
1337
|
|
|
} |
|
1338
|
|
|
|
|
1339
|
|
|
// http://doc.spip.org/@http_calendrier_ics_message |
|
1340
|
|
|
function http_calendrier_ics_message($annee, $mois, $jour, $large) |
|
1341
|
|
|
{ |
|
1342
|
|
|
|
|
1343
|
|
|
if (!autoriser('ecrire')) return ''; |
|
1344
|
|
|
|
|
1345
|
|
|
$b = _T("lien_nouvea_pense_bete"); |
|
1346
|
|
|
$v = _T("lien_nouveau_message"); |
|
1347
|
|
|
$j= _T("lien_nouvelle_annonce"); |
|
1348
|
|
|
|
|
1349
|
|
|
return " " . |
|
1350
|
|
|
http_href(generer_action_auteur("editer_message","pb/$annee-$mois-$jour"), |
|
1351
|
|
|
($large ? $b : ' '), |
|
1352
|
|
|
attribut_html($b), |
|
1353
|
|
|
'color: blue;', |
|
1354
|
|
|
'calendrier-arial10 pense-bete') . |
|
1355
|
|
|
"\n" . |
|
1356
|
|
|
http_href(generer_action_auteur("editer_message","normal/$annee-$mois-$jour"), |
|
1357
|
|
|
($large ? $v : ' '), |
|
1358
|
|
|
attribut_html($v), |
|
1359
|
|
|
'color: green;', |
|
1360
|
|
|
'calendrier-arial10 message') . |
|
1361
|
|
|
(($GLOBALS['connect_statut'] != "0minirezo") ? "" : |
|
1362
|
|
|
("\n" . |
|
1363
|
|
|
http_href(generer_action_auteur("editer_message","affich/$annee-$mois-$jour"), |
|
1364
|
|
|
($large ? $j : ' '), |
|
1365
|
|
|
attribut_html($j), |
|
1366
|
|
|
'color: #ff9900;', |
|
1367
|
|
|
'calendrier-arial10 annonce'))); |
|
1368
|
|
|
} |
|
1369
|
|
|
|
|
1370
|
|
|
// http://doc.spip.org/@http_calendrier_aide_mess |
|
1371
|
|
|
function http_calendrier_aide_mess() |
|
1372
|
|
|
{ |
|
1373
|
|
|
global $spip_lang_left; |
|
1374
|
|
|
|
|
1375
|
|
|
if (!autoriser('ecrire')) return ''; |
|
1376
|
|
|
return |
|
1377
|
|
|
"\n<br /><br /><br />" . |
|
1378
|
|
|
"\n<div class='arial1 spip_xx-small'>" . |
|
1379
|
|
|
"<span style='text-align: $spip_lang_left; font-weight: bold;'> " . _T('info_aide'). "</span>" . |
|
1380
|
|
|
"<div class='pense-bete'>" ._T('info_symbole_bleu')."\n</div>" . |
|
1381
|
|
|
"<div class='message'>" . _T('info_symbole_vert')."\n</div>" . |
|
1382
|
|
|
"<div class='annonce'>" . _T('info_symbole_jaune')."\n</div>" . |
|
1383
|
|
|
"</div>\n"; |
|
1384
|
|
|
} |
|
1385
|
|
|
|
|
1386
|
|
|
//------- fonctions d'appel MySQL. |
|
1387
|
|
|
// au dela cette limite, pas de production HTML |
|
1388
|
|
|
|
|
1389
|
|
|
// http://doc.spip.org/@quete_calendrier_mois |
|
1390
|
|
|
function quete_calendrier_mois($annee,$mois,$jour) { |
|
|
|
|
|
|
1391
|
|
|
$avant = "'" . date("Y-m-d", mktime(0,0,0,$mois,1,$annee)) . "'"; |
|
1392
|
|
|
$apres = "'" . date("Y-m-d", mktime(0,0,0,$mois+1,1,$annee)) . |
|
1393
|
|
|
" 00:00:00'"; |
|
1394
|
|
|
return array($avant, $apres); |
|
1395
|
|
|
} |
|
1396
|
|
|
|
|
1397
|
|
|
// http://doc.spip.org/@quete_calendrier_semaine |
|
1398
|
|
|
function quete_calendrier_semaine($annee,$mois,$jour) { |
|
1399
|
|
|
$w_day = date("w", mktime(0,0,0,$mois, $jour, $annee)); |
|
1400
|
|
|
if ($w_day == 0) $w_day = 7; // Gaffe: le dimanche est zero |
|
1401
|
|
|
$debut = $jour-$w_day; |
|
1402
|
|
|
$avant = "'" . date("Y-m-d", mktime(0,0,0,$mois,$debut,$annee)) . "'"; |
|
1403
|
|
|
$apres = "'" . date("Y-m-d", mktime(1,1,1,$mois,$debut+7,$annee)) . |
|
1404
|
|
|
" 23:59:59'"; |
|
1405
|
|
|
return array($avant, $apres); |
|
1406
|
|
|
} |
|
1407
|
|
|
|
|
1408
|
|
|
/// ici on prend en fait le jour, la veille et le lendemain |
|
1409
|
|
|
|
|
1410
|
|
|
// http://doc.spip.org/@quete_calendrier_jour |
|
1411
|
|
|
function quete_calendrier_jour($annee,$mois,$jour) { |
|
1412
|
|
|
$avant = "'" . date("Y-m-d", mktime(0,0,0,$mois,$jour-1,$annee)) . "'"; |
|
1413
|
|
|
$apres = "'" . date("Y-m-d", mktime(1,1,1,$mois,$jour+1,$annee)) . |
|
1414
|
|
|
" 23:59:59'"; |
|
1415
|
|
|
return array($avant, $apres); |
|
1416
|
|
|
} |
|
1417
|
|
|
|
|
1418
|
|
|
/// retourne un tableau de 2 tableaux indexes par des dates |
|
1419
|
|
|
/// - le premier indique les evenements du jour, sans indication de duree |
|
1420
|
|
|
/// - le deuxime indique les evenements commencant ce jour, avec indication de duree |
|
1421
|
|
|
|
|
1422
|
|
|
// http://doc.spip.org/@quete_calendrier_interval |
|
1423
|
|
|
function quete_calendrier_interval($limites) { |
|
1424
|
|
|
include_spip('inc/urls'); |
|
1425
|
|
|
list($avant, $apres) = $limites; |
|
1426
|
|
|
$evt = array(); |
|
1427
|
|
|
quete_calendrier_interval_articles($avant, $apres, $evt); |
|
1428
|
|
|
quete_calendrier_interval_breves($avant, $apres, $evt); |
|
1429
|
|
|
quete_calendrier_interval_rubriques($avant, $apres, $evt); |
|
1430
|
|
|
return array($evt, quete_calendrier_interval_rv($avant, $apres)); |
|
1431
|
|
|
} |
|
1432
|
|
|
|
|
1433
|
|
|
// http://doc.spip.org/@quete_calendrier_interval_forums |
|
1434
|
|
|
function quete_calendrier_interval_forums($limites, &$evenements) { |
|
1435
|
|
|
list($avant, $apres) = $limites; |
|
1436
|
|
|
$result=sql_select("DISTINCT titre, date_heure, id_forum", "spip_forum", "date_heure >= $avant AND date_heure < $apres", '', "date_heure"); |
|
1437
|
|
|
while($row=sql_fetch($result)){ |
|
1438
|
|
|
$amj = date_anneemoisjour($row['date_heure']); |
|
1439
|
|
|
$id = $row['id_forum']; |
|
1440
|
|
|
if (autoriser('voir','forum',$id)) |
|
1441
|
|
|
$evenements[$amj][]= |
|
1442
|
|
|
array( |
|
1443
|
|
|
'URL' => generer_url_entite($id, 'forum'), |
|
1444
|
|
|
'CATEGORIES' => 'calendrier-couleur7', |
|
1445
|
|
|
'SUMMARY' => $row['titre'], |
|
1446
|
|
|
'DTSTART' => date_ical($row['date_heure'])); |
|
1447
|
|
|
} |
|
1448
|
|
|
} |
|
1449
|
|
|
|
|
1450
|
|
|
/// 3 fonctions retournant les evenements d'une periode |
|
1451
|
|
|
/// le tableau retourne est indexe par les balises du format ics |
|
1452
|
|
|
/// afin qu'il soit facile de produire de tels documents. |
|
1453
|
|
|
/// L'URL de chacun de ces evenements est celle de l'espace prive |
|
1454
|
|
|
/// pour faciliter la navigation, ce qu'on obtient utilisant |
|
1455
|
|
|
/// le 4e argument des fonctions generer_url_ecrire_$table |
|
1456
|
|
|
|
|
1457
|
|
|
// http://doc.spip.org/@quete_calendrier_interval_articles |
|
1458
|
|
|
function quete_calendrier_interval_articles($avant, $apres, &$evenements) { |
|
1459
|
|
|
|
|
1460
|
|
|
$result=sql_select('id_article, titre, date, descriptif, chapo, lang', 'spip_articles', "statut='publie' AND date >= $avant AND date < $apres", '', "date"); |
|
1461
|
|
|
|
|
1462
|
|
|
if ($GLOBALS['meta']['multi_articles'] == 'oui') { |
|
1463
|
|
|
include_spip('inc/lang_liste'); |
|
1464
|
|
|
$langues = $GLOBALS['codes_langues']; |
|
1465
|
|
|
} else $langues = array(); |
|
1466
|
|
|
while($row=sql_fetch($result)){ |
|
1467
|
|
|
$amj = date_anneemoisjour($row['date']); |
|
1468
|
|
|
$id = $row['id_article']; |
|
1469
|
|
|
if (autoriser('voir','article',$id)) |
|
1470
|
|
|
$evenements[$amj][]= |
|
1471
|
|
|
array( |
|
1472
|
|
|
'CATEGORIES' => calendrier_categories('spip_articles', $id, 'id_article'), |
|
1473
|
|
|
'DESCRIPTION' => $row['descriptif'] ? $row['descriptif'] : $langues[$row['lang']], |
|
1474
|
|
|
'SUMMARY' => $row['titre'], |
|
1475
|
|
|
'URL' => generer_url_ecrire_article($id, '','','prop')); |
|
1476
|
|
|
} |
|
1477
|
|
|
} |
|
1478
|
|
|
|
|
1479
|
|
|
// http://doc.spip.org/@quete_calendrier_interval_rubriques |
|
1480
|
|
View Code Duplication |
function quete_calendrier_interval_rubriques($avant, $apres, &$evenements) { |
|
|
|
|
|
|
1481
|
|
|
|
|
1482
|
|
|
$result=sql_select('DISTINCT R.id_rubrique, titre, descriptif, date', 'spip_rubriques AS R, spip_documents_liens AS L', "statut='publie' AND date >= $avant AND date < $apres AND R.id_rubrique = L.id_objet AND L.objet='rubrique'",'', "date"); |
|
1483
|
|
|
while($row=sql_fetch($result)){ |
|
1484
|
|
|
$amj = date_anneemoisjour($row['date']); |
|
1485
|
|
|
$id = $row['id_rubrique']; |
|
1486
|
|
|
if (autoriser('voir','rubrique',$id)) |
|
1487
|
|
|
$evenements[$amj][]= |
|
1488
|
|
|
array( |
|
1489
|
|
|
'CATEGORIES' => calendrier_categories('spip_rubriques', $id, 'id_rubrique'), |
|
1490
|
|
|
'DESCRIPTION' => $row['descriptif'], |
|
1491
|
|
|
'SUMMARY' => $row['titre'], |
|
1492
|
|
|
'URL' => generer_url_ecrire_rubrique($id, '','', 'prop')); |
|
1493
|
|
|
} |
|
1494
|
|
|
} |
|
1495
|
|
|
|
|
1496
|
|
|
// http://doc.spip.org/@quete_calendrier_interval_breves |
|
1497
|
|
View Code Duplication |
function quete_calendrier_interval_breves($avant, $apres, &$evenements) { |
|
|
|
|
|
|
1498
|
|
|
$result=sql_select("id_breve, titre, date_heure, id_rubrique", 'spip_breves', "statut='publie' AND date_heure >= $avant AND date_heure < $apres", '', "date_heure"); |
|
1499
|
|
|
while($row=sql_fetch($result)){ |
|
1500
|
|
|
$amj = date_anneemoisjour($row['date_heure']); |
|
1501
|
|
|
$id = $row['id_breve']; |
|
1502
|
|
|
$ir = $row['id_rubrique']; |
|
1503
|
|
|
if (autoriser('voir','breve',$id)) |
|
1504
|
|
|
$evenements[$amj][]= |
|
1505
|
|
|
array( |
|
1506
|
|
|
'URL' => generer_url_ecrire_breve($id, '','', 'prop'), |
|
1507
|
|
|
'CATEGORIES' => calendrier_categories('spip_breves', $ir, 'id_breve'), |
|
1508
|
|
|
'SUMMARY' => $row['titre']); |
|
1509
|
|
|
} |
|
1510
|
|
|
} |
|
1511
|
|
|
|
|
1512
|
|
|
// http://doc.spip.org/@quete_calendrier_interval_rv |
|
1513
|
|
|
function quete_calendrier_interval_rv($avant, $apres) { |
|
1514
|
|
|
global $connect_id_auteur; |
|
1515
|
|
|
$evenements= $auteurs = array(); |
|
1516
|
|
|
if (!$connect_id_auteur) return $evenements; |
|
1517
|
|
|
$result=sql_select("M.id_message, M.titre, M.texte, M.date_heure, M.date_fin, M.type", "spip_messages AS M LEFT JOIN spip_auteurs_messages AS L ON (L.id_message=M.id_message)", "(L.id_auteur=$connect_id_auteur OR M.type='affich') AND M.rv='oui' AND ((M.date_fin >= $avant OR M.date_heure >= $avant) AND M.date_heure <= $apres) AND M.statut='publie'", "M.id_message", "M.date_heure"); |
|
1518
|
|
|
while($row=sql_fetch($result)){ |
|
1519
|
|
|
$date_heure=$row["date_heure"]; |
|
1520
|
|
|
$date_fin=$row["date_fin"]; |
|
1521
|
|
|
$type=$row["type"]; |
|
1522
|
|
|
$id_message=$row['id_message']; |
|
1523
|
|
|
|
|
1524
|
|
|
if ($type=="pb") |
|
1525
|
|
|
$cat = 'calendrier-couleur2'; |
|
1526
|
|
|
else { |
|
1527
|
|
|
if ($type=="affich") |
|
1528
|
|
|
$cat = 'calendrier-couleur4'; |
|
1529
|
|
|
else { |
|
1530
|
|
|
if ($type!="normal") |
|
1531
|
|
|
$cat = 'calendrier-couleur12'; |
|
1532
|
|
|
else { |
|
1533
|
|
|
$cat = 'calendrier-couleur9'; |
|
1534
|
|
|
$auteurs = array_map('array_shift', sql_allfetsel('id_auteur', 'spip_auteurs_messages', "id_message=$id_message AND id_auteur!=$connect_id_auteur")); |
|
1535
|
|
|
} |
|
1536
|
|
|
} |
|
1537
|
|
|
} |
|
1538
|
|
|
|
|
1539
|
|
|
$jour_avant = substr($avant, 9,2); |
|
1540
|
|
|
$mois_avant = substr($avant, 6,2); |
|
1541
|
|
|
$annee_avant = substr($avant, 1,4); |
|
1542
|
|
|
$jour_apres = substr($apres, 9,2); |
|
1543
|
|
|
$mois_apres = substr($apres, 6,2); |
|
1544
|
|
|
$annee_apres = substr($apres, 1,4); |
|
1545
|
|
|
$ical_apres = date_anneemoisjour("$annee_apres-$mois_apres-".sprintf("%02d",$jour_apres)); |
|
1546
|
|
|
|
|
1547
|
|
|
// Calcul pour les semaines a cheval sur deux mois |
|
1548
|
|
|
$j = 0; |
|
1549
|
|
|
$amj = date_anneemoisjour("$annee_avant-$mois_avant-".sprintf("%02d", $j+($jour_avant))); |
|
1550
|
|
|
|
|
1551
|
|
|
while ($amj <= $ical_apres) { |
|
1552
|
|
|
if (!($amj == date_anneemoisjour($date_fin) AND preg_match(",00:00:00,", $date_fin))) // Ne pas prendre la fin a minuit sur jour precedent |
|
1553
|
|
|
$evenements[$amj][$id_message]= |
|
1554
|
|
|
array( |
|
1555
|
|
|
'URL' => generer_url_ecrire("message","id_message=$id_message"), |
|
1556
|
|
|
'DTSTART' => date_ical($date_heure), |
|
1557
|
|
|
'DTEND' => date_ical($date_fin), |
|
1558
|
|
|
'DESCRIPTION' => $row['texte'], |
|
1559
|
|
|
'SUMMARY' => $row['titre'], |
|
1560
|
|
|
'CATEGORIES' => $cat, |
|
1561
|
|
|
'ATTENDEE' => $auteurs); |
|
1562
|
|
|
|
|
1563
|
|
|
$j ++; |
|
1564
|
|
|
$ladate = date("Y-m-d",mktime (1,1,1,$mois_avant, ($j + $jour_avant), $annee_avant)); |
|
1565
|
|
|
|
|
1566
|
|
|
$amj = date_anneemoisjour($ladate); |
|
1567
|
|
|
|
|
1568
|
|
|
} |
|
1569
|
|
|
|
|
1570
|
|
|
} |
|
1571
|
|
|
return $evenements; |
|
1572
|
|
|
} |
|
1573
|
|
|
|
|
1574
|
|
|
/// fonction SQL, pour la messagerie |
|
1575
|
|
|
|
|
1576
|
|
|
// http://doc.spip.org/@tache_redirige |
|
1577
|
|
|
function tache_redirige ($row) { |
|
1578
|
|
|
|
|
1579
|
|
|
$m = $row['description']; |
|
1580
|
|
|
if (substr($m,0,1) == '=') |
|
1581
|
|
|
if ($m = chapo_redirige(substr($m,1), true)) |
|
1582
|
|
|
return $m; |
|
1583
|
|
|
return generer_url_ecrire("message", "id_message=".$row['uid']); |
|
1584
|
|
|
} |
|
1585
|
|
|
|
|
1586
|
|
|
// http://doc.spip.org/@quete_calendrier_taches_annonces |
|
1587
|
|
View Code Duplication |
function quete_calendrier_taches_annonces () { |
|
|
|
|
|
|
1588
|
|
|
global $connect_id_auteur; |
|
1589
|
|
|
|
|
1590
|
|
|
if (!$connect_id_auteur) return array(); |
|
1591
|
|
|
|
|
1592
|
|
|
$r = sql_allfetsel("texte AS description, id_message AS uid, date_heure AS dtstart, date_fin AS dtend, titre AS summary, type AS category, rv AS location", "spip_messages", "type = 'affich' AND rv != 'oui' AND statut = 'publie'", "", "date_heure DESC"); |
|
1593
|
|
|
|
|
1594
|
|
|
foreach ($r as $k => $row) $r[$k]['url'] = tache_redirige($row); |
|
1595
|
|
|
return $r; |
|
1596
|
|
|
} |
|
1597
|
|
|
|
|
1598
|
|
|
// http://doc.spip.org/@quete_calendrier_taches_pb |
|
1599
|
|
View Code Duplication |
function quete_calendrier_taches_pb () { |
|
|
|
|
|
|
1600
|
|
|
global $connect_id_auteur; |
|
1601
|
|
|
|
|
1602
|
|
|
if (!$connect_id_auteur) return array(); |
|
1603
|
|
|
|
|
1604
|
|
|
$r = sql_allfetsel("texte AS description, id_message AS uid, date_heure AS dtstart, date_fin AS dtend, titre AS summary, type AS category, rv AS location", "spip_messages", "id_auteur=$connect_id_auteur AND statut='publie' AND type='pb' AND rv!='oui'"); |
|
1605
|
|
|
|
|
1606
|
|
|
foreach ($r as $k => $row) $r[$k]['url'] = tache_redirige($row); |
|
1607
|
|
|
return $r; |
|
1608
|
|
|
} |
|
1609
|
|
|
|
|
1610
|
|
|
// http://doc.spip.org/@quete_calendrier_taches_rv |
|
1611
|
|
|
function quete_calendrier_taches_rv () { |
|
1612
|
|
|
global $connect_id_auteur; |
|
1613
|
|
|
|
|
1614
|
|
|
if (!$connect_id_auteur) return array(); |
|
1615
|
|
|
|
|
1616
|
|
|
$r = sql_allfetsel("M.texte AS description, M.id_message AS uid, M.date_heure AS dtstart, M.date_fin AS dtend, M.titre AS summary, M.type AS category, M.rv AS location", "spip_messages AS M LEFT JOIN spip_auteurs_messages AS L ON (L.id_message=M.id_message)", "(L.id_auteur=$connect_id_auteur OR M.type='affich') AND M.rv='oui' AND ( (M.date_heure > DATE_SUB(NOW(), INTERVAL 1 DAY) AND M.date_heure < DATE_ADD(NOW(), INTERVAL 1 MONTH)) OR (M.date_heure < NOW() AND M.date_fin > NOW() )) AND M.statut='publie'", "M.id_message", "M.date_heure"); |
|
1617
|
|
|
foreach ($r as $k => $row) $r[$k]['url'] = tache_redirige($row); |
|
1618
|
|
|
return $r; |
|
1619
|
|
|
} |
|
1620
|
|
|
|
|
1621
|
|
|
// http://doc.spip.org/@quete_calendrier_agenda |
|
1622
|
|
|
function quete_calendrier_agenda ($annee, $mois) { |
|
1623
|
|
|
global $connect_id_auteur; |
|
1624
|
|
|
|
|
1625
|
|
|
$rv = array(); |
|
1626
|
|
|
if (!$connect_id_auteur) return $rv; |
|
1627
|
|
|
$date = date("Y-m-d", mktime(0,0,0,$mois, 1, $annee)); |
|
1628
|
|
|
$mois = mois($date); |
|
1629
|
|
|
$annee = annee($date); |
|
1630
|
|
|
|
|
1631
|
|
|
// rendez-vous personnels dans le mois |
|
1632
|
|
|
$result_messages = sql_select("M.titre AS summary, M.texte AS description, M.id_message AS uid, M.date_heure", "spip_messages AS M, spip_auteurs_messages AS L", "((L.id_auteur=$connect_id_auteur AND L.id_message=M.id_message) OR M.type='affich') AND M.rv='oui' AND M.date_heure >='$annee-$mois-1' AND date_heure < DATE_ADD('$annee-$mois-1', INTERVAL 1 MONTH) AND M.statut='publie'"); |
|
1633
|
|
|
while($row=sql_fetch($result_messages)) { |
|
1634
|
|
|
$rv[journum($row['date_heure'])] = $row; |
|
1635
|
|
|
} |
|
1636
|
|
|
return $rv; |
|
1637
|
|
|
} |
|
1638
|
|
|
|
|
1639
|
|
|
?> |
|
|
|
|
|
|
1640
|
|
|
|
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.