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