xref: /webtrees/resources/views/modules/user_blog/list.phtml (revision 3d2c98d1066d5e178a3d1ceb3bdc58b7ba8ee926)
1<?php
2
3use Fisharebest\Webtrees\Auth;
4use Fisharebest\Webtrees\I18N;
5use Fisharebest\Webtrees\Tree;
6use Illuminate\Support\Collection;
7
8/**
9 * @var Collection<stdClass> $articles
10 * @var int                  $block_id
11 * @var int                  $limit
12 * @var Tree                 $tree
13 */
14
15?>
16
17<?php if ($articles->isEmpty()) : ?>
18    <?= I18N::translate('No news articles have been submitted.') ?>
19<?php endif ?>
20
21<?php foreach ($articles as $n => $article) : ?>
22    <?php if ($n === $limit && count($articles) > $limit) : ?>
23        <p>
24            <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) ?>">
25                <?= view('icons/add') ?>
26                <?= I18N::translate('show more') ?>
27            </button>
28        </p>
29        <div class="collapse" id="more-news-<?= e($block_id) ?>">
30    <?php endif ?>
31
32    <div class="news_box">
33        <div class="news_title" dir="auto"><?= $article->subject ?></div>
34        <div class="news_date"><?= view('components/datetime', ['timestamp' => $article->updated]) ?></div>
35        <div dir="auto"><?= $article->body ?></div>
36
37        <?php if (Auth::isManager($tree)) : ?>
38            <hr>
39            <form method="post" action="<?= e(route('module', ['module' => 'user_blog', 'action' => 'DeleteJournal', 'news_id' => $article->news_id, 'tree' => $tree->name()])) ?>">
40                <?= csrf_field() ?>
41                <a class="btn btn-link" href="<?= e(route('module', ['module' => 'user_blog', 'action' => 'EditJournal', 'news_id' => $article->news_id, 'tree' => $tree->name()])) ?>">
42                    <?= I18N::translate('Edit') ?>
43                </a>
44                |
45                <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);">
46                    <?= I18N::translate('Delete') ?>
47                </button>
48            </form>
49        <?php endif ?>
50    </div>
51<?php endforeach ?>
52
53<?php if (count($articles) > $limit) : ?>
54    </div>
55<?php endif ?>
56
57<p>
58    <a class="btn btn-link" href="<?= e(route('module', ['module' => 'user_blog', 'action' => 'EditJournal', 'tree' => $tree->name()])) ?>">
59        <?= I18N::translate('Add a journal entry') ?>
60    </a>
61</p>
62