aboutsummaryrefslogtreecommitdiff
path: root/Neutron-trunk/cms-special/calendar
diff options
context:
space:
mode:
authorMinteck <nekostarfan@gmail.com>2021-08-24 15:38:16 +0200
committerMinteck <nekostarfan@gmail.com>2021-08-24 15:38:16 +0200
commit529ffcbfa97ab51a64a97f6dff08aeb2bc0cc105 (patch)
tree8a50c30271b9b328cde0d907b1441f2dabdc341b /Neutron-trunk/cms-special/calendar
parent15e4724761c50b30803df1811a525c85058f70bf (diff)
downloadelectrode-529ffcbfa97ab51a64a97f6dff08aeb2bc0cc105.tar.gz
electrode-529ffcbfa97ab51a64a97f6dff08aeb2bc0cc105.tar.bz2
electrode-529ffcbfa97ab51a64a97f6dff08aeb2bc0cc105.zip
Update
Diffstat (limited to 'Neutron-trunk/cms-special/calendar')
-rw-r--r--Neutron-trunk/cms-special/calendar/index.php159
1 files changed, 159 insertions, 0 deletions
diff --git a/Neutron-trunk/cms-special/calendar/index.php b/Neutron-trunk/cms-special/calendar/index.php
new file mode 100644
index 0000000..8843961
--- /dev/null
+++ b/Neutron-trunk/cms-special/calendar/index.php
@@ -0,0 +1,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"]);
+
+?> \ No newline at end of file