xref: /webtrees/resources/views/lists/surnames-column-list.phtml (revision 7a3804a2a6805b66ce446ee95ffb23b54c808bd7)
1cd1ec0d0SGreg Roach<?php
2cd1ec0d0SGreg Roach
310e06497SGreg Roachdeclare(strict_types=1);
410e06497SGreg Roach
5cd1ec0d0SGreg Roachuse Fisharebest\Webtrees\I18N;
652288ec7SGreg 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*7a3804a2SGreg Roach * @var array<string,string>      $params
1452288ec7SGreg Roach * @var array<array<int>>         $surnames
15cd1ec0d0SGreg Roach * @var bool                      $totals
16cd1ec0d0SGreg Roach * @var Tree                      $tree
17cd1ec0d0SGreg Roach */
18cd1ec0d0SGreg Roach
19cd1ec0d0SGreg Roach$maximum = max(array_map(static fn (array $x): int => max($x), $surnames));
20cd1ec0d0SGreg Roach$minimum = min(array_map(static fn (array $x): int => min($x), $surnames));
21cd1ec0d0SGreg Roach
22cd1ec0d0SGreg Roach?>
23cd1ec0d0SGreg Roach
24cd1ec0d0SGreg Roach<div class="wt-surnames-column-list px-3" style="columns: 15rem; column-rule: solid thin gray; border: solid thin gray;">
25cd1ec0d0SGreg Roach    <?php foreach ($surnames as $surn => $surns) : ?>
2652288ec7SGreg Roach        <?php foreach ($surns as $surname => $count) : ?>
27cd1ec0d0SGreg Roach            <?php
28cd1ec0d0SGreg Roach            $size     = 1.0 + ($maximum === $minimum ? 0 : 1.5 * ($count - $minimum) / ($maximum - $minimum));
2952288ec7SGreg Roach
3052288ec7SGreg Roach            if ($surn === Individual::NOMEN_NESCIO) {
3152288ec7SGreg Roach                $label = I18N::translateContext('Unknown surname', '…');
32*7a3804a2SGreg Roach                $url   = $module instanceof ModuleListInterface ? $module->listUrl($tree, ['surname' => $surname] + $params) : '';
3352288ec7SGreg Roach            } elseif ($surname === '') {
3452288ec7SGreg Roach                if ($surn === '') {
3552288ec7SGreg Roach                    $label = I18N::translate('No surname');
3652288ec7SGreg Roach                } else {
3752288ec7SGreg Roach                    $label = e($surn);
3852288ec7SGreg Roach                }
39*7a3804a2SGreg Roach                $url = $module instanceof ModuleListInterface ? $module->listUrl($tree, ['surname' => $surname] + $params) : '';
4052288ec7SGreg Roach            } else {
4152288ec7SGreg Roach                $label = e($surname);
42*7a3804a2SGreg Roach                $url   = $module instanceof ModuleListInterface ? $module->listUrl($tree, ['surname' => $surname] + $params) : '';
4352288ec7SGreg Roach            }
44214be48cSGreg Roach
45214be48cSGreg Roach            if ($totals) {
4652288ec7SGreg Roach                $item = I18N::translate('%1$s (%2$s)', '<span class="ut">' . $label . '</span>', I18N::number($count));
47214be48cSGreg Roach            } else {
4852288ec7SGreg Roach                $item = '<span class="ut">' . $label . '</span>';
49214be48cSGreg Roach            }
50cd1ec0d0SGreg Roach            ?>
5152288ec7SGreg Roach            <div class="wt-surnames-column-list-item ut">
5252288ec7SGreg Roach                <?php if ($url !== '') : ?>
5352288ec7SGreg Roach                    <a href="<?= e($url) ?>"><?= $item ?></a>
54cd1ec0d0SGreg Roach                <?php else : ?>
55214be48cSGreg Roach                    <?= $item ?>
56cd1ec0d0SGreg Roach                <?php endif ?>
57cd1ec0d0SGreg Roach            </div>
58cd1ec0d0SGreg Roach        <?php endforeach ?>
59cd1ec0d0SGreg Roach    <?php endforeach ?>
60cd1ec0d0SGreg Roach</div>
61