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