Subversion Repositories Applications.bazar

Rev

Rev 10 | Rev 17 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
10 ddelon 1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
3
// Copyright (C) 1999-2004 Tela Botanica (accueil@tela-botanica.org)
4
//
5
// Ce logiciel est un programme informatique servant à gérer du contenu et des
6
// applications web.
7
 
8
// Ce logiciel est régi par la licence CeCILL soumise au droit français et
9
// respectant les principes de diffusion des logiciels libres. Vous pouvez
10
// utiliser, modifier et/ou redistribuer ce programme sous les conditions
11
// de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
12
// sur le site "http://www.cecill.info".
13
 
14
// En contrepartie de l'accessibilité au code source et des droits de copie,
15
// de modification et de redistribution accordés par cette licence, il n'est
16
// offert aux utilisateurs qu'une garantie limitée.  Pour les mêmes raisons,
17
// seule une responsabilité restreinte pèse sur l'auteur du programme,  le
18
// titulaire des droits patrimoniaux et les concédants successifs.
19
 
20
// A cet égard  l'attention de l'utilisateur est attirée sur les risques
21
// associés au chargement,  à l'utilisation,  à la modification et/ou au
22
// développement et à la reproduction du logiciel par l'utilisateur étant
23
// donné sa spécificité de logiciel libre, qui peut le rendre complexe à
24
// manipuler et qui le réserve donc à des développeurs et des professionnels
25
// avertis possédant  des  connaissances  informatiques approfondies.  Les
26
// utilisateurs sont donc invités à charger  et  tester  l'adéquation  du
27
// logiciel à leurs besoins dans des conditions permettant d'assurer la
28
// sécurité de leurs systèmes et ou de leurs données et, plus généralement,
29
// à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
30
 
31
// Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
32
// pris connaissance de la licence CeCILL, et que vous en avez accepté les
33
// termes.
34
// ----
14 ddelon 35
// CVS : $Id: bazar.calendrier.php,v 1.2 2005-09-30 14:58:00 ddelon Exp $
10 ddelon 36
/**
37
* bazar_calendrier : programme affichant les evenements du bazar sous forme de Calendrier
38
*
39
*
40
*@package Bazar
41
//Auteur original :
42
*@author        David DELON <david.delon@clapas.net>
14 ddelon 43
*@version       $Revision: 1.2 $ $Date: 2005-09-30 14:58:00 $
10 ddelon 44
// +------------------------------------------------------------------------------------------------------+
45
*/
46
 
14 ddelon 47
// TODO : afficher evenement sur plusieur jours
48
// TODO : traduction entete mois calendrier
49
// Parametrage EVENEMENT : template
10 ddelon 50
 
51
// Fonction Calendrier de Pear
52
 
53
require_once 'Calendar/Month/Weekdays.php';
54
require_once 'Calendar/Day.php';
55
require_once 'Calendar/Decorator.php';
56
 
57
 
58
// Classe Utilitaire pour Calendrier
59
 
60
class DiaryEvent extends Calendar_Decorator {
61
	var $entry;
62
	function DiaryEvent($calendar) {
63
		Calendar_Decorator::Calendar_Decorator($calendar);
64
	}
65
	function setEntry($entry) {
66
		$this->entry = $entry;
67
	}
68
	function getEntry() {
69
		return $this->entry;
70
	}
71
}
72
 
73
 
74
function afficherContenuCorps() {
75
 
76
	$url = $GLOBALS['_GEN_commun']['url'] ;
77
	$db = &$GLOBALS['_GEN_commun']['pear_db'] ;
78
	$auth = &$GLOBALS['_GEN_commun']['pear_auth'] ;
79
 
80
	if (!isset($_GET['y'])) {
81
		$_GET['y'] = date('Y');
82
	}
83
 
84
	if (!isset($_GET['m'])) {
85
		$_GET['m'] = date('m');
86
	}
87
 
88
	if (!isset($_GET['d'])) {
89
		$_GET['d'] = date('d');
90
	}
91
 
92
 
14 ddelon 93
	// 	Construction Mois en Cours
94
	$month = new Calendar_Month_Weekdays($_GET['y'],$_GET['m']);
10 ddelon 95
 
14 ddelon 96
	$curStamp=$month->getTimeStamp();
97
 
98
	// Navigation
99
	$prevStamp = $month->prevMonth(true);
100
	$url->addQueryString ('y', date('Y',$prevStamp));
101
	$url->addQueryString ('m', date('n',$prevStamp));
102
	$url->addQueryString ('d', date('j',$prevStamp));
103
	$prev = $url->getUrl();
104
	$nextStamp = $month->nextMonth(true);
105
	$url->addQueryString ('y', date('Y',$nextStamp));
106
	$url->addQueryString ('m', date('n',$nextStamp));
107
	$url->addQueryString ('d', date('j',$nextStamp));
108
	$next = $url->getUrl();
10 ddelon 109
 
14 ddelon 110
	$fr_month=array("1"=>"Janvier","2"=>"Fevrier","3"=>"Mars","4"=>"Avril","5"=>"Mai","6"=>"Juin","7"=>"Juillet","8"=>"Aout","9"=>"Septembre","10"=>"Octobre","11"=>"Novembre","12"=>"Decembre");
10 ddelon 111
 
112
 
14 ddelon 113
	echo "<div class=\"navi\">";
114
	echo "<a href=\"".$prev."\"> &lt;&lt; </a>";
10 ddelon 115
 
14 ddelon 116
	echo $fr_month[(date('n',$curStamp))];
117
	echo "&nbsp;";
118
	echo (date('Y',$curStamp));
10 ddelon 119
 
14 ddelon 120
	echo "<a href=\"".$next."\"> &gt;&gt; </a>";
10 ddelon 121
 
14 ddelon 122
	echo "</div>";
10 ddelon 123
 
124
 
14 ddelon 125
	// Recherche evenement de la periode selectionnée
10 ddelon 126
 
14 ddelon 127
	$EvenementSelection=$this->tag.date('Y',$curStamp).date('m',$curStamp);
10 ddelon 128
 
14 ddelon 129
	$selection = array();
130
 
131
 
132
 	// TODO : Selectionner element du mois en cours
133
 
134
    $requete_evenements = "SELECT DISTINCT bf_id_fiche, bf_titre, bf_lieu_evenement, bf_date_debut_evenement, bf_date_fin_evenement, bf_description FROM bazar_fiche, bazar_nature where bf_date_debut_evenement=".$EvenementSelection." and bf_ce_nature=bn_id_nature and bn_label_nature='Évènements'";
135
 
136
 
137
   	$resultat_evenement = $db->query($requete_evenements);
138
 
139
    (DB::isError($resultat_evenement))
140
    ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_evenement->getMessage(), $requete_evenements))
141
    : '';
10 ddelon 142
 
14 ddelon 143
	$calcom="";
144
 
145
    while ($ligne_evenements = $resultat_evenement->fetchRow(DB_FETCHMODE_OBJECT)) {
10 ddelon 146
 
147
		$Day = new Calendar_Day(date('Y',$curStamp),date('m',$curStamp), substr($page ['tag'], -2));
148
 
149
		$DiaryEvent = new DiaryEvent($Day);
14 ddelon 150
 
10 ddelon 151
		$dayStamp = $Day->thisDay(true);
14 ddelon 152
		$url->addQueryString ('y', date('Y',$dayStamp));
153
		$url->addQueryString ('m', date('n',$dayStamp));
154
		$url->addQueryString ('d', date('j',$dayStamp));
155
		$ref = $url->getUrl();
10 ddelon 156
 
157
 
14 ddelon 158
		$calcom="</br>".$ligne_evenements->bf_titre.$calcom;
10 ddelon 159
 
160
		// Attach the payload
161
		$DiaryEvent->setEntry($calcom);
162
 
163
		// Add the decorator to the selection
164
		$selection[] = $DiaryEvent;
165
 
166
	}
167
 
14 ddelon 168
	// Affichage Calendrier
169
 
170
 
171
	$month->build($selection);
172
 
173
	echo ( "<tr>\n" );
174
	echo ( "<td>\n" );
175
 
10 ddelon 176
 
14 ddelon 177
	echo "<table class=\"calendar\">
178
	 <tr>
179
 
180
	  <th> Lundi </th>
181
	  <th> Mardi </th>
182
	  <th> Mercredi </th>
183
	  <th> Jeudi </th>
184
	  <th> Vendredi </th>
185
 
186
	  <th> Samedi </th>
187
	  <th> Dimanche </th>
188
	 </tr>
189
	 ";
190
 
191
	$todayStamp=time();
192
 
193
	while ( $day = $month->fetch() ) {
194
 
195
			$dayStamp = $day->thisDay(true);
196
 
197
			if ( $day->isEmpty() ) {
198
					$class = "other_month";
10 ddelon 199
			}
200
			else {
14 ddelon 201
				if ($todayStamp>$dayStamp) {
202
					$class="previous_month";
203
				}
204
				else {
205
					$class="current_month";
206
				}
10 ddelon 207
			}
208
 
14 ddelon 209
			$link =
210
			$_SERVER['PHP_SELF'].'?wiki='.$this->tag.date('Y',$dayStamp).date('m',$dayStamp).date('d',$dayStamp);
10 ddelon 211
 
14 ddelon 212
			// isFirst() to find start of week
213
			if ( $day->isFirst() )
214
			echo ( "<tr>\n" );
10 ddelon 215
 
14 ddelon 216
 
217
			echo ( "<td class=\"".$class."\"><a href=\"".$link."\">".$day->thisDay()."</a>\n" );
218
 
219
			if ( $day->isSelected() ) {
220
 
221
				echo ( "<a href=\"".$link."\">".$day->getEntry()."</a>\n" );
222
 
223
			}
224
			echo ( "</td>\n" );
225
 
226
			// isLast() to find end of week
227
			if ( $day->isLast() )
228
				echo ( "</tr>\n" );
10 ddelon 229
		}
14 ddelon 230
 
231
		echo "</table>";
232
 
233
	}
234
 
10 ddelon 235
?>