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