aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates/reply_form.php
blob: 8a9abf54f7ebad8f45c25daecfdd8ecdcc2a1c92 (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
62
63
64
<?php
use Digitigrade\Model\NotePrivacyScope;
use Digitigrade\Model\UserAccount;

$user = UserAccount::findByCurrentSession();

$summaryText = '';
if ($note->summary) {
    if (strtolower(substr($note->summary, 0, 3)) == 're:') {
        $summaryText = $note->summary;
    } else {
        $summaryText = "re: $note->summary";
    }
}

$scopeOptions = match ($note->privacy->scope) {
    NotePrivacyScope::NONE => ['none'],
    NotePrivacyScope::MUTUALS => ['none', 'mutuals'],
    NotePrivacyScope::FOLLOWERS => ['none', 'mutuals', 'followers'],
    default => ['none', 'mutuals', 'followers', 'public']
};
$selectedScope = $note->privacy->scope->value;
?>
<form class="noteReplyForm" id="replyForm-<?= $note->id ?>"
    _="on submit send toggle to previous <button.reply/> then wait 1s then trigger update on #liveTimelineUpdater on toggle or submit toggle @hidden"
    hidden hx-post="/fragment/note/<?= $note->id ?>/reply" hx-disabled-elt="find button" hx-swap="outerHTML">
    <div class="row summaryAndContent">
        <label for="replyContent-<?= $note->id ?>"><?= __('writeReply.label') ?></label>
        <input type="text" id="replySummary-<?= $note->id ?>" name="summary" autocomplete="off"
            value="<?= $summaryText ?>" placeholder="<?= __('writeNote.summary.label') ?>">
        <textarea id="replyContent-<?= $note->id ?>" name="content" required autocomplete="off"
            placeholder="<?= __('writeReply.placeholder') ?>"></textarea>
        <span class="hint">
            <span class="inlineIcon material-symbols markdown-outline"></span>
            <?= sprintf(__('writeNote.formattingHint'),
                '<a href="https://commonmark.org/help/" target="_blank">' . __('writeNote.formattingHint.markdown') . '</a>') ?>
        </span>
    </div>
    <details>
        <summary><?= __('writeNote.moreOptions') ?></summary>
        <div class="row">
            <label class="standalone"><?= __('writeNote.mentions.label') ?></label>
            <?php foreach (array_merge($note->mentions, [$note->author]) as $m) {
                if ($m != $user?->actor) {
                    call_template('user_mention_pill', ['type' => 'user', 'actor' => $m]);
                }
            } ?>
            <?php call_template('user_mention_pill'); ?>
        </div>
        <div class="row">
            <label for="replyScope-<?= $note->id ?>"><?= __('writeNote.scope.label') ?></label>
            <select name="scope" id="replyScope-<?= $note->id ?>" required autocomplete="off">
                <?php foreach ($scopeOptions as $s): ?>
                    <option value="<?= $s ?>" <?= $selectedScope == $s ? 'selected' : '' ?>>
                        <?= __("note.privacy.scope.$s") ?>
                    </option>
                <?php endforeach; ?>
            </select>
        </div>
    </details>
    <div class="row">
        <button class="primary"><?= __('writeReply.action') ?></button>
    </div>
</form>