summaryrefslogtreecommitdiff
path: root/resources/views/modules/media/tab.phtml
blob: 479c51d78d050e5fa0494737786afffe6a4f4ba5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php

use Fisharebest\Webtrees\Fact;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
use Illuminate\Support\Collection;

/**
 * @var bool             $can_edit
 * @var Collection<Fact> $clipboard_facts
 * @var Collection<Fact> $facts
 * @var Individual       $individual
 */

?>
<div class="wt-tab-media py-4">
    <table class="table wt-facts-table">
        <tr>
            <td colspan="2">
                <label>
                    <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">
                    <?= I18N::translate('Show all media') ?>
                </label>
            </td>
        </tr>

        <?php foreach ($facts as $fact) : ?>
            <?php if (str_ends_with($fact->tag(), ':OBJE')) : ?>
                <?= view('fact', ['fact' => $fact, 'record' => $individual]) ?>
            <?php else : ?>
                <?php
                    if ($fact->isPendingAddition()) {
                        $styleadd = 'wt-new ';
                    } elseif ($fact->isPendingDeletion()) {
                        $styleadd = 'wt-old ';
                    } else {
                        $styleadd = '';
                    }
                ?>

                <tr class="wt-level-two-media collapse">
                    <th scope="row" class="rela <?= $styleadd ?>">
                        <?= $fact->label() ?>
                        <?= view('fact-edit-links', ['fact' => $fact, 'url' => $fact->record()->url() . '#tab-media']) ?>
                    </th>

                    <td class="<?= $styleadd ?>">
                        <?php if (preg_match_all('/\n([2-4] OBJE .*)/', $fact->gedcom(), $matches, PREG_SET_ORDER) > 0) : ?>
                            <?php foreach($matches as $match) : ?>
                                <?= view('fact-gedcom-fields', ['gedcom' => $match[1], 'parent' => $fact->tag(), 'tree' => $fact->record()->tree()]) ?>
                            <?php endforeach ?>
                        <?php endif ?>
                    </td>
                </tr>
            <?php endif ?>
        <?php endforeach ?>

        <?php if ($facts->isEmpty()) : ?>
            <tr>
                <td colspan="2">
                    <?= I18N::translate('There are no media objects for this individual.') ?>
                </td>
            </tr>
        <?php endif ?>
    </table>
</div>