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