xref: /webtrees/resources/views/lists/anniversaries-list.phtml (revision 5bfc689774bb9a6401271c4ed15a6d50652c991b)
1<?php
2
3use Fisharebest\Webtrees\Fact;
4use Fisharebest\Webtrees\I18N;
5use Fisharebest\Webtrees\Individual;
6use Fisharebest\Webtrees\Registry;
7use Fisharebest\Webtrees\View;
8use Illuminate\Support\Collection;
9
10/**
11 * @var Collection<int,Fact> $facts
12 * @var int                  $id
13 * @var int                  $limit_low
14 * @var int                  $limit_high
15 */
16
17?>
18
19<?php foreach ($facts as $n => $fact) : ?>
20    <?php if ($n === $limit_low && $facts->count() > $limit_high) : ?>
21        <div>
22            <button class="btn btn-sm btn-secondary" id="show-more-<?= e($id) ?>">
23                <?= view('icons/add') ?>
24                <?= /* I18N: button label */ I18N::translate('show more') ?>
25            </button>
26        </div>
27
28        <?php View::push('javascript') ?>
29        <script>
30            document.getElementById("show-more-<?= e($id) ?>").addEventListener("click", function (ev) {
31                document.querySelectorAll("#block-<?= e($id) ?> .d-none").forEach(function (el) {
32                    el.classList.remove("d-none");
33                });
34                ev.target.parentNode.removeChild(ev.target);
35            });
36        </script>
37        <?php View::endpush() ?>
38    <?php endif ?>
39
40    <div class="<?= $n >= $limit_low && $facts->count() > $limit_high ? 'd-none' : '' ?>">
41        <?php $record = $fact->record(); ?>
42        <a href="<?= e($record->url()) ?>" class="list_item">
43            <?= $record->fullName() ?>
44        </a>
45        <?php if ($record instanceof Individual) : ?>
46            <?= view('icons/sex', ['sex' => $record->sex()]) ?>
47        <?php endif ?>
48        <div class="indent">
49            <?= $fact->label() . ' — ' . $fact->date()->display($record->tree(), null, true) ?>
50            (<?= Registry::timestampFactory()->now()->subtractYears($fact->anniv)->diffForHumans() ?>)
51            <?php if ($fact->place()->gedcomName() !== '') : ?>
52                — <a href="<?= e($fact->place()->url()) ?>" title="<?= strip_tags($fact->place()->fullName()) ?>">
53                    <?= $fact->place()->shortName() ?>
54                </a>
55            <?php endif ?>
56        </div>
57    </div>
58<?php endforeach ?>
59