xref: /webtrees/resources/views/lists/surnames-table.phtml (revision 08daf142c8732f3b3149796e49515e8fbc11d24e)
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, ['surname' => $surname] + $params)) ?>"><?= I18N::translateContext('Unknown surname', '…') ?></a>
56                            <?php elseif ($surname === '') : ?>
57                                <?php if ($surn === '') : ?>
58                                    <a href="<?= e($module->listUrl($tree, ['surname' => $surname] + $params)) ?>"><?= I18N::translate('No surname') ?></a>
59                                <?php else : ?>
60                                    <a href="<?= e($module->listUrl($tree, ['surname' => $surn] + $params)) ?>" class="ut"><?= e($surn) ?></a>
61                                <?php endif ?>
62                            <?php else : ?>
63                                <a href="<?= e($module->listUrl($tree, ['surname' => $surname] + $params)) ?>" class="ut"><?= e($surname) ?></a>
64                            <?php endif ?>
65                        <?php else : ?>
66                            <?php if ($surname === Individual::NOMEN_NESCIO) : ?>
67                                <span class="ut"><?= I18N::translateContext('Unknown surname', '…') ?></span>
68                            <?php elseif ($surname === '') : ?>
69                                <?php if ($surn === '') : ?>
70                                    <?= I18N::translate('No surname') ?>
71                                <?php else : ?>
72                                    <span class="ut"><?= e($surn) ?></span>
73                                <?php endif ?>
74                            <?php else : ?>
75                                <span class="ut"><?= e($surname) ?></span>
76                            <?php endif ?>
77                        <?php endif ?>
78                        <br>
79                    <?php endforeach ?>
80                </td>
81
82                <td class="text-center" data-sort="<?= array_sum($surns) ?>">
83                    <?php foreach ($surns as $count) : ?>
84                        <?= I18N::number($count) ?>
85                        <br>
86                    <?php endforeach ?>
87
88                    <?php if (count($surns) > 1) : ?>
89                        <?= I18N::number(array_sum($surns)) ?>
90                    <?php endif ?>
91                </td>
92            </tr>
93        <?php endforeach ?>
94    </tbody>
95</table>
96