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