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