xref: /webtrees/resources/views/modules/gedcom_news/list.phtml (revision b6017f990d38d8c56e04c0096ce9a7e8745ad4ba)
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        <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) ?>">
16            <?= view('icons/add') ?>
17            <?= I18N::translate('show more') ?>
18        </button>
19    </p>
20<div class="collapse" id="more-news-<?= e($block_id) ?>">
21    <?php endif ?>
22
23    <div class="news_box">
24        <div class="news_title" dir="auto"><?= $article->subject ?></div>
25        <div class="news_date"><?= view('components/datetime', ['timestamp' => $article->updated]) ?></div>
26        <div dir="auto"><?= $article->body ?></div>
27
28        <?php if (Auth::isManager($tree)) : ?>
29            <hr>
30            <form method="post" action="<?= e(route('module', ['module' => 'gedcom_news', 'action' => 'DeleteNews', 'news_id' => $article->news_id, 'tree' => $tree->name()])) ?>">
31                <?= csrf_field() ?>
32                <a class="btn btn-link" href="<?= e(route('module', ['module' => 'gedcom_news', 'action' => 'EditNews', 'news_id' => $article->news_id, 'tree' => $tree->name()])) ?>">
33                    <?= I18N::translate('Edit') ?>
34                </a>
35                |
36                <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);">
37                    <?= I18N::translate('Delete') ?>
38                </button>
39            </form>
40        <?php endif ?>
41    </div>
42<?php endforeach ?>
43
44    <?php if (count($articles) > 5) : ?>
45</div>
46    <?php endif ?>
47
48<?php if (Auth::isManager($tree)) : ?>
49    <p>
50        <a class="btn btn-link" href="<?= e(route('module', ['module' => 'gedcom_news', 'action' => 'EditNews', 'tree' => $tree->name()])) ?>">
51            <?= I18N::translate('Add a news article') ?>
52        </a>
53    </p>
54<?php endif ?>
55