xref: /webtrees/resources/views/modules/user_blog/list.phtml (revision 71239cb694d278d044f33328daaa60c8ed7431e9)
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' => 'user_blog', 'action' => 'DeleteJournal', 'news_id' => $article->news_id, 'ged' => $tree->name()])) ?>" method="post">
26                <?= csrf_field() ?>
27                <a class="btn btn-link" href="<?= e(route('module', ['module' => 'user_blog', 'action' => 'EditJournal', 'news_id' => $article->news_id, 'ged' => $tree->name()])) ?>">
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<p>
44    <a href="<?= e(route('module', ['module' => 'user_blog', 'action' => 'EditJournal', 'ged' => $tree->name()])) ?>">
45        <?= I18N::translate('Add a news article') ?>
46    </a>
47</p>
48