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

require_once $_SERVER['DOCUMENT_ROOT'] . "/api/renderer/render.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/api/lang/processor.php";
$buffer = ""; // Initialiser un nouveau tampon vide

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

if (file_exists($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/galery/pictures") && count(scandir($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/galery/pictures")) > 2) {
    $categories = scandir($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/galery/categories");
    array_push($categories, "unclassed");
    foreach ($categories as $category) {
        if ($category != "." && $category != "..") {
            $shown = false;
            if ($category == "unclassed") {
                buffer("<h2>" . $lang["gallery"]["unclassed"] . "</h2>");
            } else {
                buffer("<h2>" . file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/galery/categories/" . $category) . "</h2>");
            }
            buffer("<div style=\"text-align: center;\">");
            $photos = scandir($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/galery/pictures");
            foreach ($photos as $photo) {
                if ($photo == "." || $photo == "..") {} else {
                    $praw = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/data/webcontent/galery/pictures/" . $photo);
                    $pcat = explode("|", $praw)[1];
                    $ppath = explode("|", $praw)[0];
                    if ($pcat == $category) {
                        $shown = true;
                        if (file_exists($_SERVER['DOCUMENT_ROOT'] . $ppath)) {
                            buffer("<div class=\"photo\">");
                            buffer("<a href=\"{$GLOBALS["SYSTEM_ROOT"]}/cms-special/gallery/preview/?url={$GLOBALS["SYSTEM_ROOT"]}" . $ppath . "&return={$GLOBALS["SYSTEM_ROOT"]}/cms-special/gallery\"><img class=\"photo_image\" src=\"{$GLOBALS["SYSTEM_ROOT"]}" . $ppath . "\" /></a>");
                            if (isset(explode("|", $praw)[2])) {
                                buffer("<br><div class=\"photo_label\">" . explode("|", $praw)[2] . "</div>");
                            }
                            buffer("</div>");
                        } else {
                            buffer("<div class=\"photo\">");
                            buffer('<p><table class="message_error message_black"><tbody><tr><td><img src="' . $GLOBALS["SYSTEM_ROOT"] .'/resources/image/message_error.svg" class="message_img"></td><td style="width:100%;">' . $lang["gallery"]["error"] . '</td></tr></tbody></table></p>');
                            buffer("</div>");
                        }
                    }
                }
            }
            if (!$shown) {
                buffer("<p><div style=\"text-align: center;\"><i>" . $lang["gallery"]["nothing"] . "</i></div></p>");
            }
            buffer("</center></div></center>");
        }
    }
} else {
    buffer("<div style=\"text-align: center;\"><i>" . $lang["gallery"]["disabled"][0] . "<b>" . $lang["gallery"]["disabled"][1] . "</b>" . $lang["gallery"]["disabled"][2] . "</i></div>");
}
buffer("<script>window.onload = () => {setTimeout(() => {Array.from(document.getElementsByClassName('photo_image')).forEach((el) => {el.classList.add('loaded')});}, 1000)}</script>");

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

?>