xref: /webtrees/resources/views/lists/surnames-table.phtml (revision 9ed80f829cfb208ae92f7928345696619569bf4e)
1<?php
2
3use Fisharebest\Webtrees\I18N;
4use Fisharebest\Webtrees\Module\FamilyListModule;
5use Fisharebest\Webtrees\Module\IndividualListModule;
6
7?>
8
9<table class="table table-bordered table-sm datatables wt-table-surname" data-info="false" data-paging="false" data-searching="false" data-state-save="true" data-order="<?= e(json_encode($order ?? [[1, 'desc']])) ?>">
10    <caption class="sr-only">
11        <?= I18N::translate('Surnames') ?>
12    </caption>
13    <thead>
14        <tr>
15            <th>
16                <?= I18N::translate('Surname') ?>
17            </th>
18            <th>
19                <?php if ($families) :?>
20                    <?= I18N::translate('Spouses') ?>
21                <?php else : ?>
22                    <?= I18N::translate('Individuals') ?>
23                <?php endif ?>
24            </th>
25        </tr>
26    </thead>
27
28    <tbody>
29        <?php foreach ($surnames as $surn => $surns) : ?>
30            <tr>
31                <td data-sort="<?= e($surn) ?>">
32                    <!-- Multiple surname variants, e.g. von Groot, van Groot, van der Groot, etc. -->
33                    <?php foreach ($surns as $spfxsurn => $indis) : ?>
34                        <?php if ($module instanceof IndividualListModule || $module instanceof FamilyListModule) : ?>
35                            <?php if ($spfxsurn) : ?>
36                                <?php if ($surn !== '') : ?>
37                                    <a href="<?= $module->listUrl($tree, ['surname' => $surn]) ?>" dir="auto">
38                                        <?= e($spfxsurn) ?>
39                                    </a>
40                                <?php else : ?>
41                                    <a href="<?= $module->listUrl($tree, ['alpha' => ',']) ?>" dir="auto">
42                                        <?= e($spfxsurn) ?>
43                                    </a>
44                                <?php endif ?>
45                            <?php else : ?>
46                                <!-- No surname, but a value from "2 SURN"? A common workaround for toponyms, etc. -->
47                                <a href="<?= $module->listUrl($tree, ['surname' => $surn]) ?>" dir="auto"><?= e($surn) ?></a>
48                            <?php endif ?>
49                        <?php else : ?>
50                            <?php if ($spfxsurn) : ?>
51                                <span dir="auto"><?= e($spfxsurn) ?></span>
52                            <?php else : ?>
53                                <!-- No surname, but a value from "2 SURN"? A common workaround for toponyms, etc. -->
54                                <span dir="auto"><?= e($surn) ?></span>
55                            <?php endif ?>
56                        <?php endif ?>
57                        <br>
58                    <?php endforeach ?>
59                </td>
60
61                <td class="text-center" data-sort="<?= array_sum($surns) ?>">
62                    <?php foreach ($surns as $indis) : ?>
63                        <?= I18N::number($indis) ?>
64                        <br>
65                    <?php endforeach ?>
66
67                    <?php if (count($surns) > 1) : ?>
68                        <?= I18N::number(array_sum($surns)) ?>
69                    <?php endif ?>
70                </td>
71            </tr>
72        <?php endforeach ?>
73    </tbody>
74</table>
75