root / index.php @ 5ea6d54ca4b3ad5f71128088cf761478d85e1137
Historique | Voir | Annoter | Télécharger (4,12 ko)
1 | <?php
|
---|---|
2 | setlocale(LC_ALL, 'fr_FR'); |
3 | $lstJours = array("dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"); |
4 | $lstMois = array(1 => "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"); |
5 | $lstFeries = array( |
6 | "jourDeLAn" => array(1, 1, "jour de l'an"), |
7 | "rameaux" => array(0, 0, "les Rameaux"), |
8 | "paques" => array(0, 0, "Pâques"), |
9 | "lundiDePaques" => array(0, 0, "lundi de Pâques"), |
10 | "feteDuTravail" => array(1, 5, "fête du travail"), |
11 | "victoire1945" => array(8, 5, "victoire 1945"), |
12 | "ascension" => array(15, 8, "l'Ascension"), |
13 | "pentecote" => array(0, 0, "la Pentecôte"), |
14 | "lundiDePentecote" => array(0, 0, "lundi de Pentecôte"), |
15 | "feteNationale" => array(14, 7, "fête Nationale"), |
16 | "assomption" => array(15, 8, "l'Assomption"), |
17 | "toussaint" => array(1, 11, "la Toussaint"), |
18 | "armistice1918" => array(11, 11, "armistice 1918"), |
19 | "noel" => array(25, 12, "Noël") |
20 | ); |
21 | |
22 | function getPaquesDay($year) { |
23 | $b = $year-1900; |
24 | $c = $year % 19; |
25 | $d = (7*$c+1)/19; |
26 | $e = (11*$c+4-$d) % 29; |
27 | $f = $b/4; |
28 | $g = ($b+$f+31-$e) % 7; |
29 | $h = 25-$e-$g; |
30 | if ($h > 0) { |
31 | $jour = $h; |
32 | $mois = 4; |
33 | } else {
|
34 | $jour = $h+31; |
35 | $mois = 3; |
36 | } |
37 | return array($jour, $mois); |
38 | } |
39 | |
40 | $year = date("Y"); |
41 | if (isset($_GET['year'])) $year = $_GET['year']; |
42 | if (isset($_GET['annee'])) $year = $_GET['annee']; |
43 | |
44 | list($jourPaques, $moisPaques) = getPaquesDay($year); |
45 | $datePaques = strtotime("$year-$moisPaques-$jourPaques"); |
46 | $lstFeries['paques'][0] = $jourPaques; |
47 | $lstFeries['paques'][1] = $moisPaques; |
48 | $ts = strtotime("-7 days", $datePaques); |
49 | $lstFeries['rameaux'][0] = date("j", $ts); |
50 | $lstFeries['rameaux'][1] = date("n", $ts); |
51 | $ts = strtotime("1 day", $datePaques); |
52 | $lstFeries['lundiDePaques'][0] = date("j", $ts); |
53 | $lstFeries['lundiDePaques'][1] = date("n", $ts); |
54 | $ts = strtotime("39 days", $datePaques); |
55 | $lstFeries['ascension'][0] = date("j", $ts); |
56 | $lstFeries['ascension'][1] = date("n", $ts); |
57 | $ts = strtotime("49 days", $datePaques); |
58 | $lstFeries['pentecote'][0] = date("j", $ts); |
59 | $lstFeries['pentecote'][1] = date("n", $ts); |
60 | $ts = strtotime("50 days", $datePaques); |
61 | $lstFeries['lundiDePentecote'][0] = date("j", $ts); |
62 | $lstFeries['lundiDePentecote'][1] = date("n", $ts); |
63 | ?>
|
64 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
65 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
66 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr"> |
67 | <head>
|
68 | <meta http-equiv="Content-Type" content="text/HTML; charset=iso-8859-1" /> |
69 | <meta http-equiv="Content-style-type" content="text/css" /> |
70 | <meta http-equiv="Content-language" content="fr" /> |
71 | <title>Calendrier <?=$year?></title> |
72 | <link rel="stylesheet" type="text/css" href="calendrier.css" media="screen" title="Normal" /> |
73 | <link rel="stylesheet" type="text/css" href="calendrier.css" media="print" title="Normal" /> |
74 | |
75 | </head>
|
76 | |
77 | <body>
|
78 | <?php
|
79 | for ($s = 1; $s <= 2; $s++) { |
80 | print "\t\t<table>\n"; |
81 | for ($j = 0; $j <= 31; $j++) { |
82 | if ($j == 0) { |
83 | echo "\t\t\t<tr id=\"semestre$s\">\n"; |
84 | } else {
|
85 | echo "\t\t\t<tr class=\"jour$j\">\n"; |
86 | } |
87 | for ($m = 6*$s-5; $m <= 6*$s; $m++) { |
88 | if ($j == 0) { |
89 | echo "\t\t\t\t<th id=\"mois$m\">".$lstMois[$m]."</th>\n"; |
90 | $lastDay = 29; |
91 | while (checkdate($m, $lastDay, $year)) $lastDay++; |
92 | $last[$m] = $lastDay-1; |
93 | } else {
|
94 | $ts = strtotime("$year-$m-$j"); |
95 | $weekDay = $lstJours[date("w", $ts)]; |
96 | $abrvDay = strftime("%a", $ts); |
97 | if ($j <= $last[$m]) { |
98 | $classFerie = ""; |
99 | foreach ($lstFeries as $id => $f) { |
100 | if ($j == $f[0] && $m == $f[1]) { |
101 | $classFerie = " class=\"ferie\" class=\"$id\" title=\"".$f[2]."\""; |
102 | break;
|
103 | } |
104 | } |
105 | echo "\t\t\t\t<td$classFerie class=\"$weekDay\"><span class=\"nom-jour\">$abrvDay</span><span class=\"num-jour\">$j</span></td>\n"; |
106 | } else {
|
107 | if ($last[$m] == 30) { |
108 | echo "\t\t\t\t<td></td>\n"; |
109 | } else {
|
110 | if ($j == $last[$m]+1) echo "\t\t\t\t<td rowspan=\"".(31-$last[$m])."\"></td>\n"; |
111 | } |
112 | } |
113 | } |
114 | } |
115 | echo "\t\t\t</tr>\n"; |
116 | } |
117 | print "\t\t</table>\n"; |
118 | print "\t\t<br />\n"; |
119 | } |
120 | ?>
|
121 | </body>
|
122 | </html>
|