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