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