xref: /webtrees/resources/views/edit/raw-gedcom-record.phtml (revision 302fdb8d52cb4f4341c6cc9dc09d1eb0794caab6)
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    <div class="form-text">
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        <br>
27        <?= /* 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>') ?>
28    </div>
29
30    <div class="card">
31        <label class="card-header py-1 px-2" for="level0">
32            <?= $record->fullName() ?>
33        </label>
34        <textarea class="card-body form-control py-1 px-2" id="level0" name="level0" rows="1" dir="ltr" readonly><?= e($level0) ?></textarea>
35    </div>
36
37    <div class="wt-sortable-list">
38        <?php foreach ($record->facts([], false, null, true) as $fact) : ?>
39            <div class="card my-2 wt-sortable-item">
40                <input type="hidden" name="fact_id[]" value="<?= e($fact->id()) ?>">
41                <div class="card-header">
42                    <?= view('edit/reorder-card-header', ['title' => $fact->summary()]) ?>
43                </div>
44                <label class="visually-hidden" for="fact-<?= e($fact->id()) ?>"><?= $fact->summary() ?></label>
45
46                <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>
47            </div>
48        <?php endforeach ?>
49
50        <div class="card my-2">
51            <label class="card-header py-1 px-2" for="fact-add">
52                <?= I18N::translate('Add a fact') ?>
53            </label>
54            <input type="hidden" name="fact_id[]" value="">
55            <textarea class="card-body form-control py-1 px-2" dir="ltr" id="fact-add" name="fact[]" rows="5"></textarea>
56        </div>
57    </div>
58
59    <div class="row mb-3">
60        <div class="col-sm-9 offset-sm-3">
61            <button class="btn btn-primary" type="submit">
62                <?= view('icons/save') ?>
63                <?= /* I18N: A button label. */ I18N::translate('save') ?>
64            </button>
65            <a class="btn btn-secondary" href="<?= e($record->url()) ?>">
66                <?= view('icons/cancel') ?>
67                <?= /* I18N: A button label. */ I18N::translate('cancel') ?>
68            </a>
69        </div>
70    </div>
71</form>
72
73<?php View::push('javascript') ?>
74<script>
75    new Sortable(document.querySelector(".wt-sortable-list"), {
76        handle: ".card-header",
77    });
78</script>
79<?php View::endpush() ?>
80