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