xref: /webtrees/resources/views/edit/raw-gedcom-record.phtml (revision 63a2c22b53010174339c850ccde339d45092dcf2)
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                <?php if ($fact->tag() === 'OBJE:FILE') : ?>
48                    <div class="alert alert-warning mb-0">
49                        <?= view('icons/warning') ?>
50                        <?= I18N::translate('If you modify the filename, you should also rename the file.') ?>
51                    </div>
52                <?php endif ?>
53
54                <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>
55            </div>
56        <?php endforeach ?>
57
58        <div class="card my-2">
59            <label class="card-header py-1 px-2" for="fact-add">
60                <?= I18N::translate('Add a fact') ?>
61            </label>
62            <input type="hidden" name="fact_id[]" value="">
63            <textarea class="card-body form-control py-1 px-2" dir="ltr" id="fact-add" name="fact[]" rows="5"></textarea>
64        </div>
65    </div>
66
67    <div class="row mb-3">
68        <div class="col-sm-9 offset-sm-3">
69            <button class="btn btn-primary" type="submit">
70                <?= view('icons/save') ?>
71                <?= /* I18N: A button label. */ I18N::translate('save') ?>
72            </button>
73            <a class="btn btn-secondary" href="<?= e($record->url()) ?>">
74                <?= view('icons/cancel') ?>
75                <?= /* I18N: A button label. */ I18N::translate('cancel') ?>
76            </a>
77        </div>
78    </div>
79</form>
80
81<?php View::push('javascript') ?>
82<script>
83  new Sortable(document.querySelector('.wt-sortable-list'), {
84    handle: '.card-header',
85  });
86
87  webtrees.textareaPatterns(document.getElementById('edit-raw-gedcom'));
88</script>
89<?php View::endpush() ?>
90