xref: /webtrees/resources/views/lists/surnames-compact-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$items = [];
16
17foreach ($surnames as $surn => $surns) {
18    foreach ($surns as $spfxsurn => $count) {
19        $label = $spfxsurn ? e($spfxsurn) : I18N::translate('No surname');
20
21        if ($totals) {
22            $item = I18N::translate('%1$s (%2$s)', '<bdi>' . $label . '</bdi>', I18N::number($count));
23        } else {
24            $item = '<bdi>' . $label . '</bdi>';
25        }
26
27        if ($module instanceof ModuleListInterface) {
28            $items[] = '<a class="wt-surnames-compact-list-item" href="' . e($module->listUrl($tree, ['surname' => $surn])) . '">' . $item . '</a>';
29        } else {
30            $items[] = '<span class="wt-surnames-compact-list-item">' . $item . '</span>';
31        }
32    }
33}
34?>
35<span class="wt-surnames-compact-list"><?= implode(I18N::$list_separator, $items) ?></span>
36