30 |
ddelon |
1 |
<?php
|
|
|
2 |
/*vim: set expandtab tabstop=4 shiftwidth=4: */
|
|
|
3 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
4 |
// | PHP version 4.1 |
|
|
|
5 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
6 |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
|
|
|
7 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
8 |
// | This library is free software; you can redistribute it and/or |
|
|
|
9 |
// | modify it under the terms of the GNU Lesser General Public |
|
|
|
10 |
// | License as published by the Free Software Foundation; either |
|
|
|
11 |
// | version 2.1 of the License, or (at your option) any later version. |
|
|
|
12 |
// | |
|
|
|
13 |
// | This library is distributed in the hope that it will be useful, |
|
|
|
14 |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
15 |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
|
|
16 |
// | Lesser General Public License for more details. |
|
|
|
17 |
// | |
|
|
|
18 |
// | You should have received a copy of the GNU Lesser General Public |
|
|
|
19 |
// | License along with this library; if not, write to the Free Software |
|
|
|
20 |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
|
|
21 |
// +------------------------------------------------------------------------------------------------------+
|
267 |
florian |
22 |
// CVS : $Id: bazar.fonct.cal.php,v 1.21 2007-06-25 14:46:10 florian Exp $
|
30 |
ddelon |
23 |
/**
|
|
|
24 |
*
|
|
|
25 |
* Fonctions calendrier du module bazar
|
|
|
26 |
*
|
|
|
27 |
*@package bazar
|
|
|
28 |
//Auteur original :
|
|
|
29 |
*@author David Delon <david.delon@clapas.net>
|
|
|
30 |
//Autres auteurs :
|
|
|
31 |
*@copyright Tela-Botanica 2000-2004
|
267 |
florian |
32 |
*@version $Revision: 1.21 $ $Date: 2007-06-25 14:46:10 $
|
30 |
ddelon |
33 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
34 |
*/
|
|
|
35 |
|
|
|
36 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
37 |
// | ENTETE du PROGRAMME |
|
|
|
38 |
// +------------------------------------------------------------------------------------------------------+
|
225 |
neiluj |
39 |
|
55 |
florian |
40 |
require_once PAP_CHEMIN_RACINE.'api/pear/Calendar/Month/Weekdays.php';
|
|
|
41 |
require_once PAP_CHEMIN_RACINE.'api/pear/Calendar/Day.php';
|
|
|
42 |
require_once PAP_CHEMIN_RACINE.'api/pear/Calendar/Decorator.php';
|
30 |
ddelon |
43 |
|
|
|
44 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
45 |
// | LISTE de FONCTIONS |
|
|
|
46 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
47 |
|
|
|
48 |
// Classe Utilitaire pour Calendrier
|
|
|
49 |
class DiaryEvent extends Calendar_Decorator {
|
205 |
jp_milcent |
50 |
var $entry = array();
|
|
|
51 |
function DiaryEvent($calendar)
|
|
|
52 |
{
|
30 |
ddelon |
53 |
Calendar_Decorator::Calendar_Decorator($calendar);
|
|
|
54 |
}
|
205 |
jp_milcent |
55 |
function setEntry($entry)
|
|
|
56 |
{
|
|
|
57 |
$this->entry[] = $entry;
|
30 |
ddelon |
58 |
|
|
|
59 |
}
|
205 |
jp_milcent |
60 |
function getEntry()
|
|
|
61 |
{
|
30 |
ddelon |
62 |
return $this->entry;
|
|
|
63 |
}
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
|
42 |
ddelon |
67 |
// $type : calendrier
|
|
|
68 |
// $type : calendrier_appplette
|
258 |
alexandre_ |
69 |
function GestionAffichageCalendrier($arguments = array(), $type = 'calendrier') {
|
30 |
ddelon |
70 |
|
258 |
alexandre_ |
71 |
// recuperation des arguments de l applette
|
|
|
72 |
$balise = isset ($arguments[0]) ? $arguments[0] : '';
|
|
|
73 |
$tab_arguments = $arguments;
|
|
|
74 |
unset($tab_arguments[0]);
|
|
|
75 |
if (is_array($tab_arguments)) {
|
|
|
76 |
foreach($tab_arguments as $argument) {
|
|
|
77 |
if ($argument != '') {
|
|
|
78 |
$tab_parametres = explode('=', $argument, 2);
|
267 |
florian |
79 |
if (is_array($tab_parametres)) {
|
|
|
80 |
$options[$tab_parametres[0]] =
|
|
|
81 |
(isset($tab_parametres[1])? trim($tab_parametres[1], '"') : '') ;
|
|
|
82 |
}
|
258 |
alexandre_ |
83 |
}
|
|
|
84 |
}
|
|
|
85 |
}
|
|
|
86 |
|
|
|
87 |
if (!isset($options['template'])) {
|
|
|
88 |
$options['template'] = BAZ_CHEMIN_SQUELETTE.BAZ_SQUELETTE_DEFAUT;
|
|
|
89 |
} else {
|
|
|
90 |
if (file_exists(BAZ_CHEMIN_SQUELETTE.$options['template'])) {
|
|
|
91 |
$options['template'] = BAZ_CHEMIN_SQUELETTE.$options['template'];
|
|
|
92 |
}
|
|
|
93 |
}
|
|
|
94 |
|
208 |
jp_milcent |
95 |
$retour = '';
|
225 |
neiluj |
96 |
|
30 |
ddelon |
97 |
$url = $GLOBALS['_GEN_commun']['url'] ;
|
205 |
jp_milcent |
98 |
$db =& $GLOBALS['_GEN_commun']['pear_db'] ;
|
|
|
99 |
$auth =& $GLOBALS['_GEN_commun']['pear_auth'] ;
|
30 |
ddelon |
100 |
|
|
|
101 |
if (!isset($_GET['y'])) {
|
|
|
102 |
$_GET['y'] = date('Y');
|
|
|
103 |
}
|
|
|
104 |
|
|
|
105 |
if (!isset($_GET['m'])) {
|
|
|
106 |
$_GET['m'] = date('m');
|
|
|
107 |
}
|
|
|
108 |
|
|
|
109 |
// Construction Mois en Cours
|
|
|
110 |
$month = new Calendar_Month_Weekdays($_GET['y'],$_GET['m']);
|
|
|
111 |
|
205 |
jp_milcent |
112 |
$curStamp = $month->getTimeStamp();
|
|
|
113 |
$url->addQueryString('y', date('Y',$curStamp));
|
|
|
114 |
$url->addQueryString('m', date('n',$curStamp));
|
|
|
115 |
$url->addQueryString('d', date('j',$curStamp));
|
30 |
ddelon |
116 |
$cur = $url->getUrl();
|
|
|
117 |
|
|
|
118 |
// Navigation
|
|
|
119 |
$prevStamp = $month->prevMonth(true);
|
205 |
jp_milcent |
120 |
$url->addQueryString('y', date('Y',$prevStamp));
|
|
|
121 |
$url->addQueryString('m', date('n',$prevStamp));
|
|
|
122 |
$url->addQueryString('d', date('j',$prevStamp));
|
30 |
ddelon |
123 |
$prev = $url->getUrl();
|
205 |
jp_milcent |
124 |
|
30 |
ddelon |
125 |
$nextStamp = $month->nextMonth(true);
|
205 |
jp_milcent |
126 |
$url->addQueryString('y', date('Y',$nextStamp));
|
|
|
127 |
$url->addQueryString('m', date('n',$nextStamp));
|
|
|
128 |
$url->addQueryString('d', date('j',$nextStamp));
|
30 |
ddelon |
129 |
$next = $url->getUrl();
|
205 |
jp_milcent |
130 |
|
|
|
131 |
$fr_month = array( "1"=>BAZ_JANVIER,"2"=>BAZ_FEVRIER,"3"=>BAZ_MARS,"4"=>BAZ_AVRIL,"5"=>BAZ_MAI,"6"=>BAZ_JUIN,
|
|
|
132 |
"7"=>BAZ_JUILLET,"8"=>BAZ_AOUT,"9"=>BAZ_SEPTEMBRE,"10"=>BAZ_OCTOBRE,"11"=>BAZ_NOVEMBRE,"12"=>BAZ_DECEMBRE);
|
30 |
ddelon |
133 |
|
258 |
alexandre_ |
134 |
// Appel du template
|
225 |
neiluj |
135 |
|
258 |
alexandre_ |
136 |
ob_start();
|
|
|
137 |
include ($options['template']);
|
|
|
138 |
$retour .= ob_get_contents();
|
|
|
139 |
ob_end_clean();
|
|
|
140 |
|
225 |
neiluj |
141 |
|
42 |
ddelon |
142 |
// Vue Mois calendrier ou vue applette
|
|
|
143 |
|
|
|
144 |
if ((!isset($_GET['id_fiche']) && ($type=='calendrier')) || ($type=='calendrier_applette')){
|
30 |
ddelon |
145 |
|
|
|
146 |
// Recherche evenement de la periode selectionnée
|
225 |
neiluj |
147 |
|
|
|
148 |
// TODO : Selectionner element du mois en cours
|
|
|
149 |
|
|
|
150 |
$requete_evenements = "SELECT DISTINCT bf_id_fiche, bf_titre, bf_lieu_evenement, DAY(bf_date_debut_evenement) AS bf_jour_debut_evenement , bf_date_fin_evenement, bf_description ".
|
185 |
jp_milcent |
151 |
"FROM bazar_fiche, bazar_nature ".
|
225 |
neiluj |
152 |
"WHERE YEAR(bf_date_debut_evenement) = ".date('Y',$curStamp)." ".
|
|
|
153 |
"AND month(bf_date_debut_evenement) = ".date('m',$curStamp)." ".
|
185 |
jp_milcent |
154 |
"AND bf_ce_nature = bn_id_nature ".
|
213 |
jp_milcent |
155 |
"AND bn_id_nature IN (".BAZ_NUM_ANNONCE_CALENDRIER.") ".
|
263 |
alexandre_ |
156 |
"AND bf_statut_fiche = 1 ".
|
|
|
157 |
"ORDER BY bf_jour_debut_evenement";
|
225 |
neiluj |
158 |
|
30 |
ddelon |
159 |
$resultat_evenement = $db->query($requete_evenements);
|
225 |
neiluj |
160 |
|
30 |
ddelon |
161 |
(DB::isError($resultat_evenement))
|
|
|
162 |
? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_evenement->getMessage(), $requete_evenements))
|
|
|
163 |
: '';
|
225 |
neiluj |
164 |
|
|
|
165 |
$calcom="";
|
|
|
166 |
|
|
|
167 |
$selection=array();
|
|
|
168 |
$evenements=array();
|
|
|
169 |
|
|
|
170 |
$prev_curday_ymd=0;
|
|
|
171 |
|
30 |
ddelon |
172 |
while ($ligne_evenements = $resultat_evenement->fetchRow(DB_FETCHMODE_OBJECT)) {
|
225 |
neiluj |
173 |
|
|
|
174 |
$curday_ymd=date('Ym',$curStamp).$ligne_evenements->bf_jour_debut_evenement;
|
|
|
175 |
if ($curday_ymd!=$prev_curday_ymd) {
|
|
|
176 |
$Day = new Calendar_Day(date('Y',$curStamp),date('m',$curStamp), $ligne_evenements->bf_jour_debut_evenement);
|
|
|
177 |
$DiaryEvent = new DiaryEvent($Day);
|
|
|
178 |
$prev_curday_ymd=$curday_ymd;
|
|
|
179 |
}
|
30 |
ddelon |
180 |
|
225 |
neiluj |
181 |
$DiaryEvent->setEntry($ligne_evenements);
|
30 |
ddelon |
182 |
|
225 |
neiluj |
183 |
// Add the decorator to the selection
|
|
|
184 |
$selection[] = $DiaryEvent;
|
|
|
185 |
|
30 |
ddelon |
186 |
}
|
|
|
187 |
|
|
|
188 |
// Affichage Calendrier
|
225 |
neiluj |
189 |
|
|
|
190 |
|
30 |
ddelon |
191 |
$month->build($selection);
|
225 |
neiluj |
192 |
|
|
|
193 |
if ($type=='calendrier') {
|
|
|
194 |
$retour.= "<table class=\"calendar\">
|
|
|
195 |
<tr>
|
42 |
ddelon |
196 |
|
|
|
197 |
<th> ". BAZ_LUNDI ."</th>
|
|
|
198 |
<th> ". BAZ_MARDI ."</th>
|
|
|
199 |
<th> ". BAZ_MERCREDI ."</th>
|
|
|
200 |
<th> ". BAZ_JEUDI ."</th>
|
|
|
201 |
<th> ". BAZ_VENDREDI ."</th>
|
|
|
202 |
<th> ". BAZ_SAMEDI ."</th>
|
|
|
203 |
<th> ". BAZ_DIMANCHE ."</th>
|
|
|
204 |
</tr>
|
225 |
neiluj |
205 |
";
|
42 |
ddelon |
206 |
}
|
|
|
207 |
else {
|
225 |
neiluj |
208 |
$retour.= "<table class=\"calendar\">
|
|
|
209 |
<tr>
|
42 |
ddelon |
210 |
|
|
|
211 |
<th> ". BAZ_LUNDI_COURT ."</th>
|
|
|
212 |
<th> ". BAZ_MARDI_COURT ."</th>
|
|
|
213 |
<th> ". BAZ_MERCREDI_COURT ."</th>
|
|
|
214 |
<th> ". BAZ_JEUDI_COURT ."</th>
|
|
|
215 |
<th> ". BAZ_VENDREDI_COURT ."</th>
|
|
|
216 |
<th> ". BAZ_SAMEDI_COURT ."</th>
|
|
|
217 |
<th> ". BAZ_DIMANCHE_COURT ."</th>
|
|
|
218 |
</tr>
|
225 |
neiluj |
219 |
";
|
42 |
ddelon |
220 |
}
|
30 |
ddelon |
221 |
|
42 |
ddelon |
222 |
|
30 |
ddelon |
223 |
$todayStamp=time();
|
|
|
224 |
|
|
|
225 |
$today_ymd=date('Ymd',$todayStamp);
|
|
|
226 |
|
|
|
227 |
// Other month : mois
|
|
|
228 |
//
|
|
|
229 |
|
|
|
230 |
while ($day = $month->fetch() ) {
|
|
|
231 |
|
|
|
232 |
$dayStamp = $day->thisDay(true);
|
|
|
233 |
$day_ymd=date('Ymd',$dayStamp);
|
|
|
234 |
|
|
|
235 |
if ( $day->isEmpty() ) {
|
225 |
neiluj |
236 |
$class = "other_month";
|
30 |
ddelon |
237 |
}
|
|
|
238 |
else {
|
|
|
239 |
if (($day_ymd < $today_ymd)) {
|
225 |
neiluj |
240 |
$class= "previous_month";
|
30 |
ddelon |
241 |
}
|
|
|
242 |
else {
|
|
|
243 |
if ($day_ymd == $today_ymd) {
|
225 |
neiluj |
244 |
$class= "current_day";
|
30 |
ddelon |
245 |
}
|
|
|
246 |
else {
|
225 |
neiluj |
247 |
$class="current_month";
|
30 |
ddelon |
248 |
}
|
|
|
249 |
}
|
|
|
250 |
}
|
|
|
251 |
|
|
|
252 |
$url->addQueryString ('y', date('Y',$dayStamp));
|
|
|
253 |
$url->addQueryString ('m', date('n',$dayStamp));
|
|
|
254 |
$url->addQueryString ('d', date('j',$dayStamp));
|
225 |
neiluj |
255 |
|
30 |
ddelon |
256 |
$link = $url->getUrl();
|
|
|
257 |
|
|
|
258 |
// isFirst() to find start of week
|
225 |
neiluj |
259 |
if ($day->isFirst())
|
30 |
ddelon |
260 |
$retour.= ( "<tr>\n" );
|
225 |
neiluj |
261 |
|
|
|
262 |
//$retour.= ( "<td class=\"".$class."\"><a href=\"".$link."\">".$day->thisDay()."</a>\n" );
|
|
|
263 |
|
|
|
264 |
if ($type=='calendrier') {
|
|
|
265 |
$retour.= "<td class=\"".$class."\">".$day->thisDay()."\n";
|
42 |
ddelon |
266 |
if ($day->isSelected() ) {
|
225 |
neiluj |
267 |
$evenements=$day->getEntry();
|
|
|
268 |
while ($ligne_evenement=array_pop($evenements)) {
|
|
|
269 |
$id_fiches=array();
|
|
|
270 |
$id_fiches[]=$ligne_evenement->bf_id_fiche;
|
42 |
ddelon |
271 |
$url->addQueryString ('id_fiches',$id_fiches);
|
|
|
272 |
$link = $url->getUrl();
|
225 |
neiluj |
273 |
$retour.= "<a href=\"".$link."\">".$ligne_evenement->bf_titre."</a>\n";
|
42 |
ddelon |
274 |
$url->removeQueryString ('id_fiches');
|
|
|
275 |
}
|
|
|
276 |
}
|
225 |
neiluj |
277 |
}
|
|
|
278 |
else {
|
258 |
alexandre_ |
279 |
|
42 |
ddelon |
280 |
$lien_date= "<td class=\"".$class."\">".$day->thisDay()."\n";
|
|
|
281 |
if ($day->isSelected() ) {
|
|
|
282 |
$evenements=$day->getEntry();
|
|
|
283 |
$id_fiches=array();
|
|
|
284 |
while ($ligne_evenement=array_pop($evenements)) {
|
|
|
285 |
$id_fiches[]=$ligne_evenement->bf_id_fiche;
|
|
|
286 |
}
|
|
|
287 |
$url->addQueryString ('id_fiches',$id_fiches);
|
30 |
ddelon |
288 |
$link = $url->getUrl();
|
42 |
ddelon |
289 |
$lien_date= "<td class=\"".$class."\"><a href=\"".$link."\">".$day->thisDay()."</a>\n";
|
|
|
290 |
$url->removeQueryString ('id_fiches');
|
30 |
ddelon |
291 |
}
|
42 |
ddelon |
292 |
$retour.=$lien_date;
|
30 |
ddelon |
293 |
}
|
|
|
294 |
|
|
|
295 |
$retour.= ( "</td>\n" );
|
|
|
296 |
|
|
|
297 |
// isLast() to find end of week
|
|
|
298 |
if ( $day->isLast() )
|
|
|
299 |
$retour.= ( "</tr>\n" );
|
|
|
300 |
}
|
|
|
301 |
|
225 |
neiluj |
302 |
$retour.= "</table>";
|
30 |
ddelon |
303 |
|
42 |
ddelon |
304 |
|
|
|
305 |
}
|
225 |
neiluj |
306 |
|
42 |
ddelon |
307 |
// Vue detail
|
|
|
308 |
|
|
|
309 |
if ((isset($_GET['id_fiches']))) {
|
225 |
neiluj |
310 |
// Ajout des styles du bazar
|
|
|
311 |
if (defined('PAP_VERSION')) { //si on est dans Papyrus
|
|
|
312 |
GEN_stockerStyleExterne( 'bazar_interne2', 'client/bazar/bazar.interne.css');
|
|
|
313 |
}
|
|
|
314 |
|
85 |
alexandre_ |
315 |
// Ajout d'un titre pour la page avec la date
|
|
|
316 |
$jours = array ('lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi', 'dimanche') ;
|
|
|
317 |
$mois = array ('janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre',
|
|
|
318 |
'octobre', 'novembre', 'décembre') ;
|
|
|
319 |
$timestamp = strtotime ($_GET['y'].'/'.$_GET['m'].'/'.$_GET['d']) ;
|
|
|
320 |
$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_CORPS'] = '<h1>'.$jours[date('w', $timestamp)].
|
147 |
alexandre_ |
321 |
' '.$_GET['d'].' '.$mois[$_GET['m']-1].' '.$_GET['y'].'</h1>' ;
|
85 |
alexandre_ |
322 |
$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_CORPS'] .= baz_voir_fiches(0,$_GET['id_fiches'] );
|
30 |
ddelon |
323 |
}
|
205 |
jp_milcent |
324 |
|
|
|
325 |
// Nettoyage de l'url
|
|
|
326 |
$url->removeQueryString('id_fiches');
|
|
|
327 |
$url->removeQueryString('y');
|
|
|
328 |
$url->removeQueryString('m');
|
|
|
329 |
$url->removeQueryString('d');
|
42 |
ddelon |
330 |
|
|
|
331 |
return $retour;
|
30 |
ddelon |
332 |
}
|
|
|
333 |
?>
|