xref: /webtrees/resources/views/modules/user_blog/list.phtml (revision dda05045b4c2f9063e99083d2dbff48269db4ac2)
1<?php
2
3use Fisharebest\Webtrees\Auth;
4use Fisharebest\Webtrees\I18N;
5use Fisharebest\Webtrees\Tree;
6use Illuminate\Support\Collection;
7
8/**
9 * @var Collection<int,object> $articles
10 * @var int                    $block_id
11 * @var int                    $limit
12 * @var Tree                   $tree
13 */
14
15?>
16
17<?php if ($articles->isEmpty()) : ?>
18    <?= I18N::translate('No news articles have been submitted.') ?>
19<?php endif ?>
20
21<?php foreach ($articles as $n => $article) : ?>
22    <?php if ($n === $limit && count($articles) > $limit) : ?>
23        <p>
24            <button class="btn btn-sm btn-secondary" data-bs-toggle="collapse" data-bs-target="#more-news-<?= e($block_id) ?>" role="button" aria-expanded="false" aria-controls="more-news-<?= e($block_id) ?>">
25                <?= view('icons/add') ?>
26                <?= I18N::translate('show more') ?>
27            </button>
28        </p>
29        <div class="collapse" id="more-news-<?= e($block_id) ?>">
30    <?php endif ?>
31
32    <div class="news_box">
33        <div class="news_title" dir="auto"><?= $article->subject ?></div>
34        <div class="news_date"><?= view('components/datetime', ['timestamp' => $article->updated]) ?></div>
35        <div dir="auto"><?= $article->body ?></div>
36
37        <?php if (Auth::isManager($tree)) : ?>
38            <hr>
39            <form method="post" action="<?= e(route('module', ['module' => 'user_blog', 'action' => 'DeleteJournal', 'news_id' => $article->news_id, 'tree' => $tree->name()])) ?>">
40                <a class="btn btn-link" href="<?= e(route('module', ['module' => 'user_blog', 'action' => 'EditJournal', 'news_id' => $article->news_id, 'tree' => $tree->name()])) ?>">
41                    <?= I18N::translate('Edit') ?>
42                </a>
43                |
44                <button class="btn btn-link" type="submit" data-wt-confirm="<?= I18N::translate('Are you sure you want to delete “%s”?', e($article->subject)) ?>" onclick="return confirm(this.dataset.confirm);">
45                    <?= I18N::translate('Delete') ?>
46                </button>
47
48                <?= csrf_field() ?>
49            </form>
50        <?php endif ?>
51    </div>
52<?php endforeach ?>
53
54<?php if (count($articles) > $limit) : ?>
55    </div>
56<?php endif ?>
57
58<p>
59    <a class="btn btn-link" href="<?= e(route('module', ['module' => 'user_blog', 'action' => 'EditJournal', 'tree' => $tree->name()])) ?>">
60        <?= I18N::translate('Add a journal entry') ?>
61    </a>
62</p>
63