aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates/note.php
blob: fdc0dc867c9ba22b4b5191165fa02f159c8ad99b (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
<?php
use Digitigrade\Model\InteractionKind;
use Digitigrade\Model\UserAccount;

$user = UserAccount::findByCurrentSession();
$interKinds = [];
if ($user != null) {
    $interactions = $note->getInteractionsWithAuthor($user->actor);
    $interKinds = array_map(fn($inter) => $inter->kind, $interactions);
}
?>
<article class="note">
    <a href="/@/<?= $note->author->getFullHandle() ?>">
        <?php call_template('actor_avatar', ['actor' => $note->author]); ?>
    </a>
    <div>
        <div class="infoLine">
            <span class="authorName"><?= $note->author->displayName ?></span>
            <span class="authorHandle">@<?= $note->author->getFullHandle() ?></span>
            <a class="timestamp" href="/@/<?= $note->author->getFullHandle() ?>/note/<?= $note->id ?>">
                <?= // TODO: localise
                    $note->created->format('Y-m-d \a\t H:i')
                    . (isset($note->modified) && $note->modified != $note->created
                        ? ' (edited ' . $note->modified->format('Y-m-d \a\t H:i') . ')'
                        : ''
                    )
                    ?>
            </a>
        </div>
        <div class="content">
            <?= $note->getFormattedContent('text/html') ?? htmlspecialchars($note->plainContent) ?>
        </div>
        <div class="buttons">
            <?php foreach (['like', 'dislike', 'reshare'] as $action) {
                render_template('interaction_button', [
                    'action' => $action,
                    'note' => $note,
                    'active' => in_array(InteractionKind::from($action), $interKinds)
                ]);
            } ?>
        </div>
    </div>
</article>