aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates/pages/page_item.php
blob: 201a2f9c62878215481b533cad37963f4f35099f (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
<?php

use Digitigrade\Model\UserAccount;

/** @var \Digitigrade\Model\Note $note */
/** @var \Digitigrade\Page $page */

?>
<article lang="<?= htmlspecialchars($note->language) ?>">
    <div class="pageHeader">
        <div>
            <h1><?= htmlspecialchars($page->title) ?></h1>
            <a class="pageAuthor" href="/@/<?= htmlspecialchars($note->author->getFullHandle()) ?>">
                <?php call_template('actor/avatar', ['actor' => $note->author]); ?>
                <span><?= __f(
                    'note.page.author',
                    '<span class="displayName">' . htmlspecialchars($note->author->displayName) . '</span>'
                ) ?></span>
            </a>
            <div class="created">
                <?= __f('note.page.created', format_datetime($note->created)) ?>
            </div>
            <?php if (isset($note->modified) && $note->modified != $note->created): ?>
                <div class="modified">
                    <?= __f('note.page.modified', format_datetime($note->modified)) ?>
                </div>
            <?php endif; ?>
        </div>
        <div class="pageActions">
            <?php call_template('menu_button', [], function () use ($note, $page) {
                $user = UserAccount::findByCurrentSession();
                if ($note->author->isLocal && ($note->author == $user?->actor || $user?->isAdmin)) { ?>
                    <li>
                        <button hx-get="/fragment/page/<?= $note->id ?>/edit" hx-target="closest article" hx-swap="outerHTML">
                            <span class="material-symbols edit-outline"></span>
                            <span><?= __('note.action.edit') ?></span>
                        </button>
                    </li>
                    <li>
                        <button hx-delete="/fragment/note/<?= $note->id ?>"
                            hx-confirm="<?= __('note.action.delete.confirmation') ?>" hx-target="closest article"
                            hx-swap="delete" _="on htmx:afterOnLoad go back">
                            <span class="material-symbols delete-outline"></span>
                            <span><?= __('note.action.delete') ?></span>
                        </button>
                    </li>
                <?php }
            }); ?>
        </div>
    </div>
    <hr>
    <div class="pageContent">
        <?= $page->getBestContentAsHtml() ?>
    </div>
</article>