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