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