aboutsummaryrefslogtreecommitdiff
path: root/views/list/index.php
blob: 759ab0401aebf5c3546701b5a2dcbdcd64e16092 (plain) (blame)
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
<?php
    $list = null;
    $author = null;
    $user = null;

    try {
        $list = Database\ArchiveList::fromDB($lid ?? -1);
        $author = Database\User::fromDBuid($list->AuthorUID);
        $user = Database\Cookie::fromDB($TOKEN);
    }
    catch(Exception $e) {}
?>

<?php if ($list !== null): ?>
    <section class="list-container">
        <section>
            <h2><?= $list->Name ?></h2>
            <p class="user-info">
                <?php $author->icon(); ?>
                <?= $author->Username ?>
            </p>
            <p><?= $list->Description ?></p>

            <section id="list-buttons" hidden>
                <form action="/list/update" method="GET">
                    <input type="hidden" name="lid" value="<?= $list->LID ?>">
                    <input type="submit" value="Update">
                </form>
                <form action="/list/delete" method="GET">
                    <input type="hidden" name="lid" value="<?= $list->LID ?>">
                    <input type="submit" value="Delete">
                </form>
            </section>
            <script type="text/javascript">
                function showListButtons() {
                    document.getElementById('list-buttons').hidden = false;
                }
                authenticated(showListButtons);
            </script>
        </section>
        <section>
            <?php
                $items = $list->allItems();
                if (!$items) {
                    echo '<h1>No archives</h1>';
                }
                else {
                    foreach ($list->allItems() as $page) {
                        include $VIEWS_DIR . '/archive/item.php';
                    }
                    include_once $VIEWS_DIR . '/archive/item_show.php';
                }
            ?>
        </section>
    </section>

<?php else: ?>
    <p>
        List doesn't exist
    </p>

<?php endif; ?>