xref: /webtrees/resources/views/edit/raw-gedcom-fact.phtml (revision 6f4ec3cadc983f0a7294108c634bef48846b4311)
1<?php
2
3declare(strict_types=1);
4
5use Fisharebest\Webtrees\Fact;
6use Fisharebest\Webtrees\Gedcom;
7use Fisharebest\Webtrees\Http\RequestHandlers\EditRawFactAction;
8use Fisharebest\Webtrees\I18N;
9use Fisharebest\Webtrees\View;
10use Fisharebest\Webtrees\Webtrees;
11
12/**
13 * @var Fact        $fact
14 * @var string      $title
15 * @var string|null $url
16 */
17
18?>
19
20<h2 class="wt-page-title"><?= $title ?></h2>
21
22<form method="post" id="edit-raw-gedcom" action="<?= e(route(EditRawFactAction::class, ['tree' => $fact->record()->tree()->name(), 'xref' => $fact->record()->xref(), 'fact_id' => $fact->id()])) ?>" class="wt-page-content">
23    <input type="hidden" name="url" value="<?= e($url ?? $fact->record()->url()) ?>">
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    </div>
28    <div class="form-text">
29        <?= /* 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>') ?>
30    </div>
31
32    <div class="card my-2">
33        <label class="card-header py-1 px-2 d-flex" for="gedcom">
34            <?= $fact->summary() ?>
35        </label>
36        <textarea class="card-body form-control py-1 px-2" data-wt-pattern="<?= e(Gedcom::REGEX_FACT) ?>" id="gedcom" name="gedcom" rows="<?= 5 + preg_match_all('/\n/', $fact->gedcom()) ?>" dir="ltr"><?= e($fact->gedcom()) ?></textarea>
37    </div>
38
39    <div class="row mb-3">
40        <div class="col-sm-9 offset-sm-3">
41            <button class="btn btn-primary" type="submit">
42                <?= view('icons/save') ?>
43                <?= /* I18N: A button label. */ I18N::translate('save') ?>
44            </button>
45            <a class="btn btn-secondary" href="<?= e($fact->record()->url()) ?>">
46                <?= view('icons/cancel') ?>
47                <?= /* I18N: A button label. */ I18N::translate('cancel') ?>
48            </a>
49        </div>
50    </div>
51
52    <?= csrf_field() ?>
53</form>
54
55<?php View::push('javascript') ?>
56<script>
57  webtrees.textareaPatterns(document.getElementById('edit-raw-gedcom'));
58</script>
59<?php View::endpush() ?>
60