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