xref: /webtrees/resources/views/modules/sources_tab/tab.phtml (revision 61275c55e2688551b99836d7f49f54ed2b7e5788)
1<?php
2
3use Fisharebest\Webtrees\Fact;
4use Fisharebest\Webtrees\Functions\FunctionsPrintFacts;
5use Fisharebest\Webtrees\Http\RequestHandlers\AddNewFact;
6use Fisharebest\Webtrees\I18N;
7use Fisharebest\Webtrees\Individual;
8use Fisharebest\Webtrees\View;
9use Illuminate\Support\Collection;
10
11/**
12 * @var bool             $can_edit
13 * @var Collection<Fact> $clipboard_facts
14 * @var Collection<Fact> $facts
15 * @var Individual       $individual
16 */
17
18?>
19
20<div class="wt-tab-sources py-4">
21    <table class="table wt-facts-table">
22        <tr>
23            <td colspan="2">
24                <label>
25                    <input id="show-level-2-sources" type="checkbox" data-bs-toggle="collapse" data-bs-target=".wt-level-two-source">
26                    <?= I18N::translate('Show all sources') ?>
27                </label>
28            </td>
29        </tr>
30
31        <?php foreach ($facts as $fact) : ?>
32            <?php FunctionsPrintFacts::printMainSources($fact, 1) ?>
33            <?php FunctionsPrintFacts::printMainSources($fact, 2) ?>
34        <?php endforeach ?>
35
36        <?php if ($facts->isEmpty()) : ?>
37            <tr>
38                <td colspan="2">
39                    <?= I18N::translate('There are no source citations for this individual.') ?>
40                    </td>
41            </tr>
42        <?php endif ?>
43
44        <?php if ($can_edit) : ?>
45            <tr>
46                <th scope="row">
47                    <?= I18N::translate('Source') ?>
48                </th>
49                <td>
50                    <a href="<?= e(route(AddNewFact::class, ['tree' => $individual->tree()->name(), 'xref' => $individual->xref(), 'fact' => 'SOUR'])) ?>">
51                        <?= I18N::translate('Add a source citation') ?>
52                    </a>
53                </td>
54            </tr>
55        <?php endif ?>
56    </table>
57</div>
58
59<?php View::push('javascript') ?>
60<script>
61  'use strict';
62
63  webtrees.persistentToggle("show-level-2-sources");
64</script>
65<?php View::endpush() ?>
66