xref: /webtrees/resources/views/lists/surnames-column-list.phtml (revision 214be48c32e57df34e154cd8ec7bc3bf7fa4615a)
1cd1ec0d0SGreg Roach<?php
2cd1ec0d0SGreg Roach
3cd1ec0d0SGreg Roachuse Fisharebest\Webtrees\I18N;
4cd1ec0d0SGreg Roachuse Fisharebest\Webtrees\Module\IndividualListModule;
5cd1ec0d0SGreg Roachuse Fisharebest\Webtrees\Module\ModuleListInterface;
6cd1ec0d0SGreg Roachuse Fisharebest\Webtrees\Tree;
7cd1ec0d0SGreg Roach
8cd1ec0d0SGreg Roach/**
9cd1ec0d0SGreg Roach * @var IndividualListModule|null          $module
10cd1ec0d0SGreg Roach * @var array<string,array<string,string>> $surnames
11cd1ec0d0SGreg Roach * @var bool                               $totals
12cd1ec0d0SGreg Roach * @var Tree                               $tree
13cd1ec0d0SGreg Roach */
14cd1ec0d0SGreg Roach
15cd1ec0d0SGreg Roach$maximum = max(array_map(static fn (array $x): int => max($x), $surnames));
16cd1ec0d0SGreg Roach$minimum = min(array_map(static fn (array $x): int => min($x), $surnames));
17cd1ec0d0SGreg Roach
18cd1ec0d0SGreg Roach?>
19cd1ec0d0SGreg Roach
20cd1ec0d0SGreg Roach<div class="wt-surnames-column-list px-3" style="columns: 15rem; column-rule: solid thin gray; border: solid thin gray;">
21cd1ec0d0SGreg Roach    <?php foreach ($surnames as $surn => $surns) : ?>
22cd1ec0d0SGreg Roach        <?php foreach ($surns as $spfxsurn => $count) : ?>
23cd1ec0d0SGreg Roach            <?php
24cd1ec0d0SGreg Roach                $size     = 1.0 + ($maximum === $minimum ? 0 : 1.5 * ($count - $minimum) / ($maximum - $minimum));
25*214be48cSGreg Roach                $label    = $spfxsurn ? e($spfxsurn) : I18N::translate('No surname');
26*214be48cSGreg Roach
27*214be48cSGreg Roach                if ($totals) {
28*214be48cSGreg Roach                    $item = I18N::translate('%1$s (%2$s)', '<bdi>' . $label . '</bdi>', I18N::number($count));
29*214be48cSGreg Roach                } else {
30*214be48cSGreg Roach                    $item = '<bdi>' . $label . '</bdi>';
31*214be48cSGreg Roach                }
32cd1ec0d0SGreg Roach            ?>
33cd1ec0d0SGreg Roach            <div class="wt-surnames-column-list-item">
34cd1ec0d0SGreg Roach                <?php if ($module instanceof ModuleListInterface) : ?>
35cd1ec0d0SGreg Roach                    <a href="<?= e($module->listUrl($tree, ['surname' => $surn])) ?>">
36*214be48cSGreg Roach                        <?= $item ?>
37cd1ec0d0SGreg Roach                    </a>
38cd1ec0d0SGreg Roach                <?php else : ?>
39*214be48cSGreg Roach                    <?= $item ?>
40cd1ec0d0SGreg Roach                <?php endif ?>
41cd1ec0d0SGreg Roach            </div>
42cd1ec0d0SGreg Roach        <?php endforeach ?>
43cd1ec0d0SGreg Roach    <?php endforeach ?>
44cd1ec0d0SGreg Roach</div>
45