xref: /webtrees/resources/views/lists/surnames-column-list.phtml (revision 52288ec72a577b9a3a455ccc0f26d11b0df31667)
1cd1ec0d0SGreg Roach<?php
2cd1ec0d0SGreg Roach
310e06497SGreg Roachdeclare(strict_types=1);
410e06497SGreg Roach
5cd1ec0d0SGreg Roachuse Fisharebest\Webtrees\I18N;
6*52288ec7SGreg Roachuse Fisharebest\Webtrees\Individual;
7cd1ec0d0SGreg Roachuse Fisharebest\Webtrees\Module\IndividualListModule;
8cd1ec0d0SGreg Roachuse Fisharebest\Webtrees\Module\ModuleListInterface;
9cd1ec0d0SGreg Roachuse Fisharebest\Webtrees\Tree;
10cd1ec0d0SGreg Roach
11cd1ec0d0SGreg Roach/**
12cd1ec0d0SGreg Roach * @var IndividualListModule|null $module
13*52288ec7SGreg Roach * @var array<array<int>>         $surnames
14cd1ec0d0SGreg Roach * @var bool                      $totals
15cd1ec0d0SGreg Roach * @var Tree                      $tree
16cd1ec0d0SGreg Roach */
17cd1ec0d0SGreg Roach
18cd1ec0d0SGreg Roach$maximum = max(array_map(static fn (array $x): int => max($x), $surnames));
19cd1ec0d0SGreg Roach$minimum = min(array_map(static fn (array $x): int => min($x), $surnames));
20cd1ec0d0SGreg Roach
21cd1ec0d0SGreg Roach?>
22cd1ec0d0SGreg Roach
23cd1ec0d0SGreg Roach<div class="wt-surnames-column-list px-3" style="columns: 15rem; column-rule: solid thin gray; border: solid thin gray;">
24cd1ec0d0SGreg Roach    <?php foreach ($surnames as $surn => $surns) : ?>
25*52288ec7SGreg Roach        <?php foreach ($surns as $surname => $count) : ?>
26cd1ec0d0SGreg Roach            <?php
27cd1ec0d0SGreg Roach            $size     = 1.0 + ($maximum === $minimum ? 0 : 1.5 * ($count - $minimum) / ($maximum - $minimum));
28*52288ec7SGreg Roach
29*52288ec7SGreg Roach            if ($surn === Individual::NOMEN_NESCIO) {
30*52288ec7SGreg Roach                $label = I18N::translateContext('Unknown surname', '…');
31*52288ec7SGreg Roach                $url   = $module instanceof ModuleListInterface ? $module->listUrl($tree, ['alpha' => '@']) : '';
32*52288ec7SGreg Roach            } elseif ($surname === '') {
33*52288ec7SGreg Roach                if ($surn === '') {
34*52288ec7SGreg Roach                    $label = I18N::translate('No surname');
35*52288ec7SGreg Roach                } else {
36*52288ec7SGreg Roach                    $label = e($surn);
37*52288ec7SGreg Roach                }
38*52288ec7SGreg Roach                $url = $module instanceof ModuleListInterface ? $module->listUrl($tree, ['alpha' => ',']) : '';
39*52288ec7SGreg Roach            } else {
40*52288ec7SGreg Roach                $label = e($surname);
41*52288ec7SGreg Roach                $url   = $module instanceof ModuleListInterface ? $module->listUrl($tree, ['surname' => $surn]) : '';
42*52288ec7SGreg Roach            }
43214be48cSGreg Roach
44214be48cSGreg Roach            if ($totals) {
45*52288ec7SGreg Roach                $item = I18N::translate('%1$s (%2$s)', '<span class="ut">' . $label . '</span>', I18N::number($count));
46214be48cSGreg Roach            } else {
47*52288ec7SGreg Roach                $item = '<span class="ut">' . $label . '</span>';
48214be48cSGreg Roach            }
49cd1ec0d0SGreg Roach            ?>
50*52288ec7SGreg Roach            <div class="wt-surnames-column-list-item ut">
51*52288ec7SGreg Roach                <?php if ($url !== '') : ?>
52*52288ec7SGreg Roach                    <a href="<?= e($url) ?>"><?= $item ?></a>
53cd1ec0d0SGreg Roach                <?php else : ?>
54214be48cSGreg Roach                    <?= $item ?>
55cd1ec0d0SGreg Roach                <?php endif ?>
56cd1ec0d0SGreg Roach            </div>
57cd1ec0d0SGreg Roach        <?php endforeach ?>
58cd1ec0d0SGreg Roach    <?php endforeach ?>
59cd1ec0d0SGreg Roach</div>
60