xref: /webtrees/resources/views/lists/surnames-compact-list.phtml (revision 7c7db574d0bdf9952c8ec99186bddc01aa06fd48)
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[] = '<a class="wt-surnames-compact-list-item" href="' . e($url) . '">' . $item . '</a>';
41        } else {
42            $items[] = '<span class="wt-surnames-compact-list-item">' . $item . '</span>';
43        }
44    }
45}
46?>
47<span class="wt-surnames-compact-list"><?= implode(I18N::$list_separator, $items) ?></span>
48