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 $level = (int) $level; 21 $hierarchy[$level] = $tag; 22 $full_tag = implode(':', array_slice($hierarchy, 0, 1 + $level)); 23 $element = Registry::elementFactory()->make($full_tag); 24 $id = Uuid::uuid4()->toString() . '-' . $full_tag; 25 ?> 26 27 <div class="form-group row"> 28 <label class="col-sm-3 col-form-label" for="<?= e($id) ?>"> 29 <?= str_repeat(' ', max(0, $level - 1)) ?> 30 <?= $element->label() ?> 31 </label> 32 33 <div class="col-sm-9"> 34 <input type="hidden" name="<?= e($prefix) ?>levels[]" value="<?= $level ?>"> 35 <input type="hidden" name="<?= e($prefix) ?>tags[]" value="<?= e($tag) ?>"> 36 <?= $element->edit($id, $prefix . 'values[]', strtr($value, ["\r" => "\n"]), $tree) ?> 37 </div> 38 </div> 39<?php endforeach ?> 40