aboutsummaryrefslogtreecommitdiff
path: root/Neutron-trunk/cms-special/admin/calendar/index.php
blob: e5965514f8e1732dcd06f2e68694280d14860b16 (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
<?php require_once "../../../resources/private/relative.php"; getRelativeDetails("cms-special"); ?>
<?php $pageConfig = [ "domName" => "Calendrier", "headerName" => "Gestion des événements" ]; include_once $_SERVER['DOCUMENT_ROOT'] . "/cms-special/admin/\$resources/precontent.php"; ?>
        <?php
        
        if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/calendar_events")) {
            $calevn = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/calendar_events");
        } else {
            $calevn = "3";
        }
        
        ?>
        <?= $lang["admin-calendar"]["show"][0] ?> <select onchange="updateNextEvents()" id="nextevents">
            <option value="1" <?php if ($calevn == "1") { echo("selected"); } ?>>1</option>
            <option value="2" <?php if ($calevn == "2") { echo("selected"); } ?>>2</option>
            <option value="3" <?php if ($calevn == "3") { echo("selected"); } ?>>3</option>
            <option value="4" <?php if ($calevn == "4") { echo("selected"); } ?>>4</option>
            <option value="5" <?php if ($calevn == "5") { echo("selected"); } ?>>5</option>
            <option value="6" <?php if ($calevn == "6") { echo("selected"); } ?>>6</option>
            <option value="7" <?php if ($calevn == "7") { echo("selected"); } ?>>7</option>
            <option value="8" <?php if ($calevn == "8") { echo("selected"); } ?>>8</option>
            <option value="9" <?php if ($calevn == "9") { echo("selected"); } ?>>9</option>
            <option value="10" <?php if ($calevn == "10") { echo("selected"); } ?>>10</option>
        </select> <?= $lang["admin-calendar"]["show"][1] ?>
        <h3><?= $lang["admin-calendar"]["events"] ?></h3>
        <ul>
        <?php
        
        if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/caldb.json")) {
            $dbraw = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/caldb.json");
            $corrupted = false;
            if (isJson($dbraw)) {
                $events = json_decode($dbraw);
                foreach ($events->events as $event) {
                    if (isset($event->timestamp)) {
                        echo("<li><span style=\"cursor:help;\" title=\"" . $event->description . "\">" . $event->name . "</span> (" . $event->datestr . ")" . " - <a class=\"sblink\" href=\"{$GLOBALS["SYSTEM_ROOT"]}/cms-special/admin/calendar/manage/?id=" . $event->timestamp . "\" title=\"{$lang['admin-calendar']['manageph']}\">" . $lang["admin-calendar"]["manage"] . "</a></li>");
                    }
                }
            } else {
                echo("<div style=\"color:red; text-align: center;\"><b><u>{$lang['admin-calendar']['corrupt'][0]}</u> {$lang['admin-calendar']['corrupt'][1]} <u>{$lang['admin-calendar']['corrupt'][2]}</u></b></div>");
                $corrupted = true;
            }
        } else {
            echo("<div style=\"text-align: center;\">{$lang['admin-calendar']['nothing']}</div>");
        }

        ?>
        <?php
        
        if (!$corrupted) {
            echo('<br><li><i><a href="' . $GLOBALS["SYSTEM_ROOT"] . '/cms-special/admin/calendar/add" title="' . $lang["admin-calendar"]["addph"] . '" class="sblink">' . $lang["admin-calendar"]["add"] . '</a></i></li>');
        }
        
        ?>
        </ul>
<?php include_once $_SERVER['DOCUMENT_ROOT'] . "/cms-special/admin/\$resources/postcontent.php"; ?>
<script>

function updateNextEvents() {
    value = document.getElementById('nextevents').value;
    var formData = new FormData();
    formData.append("value", value);
    document.getElementById('nextevents').disabled = true;
    $.ajax({
        type: "POST",
        dataType: 'html',
        url: "<?= $GLOBALS["SYSTEM_ROOT"] ?>/api/admin/calendar_nextevents.php",
        success: function (data) {
            if (data == "ok") {
                document.getElementById('nextevents').disabled = false;
            } else {
                alert("<?= $lang["admin-errors"]["errorprefix"] ?>" + data)
                document.getElementById('nextevents').disabled = false;
            }
        },
        error: function (error) {
            alert("<?= $lang["admin-errors"]["connerror"] ?>")
            document.getElementById('nextevents').disabled = false;
        },
        data: formData,
        cache: false,
        contentType: false,
        processData: false
    });
}

</script>