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