xref: /webtrees/resources/views/modules/media/tab.phtml (revision ef3fb807042ec0187072c1155b05525722f7fa7c)
1<?php
2
3declare(strict_types=1);
4
5use Fisharebest\Webtrees\Fact;
6use Fisharebest\Webtrees\I18N;
7use Fisharebest\Webtrees\Individual;
8use Illuminate\Support\Collection;
9
10/**
11 * @var bool                 $can_edit
12 * @var Collection<int,Fact> $clipboard_facts
13 * @var Collection<int,Fact> $facts
14 * @var Individual           $individual
15 */
16
17?>
18<div class="wt-tab-media">
19    <table class="table wt-facts-table">
20        <tr>
21            <td colspan="2">
22                <label>
23                    <input id="show-level-2-media" type="checkbox" data-bs-toggle="collapse" data-bs-target=".wt-level-two-media" data-wt-persist="level-two-media" autocomplete="off">
24                    <?= I18N::translate('Show all media') ?>
25                </label>
26            </td>
27        </tr>
28
29        <?php foreach ($facts as $fact) : ?>
30            <?php if (str_ends_with($fact->tag(), ':OBJE')) : ?>
31                <?= view('fact', ['fact' => $fact, 'record' => $individual]) ?>
32            <?php else : ?>
33                <?php
34                if ($fact->isPendingAddition()) {
35                    $styleadd = 'wt-new ';
36                } elseif ($fact->isPendingDeletion()) {
37                    $styleadd = 'wt-old ';
38                } else {
39                    $styleadd = '';
40                }
41                ?>
42
43                <tr class="wt-level-two-media collapse">
44                    <th scope="row" class="rela <?= $styleadd ?>">
45                        <?= $fact->label() ?>
46                        <?= view('fact-edit-links', ['fact' => $fact, 'url' => $fact->record()->url() . '#tab-media']) ?>
47                    </th>
48
49                    <td class="<?= $styleadd ?>">
50                        <?php if (preg_match_all('/\n([2-4] OBJE .*)/', $fact->gedcom(), $matches, PREG_SET_ORDER) > 0) : ?>
51                            <?php foreach ($matches as $match) : ?>
52                                <?= view('fact-gedcom-fields', ['gedcom' => $match[1], 'parent' => $fact->tag(), 'tree' => $fact->record()->tree()]) ?>
53                            <?php endforeach ?>
54                        <?php endif ?>
55                    </td>
56                </tr>
57            <?php endif ?>
58        <?php endforeach ?>
59
60        <?php if ($facts->isEmpty()) : ?>
61            <tr>
62                <td colspan="2">
63                    <?= I18N::translate('There are no media objects for this individual.') ?>
64                </td>
65            </tr>
66        <?php endif ?>
67    </table>
68</div>
69