xref: /webtrees/resources/views/lists/surnames-table.phtml (revision 10e0649788c8d7d4974d81c048ca2b225df8f22e)
153b246c5SGreg Roach<?php
253b246c5SGreg Roach
3*10e06497SGreg Roachdeclare(strict_types=1);
4*10e06497SGreg Roach
553b246c5SGreg Roachuse Fisharebest\Webtrees\I18N;
653b246c5SGreg Roachuse Fisharebest\Webtrees\Module\IndividualListModule;
7dc270d8cSGreg Roachuse Fisharebest\Webtrees\Tree;
8dc270d8cSGreg Roach
9dc270d8cSGreg Roach/**
10dc270d8cSGreg Roach * @var bool                               $families
11dc270d8cSGreg Roach * @var IndividualListModule|null          $module
12c9128110SGreg Roach * @var array<array<int,string>>           $order
13dc270d8cSGreg Roach * @var array<string,array<string,string>> $surnames
14dc270d8cSGreg Roach * @var Tree                               $tree
15dc270d8cSGreg Roach */
1653b246c5SGreg Roach
1753b246c5SGreg Roach?>
18dd6b2bfcSGreg Roach
19b4139381SGreg Roach<table
20b4139381SGreg Roach    class="table table-bordered table-sm wt-table-surname datatables d-none"
21b4139381SGreg Roach    <?= view('lists/datatables-attributes') ?>
22b4139381SGreg Roach    data-info="false"
23b4139381SGreg Roach    data-paging="false"
24b4139381SGreg Roach    data-searching="false"
25c9128110SGreg Roach    data-order="<?= e(json_encode($order, JSON_THROW_ON_ERROR)) ?>"
26b4139381SGreg Roach>
27315eb316SGreg Roach    <caption class="visually-hidden">
28dd6b2bfcSGreg Roach        <?= I18N::translate('Surnames') ?>
29dd6b2bfcSGreg Roach    </caption>
30dd6b2bfcSGreg Roach    <thead>
31dd6b2bfcSGreg Roach        <tr>
32dd6b2bfcSGreg Roach            <th>
33dd6b2bfcSGreg Roach                <?= I18N::translate('Surname') ?>
34dd6b2bfcSGreg Roach            </th>
35dd6b2bfcSGreg Roach            <th>
3667992b6aSRichard Cissee                <?php if ($families) :?>
37dd6b2bfcSGreg Roach                    <?= I18N::translate('Spouses') ?>
38dd6b2bfcSGreg Roach                <?php else : ?>
39dd6b2bfcSGreg Roach                    <?= I18N::translate('Individuals') ?>
40dd6b2bfcSGreg Roach                <?php endif ?>
41dd6b2bfcSGreg Roach            </th>
42dd6b2bfcSGreg Roach        </tr>
43dd6b2bfcSGreg Roach    </thead>
44dd6b2bfcSGreg Roach
45dd6b2bfcSGreg Roach    <tbody>
46dd6b2bfcSGreg Roach        <?php foreach ($surnames as $surn => $surns) : ?>
47dd6b2bfcSGreg Roach            <tr>
48dd6b2bfcSGreg Roach                <td data-sort="<?= e($surn) ?>">
49dd6b2bfcSGreg Roach                    <!-- Multiple surname variants, e.g. von Groot, van Groot, van der Groot, etc. -->
50dd6b2bfcSGreg Roach                    <?php foreach ($surns as $spfxsurn => $indis) : ?>
51dc270d8cSGreg Roach                        <?php if ($module instanceof IndividualListModule) : ?>
52dd6b2bfcSGreg Roach                            <?php if ($spfxsurn) : ?>
53dd6b2bfcSGreg Roach                                <?php if ($surn !== '') : ?>
5467992b6aSRichard Cissee                                    <a href="<?= $module->listUrl($tree, ['surname' => $surn]) ?>" dir="auto">
55dd6b2bfcSGreg Roach                                        <?= e($spfxsurn) ?>
56dd6b2bfcSGreg Roach                                    </a>
57dd6b2bfcSGreg Roach                                <?php else : ?>
5867992b6aSRichard Cissee                                    <a href="<?= $module->listUrl($tree, ['alpha' => ',']) ?>" dir="auto">
59dd6b2bfcSGreg Roach                                        <?= e($spfxsurn) ?>
60dd6b2bfcSGreg Roach                                    </a>
61dd6b2bfcSGreg Roach                                <?php endif ?>
62dd6b2bfcSGreg Roach                            <?php else : ?>
63dd6b2bfcSGreg Roach                                <!-- No surname, but a value from "2 SURN"? A common workaround for toponyms, etc. -->
64214be48cSGreg Roach                                <a href="<?= $module->listUrl($tree, ['surname' => $surn]) ?>" dir="auto"><?= I18N::translate('No surname') ?></a>
6567992b6aSRichard Cissee                            <?php endif ?>
6667992b6aSRichard Cissee                        <?php else : ?>
6767992b6aSRichard Cissee                            <?php if ($spfxsurn) : ?>
68315eb316SGreg Roach                                <bdi><?= e($spfxsurn) ?></bdi>
6967992b6aSRichard Cissee                            <?php else : ?>
7067992b6aSRichard Cissee                                <!-- No surname, but a value from "2 SURN"? A common workaround for toponyms, etc. -->
71315eb316SGreg Roach                                <bdi><?= e($surn) ?></bdi>
7267992b6aSRichard Cissee                            <?php endif ?>
73dd6b2bfcSGreg Roach                        <?php endif ?>
74dd6b2bfcSGreg Roach                        <br>
75dd6b2bfcSGreg Roach                    <?php endforeach ?>
76dd6b2bfcSGreg Roach                </td>
77dd6b2bfcSGreg Roach
78dd6b2bfcSGreg Roach                <td class="text-center" data-sort="<?= array_sum($surns) ?>">
79dd6b2bfcSGreg Roach                    <?php foreach ($surns as $indis) : ?>
80dd6b2bfcSGreg Roach                        <?= I18N::number($indis) ?>
81dd6b2bfcSGreg Roach                        <br>
82dd6b2bfcSGreg Roach                    <?php endforeach ?>
83dd6b2bfcSGreg Roach
84dd6b2bfcSGreg Roach                    <?php if (count($surns) > 1) : ?>
85dd6b2bfcSGreg Roach                        <?= I18N::number(array_sum($surns)) ?>
86dd6b2bfcSGreg Roach                    <?php endif ?>
87dd6b2bfcSGreg Roach                </td>
88dd6b2bfcSGreg Roach            </tr>
89dd6b2bfcSGreg Roach        <?php endforeach ?>
90dd6b2bfcSGreg Roach    </tbody>
91dd6b2bfcSGreg Roach</table>
92