xref: /webtrees/resources/views/lists/surnames-table.phtml (revision 62e53f80eeac6a5772f46673847f5a2a8af316b1)
153b246c5SGreg Roach<?php
253b246c5SGreg Roach
310e06497SGreg Roachdeclare(strict_types=1);
410e06497SGreg Roach
553b246c5SGreg Roachuse Fisharebest\Webtrees\I18N;
652288ec7SGreg Roachuse Fisharebest\Webtrees\Individual;
753b246c5SGreg Roachuse Fisharebest\Webtrees\Module\IndividualListModule;
8dc270d8cSGreg Roachuse Fisharebest\Webtrees\Tree;
9dc270d8cSGreg Roach
10dc270d8cSGreg Roach/**
11dc270d8cSGreg Roach * @var bool                      $families
12dc270d8cSGreg Roach * @var IndividualListModule|null $module
13c9128110SGreg Roach * @var array<array<int,string>>  $order
147a3804a2SGreg Roach * @var array<string,string>      $params
1552288ec7SGreg Roach * @var array<array<int>>         $surnames
16dc270d8cSGreg Roach * @var Tree                      $tree
17dc270d8cSGreg Roach */
1853b246c5SGreg Roach
1953b246c5SGreg Roach?>
20dd6b2bfcSGreg Roach
21b4139381SGreg Roach<table
22b4139381SGreg Roach    class="table table-bordered table-sm wt-table-surname datatables d-none"
23b4139381SGreg Roach    <?= view('lists/datatables-attributes') ?>
24b4139381SGreg Roach    data-info="false"
25b4139381SGreg Roach    data-paging="false"
26b4139381SGreg Roach    data-searching="false"
27c9128110SGreg Roach    data-order="<?= e(json_encode($order, JSON_THROW_ON_ERROR)) ?>"
28b4139381SGreg Roach>
29315eb316SGreg Roach    <caption class="visually-hidden">
30dd6b2bfcSGreg Roach        <?= I18N::translate('Surnames') ?>
31dd6b2bfcSGreg Roach    </caption>
32dd6b2bfcSGreg Roach    <thead>
33dd6b2bfcSGreg Roach        <tr>
34dd6b2bfcSGreg Roach            <th>
35dd6b2bfcSGreg Roach                <?= I18N::translate('Surname') ?>
36dd6b2bfcSGreg Roach            </th>
37dd6b2bfcSGreg Roach            <th>
3867992b6aSRichard Cissee                <?php if ($families) :?>
39dd6b2bfcSGreg Roach                    <?= I18N::translate('Spouses') ?>
40dd6b2bfcSGreg Roach                <?php else : ?>
41dd6b2bfcSGreg Roach                    <?= I18N::translate('Individuals') ?>
42dd6b2bfcSGreg Roach                <?php endif ?>
43dd6b2bfcSGreg Roach            </th>
44dd6b2bfcSGreg Roach        </tr>
45dd6b2bfcSGreg Roach    </thead>
46dd6b2bfcSGreg Roach
47dd6b2bfcSGreg Roach    <tbody>
48dd6b2bfcSGreg Roach        <?php foreach ($surnames as $surn => $surns) : ?>
49dd6b2bfcSGreg Roach            <tr>
50dff81305SGreg Roach                <td data-sort="<?= $n = 1 + ($n ?? 0) ?>">
51dd6b2bfcSGreg Roach                    <!-- Multiple surname variants, e.g. von Groot, van Groot, van der Groot, etc. -->
52c5402244SGreg Roach                    <?php foreach (array_keys($surns) as $surname) : ?>
53dc270d8cSGreg Roach                        <?php if ($module instanceof IndividualListModule) : ?>
5452288ec7SGreg Roach                            <?php if ($surname === Individual::NOMEN_NESCIO) : ?>
55*62e53f80SGreg Roach                                <a href="<?= e($module->listUrl($tree, ['alpha' => '@'] + $params)) ?>"><?= I18N::translateContext('Unknown surname', '…') ?></a>
5652288ec7SGreg Roach                            <?php elseif ($surname === '') : ?>
577a3804a2SGreg Roach                                <a href="<?= e($module->listUrl($tree, ['surname' => $surn] + $params)) ?>" class="ut"><?= e($surn) ?></a>
58dd6b2bfcSGreg Roach                            <?php else : ?>
59*62e53f80SGreg Roach                                <a href="<?= e($module->listUrl($tree, ['surname' => $surn] + $params)) ?>" class="ut"><?= e($surname) ?></a>
6067992b6aSRichard Cissee                            <?php endif ?>
6167992b6aSRichard Cissee                        <?php else : ?>
6252288ec7SGreg Roach                            <?php if ($surname === Individual::NOMEN_NESCIO) : ?>
6352288ec7SGreg Roach                                <span class="ut"><?= I18N::translateContext('Unknown surname', '…') ?></span>
6452288ec7SGreg Roach                            <?php elseif ($surname === '') : ?>
6552288ec7SGreg Roach                                <span class="ut"><?= e($surn) ?></span>
6652288ec7SGreg Roach                            <?php else : ?>
6752288ec7SGreg Roach                                <span class="ut"><?= e($surname) ?></span>
6867992b6aSRichard Cissee                            <?php endif ?>
69dd6b2bfcSGreg Roach                        <?php endif ?>
70dd6b2bfcSGreg Roach                        <br>
71dd6b2bfcSGreg Roach                    <?php endforeach ?>
72dd6b2bfcSGreg Roach                </td>
73dd6b2bfcSGreg Roach
74dd6b2bfcSGreg Roach                <td class="text-center" data-sort="<?= array_sum($surns) ?>">
7552288ec7SGreg Roach                    <?php foreach ($surns as $count) : ?>
7652288ec7SGreg Roach                        <?= I18N::number($count) ?>
77dd6b2bfcSGreg Roach                        <br>
78dd6b2bfcSGreg Roach                    <?php endforeach ?>
79dd6b2bfcSGreg Roach
80dd6b2bfcSGreg Roach                    <?php if (count($surns) > 1) : ?>
81dd6b2bfcSGreg Roach                        <?= I18N::number(array_sum($surns)) ?>
82dd6b2bfcSGreg Roach                    <?php endif ?>
83dd6b2bfcSGreg Roach                </td>
84dd6b2bfcSGreg Roach            </tr>
85dd6b2bfcSGreg Roach        <?php endforeach ?>
86dd6b2bfcSGreg Roach    </tbody>
87dd6b2bfcSGreg Roach</table>
88