diff options
| author | Greg Roach <greg@subaqua.co.uk> | 2021-07-17 09:19:07 +0100 |
|---|---|---|
| committer | Greg Roach <greg@subaqua.co.uk> | 2021-07-17 09:27:41 +0100 |
| commit | c8fd93486d297904a43757cecab7a8694c4f3f21 (patch) | |
| tree | 52fa9cfcb82187da03f913fece9e27d8d392c452 /app | |
| parent | 2f86083cc04612ee254f40b0d8f158aab531a29f (diff) | |
| download | webtrees-c8fd93486d297904a43757cecab7a8694c4f3f21.tar.gz webtrees-c8fd93486d297904a43757cecab7a8694c4f3f21.tar.bz2 webtrees-c8fd93486d297904a43757cecab7a8694c4f3f21.zip | |
Labels on advanced search page
Diffstat (limited to 'app')
| -rw-r--r-- | app/Http/RequestHandlers/SearchAdvancedPage.php | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/app/Http/RequestHandlers/SearchAdvancedPage.php b/app/Http/RequestHandlers/SearchAdvancedPage.php index e44f862976..bd35e22ae2 100644 --- a/app/Http/RequestHandlers/SearchAdvancedPage.php +++ b/app/Http/RequestHandlers/SearchAdvancedPage.php @@ -19,7 +19,6 @@ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; -use Fisharebest\Webtrees\GedcomTag; use Fisharebest\Webtrees\Http\ViewResponseTrait; use Fisharebest\Webtrees\I18N; use Fisharebest\Webtrees\Registry; @@ -33,8 +32,9 @@ use Psr\Http\Server\RequestHandlerInterface; use function array_fill_keys; use function array_filter; use function array_key_exists; +use function array_merge; use function assert; -use function ord; +use function strtr; /** * Search for genealogy data @@ -167,7 +167,7 @@ class SearchAdvancedPage implements RequestHandlerInterface return $this->viewResponse('search-advanced-page', [ 'date_options' => $date_options, 'fields' => $fields, - 'field_labels' => $this->customFieldLabels(), + 'field_labels' => $this->fieldLabels(), 'individuals' => $individuals, 'modifiers' => $modifiers, 'name_options' => $name_options, @@ -200,7 +200,7 @@ class SearchAdvancedPage implements RequestHandlerInterface return $default_facts ->reject(fn (string $field): bool => array_key_exists($field, $fields)) ->sort($comparator) - ->mapWithKeys(fn (string $fact): array => [$fact => GedcomTag::getLabel($fact)]) + ->mapWithKeys(fn (string $fact): array => [$fact => Registry::elementFactory()->make($fact)->label()]) ->all(); } @@ -210,14 +210,18 @@ class SearchAdvancedPage implements RequestHandlerInterface * * @return array<string,string> */ - private function customFieldLabels(): array + private function fieldLabels(): array { - return [ - 'FATHER:NAME:GIVN' => I18N::translate('Given names'), - 'FATHER:NAME:SURN' => I18N::translate('Surname'), - 'MOTHER:NAME:GIVN' => I18N::translate('Given names'), - 'MOTHER:NAME:SURN' => I18N::translate('Surname'), - ]; + + $return = []; + + foreach (array_merge(self::OTHER_ADVANCED_FIELDS, self::DEFAULT_ADVANCED_FIELDS) as $field) { + $tmp = strtr($field, ['MOTHER:' => 'INDI:', 'FATHER:' => 'INDI:']); + $return[$field] = Registry::elementFactory()->make($tmp)->label(); + } + + + return $return; } /** |
