xref: /webtrees/resources/views/modules/gedcom_news/list.phtml (revision 9320815f1ce8e5a76b792d0fc59d7ba088fe3793)
1<?php
2
3use Fisharebest\Webtrees\Auth;
4use Fisharebest\Webtrees\I18N;
5use Fisharebest\Webtrees\Tree;
6use Illuminate\Support\Collection;
7
8/**
9 * @var Collection<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-toggle="collapse" data-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' => 'gedcom_news', 'action' => 'DeleteNews', 'news_id' => $article->news_id, 'tree' => $tree->name()])) ?>">
40                <?= csrf_field() ?>
41                <a class="btn btn-link" href="<?= e(route('module', ['module' => 'gedcom_news', 'action' => 'EditNews', 'news_id' => $article->news_id, 'tree' => $tree->name()])) ?>">
42                    <?= I18N::translate('Edit') ?>
43                </a>
44                |
45                <button class="btn btn-link" type="submit" data-confirm="<?= I18N::translate('Are you sure you want to delete “%s”?', e($article->subject)) ?>" onclick="return confirm(this.dataset.confirm);">
46                    <?= I18N::translate('Delete') ?>
47                </button>
48            </form>
49        <?php endif ?>
50    </div>
51<?php endforeach ?>
52
53    <?php if (count($articles) > $limit) : ?>
54</div>
55    <?php endif ?>
56
57<?php if (Auth::isManager($tree)) : ?>
58    <p>
59        <a class="btn btn-link" href="<?= e(route('module', ['module' => 'gedcom_news', 'action' => 'EditNews', 'tree' => $tree->name()])) ?>">
60            <?= I18N::translate('Add a news article') ?>
61        </a>
62    </p>
63<?php endif ?>
64