xref: /webtrees/resources/views/modules/recent_changes/changes-table.phtml (revision 18fd0859d876caec952296f28638ed0844e10712)
1<?php
2
3declare(strict_types=1);
4
5use Fisharebest\Webtrees\Family;
6use Fisharebest\Webtrees\I18N;
7use Fisharebest\Webtrees\Individual;
8use Fisharebest\Webtrees\Location;
9use Fisharebest\Webtrees\Media;
10use Fisharebest\Webtrees\Note;
11use Fisharebest\Webtrees\Repository;
12use Fisharebest\Webtrees\Source;
13use Fisharebest\Webtrees\Submitter;
14use Fisharebest\Webtrees\View;
15use Illuminate\Support\Collection;
16
17/**
18 * @var int                      $limit_high
19 * @var int                      $limit_low
20 * @var array<array<int,string>> $order
21 * @var Collection<int,object>   $rows
22 * @var bool                     $show_date
23 * @var bool                     $show_user
24 */
25?>
26
27<div class="table-responsive">
28    <table
29        class="table table-sm wt-table-changes datatables d-none"
30        <?= view('lists/datatables-attributes') ?>
31        data-paging="<?= $rows->count() >= $limit_high ? 'true' : 'false' ?>"
32        data-filter="false"
33        data-info="false"
34        data-length-change="false"
35        data-order="<?= e(json_encode($order, JSON_THROW_ON_ERROR)) ?>"
36        data-page-length="<?= e($limit_low) ?>"
37    >
38        <thead>
39            <tr>
40                <th class="wt-side-block-optional">
41                <span class="visually-hidden">
42                    <?= I18N::translate('Type') ?>
43                </span>
44                </th>
45                <th>
46                    <?= I18N::translate('Record') ?>
47                </th>
48                <th class="<?= $show_date ? '' : 'd-none' ?>">
49                    <?= I18N::translate('Last change') ?>
50                </th>
51                <th class="<?= $show_user ? '' : 'd-none' ?>">
52                    <?= I18N::translate('Editor') ?>
53                </th>
54            </tr>
55        </thead>
56        <tbody>
57            <?php foreach ($rows as $row) : ?>
58                <tr>
59                    <td data-sort="<?= $row->record->tag() ?>" class="text-centre wt-side-block-optional">
60                        <?php if ($row->record->tag() === Individual::RECORD_TYPE) : ?>
61                            <?= view('icons/individual') ?>
62                            <span class="visually-hidden"><?= I18N::translate('Individual') ?></span>
63                        <?php elseif ($row->record->tag() === Family::RECORD_TYPE) : ?>
64                            <?= view('icons/family') ?>
65                            <span class="visually-hidden"><?= I18N::translate('Family') ?></span>
66                        <?php elseif ($row->record->tag() === Media::RECORD_TYPE) : ?>
67                            <?= view('icons/media') ?>
68                            <span class="visually-hidden"><?= I18N::translate('Media') ?></span>
69                        <?php elseif ($row->record->tag() === Note::RECORD_TYPE) : ?>
70                            <?= view('icons/note') ?>
71                            <span class="visually-hidden"><?= I18N::translate('Note') ?></span>
72                        <?php elseif ($row->record->tag() === Source::RECORD_TYPE) : ?>
73                            <?= view('icons/source') ?>
74                            <span class="visually-hidden"><?= I18N::translate('Source') ?></span>
75                        <?php elseif ($row->record->tag() === Submitter::RECORD_TYPE) : ?>
76                            <?= view('icons/submitter') ?>
77                            <span class="visually-hidden"><?= I18N::translate('Submitter') ?></span>
78                        <?php elseif ($row->record->tag() === Repository::RECORD_TYPE) : ?>
79                            <?= view('icons/repository') ?>
80                            <span class="visually-hidden"><?= I18N::translate('Repository') ?></span>
81                        <?php elseif ($row->record->tag() === Location::RECORD_TYPE) : ?>
82                            <?= view('icons/location') ?>
83                            <span class="visually-hidden"><?= I18N::translate('Location') ?></span>
84                        <?php endif ?>
85                    </td>
86
87                    <td data-sort="<?= e($row->record->sortName()) ?>">
88                        <a href="<?= e($row->record->url()) ?>"><?= $row->record->fullName() ?></a>
89                    </td>
90
91                    <td data-sort="<?= $row->time->timestamp() ?>" class="<?= $show_date ? '' : 'd-none' ?>">
92                        <?= view('components/datetime', ['timestamp' => $row->time]) ?>
93                    </td>
94
95                    <td class="<?= $show_user ? '' : 'd-none' ?>">
96                        <?= e($row->user->userName()) ?>
97                    </td>
98                </tr>
99            <?php endforeach ?>
100        </tbody>
101    </table>
102</div>
103
104<?php View::push('javascript') ?>
105<script>
106  $(".wt-table-changes").dataTable().removeClass("d-none");
107</script>
108<?php View::endpush() ?>
109