1cd1ec0d0SGreg Roach<?php 2cd1ec0d0SGreg Roach 310e06497SGreg Roachdeclare(strict_types=1); 410e06497SGreg Roach 5cd1ec0d0SGreg Roachuse Fisharebest\Webtrees\I18N; 652288ec7SGreg 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 18cd1ec0d0SGreg Roach$items = []; 19cd1ec0d0SGreg Roach 20cd1ec0d0SGreg Roachforeach ($surnames as $surn => $surns) { 2152288ec7SGreg Roach foreach ($surns as $surname => $count) { 22*62e53f80SGreg Roach if ($surname === Individual::NOMEN_NESCIO) { 2352288ec7SGreg Roach $label = I18N::translateContext('Unknown surname', '…'); 2452288ec7SGreg Roach $url = $module instanceof ModuleListInterface ? $module->listUrl($tree, ['alpha' => '@']) : ''; 2552288ec7SGreg Roach } elseif ($surname === '') { 2652288ec7SGreg Roach $label = e($surn); 27*62e53f80SGreg Roach $url = $module instanceof ModuleListInterface ? $module->listUrl($tree, ['surname' => $surn]) : ''; 2852288ec7SGreg Roach } else { 2952288ec7SGreg Roach $label = e($surname); 3052288ec7SGreg Roach $url = $module instanceof ModuleListInterface ? $module->listUrl($tree, ['surname' => $surn]) : ''; 31cd1ec0d0SGreg Roach } 32cd1ec0d0SGreg Roach 3352288ec7SGreg Roach if ($totals) { 3452288ec7SGreg Roach $item = I18N::translate('%1$s (%2$s)', '<span class="ut">' . $label . '</span>', I18N::number($count)); 3552288ec7SGreg Roach } else { 3652288ec7SGreg Roach $item = $label; 3752288ec7SGreg Roach } 3852288ec7SGreg Roach 3952288ec7SGreg Roach if ($url !== '') { 4052288ec7SGreg Roach $items[] = '<a class="wt-surnames-compact-list-item" href="' . e($url) . '">' . $item . '</a>'; 41cd1ec0d0SGreg Roach } else { 42cd1ec0d0SGreg Roach $items[] = '<span class="wt-surnames-compact-list-item">' . $item . '</span>'; 43cd1ec0d0SGreg Roach } 44cd1ec0d0SGreg Roach } 45cd1ec0d0SGreg Roach} 46cd1ec0d0SGreg Roach?> 47cd1ec0d0SGreg Roach<span class="wt-surnames-compact-list"><?= implode(I18N::$list_separator, $items) ?></span> 48