xref: /webtrees/resources/views/edit/raw-gedcom-record.phtml (revision 0d047a8c74753c7558a60f4789c838996d6fae8b)
1<?php
2
3use Fisharebest\Webtrees\GedcomRecord;
4use Fisharebest\Webtrees\Http\RequestHandlers\EditRawRecordAction;
5use Fisharebest\Webtrees\I18N;
6use Fisharebest\Webtrees\Tree;
7use Fisharebest\Webtrees\View;
8use Fisharebest\Webtrees\Webtrees;
9
10/**
11 * @var string       $level0
12 * @var GedcomRecord $record
13 * @var string       $title
14 * @var Tree         $tree
15 */
16
17?>
18
19<h2 class="wt-page-title"><?= $title ?></h2>
20
21<form method="post" action="<?= e(route(EditRawRecordAction::class, ['tree' => $tree->name(), 'xref' => $record->xref()])) ?>" class="wt-page-content">
22    <?= csrf_field() ?>
23
24    <p class="text-muted small">
25        <?= I18N::translate('This page allows you to bypass the usual forms, and edit the underlying data directly. It is an advanced option, and you should not use it unless you understand the GEDCOM format. If you make a mistake here, it can be difficult to fix.') ?>
26    </p>
27    <p class="text-muted small">
28        <?= /* I18N: %s is a URL */ I18N::translate('You can download a copy of the GEDCOM specification from %s.', '<a href="' . e(Webtrees::GEDCOM_PDF) . '">' . e(Webtrees::GEDCOM_PDF) . '</a>') ?>
29    </p>
30
31    <div class="card">
32        <label class="card-header py-1 px-2" for="fact0">
33            <?= $record->fullName() ?>
34        </label>
35        <textarea class="card-body form-control py-1 px-2" id="fact0" rows="1" dir="ltr" readonly disabled><?= e($level0) ?></textarea>
36    </div>
37
38    <div class="wt-sortable-list">
39        <?php foreach ($record->facts([], false, null, true) as $fact) : ?>
40            <div class="card my-2 wt-sortable-item">
41                <input type="hidden" name="fact_id[]" value="<?= e($fact->id()) ?>">
42                <div class="card-header">
43                    <?= view('edit/reorder-card-header', ['title' => $fact->summary()]) ?>
44                </div>
45                <label class="sr-only" for="fact-<?= e($fact->id()) ?>"><?= $fact->summary() ?></label>
46
47                <textarea class="card-body form-control py-1 px-2" dir="ltr" id="fact-<?= e($fact->id()) ?>" name="fact[]" rows="<?= 1 + preg_match_all('/\n/', $fact->gedcom()) ?>"><?= e($fact->gedcom()) ?></textarea>
48            </div>
49        <?php endforeach ?>
50
51        <div class="card my-2">
52            <label class="card-header py-1 px-2" for="fact-add">
53                <?= I18N::translate('Add a fact') ?>
54            </label>
55            <input type="hidden" name="fact_id[]" value="">
56            <textarea class="card-body form-control py-1 px-2" dir="ltr" id="fact-add" name="fact[]" rows="5"></textarea>
57        </div>
58    </div>
59
60    <div class="row form-group">
61        <div class="col-sm-9 offset-sm-3">
62            <button class="btn btn-primary" type="submit">
63                <?= view('icons/save') ?>
64                <?= /* I18N: A button label. */ I18N::translate('save') ?>
65            </button>
66            <a class="btn btn-secondary" href="<?= e($record->url()) ?>">
67                <?= view('icons/cancel') ?>
68                <?= /* I18N: A button label. */ I18N::translate('cancel') ?>
69            </a>
70        </div>
71    </div>
72</form>
73
74<?php View::push('javascript') ?>
75<script>
76    new Sortable(document.querySelector(".wt-sortable-list"), {
77        handle: ".card-header",
78    });
79</script>
80<?php View::endpush() ?>
81