diff options
Diffstat (limited to 'pages/docs.inc')
-rw-r--r-- | pages/docs.inc | 77 |
1 files changed, 50 insertions, 27 deletions
diff --git a/pages/docs.inc b/pages/docs.inc index f4ffcc3..5e0ac65 100644 --- a/pages/docs.inc +++ b/pages/docs.inc @@ -34,6 +34,19 @@ if ($select === "add") { require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; +function showDocument($item) { ?> + <div style="display: grid; grid-template-columns: 2fr repeat(3, 1fr);"> + <?= $item["name"] ?> + <?php if (str_starts_with(strip_tags($item["contents"]), "/delete")): ?> + <span class="badge bg-warning rounded-pill text-black" style="width: max-content;">Deleting in <?= round((($item["last"]["date"] + 86400) - time()) / 3600) ?> hours</span> + <?php else: ?> + <span class="text-muted"><?= prettySize(filesize($_SERVER['DOCUMENT_ROOT'] . "/includes/data/docs/" . $item["id"] . ".json")) ?></span> + <span class="relative-time text-muted" data-relative-timestamp="<?= $item["last"]["date"] ?>"><?= timeAgo($item["last"]["date"]) ?></span> + <span class="text-muted"><?= $item["last"]["author"] === "raindrops" ? "Raindrops System" : "Cloudburst System" ?></span> + <?php endif; ?> + </div> +<?php } + ?> <br> @@ -249,57 +262,67 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; } } + foreach ($categories as $category => $_) { + uasort($categories[$category], function ($a, $b) { + return preg_replace("/[^a-z\d]/m", "", strtolower($b["name"])) < preg_replace("/[^a-z\d]/m", "", strtolower($a["name"])); + }); + } + + foreach ($categoryFirst as $category => $_) { + uasort($categoryFirst[$category], function ($a, $b) { + return preg_replace("/[^a-z\d]/m", "", strtolower($b["name"])) < preg_replace("/[^a-z\d]/m", "", strtolower($a["name"])); + }); + } + uasort($unsorted, function ($a, $b) { - return $b["last"]["date"] - $a["last"]["date"]; + return preg_replace("/[^a-z\d]/m", "", strtolower($b["name"])) < preg_replace("/[^a-z\d]/m", "", strtolower($a["name"])); }); uasort($deletable, function ($a, $b) { - return $b["last"]["date"] - $a["last"]["date"]; + return preg_replace("/[^a-z\d]/m", "", strtolower($b["name"])) < preg_replace("/[^a-z\d]/m", "", strtolower($a["name"])); }); $fullList = [...$categoryFirst, ...$categories]; ?> - <?php foreach ($fullList as $category => $items): ?> + <?php foreach ($fullList as $category => $items): if ($category != "Archives"): ?> <h4><?= str_starts_with($category, ".") ? substr($category, 1) : $category ?></h4><div class="list-group"> <?php foreach ($items as $item): ?> <a href="/-/docs/<?= $item["id"] ?>" id="document-<?= $item["id"] ?>" class="list-group-item list-group-item-action document-listing <?php if (str_starts_with(strip_tags($item["contents"]), "/delete")): ?>opacity-75<?php endif; ?>"> - <?= $item["name"] ?> - <?php if (str_starts_with(strip_tags($item["contents"]), "/delete")): ?> - <span class="badge bg-warning rounded-pill text-black">Deleting in <?= round((($item["last"]["date"] + 86400) - time()) / 3600) ?> hours</span> - <?php else: ?> - <span class="relative-time text-muted" data-relative-timestamp="<?= $item["last"]["date"] ?>"><?= timeAgo($item["last"]["date"]) ?></span> - <?php endif; ?> + <?php showDocument($item) ?> </a> <?php endforeach; ?></div> <hr> - <?php endforeach; ?> + <?php endif; endforeach; ?> <h4>Unsorted</h4><div class="list-group"> <?php foreach ($unsorted as $item): ?> <a href="/-/docs/<?= $item["id"] ?>" id="document-<?= $item["id"] ?>" class="list-group-item list-group-item-action document-listing <?php if (str_starts_with(strip_tags($item["contents"]), "/delete")): ?>opacity-75<?php endif; ?>"> - <?= $item["name"] ?> - <?php if (str_starts_with(strip_tags($item["contents"]), "/delete")): ?> - <span class="badge bg-warning rounded-pill text-black">Deleting in <?= round((($item["last"]["date"] + 86400) - time()) / 3600) ?> hours</span> - <?php else: ?> - <span class="relative-time text-muted" data-relative-timestamp="<?= $item["last"]["date"] ?>"><?= timeAgo($item["last"]["date"]) ?></span> - <?php endif; ?> + <?php showDocument($item) ?> </a> <?php endforeach; ?></div> <hr> - <h4 id="deletable">Marked for deletion</h4><div class="list-group"> - <?php foreach ($deletable as $item): ?> - <a href="/-/docs/<?= $item["id"] ?>" id="document-<?= $item["id"] ?>" class="list-group-item list-group-item-action document-listing <?php if (str_starts_with(strip_tags($item["contents"]), "/delete")): ?>opacity-75<?php endif; ?>"> - <?= $item["name"] ?> - <?php if (str_starts_with(strip_tags($item["contents"]), "/delete")): ?> - <span class="badge bg-warning rounded-pill text-black">Deleting in <?= round((($item["last"]["date"] + 86400) - time()) / 3600) ?> hours</span> - <?php else: ?> - <span class="relative-time text-muted" data-relative-timestamp="<?= $item["last"]["date"] ?>"><?= timeAgo($item["last"]["date"]) ?></span> - <?php endif; ?> - </a> - <?php endforeach; ?></div> + <details> + <summary>Show archives and marked for deletion</summary> + + <h4 style="margin-top: 10px;">Archives</h4> + <div class="list-group"> + <?php foreach ($categories["Archives"] as $item): ?> + <a href="/-/docs/<?= $item["id"] ?>" id="document-<?= $item["id"] ?>" class="list-group-item list-group-item-action document-listing <?php if (str_starts_with(strip_tags($item["contents"]), "/delete")): ?>opacity-75<?php endif; ?>"> + <?php showDocument($item) ?> + </a> + <?php endforeach; ?></div> + + <hr> + <h4 id="deletable">Marked for deletion</h4><div class="list-group"> + <?php foreach ($deletable as $item): ?> + <a href="/-/docs/<?= $item["id"] ?>" id="document-<?= $item["id"] ?>" class="list-group-item list-group-item-action document-listing <?php if (str_starts_with(strip_tags($item["contents"]), "/delete")): ?>opacity-75<?php endif; ?>"> + <?php showDocument($item) ?> + </a> + <?php endforeach; ?></div> + </details> </div> <hr> |