xref: /webtrees/resources/views/edit/raw-gedcom-record.phtml (revision 81443e3cbe4eef5ccdcf8dae716a7e35f7417b60)
13b3db8adSGreg Roach<?php
23b3db8adSGreg Roach
348c46458SGreg Roachuse Fisharebest\Webtrees\Gedcom;
47c2c99faSGreg Roachuse Fisharebest\Webtrees\GedcomRecord;
52917771cSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\EditRawRecordAction;
63b3db8adSGreg Roachuse Fisharebest\Webtrees\I18N;
77c2c99faSGreg Roachuse Fisharebest\Webtrees\Tree;
83b3db8adSGreg Roachuse Fisharebest\Webtrees\View;
99d7cdf93SGreg Roachuse Fisharebest\Webtrees\Webtrees;
103b3db8adSGreg Roach
117c2c99faSGreg Roach/**
127c2c99faSGreg Roach * @var string       $level0
137c2c99faSGreg Roach * @var GedcomRecord $record
147c2c99faSGreg Roach * @var string       $title
157c2c99faSGreg Roach * @var Tree         $tree
167c2c99faSGreg Roach */
177c2c99faSGreg Roach
183b3db8adSGreg Roach?>
19dd6b2bfcSGreg Roach
20dd6b2bfcSGreg Roach<h2 class="wt-page-title"><?= $title ?></h2>
21dd6b2bfcSGreg Roach
2248c46458SGreg Roach<form method="post" id="edit-raw-gedcom" action="<?= e(route(EditRawRecordAction::class, ['tree' => $tree->name(), 'xref' => $record->xref()])) ?>" class="wt-page-content">
23315eb316SGreg Roach    <div class="form-text">
24dd6b2bfcSGreg 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.') ?>
25315eb316SGreg Roach        <br>
269d7cdf93SGreg 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>') ?>
27315eb316SGreg Roach    </div>
28dd6b2bfcSGreg Roach
29dd6b2bfcSGreg Roach    <div class="card">
304c3814d0SGreg Roach        <label class="card-header py-1 px-2" for="level0">
3139ca88baSGreg Roach            <?= $record->fullName() ?>
32dd6b2bfcSGreg Roach        </label>
334c3814d0SGreg Roach        <textarea class="card-body form-control py-1 px-2" id="level0" name="level0" rows="1" dir="ltr" readonly><?= e($level0) ?></textarea>
34dd6b2bfcSGreg Roach    </div>
35dd6b2bfcSGreg Roach
3692044e0dSGreg Roach    <div class="wt-sortable-list">
377bb122d6SGreg Roach        <?php foreach ($record->facts([], false, null, true) as $fact) : ?>
3892044e0dSGreg Roach            <div class="card my-2 wt-sortable-item">
399ba7eeb1SGreg Roach                <input type="hidden" name="fact_id[]" value="<?= e($fact->id()) ?>">
4092044e0dSGreg Roach                <div class="card-header">
4192044e0dSGreg Roach                    <?= view('edit/reorder-card-header', ['title' => $fact->summary()]) ?>
4292044e0dSGreg Roach                </div>
43315eb316SGreg Roach                <label class="visually-hidden" for="fact-<?= e($fact->id()) ?>"><?= $fact->summary() ?></label>
4492044e0dSGreg Roach
459313feb8SGreg Roach                <?php if ($fact->tag() === 'OBJE:FILE') : ?>
469313feb8SGreg Roach                    <div class="alert alert-warning mb-0">
479313feb8SGreg Roach                        <?= view('icons/warning') ?>
489313feb8SGreg Roach                        <?= I18N::translate('If you modify the filename, you should also rename the file.') ?>
499313feb8SGreg Roach                    </div>
509313feb8SGreg Roach                <?php endif ?>
519313feb8SGreg Roach
5248c46458SGreg 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>
53dd6b2bfcSGreg Roach            </div>
54dd6b2bfcSGreg Roach        <?php endforeach ?>
55dd6b2bfcSGreg Roach
56dd6b2bfcSGreg Roach        <div class="card my-2">
57dd6b2bfcSGreg Roach            <label class="card-header py-1 px-2" for="fact-add">
58dd6b2bfcSGreg Roach                <?= I18N::translate('Add a fact') ?>
59dd6b2bfcSGreg Roach            </label>
60cd0fe2c5SGreg Roach            <input type="hidden" name="fact_id[]" value="">
61c67a93abSGreg Roach            <textarea class="card-body form-control py-1 px-2" dir="ltr" id="fact-add" name="fact[]" rows="5"></textarea>
62dd6b2bfcSGreg Roach        </div>
63dd6b2bfcSGreg Roach    </div>
64dd6b2bfcSGreg Roach
659e3c2cf9SGreg Roach    <div class="row mb-3">
66dd6b2bfcSGreg Roach        <div class="col-sm-9 offset-sm-3">
67dd6b2bfcSGreg Roach            <button class="btn btn-primary" type="submit">
68d993d560SGreg Roach                <?= view('icons/save') ?>
69dd6b2bfcSGreg Roach                <?= /* I18N: A button label. */ I18N::translate('save') ?>
70dd6b2bfcSGreg Roach            </button>
71dd6b2bfcSGreg Roach            <a class="btn btn-secondary" href="<?= e($record->url()) ?>">
72d993d560SGreg Roach                <?= view('icons/cancel') ?>
73dd6b2bfcSGreg Roach                <?= /* I18N: A button label. */ I18N::translate('cancel') ?>
74dd6b2bfcSGreg Roach            </a>
75dd6b2bfcSGreg Roach        </div>
76dd6b2bfcSGreg Roach    </div>
77*81443e3cSGreg Roach
78*81443e3cSGreg Roach    <?= csrf_field() ?>
79dd6b2bfcSGreg Roach</form>
80dd6b2bfcSGreg Roach
81dd6b2bfcSGreg Roach<?php View::push('javascript') ?>
82dd6b2bfcSGreg Roach<script>
8348c46458SGreg Roach  new Sortable(document.querySelector('.wt-sortable-list'), {
8448c46458SGreg Roach    handle: '.card-header',
85dd6b2bfcSGreg Roach  });
8648c46458SGreg Roach
8748c46458SGreg Roach  webtrees.textareaPatterns(document.getElementById('edit-raw-gedcom'));
88dd6b2bfcSGreg Roach</script>
89dd6b2bfcSGreg Roach<?php View::endpush() ?>
90