xref: /webtrees/resources/views/edit/raw-gedcom-record.phtml (revision ac71572d8462e396ed5a307f05b29381e49f9e6e)
1<?php
2
3declare(strict_types=1);
4
5use Fisharebest\Webtrees\Gedcom;
6use Fisharebest\Webtrees\GedcomRecord;
7use Fisharebest\Webtrees\Http\RequestHandlers\EditRawRecordAction;
8use Fisharebest\Webtrees\I18N;
9use Fisharebest\Webtrees\Tree;
10use Fisharebest\Webtrees\View;
11use Fisharebest\Webtrees\Webtrees;
12
13/**
14 * @var string       $level0
15 * @var GedcomRecord $record
16 * @var string       $title
17 * @var Tree         $tree
18 */
19
20?>
21
22<h2 class="wt-page-title"><?= $title ?></h2>
23
24<form method="post" id="edit-raw-gedcom" action="<?= e(route(EditRawRecordAction::class, ['tree' => $tree->name(), 'xref' => $record->xref()])) ?>" class="wt-page-content">
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
80    <?= csrf_field() ?>
81</form>
82
83<?php View::push('javascript') ?>
84<script>
85  new Sortable(document.querySelector('.wt-sortable-list'), {
86    handle: '.card-header',
87  });
88
89  webtrees.textareaPatterns(document.getElementById('edit-raw-gedcom'));
90</script>
91<?php View::endpush() ?>
92