summaryrefslogtreecommitdiff
path: root/app/Http/RequestHandlers/CreateNoteAction.php
diff options
context:
space:
mode:
authorGreg Roach <greg@subaqua.co.uk>2022-12-18 21:13:05 +0000
committerGreg Roach <greg@subaqua.co.uk>2022-12-19 12:38:37 +0000
commit03f0aef85c359470fbc7c707bc177b4b3a2fef25 (patch)
tree047953d5bcdfe040ad59c8d8b31db286721de1e0 /app/Http/RequestHandlers/CreateNoteAction.php
parentdaf848998f45daff1b80cad8cdd248959fcfe8c0 (diff)
downloadwebtrees-03f0aef85c359470fbc7c707bc177b4b3a2fef25.tar.gz
webtrees-03f0aef85c359470fbc7c707bc177b4b3a2fef25.tar.bz2
webtrees-03f0aef85c359470fbc7c707bc177b4b3a2fef25.zip
Use elements to reformat new records
Diffstat (limited to 'app/Http/RequestHandlers/CreateNoteAction.php')
-rw-r--r--app/Http/RequestHandlers/CreateNoteAction.php13
1 files changed, 6 insertions, 7 deletions
diff --git a/app/Http/RequestHandlers/CreateNoteAction.php b/app/Http/RequestHandlers/CreateNoteAction.php
index 9b114bfa2f..c5cf2077ff 100644
--- a/app/Http/RequestHandlers/CreateNoteAction.php
+++ b/app/Http/RequestHandlers/CreateNoteAction.php
@@ -39,20 +39,19 @@ class CreateNoteAction implements RequestHandlerInterface
public function handle(ServerRequestInterface $request): ResponseInterface
{
$tree = Validator::attributes($request)->tree();
- $note = Validator::parsedBody($request)->string('note');
- $restriction = Validator::parsedBody($request)->isInArray(['', 'NONE', 'PRIVACY', 'CONFIDENTIAL', 'LOCKED'])->string('restriction');
+ $note = Validator::parsedBody($request)->isNotEmpty()->string('note');
+ $restriction = Validator::parsedBody($request)->string('restriction');
- // Convert HTML line endings to GEDCOM continuations
- $note = strtr($note, ["\r\n" => "\n1 CONT "]);
+ $note = Registry::elementFactory()->make('NOTE:CONT')->canonical($note);
+ $restriction = Registry::elementFactory()->make('NOTE:RESN')->canonical($restriction);
- $gedcom = '0 @@ NOTE ' . $note;
+ $gedcom = '0 @@ NOTE ' . strtr($note, ["\n" => "\n1 CONT "]);
if ($restriction !== '') {
- $gedcom .= "\n1 RESN " . $restriction;
+ $gedcom .= "\n1 RESN " . strtr($restriction, ["\n" => "\n2 CONT "]);
}
$record = $tree->createRecord($gedcom);
- $record = Registry::noteFactory()->new($record->xref(), $record->gedcom(), null, $tree);
// value and text are for autocomplete
// html is for interactive modals