. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Elements; use Fisharebest\Webtrees\I18N; use Fisharebest\Webtrees\SurnameTradition; use Fisharebest\Webtrees\Tree; use function e; use function view; /** * NAME_PERSONAL := {Size=1:120} * [ * | // | * // | // | * // ] * The surname of an individual, if known, is enclosed between two slash (/) * characters. The order of the name parts should be the order that the person * would, by custom of their culture, have used when giving it to a recorder. * Early versions of Personal Ancestral File ® and other products did not use * the trailing slash when the surname was the last element of the name. If * part of name is illegible, that part is indicated by an ellipsis (...). * Capitalize the name of a person or place in the conventional manner— * capitalize the first letter of each part and lowercase the other letters, * unless conventional usage is otherwise. For example: McMurray. * Examples: * William Lee (given name only or surname not known) * /Parry/ (surname only) * William Lee /Parry/ * William Lee /Mac Parry/ (both parts (Mac and Parry) are surname parts * William /Lee/ Parry (surname imbedded in the name string) * William Lee /Pa.../ */ class NamePersonal extends AbstractElement { protected const MAXIMUM_LENGTH = 120; protected const SUBTAGS = [ 'TYPE' => '0:1', 'NPFX' => '0:1', 'GIVN' => '0:1', 'SPFX' => '0:1', 'SURN' => '0:1', 'NSFX' => '0:1', 'NICK' => '0:1', ]; /** * Create a default value for this element. * * @param Tree $tree * * @return string */ public function default(Tree $tree): string { $surname_tradition = SurnameTradition::create($tree->getPreference('SURNAME_TRADITION')); if ($surname_tradition->hasSurnames()) { return '//'; } return ''; } /** * An edit control for this data. * * @param string $id * @param string $name * @param string $value * @param Tree $tree * * @return string */ public function edit(string $id, string $name, string $value, Tree $tree): string { return '
' . view('edit/input-addon-edit-name', ['id' => $id]) . '' . view('edit/input-addon-keyboard', ['id' => $id]) . view('edit/input-addon-help', ['fact' => 'NAME']) . '
'; } /** * @return array */ public function subtags(): array { $language = I18N::languageTag(); switch ($language) { case 'hu': case 'jp': case 'ko': case 'zh-Hans': case 'zh-Hant': $subtags = [ 'TYPE' => '0:1', 'NPFX' => '0:1', 'SPFX' => '0:1', 'SURN' => '0:1', 'GIVN' => '0:1', 'NSFX' => '0:1', 'NICK' => '0:1', ]; break; default: $subtags = [ 'TYPE' => '0:1', 'NPFX' => '0:1', 'GIVN' => '0:1', 'SPFX' => '0:1', 'SURN' => '0:1', 'NSFX' => '0:1', 'NICK' => '0:1', ]; break; } return $subtags; } }