xref: /webtrees/resources/views/lists/surnames-bullet-list.phtml (revision 62e53f80eeac6a5772f46673847f5a2a8af316b1)
1cd1ec0d0SGreg Roach<?php
2cd1ec0d0SGreg Roach
310e06497SGreg Roachdeclare(strict_types=1);
410e06497SGreg Roach
5cd1ec0d0SGreg Roachuse Fisharebest\Webtrees\I18N;
6*62e53f80SGreg Roachuse Fisharebest\Webtrees\Individual;
7cd1ec0d0SGreg Roachuse Fisharebest\Webtrees\Module\IndividualListModule;
8cd1ec0d0SGreg Roachuse Fisharebest\Webtrees\Module\ModuleListInterface;
9cd1ec0d0SGreg Roachuse Fisharebest\Webtrees\Tree;
10cd1ec0d0SGreg Roach
11cd1ec0d0SGreg Roach/**
12cd1ec0d0SGreg Roach * @var IndividualListModule|null $module
1352288ec7SGreg Roach * @var array<array<int>>         $surnames
14cd1ec0d0SGreg Roach * @var bool                      $totals
15cd1ec0d0SGreg Roach * @var Tree                      $tree
16cd1ec0d0SGreg Roach */
17cd1ec0d0SGreg Roach
18*62e53f80SGreg Roach$items = [];
19cd1ec0d0SGreg Roach
20*62e53f80SGreg Roachforeach ($surnames as $surn => $surns) {
21*62e53f80SGreg Roach    foreach ($surns as $surname => $count) {
22*62e53f80SGreg Roach        if ($surname === Individual::NOMEN_NESCIO) {
23*62e53f80SGreg Roach            $label = I18N::translateContext('Unknown surname', '…');
24*62e53f80SGreg Roach            $url   = $module instanceof ModuleListInterface ? $module->listUrl($tree, ['alpha' => '@']) : '';
25*62e53f80SGreg Roach        } elseif ($surname === '') {
26*62e53f80SGreg Roach            $label = e($surn);
27*62e53f80SGreg Roach            $url   = $module instanceof ModuleListInterface ? $module->listUrl($tree, ['surname' => $surn]) : '';
28*62e53f80SGreg Roach        } else {
29*62e53f80SGreg Roach            $label = e($surname);
30*62e53f80SGreg Roach            $url   = $module instanceof ModuleListInterface ? $module->listUrl($tree, ['surname' => $surn]) : '';
31*62e53f80SGreg Roach        }
32*62e53f80SGreg Roach
33*62e53f80SGreg Roach        if ($totals) {
34*62e53f80SGreg Roach            $item = I18N::translate('%1$s (%2$s)', '<span class="ut">' . $label . '</span>', I18N::number($count));
35*62e53f80SGreg Roach        } else {
36*62e53f80SGreg Roach            $item = $label;
37*62e53f80SGreg Roach        }
38*62e53f80SGreg Roach
39*62e53f80SGreg Roach        if ($url !== '') {
40*62e53f80SGreg Roach            $items[] = '<li class="wt-surnames-bullet-list-item"><a href="' . e($url) . '">' . $item . '</a></li>';
41*62e53f80SGreg Roach        } else {
42*62e53f80SGreg Roach            $items[] = '<li class="wt-surnames-bullet-list-item">' . $item . '</li>';
43*62e53f80SGreg Roach        }
44*62e53f80SGreg Roach    }
45*62e53f80SGreg Roach}
46*62e53f80SGreg Roach?>
47*62e53f80SGreg Roach<ul class="wt-surnames-bullet-list"><?= implode('', $items) ?></ul>
48*62e53f80SGreg Roach
49