xref: /webtrees/resources/views/edit/raw-gedcom-record.phtml (revision 48c46458274530da7984e76f97075c0ca0c96b56)
1<?php
2
3use Fisharebest\Webtrees\Gedcom;
4use Fisharebest\Webtrees\GedcomRecord;
5use Fisharebest\Webtrees\Http\RequestHandlers\EditRawRecordAction;
6use Fisharebest\Webtrees\I18N;
7use Fisharebest\Webtrees\Tree;
8use Fisharebest\Webtrees\View;
9use Fisharebest\Webtrees\Webtrees;
10
11/**
12 * @var string       $level0
13 * @var GedcomRecord $record
14 * @var string       $title
15 * @var Tree         $tree
16 */
17
18?>
19
20<h2 class="wt-page-title"><?= $title ?></h2>
21
22<form method="post" id="edit-raw-gedcom" action="<?= e(route(EditRawRecordAction::class, ['tree' => $tree->name(), 'xref' => $record->xref()])) ?>" class="wt-page-content">
23    <?= csrf_field() ?>
24
25    <div class="form-text">
26        <?= 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.') ?>
27        <br>
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    </div>
30
31    <div class="card">
32        <label class="card-header py-1 px-2" for="level0">
33            <?= $record->fullName() ?>
34        </label>
35        <textarea class="card-body form-control py-1 px-2" id="level0" name="level0" rows="1" dir="ltr" readonly><?= 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="visually-hidden" for="fact-<?= e($fact->id()) ?>"><?= $fact->summary() ?></label>
46
47                <textarea class="card-body form-control py-1 px-2" data-wt-pattern="<?= e(Gedcom::REGEX_FACT) ?>" 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 mb-3">
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
80  webtrees.textareaPatterns(document.getElementById('edit-raw-gedcom'));
81</script>
82<?php View::endpush() ?>
83