aboutsummaryrefslogtreecommitdiff
path: root/Neutron-trunk/cms-special/admin-v2/flags/index.php
blob: c243a4974f490ca2ef6c2d2dac2f08f329d2a7bd (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
<?php require_once "../../../resources/private/relative.php"; getRelativeDetails("cms-special"); ?>
<?php

/** @var boolean $__electrode */
if (isset($__electrode) && $__electrode) {
    header("Location: {$GLOBALS["SYSTEM_ROOT"]}/cms-special/admin/home");
    require $_SERVER['DOCUMENT_ROOT'] . "/api/electrode/quit.php";quit();
}

function fflag($name, $title, $description) {
    echo('<div class="widget"><div id="header-' . $name . '" class="widget-header ');
    if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/flag_{$name}")) { echo("enabled"); } else { echo("disabled"); }
    echo("\"><table><tbody><tr><td><label class=\"switch\"><input name=\"{$name}\" type=\"checkbox\" onclick=\"updateWidgetStatus('{$name}')\" onchange=\"updateWidgetStatus('{$name}')\"");
    if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/flag_{$name}")) { echo(" checked"); }
    echo("><span class=\"slider round\"></span></label></td><td class=\"widget-header-info\"><b>{$title}</b></td></tr></tbody></table></div><p>{$description}</p></div>");
}

$pageConfig = [ "domName" => "Drapeaux", "headerName" => "Drapeaux" ]; require_once $_SERVER['DOCUMENT_ROOT'] . "/cms-special/admin/\$resources/precontent.php"; ?>
        <p><table class="message_info"><tbody><tr><td><img src="<?= $GLOBALS["SYSTEM_ROOT"] ?>/resources/image/message_info.svg" class="message_img"></td><td style="width:100%;"><p><?= $lang["admin-flags"]["notice"] ?></p></td></tr></tbody></table></p>

<?php fflag("boundaries", "Show Layout Boundaries", "Shows a thin colored border around different DOM elements.") ?>
<?php fflag("trace", "Trace Rendering Process", "Shows technical info on the bottom of each page. May contain personal/confidential information!") ?>

<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/cms-special/admin/\$resources/postcontent.php"; ?>

<script>

function updateWidgetStatus(widget) {
    checkbox = document.getElementsByName(widget)[0]
    if (typeof checkbox == "undefined") {} else {
        if (checkbox.checked) {
            enabled = true;
            document.getElementById('header-' + widget).classList.remove('disabled');
            document.getElementById('header-' + widget).classList.add('enabled');
        } else {
            enabled = false;
            document.getElementById('header-' + widget).classList.remove('enabled');
            document.getElementById('header-' + widget).classList.add('disabled');
        }
        Array.from(document.getElementsByTagName('input')).forEach((el) => {el.disabled = true})

        var formData = new FormData();
        formData.append("element", widget);
        if (enabled) {
            url = "<?= $GLOBALS["SYSTEM_ROOT"] ?>/api/admin/flag_enable.php";
        } else {
            url = "<?= $GLOBALS["SYSTEM_ROOT"] ?>/api/admin/flag_disable.php";
        }
        $.ajax({
            type: "POST",
            dataType: 'html',
            url: url,
            success: function (data) {
                if (data == "ok") {
                    setTimeout(() => {
                        location.reload();
                    }, 500)
                } else {
                    alert("<?= $lang["admin-errors"]["errorprefix"] ?>" + data);
                }
            },
            error: function (error) {
                alert("<?= $lang["admin-errors"]["connerror"] ?>");
                window.onbeforeunload = undefined;
            },
            data: formData,
            cache: false,
            contentType: false,
            processData: false
        });

    }
}

</script>