xref: /webtrees/resources/views/modules/gedcom_news/list.phtml (revision 600daa5d4fa729dbec2d21fb3adffed0ae6efda9)
1<?php
2
3use Fisharebest\Webtrees\Auth;
4use Fisharebest\Webtrees\I18N;
5
6?>
7
8<?php if ($articles->isEmpty()) : ?>
9    <?= I18N::translate('No news articles have been submitted.') ?>
10<?php endif ?>
11
12<?php foreach ($articles as $n => $article) : ?>
13    <?php if ($n === 5 && count($articles) > 5) : ?>
14    <p>
15        <a class="btn btn-link" data-toggle="collapse" data-target="#more-news-<?= e($block_id) ?>" role="button" aria-expanded="false" aria-controls="more-news-<?= e($block_id) ?>"><?= I18N::translate('More news articles') ?>
16        </a>
17    </p>
18<div class="collapse" id="more-news-<?= e($block_id) ?>">
19    <?php endif ?>
20
21    <div class="news_box">
22        <div class="news_title" dir="auto"><?= $article->subject ?></div>
23        <div class="news_date"><?= view('components/datetime', ['timestamp' => $article->updated]) ?></div>
24        <div dir="auto"><?= $article->body ?></div>
25
26        <?php if (Auth::isManager($tree)) : ?>
27            <hr>
28            <form method="post" action="<?= e(route('module', ['module' => 'gedcom_news', 'action' => 'DeleteNews', 'news_id' => $article->news_id, 'tree' => $tree->name()])) ?>">
29                <?= csrf_field() ?>
30                <a class="btn btn-link" href="<?= e(route('module', ['module' => 'gedcom_news', 'action' => 'EditNews', 'news_id' => $article->news_id, 'tree' => $tree->name()])) ?>">
31                    <?= I18N::translate('Edit') ?>
32                </a>
33                |
34                <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);">
35                    <?= I18N::translate('Delete') ?>
36                </button>
37            </form>
38        <?php endif ?>
39    </div>
40<?php endforeach ?>
41
42    <?php if (count($articles) > 5) : ?>
43</div>
44    <?php endif ?>
45
46<?php if (Auth::isManager($tree)) : ?>
47    <p>
48        <a class="btn btn-link" href="<?= e(route('module', ['module' => 'gedcom_news', 'action' => 'EditNews', 'tree' => $tree->name()])) ?>">
49            <?= I18N::translate('Add a news article') ?>
50        </a>
51    </p>
52<?php endif ?>
53