Statistiques
| Branche: | Révision :

root / index.php @ e003fd329383bccc0daad56c535e3d47fe4dbc4b

Historique | Voir | Annoter | Télécharger (3,9 ko)

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