diff options
| -rw-r--r-- | app/Functions/FunctionsImport.php | 14 | ||||
| -rw-r--r-- | app/Functions/FunctionsPrintFacts.php | 227 | ||||
| -rw-r--r-- | app/GedcomTag.php | 380 | ||||
| -rw-r--r-- | app/Http/RequestHandlers/CheckTree.php | 3 | ||||
| -rw-r--r-- | app/Http/RequestHandlers/FamilyPage.php | 2 | ||||
| -rw-r--r-- | app/Http/RequestHandlers/IndividualPage.php | 2 | ||||
| -rw-r--r-- | app/Http/RequestHandlers/MediaPage.php | 2 | ||||
| -rw-r--r-- | app/Http/RequestHandlers/NotePage.php | 2 | ||||
| -rw-r--r-- | app/Http/RequestHandlers/RepositoryPage.php | 2 | ||||
| -rw-r--r-- | app/Http/RequestHandlers/SourcePage.php | 2 | ||||
| -rw-r--r-- | app/Http/RequestHandlers/TreePreferencesPage.php | 36 | ||||
| -rw-r--r-- | app/MediaFile.php | 6 | ||||
| -rw-r--r-- | app/Module/IndividualFactsTabModule.php | 2 | ||||
| -rw-r--r-- | app/Module/OnThisDayModule.php | 66 | ||||
| -rw-r--r-- | app/Module/UpcomingAnniversariesModule.php | 66 | ||||
| -rw-r--r-- | app/Services/ClipboardService.php | 24 | ||||
| -rw-r--r-- | phpstan-baseline.neon | 10 | ||||
| -rw-r--r-- | resources/views/edit/new-individual.phtml | 8 | ||||
| -rw-r--r-- | resources/views/individual-name.phtml | 3 | ||||
| -rw-r--r-- | resources/views/modules/media-list/page.phtml | 8 |
20 files changed, 161 insertions, 704 deletions
diff --git a/app/Functions/FunctionsImport.php b/app/Functions/FunctionsImport.php index 7c3575ec93..0cf0e79ef5 100644 --- a/app/Functions/FunctionsImport.php +++ b/app/Functions/FunctionsImport.php @@ -20,10 +20,10 @@ declare(strict_types=1); namespace Fisharebest\Webtrees\Functions; use Fisharebest\Webtrees\Date; +use Fisharebest\Webtrees\Elements\UnknownElement; use Fisharebest\Webtrees\Exceptions\GedcomErrorException; use Fisharebest\Webtrees\Family; use Fisharebest\Webtrees\Gedcom; -use Fisharebest\Webtrees\GedcomTag; use Fisharebest\Webtrees\Header; use Fisharebest\Webtrees\Individual; use Fisharebest\Webtrees\Location; @@ -283,10 +283,6 @@ class FunctionsImport // import different types of records if (preg_match('/^0 @(' . Gedcom::REGEX_XREF . ')@ (' . Gedcom::REGEX_TAG . ')/', $gedrec, $match)) { [, $xref, $type] = $match; - // check for a _UID, if the record doesn't have one, add one - if ($tree->getPreference('GENERATE_UIDS') === '1' && !str_contains($gedrec, "\n1 _UID ")) { - $gedrec .= "\n1 _UID " . GedcomTag::createUid(); - } } elseif (preg_match('/0 (HEAD|TRLR|_PLAC |_PLAC_DEFN)/', $gedrec, $match)) { $type = $match[1]; $xref = $type; // For records without an XREF, use the type as a pseudo XREF. @@ -294,6 +290,14 @@ class FunctionsImport throw new GedcomErrorException($gedrec); } + // Add a _UID + if ($tree->getPreference('GENERATE_UIDS') === '1' && !str_contains($gedrec, "\n1 _UID ")) { + $element = Registry::elementFactory()->make($type . ':_UID'); + if (!$element instanceof UnknownElement) { + $gedrec .= "\n1 _UID " . $element->default($tree); + } + } + // If the user has downloaded their GEDCOM data (containing media objects) and edited it // using an application which does not support (and deletes) media objects, then add them // back in. diff --git a/app/Functions/FunctionsPrintFacts.php b/app/Functions/FunctionsPrintFacts.php index d278ec0881..fb238b41f9 100644 --- a/app/Functions/FunctionsPrintFacts.php +++ b/app/Functions/FunctionsPrintFacts.php @@ -21,12 +21,11 @@ namespace Fisharebest\Webtrees\Functions; use Fisharebest\Webtrees\Age; use Fisharebest\Webtrees\Auth; -use Fisharebest\Webtrees\Contracts\UserInterface; -use Fisharebest\Webtrees\Date; use Fisharebest\Webtrees\Fact; use Fisharebest\Webtrees\Family; use Fisharebest\Webtrees\Filter; use Fisharebest\Webtrees\Gedcom; +use Fisharebest\Webtrees\Elements\UnknownElement; use Fisharebest\Webtrees\GedcomRecord; use Fisharebest\Webtrees\GedcomTag; use Fisharebest\Webtrees\Http\RequestHandlers\EditFactPage; @@ -38,11 +37,7 @@ use Fisharebest\Webtrees\Module\ModuleInterface; use Fisharebest\Webtrees\Module\RelationshipsChartModule; use Fisharebest\Webtrees\Note; use Fisharebest\Webtrees\Registry; -use Fisharebest\Webtrees\Repository; use Fisharebest\Webtrees\Services\ModuleService; -use Fisharebest\Webtrees\Services\UserService; -use Fisharebest\Webtrees\Submission; -use Fisharebest\Webtrees\Submitter; use Fisharebest\Webtrees\Tree; use Ramsey\Uuid\Uuid; @@ -57,10 +52,8 @@ use function ob_start; use function preg_match; use function preg_match_all; use function preg_replace; -use function preg_split; use function route; use function str_contains; -use function str_replace; use function strip_tags; use function strlen; use function strpos; @@ -130,8 +123,7 @@ class FunctionsPrintFacts // These links were once used internally to record the sort order. return; default: - // Hide unrecognized/custom tags? - if ($hide_errors && !GedcomTag::isTag($tag)) { + if ($element instanceof UnknownElement && $hide_errors) { return; } break; @@ -201,85 +193,9 @@ class FunctionsPrintFacts } // Print the value of this fact/event - switch ($tag) { - case 'ADDR': - case 'AFN': - case 'LANG': - case 'PUBL': - case 'RESN': - echo '<div class="field">' . $element->value($value, $tree) . '</div>'; - break; - case 'ASSO': - // we handle this later, in format_asso_rela_record() - break; - case 'EMAIL': - case 'EMAI': - case '_EMAIL': - echo '<div class="field"><a href="mailto:', e($value), '">', e($value), '</a></div>'; - break; - case 'REPO': - $repository = $fact->target(); - if ($repository instanceof Repository) { - echo '<div><a class="field" href="', e($repository->url()), '">', $repository->fullName(), '</a></div>'; - } else { - echo '<div class="error">', e($value), '</div>'; - } - break; - case 'SUBM': - $submitter = $fact->target(); - if ($submitter instanceof Submitter) { - echo '<div><a class="field" href="', e($submitter->url()), '">', $submitter->fullName(), '</a></div>'; - } else { - echo '<div class="error">', e($value), '</div>'; - } - break; - case 'SUBN': - $submission = $fact->target(); - if ($submission instanceof Submission) { - echo '<div><a class="field" href="', e($submission->url()), '">', $submission->fullName(), '</a></div>'; - } else { - echo '<div class="error">', e($value), '</div>'; - } - break; - case 'URL': - case '_URL': - case 'WWW': - echo '<div class="field"><a href="', e($value), '">', e($value), '</a></div>'; - break; - case 'TEXT': // 0 SOUR / 1 TEXT - echo Filter::formatText($value, $tree); - break; - case '_GOV': - echo '<div class="field"><a href="https://gov.genealogy.net/item/show/', e($value), '">', e($value), '</a></div>'; - break; - default: - // Display the value for all other facts/events - switch ($value) { - case '': - case 'CLOSE_RELATIVE': - // Nothing to display - break; - case 'N': - // Not valid GEDCOM - echo '<div class="field">', I18N::translate('No'), '</div>'; - break; - case 'Y': - echo '<div class="field">', I18N::translate('Yes'), '</div>'; - break; - default: - if (preg_match('/^@(' . Gedcom::REGEX_XREF . ')@$/', $value, $match)) { - $target = $fact->target(); - if ($target instanceof GedcomRecord) { - echo '<div><a href="', e($target->url()), '">', $target->fullName(), '</a></div>'; - } else { - echo '<div class="error">', e($value), '</div>'; - } - } else { - echo '<div class="field"><span dir="auto">', e($value), '</span></div>'; - } - break; - } - break; + // we handle ASSO later, in format_asso_rela_record() + if ($tag !== 'ASSO') { + echo '<div class="field">', $element->value($value, $tree), '</div>'; } // Print the type of this fact/event @@ -313,14 +229,10 @@ class FunctionsPrintFacts } // Print any other "2 XXXX" attributes, in the order in which they appear. - preg_match_all('/\n2 (' . Gedcom::REGEX_TAG . ') (.+)/', $fact->gedcom(), $matches, PREG_SET_ORDER); - - //0 SOUR / 1 DATA / 2 EVEN / 3 DATE and 3 PLAC must be collected separately - preg_match_all('/\n2 EVEN .*((\n[3].*)*)/', $fact->gedcom(), $evenMatches, PREG_SET_ORDER); - $currentEvenMatch = 0; + preg_match_all('/\n2 (' . Gedcom::REGEX_TAG . ') ?(.*)((\n[3-9].*)*)/', $fact->gedcom(), $l2_matches, PREG_SET_ORDER); - foreach ($matches as $match) { - switch ($match[1]) { + foreach ($l2_matches as $l2_match) { + switch ($l2_match[1]) { case 'DATE': case 'TIME': case 'AGE': @@ -343,93 +255,52 @@ class FunctionsPrintFacts case 'SOUR': // These will be shown at the end break; - case '_UID': - case 'RIN': - // These don't belong at level 2, so do not display them. - // They are only shown when editing. - break; - case 'EVEN': // 0 SOUR / 1 DATA / 2 EVEN / 3 DATE / 3 PLAC - $events = []; - foreach (preg_split('/ *, */', $match[2]) as $event) { - $events[] = GedcomTag::getLabel($event); - } - echo GedcomTag::getLabelValue('EVEN', implode(I18N::$list_separator, $events)); + default: + $subtag = $record::RECORD_TYPE . ':' . $tag . ':' . $l2_match[1]; + $element = Registry::elementFactory()->make($subtag); - if (preg_match('/\n3 DATE (.+)/', $evenMatches[$currentEvenMatch][0], $date_match)) { - $date = new Date($date_match[1]); - echo GedcomTag::getLabelValue('DATE', $date->display()); - } - if (preg_match('/\n3 PLAC (.+)/', $evenMatches[$currentEvenMatch][0], $plac_match)) { - echo GedcomTag::getLabelValue('PLAC', $plac_match[1]); + if ($element instanceof UnknownElement && $hide_errors) { + break; } - $currentEvenMatch++; - break; - case 'FAMC': // 0 INDI / 1 ADOP / 2 FAMC / 3 ADOP - $family = Registry::familyFactory()->make(str_replace('@', '', $match[2]), $tree); - if ($family instanceof Family) { - echo GedcomTag::getLabelValue('FAM', '<a href="' . e($family->url()) . '">' . $family->fullName() . '</a>'); - if (preg_match('/\n3 ADOP (HUSB|WIFE|BOTH)/', $fact->gedcom(), $adop_match)) { - echo Registry::elementFactory()->make('INDI:ADOP:FAMC:ADOP')->labelValue($adop_match[1], $tree); - } - } else { - echo GedcomTag::getLabelValue('FAM', '<span class="error">' . $match[2] . '</span>'); - } - break; - case '_WT_USER': - if (Auth::check()) { - $user = (new UserService())->findByIdentifier($match[2]); // may not exist - if ($user instanceof UserInterface) { - echo GedcomTag::getLabelValue('_WT_USER', '<span dir="auto">' . e($user->realName()) . '</span>'); - } else { - echo GedcomTag::getLabelValue('_WT_USER', e($match[2])); + echo $element->labelValue($l2_match[2], $tree); + + preg_match_all('/\n3 (' . Gedcom::REGEX_TAG . ') ?(.*)((\n[4-9].*)*)/', $l2_match[3], $l3_matches, PREG_SET_ORDER); + + foreach ($l3_matches as $l3_match) { + $subsubtag = $subtag . ':' . $l3_match[1]; + $element = Registry::elementFactory()->make($subsubtag); + + if ($element instanceof UnknownElement && $hide_errors) { + continue; } - } - break; - case 'RESN': - switch ($match[2]) { - case 'none': - // Note: "2 RESN none" is not valid gedcom. - // However, webtrees privacy rules will interpret it as "show an otherwise private fact to public". - echo GedcomTag::getLabelValue('RESN', '<i class="icon-resn-none"></i> ' . I18N::translate('Show to visitors')); - break; - case 'privacy': - echo GedcomTag::getLabelValue('RESN', '<i class="icon-resn-privacy"></i> ' . I18N::translate('Show to members')); - break; - case 'confidential': - echo GedcomTag::getLabelValue('RESN', '<i class="icon-resn-confidential"></i> ' . I18N::translate('Show to managers')); - break; - case 'locked': - echo GedcomTag::getLabelValue('RESN', '<i class="icon-resn-locked"></i> ' . I18N::translate('Only managers can edit')); - break; - default: - echo GedcomTag::getLabelValue('RESN', e($match[2])); - break; - } - break; - case 'CALN': - echo GedcomTag::getLabelValue('CALN', Filter::expandUrls($match[2], $tree)); - break; - case 'URL': - case '_URL': - case 'WWW': - $link = '<a href="' . e($match[2]) . '">' . e($match[2]) . '</a>'; - echo GedcomTag::getLabelValue($tag . ':' . $match[1], $link); - break; - default: - if (!$hide_errors || GedcomTag::isTag($match[1])) { - if (preg_match('/^@(' . Gedcom::REGEX_XREF . ')@$/', $match[2], $xmatch)) { - // Links - $linked_record = Registry::gedcomRecordFactory()->make($xmatch[1], $tree); - if ($linked_record) { - $link = '<a href="' . e($linked_record->url()) . '">' . $linked_record->fullName() . '</a>'; - echo GedcomTag::getLabelValue($tag . ':' . $match[1], $link); - } else { - echo GedcomTag::getLabelValue($tag . ':' . $match[1], e($match[2])); + + echo $element->labelValue($l3_match[2], $tree); + + preg_match_all('/\n4 (' . Gedcom::REGEX_TAG . ') ?(.*)((\n[5-9].*)*)/', $l3_match[3], $l4_matches, PREG_SET_ORDER); + + foreach ($l4_matches as $l4_match) { + $subsubsubtag = $subsubtag . ':' . $l4_match[1]; + $element = Registry::elementFactory()->make($subsubsubtag); + + if ($element instanceof UnknownElement && $hide_errors) { + continue; + } + + echo $element->labelValue($l4_match[2], $tree); + + preg_match_all('/\n5 (' . Gedcom::REGEX_TAG . ') ?(.*)((\n[6-9].*)*)/', $l4_match[3], $l5_matches, PREG_SET_ORDER); + + foreach ($l5_matches as $l5_match) { + $subsubsubsubtag = $subsubsubtag . ':' . $l5_match[1]; + $element = Registry::elementFactory()->make($subsubsubsubtag); + + if ($element instanceof UnknownElement && $hide_errors) { + continue; + } + + echo $element->labelValue($l5_match[2], $tree); } - } else { - // Non links - echo GedcomTag::getLabelValue($tag . ':' . $match[1], e($match[2])); } } break; diff --git a/app/GedcomTag.php b/app/GedcomTag.php index 2a69a53647..d323582f93 100644 --- a/app/GedcomTag.php +++ b/app/GedcomTag.php @@ -29,386 +29,6 @@ use function str_contains; */ class GedcomTag { - /** All tags that webtrees knows how to translate - including special/internal tags */ - private const ALL_TAGS = [ - 'ABBR', - 'ADDR', - 'ADR1', - 'ADR2', - 'ADOP', - 'ADOP:DATE', - 'ADOP:PLAC', - 'AFN', - 'AGE', - 'AGNC', - 'ALIA', - 'ANCE', - 'ANCI', - 'ANUL', - 'ASSO', - 'AUTH', - 'BAPL', - 'BAPL:DATE', - 'BAPL:PLAC', - 'BAPM', - 'BAPM:DATE', - 'BAPM:PLAC', - 'BARM', - 'BARM:DATE', - 'BARM:PLAC', - 'BASM', - 'BASM:DATE', - 'BASM:PLAC', - 'BIRT', - 'BIRT:DATE', - 'BIRT:PLAC', - 'BLES', - 'BLES:DATE', - 'BLES:PLAC', - 'BLOB', - 'BURI', - 'BURI:DATE', - 'BURI:PLAC', - 'CALN', - 'CAST', - 'CAUS', - 'CEME', - 'CENS', - 'CENS:DATE', - 'CENS:PLAC', - 'CHAN', - 'CHAN:DATE', - 'CHAN:_WT_USER', - 'CHAR', - 'CHIL', - 'CHR', - 'CHR:DATE', - 'CHR:PLAC', - 'CHRA', - 'CITN', - 'CITY', - 'COMM', - 'CONC', - 'CONT', - 'CONF', - 'CONF:DATE', - 'CONF:PLAC', - 'CONL', - 'COPR', - 'CORP', - 'CREM', - 'CREM:DATE', - 'CREM:PLAC', - 'CTRY', - 'DATA', - 'DATA:DATE', - 'DATE', - 'DEAT', - 'DEAT:CAUS', - 'DEAT:DATE', - 'DEAT:PLAC', - 'DESC', - 'DESI', - 'DEST', - 'DIV', - 'DIVF', - 'DSCR', - 'EDUC', - 'EDUC:AGNC', - 'EMAI', - 'EMAIL', - 'EMAL', - 'EMIG', - 'EMIG:DATE', - 'EMIG:PLAC', - 'ENDL', - 'ENDL:DATE', - 'ENDL:PLAC', - 'ENGA', - 'ENGA:DATE', - 'ENGA:PLAC', - 'EVEN', - 'EVEN:DATE', - 'EVEN:PLAC', - 'EVEN:TYPE', - 'FACT', - 'FACT:TYPE', - 'FAM', - 'FAMC', - 'FAMF', - 'FAMS', - 'FAX', - 'FCOM', - 'FCOM:DATE', - 'FCOM:PLAC', - 'FILE', - 'FONE', - 'FORM', - 'GEDC', - 'GIVN', - 'GRAD', - 'HEAD', - 'HUSB', - 'IDNO', - 'IMMI', - 'IMMI:DATE', - 'IMMI:PLAC', - 'INDI', - 'INFL', - 'LANG', - 'LATI', - 'LEGA', - 'LONG', - 'MAP', - 'MARB', - 'MARB:DATE', - 'MARB:PLAC', - 'MARR_CIVIL', - 'MARR_PARTNERS', - 'MARR_RELIGIOUS', - 'MARR_UNKNOWN', - 'MARC', - 'MARL', - 'MARR', - 'MARR:DATE', - 'MARR:PLAC', - 'MARS', - 'MEDI', - 'NAME', - 'NAME:FONE', - 'NAME:_HEB', - 'NATI', - 'NATU', - 'NATU:DATE', - 'NATU:PLAC', - 'NCHI', - 'NICK', - 'NMR', - 'NOTE', - 'NPFX', - 'NSFX', - 'OBJE', - 'OCCU', - 'OCCU:AGNC', - 'ORDI', - 'ORDN', - 'ORDN:AGNC', - 'ORDN:DATE', - 'ORDN:PLAC', - 'PAGE', - 'PEDI', - 'PHON', - 'PLAC', - 'PLAC:FONE', - 'PLAC:ROMN', - 'PLAC:_HEB', - 'POST', - 'PROB', - 'PROP', - 'PUBL', - 'QUAY', - 'REFN', - 'RELA', - 'RELI', - 'REPO', - 'RESI', - 'RESI:DATE', - 'RESI:PLAC', - 'RESN', - 'RETI', - 'RETI:AGNC', - 'RFN', - 'RIN', - 'ROLE', - 'ROMN', - 'SERV', - 'SEX', - 'SHARED_NOTE', - 'SLGC', - 'SLGC:DATE', - 'SLGC:PLAC', - 'SLGS', - 'SLGS:DATE', - 'SLGS:PLAC', - 'SOUR', - 'SPFX', - 'SSN', - 'STAE', - 'STAT', - 'STAT:DATE', - 'SUBM', - 'SUBN', - 'SURN', - 'TEMP', - 'TEXT', - 'TIME', - 'TITL', - 'TITL:FONE', - 'TITL:ROMN', - 'TITL:_HEB', - 'TRLR', - 'TYPE', - 'URL', - 'VERS', - 'WIFE', - 'WILL', - 'WWW', - '_ADOP_CHIL', - '_ADOP_GCHI', - '_ADOP_GCH1', - '_ADOP_GCH2', - '_ADOP_HSIB', - '_ADOP_SIBL', - '_ADPF', - '_ADPM', - '_AKA', - '_AKAN', - '_ASSO', - '_BAPM_CHIL', - '_BAPM_GCHI', - '_BAPM_GCH1', - '_BAPM_GCH2', - '_BAPM_HSIB', - '_BAPM_SIBL', - '_BIBL', - '_BIRT_CHIL', - '_BIRT_GCHI', - '_BIRT_GCH1', - '_BIRT_GCH2', - '_BIRT_HSIB', - '_BIRT_SIBL', - '_BRTM', - '_BRTM:DATE', - '_BRTM:PLAC', - '_BURI_CHIL', - '_BURI_GCHI', - '_BURI_GCH1', - '_BURI_GCH2', - '_BURI_GPAR', - '_BURI_HSIB', - '_BURI_SIBL', - '_BURI_SPOU', - '_CHR_CHIL', - '_CHR_GCHI', - '_CHR_GCH1', - '_CHR_GCH2', - '_CHR_HSIB', - '_CHR_SIBL', - '_COML', - '_CREM_CHIL', - '_CREM_GCHI', - '_CREM_GCH1', - '_CREM_GCH2', - '_CREM_GPAR', - '_CREM_HSIB', - '_CREM_SIBL', - '_CREM_SPOU', - '_DATE', - '_DBID', - '_DEAT_CHIL', - '_DEAT_GCHI', - '_DEAT_GCH1', - '_DEAT_GCH2', - '_DEAT_GPAR', - '_DEAT_GPA1', - '_DEAT_GPA2', - '_DEAT_HSIB', - '_DEAT_PARE', - '_DEAT_SIBL', - '_DEAT_SPOU', - '_DEG', - '_DETS', - '_DNA', - '_EMAIL', - '_EYEC', - '_FA1', - '_FA2', - '_FA3', - '_FA4', - '_FA5', - '_FA6', - '_FA7', - '_FA8', - '_FA9', - '_FA10', - '_FA11', - '_FA12', - '_FA13', - '_FNRL', - '_FREL', - '_GEDF', - '_GODP', - '_GOV', - '_HAIR', - '_HEB', - '_HEIG', - '_HNM', - '_HOL', - '_INTE', - '_LOC', - '_MARI', - '_MARNM', - '_PRIM', - '_MARNM_SURN', - '_MARR_CHIL', - '_MARR_FAMC', - '_MARR_GCHI', - '_MARR_GCH1', - '_MARR_GCH2', - '_MARR_HSIB', - '_MARR_PARE', - '_MARR_SIBL', - '_MBON', - '_MDCL', - '_MEDC', - '_MEND', - '_MILI', - '_MILT', - '_MREL', - '_MSTAT', - '_NAME', - '_NAMS', - '_NLIV', - '_NMAR', - '_NMR', - '_PLACE', - '_WT_USER', - '_PRMN', - '_SCBK', - '_SEPR', - '_SSHOW', - '_STAT', - '_SUBQ', - '_TODO', - '_TYPE', - '_UID', - '_URL', - '_WEIG', - '_WITN', - '_YART', - '__BRTM_CHIL', - '__BRTM_GCHI', - '__BRTM_GCH1', - '__BRTM_GCH2', - '__BRTM_HSIB', - '__BRTM_SIBL', - // These pseudo-tags are generated dynamically to display media object attributes - '__FILE_SIZE__', - '__IMAGE_SIZE__', - ]; - - /** - * Is $tag one of our known tags? - * - * @param string $tag - * - * @return bool - */ - public static function isTag(string $tag): bool - { - return in_array($tag, self::ALL_TAGS, true); - } - /** * Translate a tag, for an (optional) record * diff --git a/app/Http/RequestHandlers/CheckTree.php b/app/Http/RequestHandlers/CheckTree.php index 90ad683b6a..33dace3523 100644 --- a/app/Http/RequestHandlers/CheckTree.php +++ b/app/Http/RequestHandlers/CheckTree.php @@ -20,7 +20,6 @@ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fisharebest\Webtrees\Gedcom; -use Fisharebest\Webtrees\GedcomTag; use Fisharebest\Webtrees\Header; use Fisharebest\Webtrees\Http\ViewResponseTrait; use Fisharebest\Webtrees\I18N; @@ -331,6 +330,6 @@ class CheckTree implements RequestHandlerInterface */ private function formatType(string $type): string { - return '<b title="' . GedcomTag::getLabel($type) . '">' . $type . '</b>'; + return '<b>' . $type . '</b>'; } } diff --git a/app/Http/RequestHandlers/FamilyPage.php b/app/Http/RequestHandlers/FamilyPage.php index a451a6c262..a2c0ba39a0 100644 --- a/app/Http/RequestHandlers/FamilyPage.php +++ b/app/Http/RequestHandlers/FamilyPage.php @@ -81,7 +81,7 @@ class FamilyPage implements RequestHandlerInterface return redirect($family->url(), StatusCodeInterface::STATUS_MOVED_PERMANENTLY); } - $clipboard_facts = $this->clipboard_service->pastableFacts($family, new Collection()); + $clipboard_facts = $this->clipboard_service->pastableFacts($family); $facts = $family->facts([], true) ->filter(static function (Fact $fact): bool { diff --git a/app/Http/RequestHandlers/IndividualPage.php b/app/Http/RequestHandlers/IndividualPage.php index 6e9a1c5f7d..f282d58b7c 100644 --- a/app/Http/RequestHandlers/IndividualPage.php +++ b/app/Http/RequestHandlers/IndividualPage.php @@ -136,7 +136,7 @@ class IndividualPage implements RequestHandlerInterface return $this->viewResponse('individual-page', [ 'age' => $this->ageString($individual), - 'clipboard_facts' => $this->clipboard_service->pastableFacts($individual, new Collection()), + 'clipboard_facts' => $this->clipboard_service->pastableFacts($individual), 'individual' => $individual, 'individual_media' => $individual_media, 'meta_description' => $this->metaDescription($individual), diff --git a/app/Http/RequestHandlers/MediaPage.php b/app/Http/RequestHandlers/MediaPage.php index 5655ea3974..b2dd8ccfa2 100644 --- a/app/Http/RequestHandlers/MediaPage.php +++ b/app/Http/RequestHandlers/MediaPage.php @@ -80,7 +80,7 @@ class MediaPage implements RequestHandlerInterface } return $this->viewResponse('media-page', [ - 'clipboard_facts' => $this->clipboard_service->pastableFacts($media, new Collection()), + 'clipboard_facts' => $this->clipboard_service->pastableFacts($media), 'data_filesystem' => $data_filesystem, 'families' => $media->linkedFamilies('OBJE'), 'facts' => $this->facts($media), diff --git a/app/Http/RequestHandlers/NotePage.php b/app/Http/RequestHandlers/NotePage.php index e16564728c..7f936ce296 100644 --- a/app/Http/RequestHandlers/NotePage.php +++ b/app/Http/RequestHandlers/NotePage.php @@ -79,7 +79,7 @@ class NotePage implements RequestHandlerInterface } return $this->viewResponse('note-page', [ - 'clipboard_facts' => $this->clipboard_service->pastableFacts($note, new Collection()), + 'clipboard_facts' => $this->clipboard_service->pastableFacts($note), 'facts' => $this->facts($note), 'families' => $note->linkedFamilies('NOTE'), 'individuals' => $note->linkedIndividuals('NOTE'), diff --git a/app/Http/RequestHandlers/RepositoryPage.php b/app/Http/RequestHandlers/RepositoryPage.php index 83f86c8db7..af215a7468 100644 --- a/app/Http/RequestHandlers/RepositoryPage.php +++ b/app/Http/RequestHandlers/RepositoryPage.php @@ -94,7 +94,7 @@ class RepositoryPage implements RequestHandlerInterface } return $this->viewResponse('repository-page', [ - 'clipboard_facts' => $this->clipboard_service->pastableFacts($repository, new Collection()), + 'clipboard_facts' => $this->clipboard_service->pastableFacts($repository), 'facts' => $this->facts($repository), 'meta_description' => '', 'meta_robots' => 'index,follow', diff --git a/app/Http/RequestHandlers/SourcePage.php b/app/Http/RequestHandlers/SourcePage.php index 81be278d02..cb4089ec4a 100644 --- a/app/Http/RequestHandlers/SourcePage.php +++ b/app/Http/RequestHandlers/SourcePage.php @@ -99,7 +99,7 @@ class SourcePage implements RequestHandlerInterface } return $this->viewResponse('source-page', [ - 'clipboard_facts' => $this->clipboard_service->pastableFacts($source, new Collection()), + 'clipboard_facts' => $this->clipboard_service->pastableFacts($source), 'facts' => $this->facts($source), 'families' => $source->linkedFamilies('SOUR'), 'individuals' => $source->linkedIndividuals('SOUR'), diff --git a/app/Http/RequestHandlers/TreePreferencesPage.php b/app/Http/RequestHandlers/TreePreferencesPage.php index 520a6d6d12..535c31180a 100644 --- a/app/Http/RequestHandlers/TreePreferencesPage.php +++ b/app/Http/RequestHandlers/TreePreferencesPage.php @@ -37,12 +37,9 @@ use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; use function app; -use function array_merge; -use function array_unique; use function assert; use function e; use function explode; -use function uasort; /** * Edit the tree preferences. @@ -53,7 +50,7 @@ class TreePreferencesPage implements RequestHandlerInterface private const ALL_FAM_FACTS = [ 'RESN', 'ANUL', 'CENS', 'DIV', 'DIVF', 'ENGA', 'MARB', 'MARC', 'MARR', 'MARL', 'MARS', 'RESI', 'EVEN', - 'NCHI', 'SUBM', 'SLGS', 'REFN', 'RIN', 'CHAN', 'NOTE', 'SHARED_NOTE', 'SOUR', 'OBJE', + 'NCHI', 'SUBM', 'SLGS', 'REFN', 'RIN', 'CHAN', 'NOTE', 'SOUR', 'OBJE', '_NMR', '_COML', '_MBON', '_MARI', '_SEPR', '_TODO', ]; @@ -62,7 +59,7 @@ class TreePreferencesPage implements RequestHandlerInterface 'BLES', 'CHRA', 'CONF', 'FCOM', 'ORDN', 'NATU', 'EMIG', 'IMMI', 'CENS', 'PROB', 'WILL', 'GRAD', 'RETI', 'EVEN', 'CAST', 'DSCR', 'EDUC', 'IDNO', 'NATI', 'NCHI', 'NMR', 'OCCU', 'PROP', 'RELI', 'RESI', 'SSN', 'TITL', 'FACT', 'BAPL', 'CONL', 'ENDL', 'SLGC', 'SUBM', 'ASSO', - 'ALIA', 'ANCI', 'DESI', 'RFN', 'AFN', 'REFN', 'RIN', 'CHAN', 'NOTE', 'SHARED_NOTE', 'SOUR', 'OBJE', + 'ALIA', 'ANCI', 'DESI', 'RFN', 'AFN', 'REFN', 'RIN', 'CHAN', 'NOTE', 'SOUR', 'OBJE', '_BRTM', '_DEG', '_DNA', '_EYEC', '_FNRL', '_HAIR', '_HEIG', '_HNM', '_HOL', '_INTE', '_MDCL', '_MEDC', '_MILI', '_MILT', '_NAME', '_NAMS', '_NLIV', '_NMAR', '_PRMN', '_TODO', '_UID', '_WEIG', '_YART', ]; @@ -76,12 +73,12 @@ class TreePreferencesPage implements RequestHandlerInterface ]; private const ALL_REPO_FACTS = [ - 'NAME', 'ADDR', 'PHON', 'EMAIL', 'FAX', 'WWW', 'NOTE', 'SHARED_NOTE', 'REFN', 'RIN', 'CHAN', 'RESN', + 'NAME', 'ADDR', 'PHON', 'EMAIL', 'FAX', 'WWW', 'NOTE', 'REFN', 'RIN', 'CHAN', 'RESN', ]; private const ALL_SOUR_FACTS = [ 'DATA', 'AUTH', 'TITL', 'ABBR', 'PUBL', 'TEXT', 'REPO', 'REFN', 'RIN', - 'CHAN', 'NOTE', 'SHARED_NOTE', 'OBJE', 'RESN', + 'CHAN', 'NOTE', 'OBJE', 'RESN', ]; /** @var ModuleService */ @@ -161,29 +158,6 @@ class TreePreferencesPage implements RequestHandlerInterface Auth::PRIV_HIDE => I18N::translate('Hide from everyone'), ]; - $tags = array_unique(array_merge( - explode(',', $tree->getPreference('INDI_FACTS_ADD')), - explode(',', $tree->getPreference('INDI_FACTS_UNIQUE')), - explode(',', $tree->getPreference('FAM_FACTS_ADD')), - explode(',', $tree->getPreference('FAM_FACTS_UNIQUE')), - explode(',', $tree->getPreference('NOTE_FACTS_ADD')), - explode(',', $tree->getPreference('NOTE_FACTS_UNIQUE')), - explode(',', $tree->getPreference('SOUR_FACTS_ADD')), - explode(',', $tree->getPreference('SOUR_FACTS_UNIQUE')), - explode(',', $tree->getPreference('REPO_FACTS_ADD')), - explode(',', $tree->getPreference('REPO_FACTS_UNIQUE')), - ['SOUR', 'REPO', 'OBJE', '_PRIM', 'NOTE', 'SUBM', 'SUBN', '_UID', 'CHAN'] - )); - - $all_tags = []; - foreach ($tags as $tag) { - if ($tag) { - $all_tags[$tag] = GedcomTag::getLabel($tag); - } - } - - uasort($all_tags, '\Fisharebest\Webtrees\I18N::strcasecmp'); - // For historical reasons, we have two fields in one $calendar_formats = explode('_and_', $tree->getPreference('CALENDAR_FORMAT') . '_and_'); @@ -222,7 +196,7 @@ class TreePreferencesPage implements RequestHandlerInterface $all_repo_facts = Collection::make(self::ALL_REPO_FACTS) ->mapWithKeys(static function (string $tag): array { - return [$tag => Registry::elementFactory()->make('SOUR:' . $tag)->label()]; + return [$tag => Registry::elementFactory()->make('REPO:' . $tag)->label()]; }) ->sort(I18N::comparator()); diff --git a/app/MediaFile.php b/app/MediaFile.php index 9863e8ff37..f31ed0f28e 100644 --- a/app/MediaFile.php +++ b/app/MediaFile.php @@ -308,7 +308,7 @@ class MediaFile * * @param FilesystemOperator $data_filesystem * - * @return array<string> + * @return array<string,string> */ public function attributes(FilesystemOperator $data_filesystem): array { @@ -318,7 +318,7 @@ class MediaFile try { $bytes = $this->media()->tree()->mediaFilesystem($data_filesystem)->fileSize($this->filename()); $kb = intdiv($bytes + 1023, 1024); - $attributes['__FILE_SIZE__'] = I18N::translate('%s KB', I18N::number($kb)); + $attributes[I18N::translate('File size')] = I18N::translate('%s KB', I18N::number($kb)); } catch (FilesystemException | UnableToRetrieveMetadata $ex) { // External/missing files have no size. } @@ -327,7 +327,7 @@ class MediaFile try { $data = $filesystem->read($this->filename()); [$width, $height] = getimagesizefromstring($data); - $attributes['__IMAGE_SIZE__'] = I18N::translate('%1$s × %2$s pixels', I18N::number($width), I18N::number($height)); + $attributes[I18N::translate('Image dimensions')] = I18N::translate('%1$s × %2$s pixels', I18N::number($width), I18N::number($height)); } catch (FilesystemException | UnableToReadFile $ex) { // Cannot read the file. } diff --git a/app/Module/IndividualFactsTabModule.php b/app/Module/IndividualFactsTabModule.php index d9067fa683..93e59a4263 100644 --- a/app/Module/IndividualFactsTabModule.php +++ b/app/Module/IndividualFactsTabModule.php @@ -167,7 +167,7 @@ class IndividualFactsTabModule extends AbstractModule implements ModuleTabInterf return view('modules/personal_facts/tab', [ 'can_edit' => $individual->canEdit(), - 'clipboard_facts' => $this->clipboard_service->pastableFacts($individual, new Collection()), + 'clipboard_facts' => $this->clipboard_service->pastableFacts($individual), 'has_historical_facts' => $historical_facts !== [], 'individual' => $individual, 'facts' => $indifacts, diff --git a/app/Module/OnThisDayModule.php b/app/Module/OnThisDayModule.php index 7b7b1bf3cf..75ea6ae380 100644 --- a/app/Module/OnThisDayModule.php +++ b/app/Module/OnThisDayModule.php @@ -21,8 +21,8 @@ namespace Fisharebest\Webtrees\Module; use Fisharebest\Webtrees\Carbon; use Fisharebest\Webtrees\Gedcom; -use Fisharebest\Webtrees\GedcomTag; use Fisharebest\Webtrees\I18N; +use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\CalendarService; use Fisharebest\Webtrees\Tree; use Illuminate\Support\Str; @@ -52,36 +52,36 @@ class OnThisDayModule extends AbstractModule implements ModuleBlockInterface // All standard GEDCOM 5.5.1 events except CENS, RESI and EVEN private const ALL_EVENTS = [ - 'ADOP', - 'ANUL', - 'BAPM', - 'BARM', - 'BASM', - 'BIRT', - 'BLES', - 'BURI', - 'CHR', - 'CHRA', - 'CONF', - 'CREM', - 'DEAT', - 'DIV', - 'DIVF', - 'EMIG', - 'ENGA', - 'FCOM', - 'GRAD', - 'IMMI', - 'MARB', - 'MARC', - 'MARL', - 'MARR', - 'MARS', - 'NATU', - 'ORDN', - 'PROB', - 'RETI', - 'WILL', + 'ADOP' => 'INDI:ADOP', + 'ANUL' => 'FAM:ANUL', + 'BAPM' => 'INDI:BAPM', + 'BARM' => 'INDI:BARM', + 'BASM' => 'INDI:BASM', + 'BIRT' => 'INDI:BIRT', + 'BLES' => 'INDI:BLES', + 'BURI' => 'INDI:BURI', + 'CHR' => 'INDI:CHR', + 'CHRA' => 'INDI:CHRA', + 'CONF' => 'INDI:CONF', + 'CREM' => 'INDI:CREM', + 'DEAT' => 'INDI:DEAT', + 'DIV' => 'FAM:DIV', + 'DIVF' => 'FAM:DIVF', + 'EMIG' => 'INDI:EMIG', + 'ENGA' => 'FAM:ENGA', + 'FCOM' => 'INDI:FCOM', + 'GRAD' => 'INDI:GRAD', + 'IMMI' => 'INDI:IMMI', + 'MARB' => 'FAM:MARB', + 'MARC' => 'FAM:MARC', + 'MARL' => 'FAM:MARL', + 'MARR' => 'FAM:MARR', + 'MARS' => 'FAM:MARS', + 'NATU' => 'INDI:NATU', + 'ORDN' => 'INDI:ORDN', + 'PROB' => 'INDI:PROB', + 'RETI' => 'INDI:RETI', + 'WILL' => 'INDI:WILL', ]; private const DEFAULT_EVENTS = [ @@ -250,8 +250,8 @@ class OnThisDayModule extends AbstractModule implements ModuleBlockInterface $event_array = explode(',', $events); $all_events = []; - foreach (self::ALL_EVENTS as $event) { - $all_events[$event] = GedcomTag::getLabel($event); + foreach (self::ALL_EVENTS as $event => $tag) { + $all_events[$event] = Registry::elementFactory()->make($tag)->label(); } $info_styles = [ diff --git a/app/Module/UpcomingAnniversariesModule.php b/app/Module/UpcomingAnniversariesModule.php index dfda30e265..75f0cf10c7 100644 --- a/app/Module/UpcomingAnniversariesModule.php +++ b/app/Module/UpcomingAnniversariesModule.php @@ -21,8 +21,8 @@ namespace Fisharebest\Webtrees\Module; use Fisharebest\Webtrees\Carbon; use Fisharebest\Webtrees\Gedcom; -use Fisharebest\Webtrees\GedcomTag; use Fisharebest\Webtrees\I18N; +use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Services\CalendarService; use Fisharebest\Webtrees\Tree; use Illuminate\Support\Str; @@ -56,36 +56,36 @@ class UpcomingAnniversariesModule extends AbstractModule implements ModuleBlockI // All standard GEDCOM 5.5.1 events except CENS, RESI and EVEN private const ALL_EVENTS = [ - 'ADOP', - 'ANUL', - 'BAPM', - 'BARM', - 'BASM', - 'BIRT', - 'BLES', - 'BURI', - 'CHR', - 'CHRA', - 'CONF', - 'CREM', - 'DEAT', - 'DIV', - 'DIVF', - 'EMIG', - 'ENGA', - 'FCOM', - 'GRAD', - 'IMMI', - 'MARB', - 'MARC', - 'MARL', - 'MARR', - 'MARS', - 'NATU', - 'ORDN', - 'PROB', - 'RETI', - 'WILL', + 'ADOP' => 'INDI:ADOP', + 'ANUL' => 'FAM:ANUL', + 'BAPM' => 'INDI:BAPM', + 'BARM' => 'INDI:BARM', + 'BASM' => 'INDI:BASM', + 'BIRT' => 'INDI:BIRT', + 'BLES' => 'INDI:BLES', + 'BURI' => 'INDI:BURI', + 'CHR' => 'INDI:CHR', + 'CHRA' => 'INDI:CHRA', + 'CONF' => 'INDI:CONF', + 'CREM' => 'INDI:CREM', + 'DEAT' => 'INDI:DEAT', + 'DIV' => 'FAM:DIV', + 'DIVF' => 'FAM:DIVF', + 'EMIG' => 'INDI:EMIG', + 'ENGA' => 'FAM:ENGA', + 'FCOM' => 'INDI:FCOM', + 'GRAD' => 'INDI:GRAD', + 'IMMI' => 'INDI:IMMI', + 'MARB' => 'FAM:MARB', + 'MARC' => 'FAM:MARC', + 'MARL' => 'FAM:MARL', + 'MARR' => 'FAM:MARR', + 'MARS' => 'FAM:MARS', + 'NATU' => 'INDI:NATU', + 'ORDN' => 'INDI:ORDN', + 'PROB' => 'INDI:PROB', + 'RETI' => 'INDI:RETI', + 'WILL' => 'INDI:WILL', ]; private const DEFAULT_EVENTS = [ @@ -265,8 +265,8 @@ class UpcomingAnniversariesModule extends AbstractModule implements ModuleBlockI $event_array = explode(',', $events); $all_events = []; - foreach (self::ALL_EVENTS as $event) { - $all_events[$event] = GedcomTag::getLabel($event); + foreach (self::ALL_EVENTS as $event => $tag) { + $all_events[$event] = Registry::elementFactory()->make($tag)->label(); } $info_styles = [ diff --git a/app/Services/ClipboardService.php b/app/Services/ClipboardService.php index 07e316d601..e576d2e3d2 100644 --- a/app/Services/ClipboardService.php +++ b/app/Services/ClipboardService.php @@ -24,6 +24,8 @@ use Fisharebest\Webtrees\GedcomRecord; use Fisharebest\Webtrees\Session; use Illuminate\Support\Collection; +use function explode; + /** * Copy and past facts between records. */ @@ -46,10 +48,7 @@ class ClipboardService // If we are copying the same fact twice, make sure the new one is at the end. unset($clipboard[$record_type][$fact_id]); - $clipboard[$record_type][$fact_id] = [ - 'factrec' => $fact->gedcom(), - 'fact' => $fact->getTag(), - ]; + $clipboard[$record_type][$fact_id] = $fact->gedcom(); // The clipboard only holds a limited number of facts. $clipboard[$record_type] = array_slice($clipboard[$record_type], -self::CLIPBOARD_SIZE); @@ -72,7 +71,7 @@ class ClipboardService $record_type = $record->tag(); if (isset($clipboard[$record_type][$fact_id])) { - $record->createFact($clipboard[$record_type][$fact_id]['factrec'], true); + $record->createFact($clipboard[$record_type][$fact_id], true); return true; } @@ -84,21 +83,18 @@ class ClipboardService * Create a list of facts that can be pasted into a given record * * @param GedcomRecord $record - * @param Collection $exclude_types * * @return Collection<Fact> */ - public function pastableFacts(GedcomRecord $record, Collection $exclude_types): Collection + public function pastableFacts(GedcomRecord $record): Collection { // The facts are stored in the session. return (new Collection(Session::get('clipboard', [])[$record->tag()] ?? [])) // Put the most recently copied fact at the top of the list. ->reverse() // Create facts for the record. - ->map(static function (array $clipping) use ($record): Fact { - return new Fact($clipping['factrec'], $record, md5($clipping['factrec'])); - })->filter(static function (Fact $fact) use ($exclude_types): bool { - return $exclude_types->isEmpty() || !$exclude_types->contains($fact->getTag()); + ->map(static function (string $clipping) use ($record): Fact { + return new Fact($clipping, $record, md5($clipping)); }); } @@ -116,11 +112,11 @@ class ClipboardService return (new Collection(Session::get('clipboard', []))) ->flatten(1) ->reverse() - ->map(static function (array $clipping) use ($record): Fact { - return new Fact($clipping['factrec'], $record, md5($clipping['factrec'])); + ->map(static function (string $clipping) use ($record): Fact { + return new Fact($clipping, $record, md5($clipping)); }) ->filter(static function (Fact $fact) use ($types): bool { - return $types->contains($fact->getTag()); + return $types->contains(explode(':', $fact->tag())[1]); }); } } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 2457fd2f27..71cff98390 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -101,11 +101,6 @@ parameters: path: app/Functions/FunctionsPrint.php - - message: "#^Argument of an invalid type array\\<int, string\\>\\|false supplied for foreach, only iterables are supported\\.$#" - count: 1 - path: app/Functions/FunctionsPrintFacts.php - - - message: "#^Parameter \\#3 \\$offset of function strpos expects int, int\\<0, max\\>\\|false given\\.$#" count: 1 path: app/Functions/FunctionsPrintFacts.php @@ -1565,11 +1560,6 @@ parameters: path: app/Services/CaptchaService.php - - message: "#^Method Fisharebest\\\\Webtrees\\\\Services\\\\ClipboardService\\:\\:pastableFacts\\(\\) has parameter \\$exclude_types with no value type specified in iterable type Illuminate\\\\Support\\\\Collection\\.$#" - count: 1 - path: app/Services/ClipboardService.php - - - message: "#^Method Fisharebest\\\\Webtrees\\\\Services\\\\ClipboardService\\:\\:pastableFactsOfType\\(\\) has parameter \\$types with no value type specified in iterable type Illuminate\\\\Support\\\\Collection\\.$#" count: 1 path: app/Services/ClipboardService.php diff --git a/resources/views/edit/new-individual.phtml b/resources/views/edit/new-individual.phtml index 66f721d144..d64e097f6f 100644 --- a/resources/views/edit/new-individual.phtml +++ b/resources/views/edit/new-individual.phtml @@ -5,7 +5,6 @@ use Fisharebest\Webtrees\Fact; use Fisharebest\Webtrees\Family; use Fisharebest\Webtrees\Functions\FunctionsEdit; use Fisharebest\Webtrees\Gedcom; -use Fisharebest\Webtrees\GedcomTag; use Fisharebest\Webtrees\Http\RequestHandlers\AddChildToFamilyAction; use Fisharebest\Webtrees\Http\RequestHandlers\AddChildToIndividualAction; use Fisharebest\Webtrees\Http\RequestHandlers\AddParentToIndividualAction; @@ -17,6 +16,7 @@ use Fisharebest\Webtrees\Http\RequestHandlers\EditRawFactPage; use Fisharebest\Webtrees\Http\RequestHandlers\ManageTrees; use Fisharebest\Webtrees\I18N; use Fisharebest\Webtrees\Individual; +use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\SurnameTradition; use Fisharebest\Webtrees\Tree; use Fisharebest\Webtrees\View; @@ -193,7 +193,8 @@ $bdm = ''; // used to copy '1 SOUR' to '2 SOUR' for BIRT DEAT MARR // Edit existing tags, grouped together if (preg_match_all('/2 ' . $tag . ' (.+)/', $namerec, $match)) { foreach ($match[1] as $value) { - echo FunctionsEdit::addSimpleTag($tree, '2 ' . $tag . ' ' . $value, '', GedcomTag::getLabel('NAME:' . $tag)); + $label = Registry::elementFactory()->make('INDI:NAME:' . $tag)->label(); + echo FunctionsEdit::addSimpleTag($tree, '2 ' . $tag . ' ' . $value, '', $label); if ($tag === '_MARNM') { preg_match_all('/\/([^\/]*)\//', $value, $matches); echo FunctionsEdit::addSimpleTag($tree, '2 _MARNM_SURN ' . implode(',', $matches[1])); @@ -202,7 +203,8 @@ $bdm = ''; // used to copy '1 SOUR' to '2 SOUR' for BIRT DEAT MARR } // Allow a new tag to be entered if (!array_key_exists($tag, $name_fields)) { - echo FunctionsEdit::addSimpleTag($tree, '0 ' . $tag, '', GedcomTag::getLabel('NAME:' . $tag)); + $label = Registry::elementFactory()->make('INDI:NAME:' . $tag)->label(); + echo FunctionsEdit::addSimpleTag($tree, '0 ' . $tag, '', $label); if ($tag === '_MARNM') { echo FunctionsEdit::addSimpleTag($tree, '0 _MARNM_SURN'); } diff --git a/resources/views/individual-name.phtml b/resources/views/individual-name.phtml index 72315ea4c3..4c3d32792e 100644 --- a/resources/views/individual-name.phtml +++ b/resources/views/individual-name.phtml @@ -4,7 +4,6 @@ use Fisharebest\Webtrees\Fact; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Functions\FunctionsPrint; use Fisharebest\Webtrees\Functions\FunctionsPrintFacts; -use Fisharebest\Webtrees\GedcomTag; use Fisharebest\Webtrees\Http\RequestHandlers\CopyFact; use Fisharebest\Webtrees\Http\RequestHandlers\DeleteFact; use Fisharebest\Webtrees\Http\RequestHandlers\EditName; @@ -59,7 +58,7 @@ if ($fact->isPendingDeletion()) { <?php [, $tag, $value] = $match ?> <?php if ($tag !== 'SOUR' && $tag !== 'NOTE') : ?> <dt class="col-md-4 col-lg-3"> - <?= GedcomTag::getLabel($tag) ?> + <?= Registry::elementFactory()->make($fact->tag() . ':' . $tag)->label() ?> </dt> <dd class="col-md-8 col-lg-9"> <?php if ($tag === 'TYPE') : ?> diff --git a/resources/views/modules/media-list/page.phtml b/resources/views/modules/media-list/page.phtml index 4e5f42f9b4..654602e06d 100644 --- a/resources/views/modules/media-list/page.phtml +++ b/resources/views/modules/media-list/page.phtml @@ -3,7 +3,6 @@ use Fisharebest\Webtrees\Auth; use Fisharebest\Webtrees\Functions\FunctionsPrint; use Fisharebest\Webtrees\Functions\FunctionsPrintFacts; -use Fisharebest\Webtrees\GedcomTag; use Fisharebest\Webtrees\I18N; use Fisharebest\Webtrees\Media; use Fisharebest\Webtrees\MediaFile; @@ -132,8 +131,11 @@ use League\Flysystem\FilesystemOperator; echo Registry::elementFactory()->make('OBJE:FILE')->labelValue($media_file->filename(), $media_object->tree()); } if (Auth::isEditor($tree)) { - foreach ($media_file->attributes($data_filesystem) as $tag => $value) { - echo GedcomTag::getLabelValue($tag, $value); + foreach ($media_file->attributes($data_filesystem) as $label => $value) { + $label = '<span class="label">' . $label . '</span>'; + $value = '<span class="value">' . $value . '</span>'; + + echo '<div>' . I18N::translate(/* I18N: e.g. "Occupation: farmer" */ '%1$s: %2$s', $label, $value) . '</div>'; } } } else { |
