summaryrefslogtreecommitdiff
path: root/resources/views/lists/surnames-column-list.phtml
blob: edbeef98b5d4a2bb4f07a041e8db4a269e1bf41f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php

use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Module\IndividualListModule;
use Fisharebest\Webtrees\Module\ModuleListInterface;
use Fisharebest\Webtrees\Tree;

/**
 * @var IndividualListModule|null          $module
 * @var array<string,array<string,string>> $surnames
 * @var bool                               $totals
 * @var Tree                               $tree
 */

$maximum = max(array_map(static fn (array $x): int => max($x), $surnames));
$minimum = min(array_map(static fn (array $x): int => min($x), $surnames));

?>

<div class="wt-surnames-column-list px-3" style="columns: 15rem; column-rule: solid thin gray; border: solid thin gray;">
    <?php foreach ($surnames as $surn => $surns) : ?>
        <?php foreach ($surns as $spfxsurn => $count) : ?>
            <?php
                $size = 1.0 + ($maximum === $minimum ? 0 : 1.5 * ($count - $minimum) / ($maximum - $minimum));
                $tag_item = $totals ? I18N::translate('%1$s (%2$s)', '<bdi>' . e($spfxsurn) . '</bdi>', I18N::number($count)) : e($spfxsurn);
            ?>
            <div class="wt-surnames-column-list-item">
                <?php if ($module instanceof ModuleListInterface) : ?>
                    <a href="<?= e($module->listUrl($tree, ['surname' => $surn])) ?>">
                        <?= $tag_item ?>
                    </a>
                <?php else : ?>
                    <?= $tag_item ?>
                <?php endif ?>
            </div>
        <?php endforeach ?>
    <?php endforeach ?>
</div>