Bonjour,

Je viens enfin de trouver un script simple pour gérer un calendrier d'événements. (J'aurais voulu en trouver un qui se gère avec une bdd sql mais je ne comprenais pas le fonctionnement : si vous avez quelque chose...)
Le problème, c'est qu'il n'y a pas d'exemple pour ajouter des liens sur les dates
où on veut mettre quelque chose... quelqu'un peut-il me donner un exemple?
Merci d'avance
Pau



Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
<?php
 
// Appel au script du calendrier
require_once("calendar.php");
// Parametrage
$params = array("LANGUAGE_CODE" => "fr",
              "FIRST_WEEK_DAY" => 1,
              "USE_SESSION" => false);
// Affichage
Calendar($params);
?>






Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
function Calendar($params) {
	// 
	// VARIABLES
	// 
 
	// Global variables 
	global $_SESSION;
	global $_SERVER;
	global $_GET;
 
	// Default parameters
	$PREFIX         = "calendar_";
	$CSS_PREFIX     = "calendar_";
	$DATE_URL       = "";
	$URL_PARAMETER  = "date";
	$USE_SESSION    = false;
	$PRESERVE_URL   = true;
	$JS             = false;
	$JS_URL         = "";
	$FIRST_WEEK_DAY = 1;
	$LANGUAGE_CODE  = "fr";
 
	// Overwrite parameters with custom values
	extract($params);
 
	// Translations for month and day
//	include($_SERVER["DOCUMENT_ROOT"]."/".dirname($_SERVER["PHP_SELF"])."/calendar_locales.php");
	include("calendar_locales.php");
	// Month names
	if (isset($MONTHS[$LANGUAGE_CODE])) {
		$month_name = $MONTHS[$LANGUAGE_CODE];
	} else {
		$month_name = $MONTHS["fr"];
	}
	// Short names of days
	if (isset($WEEK_DAYS[$LANGUAGE_CODE])) {
		$day_name = $WEEK_DAYS[$LANGUAGE_CODE];
	} else {
		$day_name = $WEEK_DAYS["fr"];
	}
	// Current month's name
	if (isset($MONTH_HEADER[$LANGUAGE_CODE])) {
		$month_header = $MONTH_HEADER[$LANGUAGE_CODE];
	} else {
		$month_header = $MONTH_HEADER["fr"];
	}
 
 
	// 
	// FUNCTIONS
	// 
 
	// This function displays HTML code: if $JS = true, we do not display line
	// breaks
	if (! function_exists("calendar_display")) {
		function calendar_display($text, $JS) {
			if ($JS) {
				echo "document.writeln('".$text."');\n";
			} else {
				echo $text."\n";
			}
		}
	}
 
	// This function sets the calendar URL parameter $URL_PARAMETER to $date in
	// the given URL $URL. Used for the previous and next arrows of the calendar
	// title.
	if (! function_exists("calendar_calculate_URL")) {
		function calendar_calculate_URL($URL, $URL_PARAMETER, $date, $PRESERVE_URL, $USE_SESSION) {
			$URL_components = parse_url($URL);
			$new_URL        = $URL_components["path"]."?";
			$add_SID        = $USE_SESSION;
			// We retrieve and preserve the current URL parameters if required
			if ($PRESERVE_URL && isset($URL_components["query"])) {
				parse_str($URL_components["query"], $query_string);
				// We build the query string
				foreach ($query_string as $param => $value) {
					if ($param != $URL_PARAMETER) {
						$new_URL .= $param."=".urlencode($value)."&amp;";
					}
					// If the SID is already there, we do not add it again
					if ($USE_SESSION && $param == session_name()) {
						$add_SID = false;
					}
				}
			}
 
			// We add the date
			$new_URL .= $URL_PARAMETER."=".$date;
 
			// We also add the session ID (SID) if necessary
			if ($add_SID && SID != "") {
				$new_URL .= "&amp;".SID;
			}
 
			return $new_URL;
		}
	}
 
	// This function calculates the date of the previous month with the mmyyyy
	// format
	if (! function_exists("calendar_previous_month")) {
		function calendar_previous_month($month, $year) {
			if ($month == 1) {
				$new_month = "12";
				$new_year  = $year - 1;
			} else {
				$new_month = (($month > 10)?"":"0").($month - 1);
				$new_year  = $year;
			}
 
			return $new_month.$new_year;
		}
	}
 
	// This function calculates the date of the next month with the mmyyyy format
	if (! function_exists("calendar_next_month")) {
		function calendar_next_month($month, $year) {
			if ($month == 12) {
				$new_month = "01";
				$new_year  = $year + 1;
			} else {
				$new_month = (($month < 9)?"0":"").($month + 1);
				$new_year  = $year;
			}
 
			return $new_month.$new_year;
		}
	}
 
	// 
	// MAIN LOOP
	// 
 
	// In the case of JavaScript integration with session, we create the session.
	// We are allowed to do that because in JavaScript integration this PHP script
	// is not included in any custom page.
	if ($JS && $USE_SESSION) {
		session_start();
	}
 
	// Today's date
	$today = date("dmY");
 
	// Month and year to display (gotten from URL)
	if (isset($_GET[$PREFIX."date"])) {
		if ($_GET[$PREFIX."date"] != "") {
			$month = (int)substr($_GET[$PREFIX."date"], 0, 2);
			$year  = substr($_GET[$PREFIX."date"], 2);
		}
	}
 
	// Default month to show (if not found in the URL)
	if (!isset($month)) {
		$month = gmdate("n");
		// In the case of session, we must get the session date
		if ($USE_SESSION && isset($_SESSION[$PREFIX."month"])) {
			$month = $_SESSION[$PREFIX."month"];
		}
	}
	// We put the month in the session if required
	if ($USE_SESSION) {
		$_SESSION[$PREFIX."month"] = $month;
	}
 
	// Default year to show (if not found in the URL)
	if (!isset($year)) {
		$year = gmdate("Y");
		// In the case of session, we must get the session date
		if ($USE_SESSION && isset($_SESSION[$PREFIX."year"])) {
			$year = $_SESSION[$PREFIX."year"];
		}
	}
	// We put the year in the session if required
	if ($USE_SESSION) {
		$_SESSION[$PREFIX."year"] = $year;
	}
 
	// We display the top of the calendar
	if ($JS) {
		$URL_page = $JS_URL;
	} else {
		$URL_page = $_SERVER["REQUEST_URI"];
	}
	calendar_display("<table class=\"".$CSS_PREFIX."main\">", $JS);
	calendar_display("	<tr class=\"".$CSS_PREFIX."title\">", $JS);
	calendar_display("		<td class=\"".$CSS_PREFIX."title_left_arrow\"><a href=\"".calendar_calculate_URL($URL_page, $PREFIX."date", calendar_previous_month($month, $year), $PRESERVE_URL, $USE_SESSION)."\" class=\"".$CSS_PREFIX."title_left_arrow_clickable\">&lt;&lt;</a></td>", $JS);
	if ($DATE_URL != "") {
		calendar_display("		<td class=\"".$CSS_PREFIX."title_month\"><a href=\"".calendar_calculate_URL($DATE_URL, $URL_PARAMETER, (($month < 10)?"0":"").$month.$year, true, $USE_SESSION)."\" class=\"".$CSS_PREFIX."title_month_clickable\">".$month_name[$month - 1]." ".$year."</a></td>", $JS);
	} else {
		calendar_display("		<td class=\"".$CSS_PREFIX."title_month\">".str_replace("%y", $year, str_replace("%m", $month_name[$month - 1], $month_header))."</td>", $JS);
	}
	calendar_display("		<td class=\"".$CSS_PREFIX."title_right_arrow\"><a href=\"".calendar_calculate_URL($URL_page, $PREFIX."date", calendar_next_month($month, $year), $PRESERVE_URL, $USE_SESSION)."\" class=\"".$CSS_PREFIX."title_right_arrow_clickable\">&gt;&gt;</a></td>", $JS);
	calendar_display("	</tr>", $JS);
	calendar_display("	<tr>", $JS);
	calendar_display("		<td colspan=\"3\">", $JS);
	calendar_display("			<table class=\"".$CSS_PREFIX."table\">", $JS);
	calendar_display("				<tr>", $JS);
	for ($counter = 0; $counter < 7; $counter++) {
		calendar_display("					<th>".$day_name[($FIRST_WEEK_DAY + $counter) % 7]."</th>", $JS);
	}
	calendar_display("				</tr>", $JS);
 
	// We calculate the first day of the month to show
	$first_month_day = gmmktime(0, 0, 0, $month, 1, $year);
 
	// We calculate the week day of this first day so that we can determine how
	// many days we are far from the first week day
	$offset = (7 - ($FIRST_WEEK_DAY % 7 - gmdate("w", $first_month_day))) % 7;
 
	// First day of the calendar
	$current_day = $first_month_day - 3600 * 24 * $offset;
 
	// We are going to display a table => 2 nested loops
	// How many rows in the calendar?
	$row_number = ceil((gmdate("t", $first_month_day) + $offset) / 7);
	for ($row = 1; $row <= $row_number; $row++) {
		// The first loop displays the rows
		calendar_display("				<tr>", $JS);
 
		// The second loop displays the days (as columns)
		for ($column = 1; $column <= 7; $column++) {
			// Day currently displayed
			$day = gmdate("j", $current_day);
 
			// If it is saturday or sunday, we use the "weekend" style
			if (gmdate("w", $current_day) == 6 || gmdate("w", $current_day) == 0) {
				$table_cell = "					<td class=\"".$CSS_PREFIX."weekend\">";
			} else {
				$table_cell = "					<td>";
			}
 
			// We display the current day
			$CSS_class = "";
			// Clickable days?
			if ($DATE_URL != "") {
				if (gmdate("dmY", $current_day) == $today) {
					$CSS_class = $CSS_PREFIX."today_clickable";
				} else {
					// Days not in the current month with CSS clas "other_month"
					if (gmdate("n", $current_day) != $month) {
						$CSS_class = $CSS_PREFIX."other_month_clickable";
					} else {
						$CSS_class = $CSS_PREFIX."day_clickable";
					}
				}
				$table_cell .= "<a href=\"".calendar_calculate_URL($DATE_URL, $URL_PARAMETER, gmdate("dmY", $current_day), true, $USE_SESSION)."\" class=\"".$CSS_class."\">".$day."</a>";
			} else {
				// Days not in the current month with CSS clas "other_month"
				if (gmdate("n", $current_day) != $month) {
					$CSS_class = $CSS_PREFIX."other_month";
				}
				// If we are displaying today's day, CSS class "today"
				if (gmdate("dmY", $current_day) == $today) {
					$CSS_class = $CSS_PREFIX."today";
				}
				if ($CSS_class == "") {
					$table_cell .= $day;
				} else {
					$table_cell .= "<span class=\"".$CSS_class."\">".$day."</span>";
				}
			}
 
			// End of day cell
			calendar_display($table_cell."</td>", $JS);
 
			// Next day
			$current_day += 3600 * 24 + 1;
		}
 
		// End of rows
		calendar_display("				</tr>", $JS);
	}
 
	calendar_display("			</table>", $JS);
	calendar_display("		</td>", $JS);
	calendar_display("	</tr>", $JS);
	calendar_display("</table>", $JS);
}
?>