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