Subversion Repositories Applications.bazar

Rev

Rev 10 | Rev 17 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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