xref: /webtrees/resources/views/lists/anniversaries-list.phtml (revision 812fae19cf71ff226c876649b30cc1f87b498706)
148f08416SGreg Roach<?php
248f08416SGreg Roach
310e06497SGreg Roachdeclare(strict_types=1);
410e06497SGreg Roach
548f08416SGreg Roachuse Fisharebest\Webtrees\Fact;
6e24053e5SGreg Roachuse Fisharebest\Webtrees\I18N;
748f08416SGreg Roachuse Fisharebest\Webtrees\Individual;
8d97083feSGreg Roachuse Fisharebest\Webtrees\Registry;
9e24053e5SGreg Roachuse Fisharebest\Webtrees\View;
10cd51dbdfSGreg Roachuse Illuminate\Support\Collection;
1148f08416SGreg Roach
12cd51dbdfSGreg Roach/**
1336779af1SGreg Roach * @var Collection<int,Fact> $facts
147c2c99faSGreg Roach * @var int                  $id
1501221f27SGreg Roach * @var int                  $limit_low
1601221f27SGreg Roach * @var int                  $limit_high
17cd51dbdfSGreg Roach */
1848f08416SGreg Roach
1948f08416SGreg Roach?>
2048f08416SGreg Roach
21e24053e5SGreg Roach<?php foreach ($facts as $n => $fact) : ?>
2201221f27SGreg Roach    <?php if ($n === $limit_low && $facts->count() > $limit_high) : ?>
23e24053e5SGreg Roach        <div>
24e24053e5SGreg Roach            <button class="btn btn-sm btn-secondary" id="show-more-<?= e($id) ?>">
25e24053e5SGreg Roach                <?= view('icons/add') ?>
26e24053e5SGreg Roach                <?= /* I18N: button label */ I18N::translate('show more') ?>
27e24053e5SGreg Roach            </button>
28e24053e5SGreg Roach        </div>
29cb867caaSGreg Roach
30cb867caaSGreg Roach        <?php View::push('javascript') ?>
31cb867caaSGreg Roach        <script>
32cb867caaSGreg Roach            document.getElementById("show-more-<?= e($id) ?>").addEventListener("click", function (ev) {
33cb867caaSGreg Roach                document.querySelectorAll("#block-<?= e($id) ?> .d-none").forEach(function (el) {
34cb867caaSGreg Roach                    el.classList.remove("d-none");
35cb867caaSGreg Roach                });
36cb867caaSGreg Roach                ev.target.parentNode.removeChild(ev.target);
37cb867caaSGreg Roach            });
38cb867caaSGreg Roach        </script>
39b4c5c807SGreg Roach        <?php View::endpush() ?>
40e24053e5SGreg Roach    <?php endif ?>
41e24053e5SGreg Roach
4201221f27SGreg Roach    <div class="<?= $n >= $limit_low && $facts->count() > $limit_high ? 'd-none' : '' ?>">
4348f08416SGreg Roach        <?php $record = $fact->record(); ?>
447a821518SGreg Roach        <a href="<?= e($record->url()) ?>" class="list_item">
4548f08416SGreg Roach            <?= $record->fullName() ?>
4648f08416SGreg Roach        </a>
4748f08416SGreg Roach        <?php if ($record instanceof Individual) : ?>
4808362db4SGreg Roach            <?= view('icons/sex', ['sex' => $record->sex()]) ?>
4948f08416SGreg Roach        <?php endif ?>
5048f08416SGreg Roach        <div class="indent">
5166ecd017SGreg Roach            <?= $fact->label() . ' — ' . $fact->date()->display($record->tree(), null, true) ?>
52*812fae19SGreg Roach            <?php if (PHP_INT_SIZE >= 8 || $fact->date()->gregorianYear() > 1901) : ?>
53d97083feSGreg Roach                (<?= Registry::timestampFactory()->now()->subtractYears($fact->anniv)->diffForHumans() ?>)
54*812fae19SGreg Roach            <?php else : ?>
55*812fae19SGreg Roach                (<?= I18N::plural('%s year', '%s years', $fact->anniv, I18N::number($fact->anniv)) ?>)
568eeae412SGreg Roach            <?php endif ?>
5748f08416SGreg Roach            <?php if ($fact->place()->gedcomName() !== '') : ?>
5848f08416SGreg Roach                — <a href="<?= e($fact->place()->url()) ?>" title="<?= strip_tags($fact->place()->fullName()) ?>">
5948f08416SGreg Roach                    <?= $fact->place()->shortName() ?>
6048f08416SGreg Roach                </a>
6148f08416SGreg Roach            <?php endif ?>
6248f08416SGreg Roach        </div>
63e24053e5SGreg Roach    </div>
6448f08416SGreg Roach<?php endforeach ?>
65