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