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