xref: /webtrees/resources/views/edit/edit-gedcom-fields.phtml (revision 273a564e3de4d5154e894fa56a60fe99383cf8b2)
1<?php
2
3use Fisharebest\Webtrees\Registry;
4use Fisharebest\Webtrees\Tree;
5use Ramsey\Uuid\Uuid;
6
7/**
8 * @var string        $gedcom
9 * @var array<string> $hierarchy
10 * @var string        $prefix
11 * @var Tree          $tree
12 */
13
14?>
15
16<?php foreach (explode("\n", $gedcom) as $line) : ?>
17    <?php
18    preg_match('/^(\d+) (\w+) ?(.*)/', $line, $match);
19    [, $level, $tag, $value] = $match;
20    $hierarchy[$level] = $tag;
21    $full_tag          = implode(':', array_slice($hierarchy, 0, 1 + (int) $level));
22    $element           = Registry::elementFactory()->make($full_tag);
23    $id                = Uuid::uuid4()->toString() . '-' . $full_tag;
24    ?>
25
26    <div class="form-group row">
27        <label class="col-sm-3 col-form-label" for="<?= e($id) ?>">
28            <?= str_repeat('&nbsp;', max(0, $level -1)) ?>
29            <?= $element->label() ?>
30        </label>
31
32        <div class="col-sm-9">
33            <input type="hidden" name="<?= e($prefix) ?>levels[]" value="<?= e($level) ?>">
34            <input type="hidden" name="<?= e($prefix) ?>tags[]" value="<?= e($tag) ?>">
35            <?= $element->edit($id, $prefix . 'values[]', strtr($value, ["\r" => "\n"]), $tree) ?>
36        </div>
37    </div>
38<?php endforeach ?>
39