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