xref: /webtrees/resources/views/lists/surnames-table.phtml (revision a609a185b4ae6c27a52180bb877790ca77672e68)
1<?php
2
3declare(strict_types=1);
4
5use Fisharebest\Webtrees\I18N;
6use Fisharebest\Webtrees\Individual;
7use Fisharebest\Webtrees\Module\IndividualListModule;
8use Fisharebest\Webtrees\Tree;
9
10/**
11 * @var bool                      $families
12 * @var IndividualListModule|null $module
13 * @var array<array<int,string>>  $order
14 * @var array<string,string>      $params
15 * @var array<array<int>>         $surnames
16 * @var Tree                      $tree
17 */
18
19?>
20
21<table
22    class="table table-bordered table-sm wt-table-surname datatables d-none"
23    <?= view('lists/datatables-attributes') ?>
24    data-info="false"
25    data-paging="false"
26    data-searching="false"
27    data-order="<?= e(json_encode($order, JSON_THROW_ON_ERROR)) ?>"
28>
29    <caption class="visually-hidden">
30        <?= I18N::translate('Surnames') ?>
31    </caption>
32    <thead>
33        <tr>
34            <th>
35                <?= I18N::translate('Surname') ?>
36            </th>
37            <th>
38                <?php if ($families) :?>
39                    <?= I18N::translate('Spouses') ?>
40                <?php else : ?>
41                    <?= I18N::translate('Individuals') ?>
42                <?php endif ?>
43            </th>
44        </tr>
45    </thead>
46
47    <tbody>
48        <?php foreach ($surnames as $surn => $surns) : ?>
49            <tr>
50                <td data-sort="<?= $n = 1 + ($n ?? 0) ?>">
51                    <!-- Multiple surname variants, e.g. von Groot, van Groot, van der Groot, etc. -->
52                    <?php foreach (array_keys($surns) as $surname) : ?>
53                        <?php if ($module instanceof IndividualListModule) : ?>
54                            <?php if ($surname === Individual::NOMEN_NESCIO) : ?>
55                                <a href="<?= e($module->listUrl($tree, ['alpha' => '@'] + $params)) ?>"><?= I18N::translateContext('Unknown surname', '…') ?></a>
56                            <?php elseif ($surname === '') : ?>
57                                <a href="<?= e($module->listUrl($tree, ['surname' => $surn] + $params)) ?>" class="ut"><?= e($surn) ?></a>
58                            <?php else : ?>
59                                <a href="<?= e($module->listUrl($tree, ['surname' => $surn] + $params)) ?>" class="ut"><?= e($surname) ?></a>
60                            <?php endif ?>
61                        <?php else : ?>
62                            <?php if ($surname === Individual::NOMEN_NESCIO) : ?>
63                                <span class="ut"><?= I18N::translateContext('Unknown surname', '…') ?></span>
64                            <?php elseif ($surname === '') : ?>
65                                <span class="ut"><?= e($surn) ?></span>
66                            <?php else : ?>
67                                <span class="ut"><?= e($surname) ?></span>
68                            <?php endif ?>
69                        <?php endif ?>
70                        <br>
71                    <?php endforeach ?>
72                </td>
73
74                <td class="text-center" data-sort="<?= array_sum($surns) ?>">
75                    <?php foreach ($surns as $count) : ?>
76                        <?= I18N::number($count) ?>
77                        <br>
78                    <?php endforeach ?>
79
80                    <?php if (count($surns) > 1) : ?>
81                        <?= I18N::number(array_sum($surns)) ?>
82                    <?php endif ?>
83                </td>
84            </tr>
85        <?php endforeach ?>
86    </tbody>
87</table>
88