aboutsummaryrefslogtreecommitdiff
path: root/Neutron-trunk/cms-special/calendar/index.php
blob: 8843961bca9b184d16f837d3cb398b1fc533cb5e (plain)
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
<?php require_once "../../resources/private/relative.php"; getRelativeDetails("cms-special"); ?>
<?php

function dbtest($string) {
    json_decode($string);
    return (json_last_error() == JSON_ERROR_NONE);
}

include_once $_SERVER['DOCUMENT_ROOT'] . "/api/engine-cyclic/render.php";
include_once $_SERVER['DOCUMENT_ROOT'] . "/api/lang/processor.php";
$buffer = ""; // Initialiser un nouveau tampon vide

function buffer(string $value) {
    global $buffer;
    $buffer = $buffer . $value;
}

    $jsonraw = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/caldb.json");
    if (dbtest($jsonraw)) {
        $json = json_decode($jsonraw);
        $eventlist = [];
        $eventlistpassed = [];
        foreach ($json->events as $event) {
            if (isset($event->timestamp)) {
                (int)$currentDate = date("Ymd");
                if ($currentDate < $event->timestamp || $currentDate == $event->timestamp) {
                    array_push($eventlist, $event->timestamp);
                } else {
                    array_push($eventlistpassed, $event->timestamp);
                }
            }
        }
        sort($eventlist);
        sort($eventlistpassed);
        $pos = 1;
        $shown = 0;
        buffer("<h2>" . $lang["calendar"]["futureh"] . "</h2>");
        foreach ($eventlist as $event) {
            if (1 == 2) {} else {
                foreach ($json->events as $el) {
                    if (isset($el->timestamp)) {
                        if ($el->timestamp == $event) {
                            (int)$currentDate = date("Ymd");
                            if ($currentDate < $el->timestamp) {
                                $shown = $shown + 1;
                                buffer("<h3>" . $el->datestr . "</h3><ul><li>" . $el->name . "</li>");
                                if ($el->description != "") {
                                    buffer("<li>" . $el->description . "</li>");
                                }
                                if (isset($el->link)) {
                                    if ($el->link != "" && $el->link != "http://") {
                                        buffer("<br><li><a target=\"_blank\" href=\"" . $el->link . "\" title=\"" . $lang["calendar"]["newtab"] . "\">" . $lang["calendar"]["more"] . "</a></li>");
                                    }
                                }
                                buffer("</ul>");
                                $pos = $pos + 1;
                            }
                            if ($currentDate == $el->timestamp) {
                                $shown = $shown + 1;
                                buffer("<h3>" . $lang["calendar"]["today"] . "</h3><ul><li>" . $el->name . "</li>");
                                if ($el->description != "") {
                                    buffer("<li>" . $el->description . "</li>");
                                }
                                if (isset($el->link)) {
                                    if ($el->link != "" && $el->link != "http://") {
                                        buffer("<br><li><a target=\"_blank\" href=\"" . $el->link . "\" title=\"" . $lang["calendar"]["newtab"] . "\">" . $lang["calendar"]["more"] . "</a></li>");
                                    }
                                }
                                buffer("</ul>");
                                $pos = $pos + 1;
                            }
                            if ($currentDate > $el->timestamp) {
                                $shown = $shown + 1;
                                buffer("<h3>" . $lang["calendar"]["pasth"] . " (" . $el->datestr . ")</h3><ul><li>" . $el->name . "</li>");
                                if ($el->description != "") {
                                    buffer("<li>" . $el->description . "</li>");
                                }
                                if (isset($el->link)) {
                                    if ($el->link != "" && $el->link != "http://") {
                                        buffer("<br><li><a target=\"_blank\" href=\"" . $el->link . "\" title=\"" . $lang["calendar"]["newtab"] . "\">" . $lang["calendar"]["more"] . "</a></li>");
                                    }
                                }
                                buffer("</ul>");
                                $pos = $pos + 1;
                            }
                        }
                    }
                }
            }
        }
        if ($shown == "0") {
            buffer("</ul><div style=\"text-align: center;\"><i>" . $lang["calendar"]["future"] . "</i></div>");
        }
        buffer("<h2>" . $lang["calendar"]["pasth"] . "</h2>");
        $pos = 1;
        $shown = 0;
        foreach ($eventlistpassed as $event) {
            if (1 == 2) {} else {
                foreach ($json->events as $el) {
                    if (isset($el->timestamp)) {
                        if ($el->timestamp == $event) {
                            (int)$currentDate = date("Ymd");
                            if ($currentDate < $el->timestamp) {
                                $shown = $shown + 1;
                                buffer("<h3>" . $el->datestr . "</h3><ul><li>" . $el->name . "</li>");
                                if ($el->description != "") {
                                    buffer("<li>" . $el->description . "</li>");
                                }
                                if (isset($el->link)) {
                                    if ($el->link != "" && $el->link != "http://") {
                                        buffer("<br><li><a target=\"_blank\" href=\"" . $el->link . "\" title=\"" . $lang["calendar"]["newtab"] . "\">" . $lang["calendar"]["more"] . "</a></li>");
                                    }
                                }
                                buffer("</ul>");
                                $pos = $pos + 1;
                            }
                            if ($currentDate == $el->timestamp) {
                                $shown = $shown + 1;
                                buffer("<h3>" . $lang["calendar"]["today"] . "</h3><ul><li>" . $el->name . "</li>");
                                if ($el->description != "") {
                                    buffer("<li>" . $el->description . "</li>");
                                }
                                if (isset($el->link)) {
                                    if ($el->link != "" && $el->link != "http://") {
                                        buffer("<br><li><a target=\"_blank\" href=\"" . $el->link . "\" title=\"" . $lang["calendar"]["newtab"] . "\">" . $lang["calendar"]["more"] . "</a></li>");
                                    }
                                }
                                buffer("</ul>");
                                $pos = $pos + 1;
                            }
                            if ($currentDate > $el->timestamp) {
                                $shown = $shown + 1;
                                buffer("<h3>" . $el->datestr . "</h3><ul><li>" . $el->name . "</li>");
                                if ($el->description != "") {
                                    buffer("<li>" . $el->description . "</li>");
                                }
                                if (isset($el->link)) {
                                    if ($el->link != "" && $el->link != "http://") {
                                        buffer("<br><li><a target=\"_blank\" href=\"" . $el->link . "\" title=\"" . $lang["calendar"]["newtab"] . "\">" . $lang["calendar"]["more"] . "</a></li>");
                                    }
                                }
                                buffer("</ul>");
                                $pos = $pos + 1;
                            }
                        }
                    }
                }
            }
        }
        if ($shown == "0") {
            buffer("</ul><div style=\"text-align: center;\"><i>" . $lang["calendar"]["past"] . "</i></div>");
        }
    } else {
        buffer("<b>" . $lang["calendar"]["corrupted"] . "</b>");
    }

renderSpecial($buffer, $lang["calendar"]["title"]);

?>