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