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