xref: /webtrees/resources/views/modules/sources_tab/tab.phtml (revision 4a213054c13c5caf2ed7b812a0d260527e167ef6)
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-toggle="collapse" data-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            <?= view('edit/paste-fact-row', ['record' => $individual, 'facts' => $clipboard_facts]) ?>
46
47            <tr>
48                <th scope="row">
49                    <?= I18N::translate('Source') ?>
50                </th>
51                <td>
52                    <a href="<?= e(route(AddNewFact::class, ['tree' => $individual->tree()->name(), 'xref' => $individual->xref(), 'fact' => 'SOUR'])) ?>">
53                        <?= I18N::translate('Add a source citation') ?>
54                    </a>
55                </td>
56            </tr>
57        <?php endif ?>
58    </table>
59</div>
60
61<?php View::push('javascript') ?>
62<script>
63  'use strict';
64
65  webtrees.persistentToggle("show-level-2-sources");
66</script>
67<?php View::endpush() ?>
68