aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates/reply_form.php
blob: 1b9961ed34cd35808d553efd6377a00c7dc14d00 (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
<?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">
        <label for="replyContent-<?= $note->id ?>"><?= __('writeReply.label') ?></label>
        <textarea id="replyContent-<?= $note->id ?>" name="content" required autocomplete="off"></textarea>
    </div>
    <div class="row">
        <label for="replySummary-<?= $note->id ?>"><?= __('writeNote.summary.label') ?></label>
        <input type="text" id="replySummary-<?= $note->id ?>" name="summary" autocomplete="off"
            value="<?= $summaryText ?>">
    </div>
    <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>
    <div class="row">
        <button class="primary"><?= __('writeReply.action') ?></button>
    </div>
</form>