xref: /webtrees/resources/views/edit/raw-gedcom-record.phtml (revision 10e0649788c8d7d4974d81c048ca2b225df8f22e)
13b3db8adSGreg Roach<?php
23b3db8adSGreg Roach
3*10e06497SGreg Roachdeclare(strict_types=1);
4*10e06497SGreg Roach
548c46458SGreg Roachuse Fisharebest\Webtrees\Gedcom;
67c2c99faSGreg Roachuse Fisharebest\Webtrees\GedcomRecord;
72917771cSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\EditRawRecordAction;
83b3db8adSGreg Roachuse Fisharebest\Webtrees\I18N;
97c2c99faSGreg Roachuse Fisharebest\Webtrees\Tree;
103b3db8adSGreg Roachuse Fisharebest\Webtrees\View;
119d7cdf93SGreg Roachuse Fisharebest\Webtrees\Webtrees;
123b3db8adSGreg Roach
137c2c99faSGreg Roach/**
147c2c99faSGreg Roach * @var string       $level0
157c2c99faSGreg Roach * @var GedcomRecord $record
167c2c99faSGreg Roach * @var string       $title
177c2c99faSGreg Roach * @var Tree         $tree
187c2c99faSGreg Roach */
197c2c99faSGreg Roach
203b3db8adSGreg Roach?>
21dd6b2bfcSGreg Roach
22dd6b2bfcSGreg Roach<h2 class="wt-page-title"><?= $title ?></h2>
23dd6b2bfcSGreg Roach
2448c46458SGreg Roach<form method="post" id="edit-raw-gedcom" action="<?= e(route(EditRawRecordAction::class, ['tree' => $tree->name(), 'xref' => $record->xref()])) ?>" class="wt-page-content">
25315eb316SGreg Roach    <div class="form-text">
26dd6b2bfcSGreg Roach        <?= 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.') ?>
27315eb316SGreg Roach        <br>
289d7cdf93SGreg Roach        <?= /* 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>') ?>
29315eb316SGreg Roach    </div>
30dd6b2bfcSGreg Roach
31dd6b2bfcSGreg Roach    <div class="card">
324c3814d0SGreg Roach        <label class="card-header py-1 px-2" for="level0">
3339ca88baSGreg Roach            <?= $record->fullName() ?>
34dd6b2bfcSGreg Roach        </label>
354c3814d0SGreg Roach        <textarea class="card-body form-control py-1 px-2" id="level0" name="level0" rows="1" dir="ltr" readonly><?= e($level0) ?></textarea>
36dd6b2bfcSGreg Roach    </div>
37dd6b2bfcSGreg Roach
3892044e0dSGreg Roach    <div class="wt-sortable-list">
397bb122d6SGreg Roach        <?php foreach ($record->facts([], false, null, true) as $fact) : ?>
4092044e0dSGreg Roach            <div class="card my-2 wt-sortable-item">
419ba7eeb1SGreg Roach                <input type="hidden" name="fact_id[]" value="<?= e($fact->id()) ?>">
4292044e0dSGreg Roach                <div class="card-header">
4392044e0dSGreg Roach                    <?= view('edit/reorder-card-header', ['title' => $fact->summary()]) ?>
4492044e0dSGreg Roach                </div>
45315eb316SGreg Roach                <label class="visually-hidden" for="fact-<?= e($fact->id()) ?>"><?= $fact->summary() ?></label>
4692044e0dSGreg Roach
479313feb8SGreg Roach                <?php if ($fact->tag() === 'OBJE:FILE') : ?>
489313feb8SGreg Roach                    <div class="alert alert-warning mb-0">
499313feb8SGreg Roach                        <?= view('icons/warning') ?>
509313feb8SGreg Roach                        <?= I18N::translate('If you modify the filename, you should also rename the file.') ?>
519313feb8SGreg Roach                    </div>
529313feb8SGreg Roach                <?php endif ?>
539313feb8SGreg Roach
5448c46458SGreg Roach                <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>
55dd6b2bfcSGreg Roach            </div>
56dd6b2bfcSGreg Roach        <?php endforeach ?>
57dd6b2bfcSGreg Roach
58dd6b2bfcSGreg Roach        <div class="card my-2">
59dd6b2bfcSGreg Roach            <label class="card-header py-1 px-2" for="fact-add">
60dd6b2bfcSGreg Roach                <?= I18N::translate('Add a fact') ?>
61dd6b2bfcSGreg Roach            </label>
62cd0fe2c5SGreg Roach            <input type="hidden" name="fact_id[]" value="">
63c67a93abSGreg Roach            <textarea class="card-body form-control py-1 px-2" dir="ltr" id="fact-add" name="fact[]" rows="5"></textarea>
64dd6b2bfcSGreg Roach        </div>
65dd6b2bfcSGreg Roach    </div>
66dd6b2bfcSGreg Roach
679e3c2cf9SGreg Roach    <div class="row mb-3">
68dd6b2bfcSGreg Roach        <div class="col-sm-9 offset-sm-3">
69dd6b2bfcSGreg Roach            <button class="btn btn-primary" type="submit">
70d993d560SGreg Roach                <?= view('icons/save') ?>
71dd6b2bfcSGreg Roach                <?= /* I18N: A button label. */ I18N::translate('save') ?>
72dd6b2bfcSGreg Roach            </button>
73dd6b2bfcSGreg Roach            <a class="btn btn-secondary" href="<?= e($record->url()) ?>">
74d993d560SGreg Roach                <?= view('icons/cancel') ?>
75dd6b2bfcSGreg Roach                <?= /* I18N: A button label. */ I18N::translate('cancel') ?>
76dd6b2bfcSGreg Roach            </a>
77dd6b2bfcSGreg Roach        </div>
78dd6b2bfcSGreg Roach    </div>
7981443e3cSGreg Roach
8081443e3cSGreg Roach    <?= csrf_field() ?>
81dd6b2bfcSGreg Roach</form>
82dd6b2bfcSGreg Roach
83dd6b2bfcSGreg Roach<?php View::push('javascript') ?>
84dd6b2bfcSGreg Roach<script>
8548c46458SGreg Roach  new Sortable(document.querySelector('.wt-sortable-list'), {
8648c46458SGreg Roach    handle: '.card-header',
87dd6b2bfcSGreg Roach  });
8848c46458SGreg Roach
8948c46458SGreg Roach  webtrees.textareaPatterns(document.getElementById('edit-raw-gedcom'));
90dd6b2bfcSGreg Roach</script>
91dd6b2bfcSGreg Roach<?php View::endpush() ?>
92