xref: /webtrees/resources/views/modules/gedcom_news/list.phtml (revision 84586c024c68dbfa3b15df636ed2b74037428442)
1<?php use Fisharebest\Webtrees\Auth; ?>
2<?php use Fisharebest\Webtrees\Functions\FunctionsDate; ?>
3<?php use Fisharebest\Webtrees\I18N; ?>
4
5<?php if (empty($articles)) : ?>
6    <?= I18N::translate('No news articles have been submitted.') ?>
7<?php endif ?>
8
9<?php foreach ($articles as $n => $article) : ?>
10    <?php if ($n === 5 && count($articles) > 5) : ?>
11        <p>
12            <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') ?>
13            </a>
14        </p>
15        <div class="collapse" id="more-news-<?= e($block_id) ?>">
16    <?php endif ?>
17
18    <div class="news_box">
19        <div class="news_title"><?= e($article->subject) ?></div>
20        <div class="news_date"><?= FunctionsDate::formatTimestamp($article->updated) ?></div>
21        <div style="white-space: pre-wrap"><?= e($article->body) ?></div>
22
23        <?php if (Auth::isManager($tree)) : ?>
24            <hr>
25            <form action="<?= e(route('module', ['module' => 'gedcom_news', 'action' => 'DeleteNews', 'news_id' => $article->news_id, 'ged' => $tree->getName()])) ?>" method="post">
26                <?= csrf_field() ?>
27                <a class="btn btn-link" href="<?= e(route('module', ['module' => 'gedcom_news', 'action' => 'EditNews', 'news_id' => $article->news_id, 'ged' => $tree->getName()])) ?>">
28                    <?= I18N::translate('Edit') ?>
29                </a>
30                |
31                <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);">
32                    <?= I18N::translate('Delete') ?>
33                </button>
34            </form>
35        <?php endif ?>
36    </div>
37<?php endforeach ?>
38
39<?php if (count($articles) > 5) : ?>
40    </div>
41<?php endif ?>
42
43<?php if (Auth::isManager($tree)) : ?>
44    <p>
45        <a href="<?= e(route('module', ['module' => 'gedcom_news', 'action' => 'EditNews', 'ged' => $tree->getName()])) ?>">
46            <?= I18N::translate('Add a news article') ?>
47        </a>
48    </p>
49<?php endif ?>
50