Issues (2563)

app/Elements/Census.php (1 issue)

Labels
Severity
1
<?php
2
3
/**
4
 * webtrees: online genealogy
5
 * Copyright (C) 2025 webtrees development team
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
 * GNU General Public License for more details.
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16
 */
17
18
declare(strict_types=1);
19
20
namespace Fisharebest\Webtrees\Elements;
21
22
use Fisharebest\Webtrees\Census\Census as Censuses;
23
use Fisharebest\Webtrees\I18N;
24
use Fisharebest\Webtrees\Individual;
25
use Fisharebest\Webtrees\Module\CensusAssistantModule;
26
use Fisharebest\Webtrees\Registry;
27
use Fisharebest\Webtrees\Services\ModuleService;
28
use Fisharebest\Webtrees\Tree;
29
use Fisharebest\Webtrees\Validator;
30
use Psr\Http\Message\ServerRequestInterface;
31
32
/**
33
 * Census
34
 */
35
class Census extends AbstractEventElement
36
{
37
    protected const array SUBTAGS = [
0 ignored issues
show
A parse error occurred: Syntax error, unexpected T_STRING, expecting '=' on line 37 at column 26
Loading history...
38
        'TYPE'  => '0:1:?',
39
        'DATE'  => '0:1',
40
        'AGE'   => '0:1',
41
        'PLAC'  => '0:1',
42
        'ADDR'  => '0:1',
43
        'EMAIL' => '0:1:?',
44
        'WWW'   => '0:1:?',
45
        'PHON'  => '0:1:?',
46
        'FAX'   => '0:1:?',
47
        'CAUS'  => '0:1:?',
48
        'AGNC'  => '0:1:?',
49
        'RELI'  => '0:1:?',
50
        'NOTE'  => '0:M',
51
        'OBJE'  => '0:M',
52
        'SOUR'  => '0:M',
53
        'RESN'  => '0:1',
54
    ];
55
56
    /**
57
     * An edit control for this data.
58
     *
59
     * @param string $id
60
     * @param string $name
61
     * @param string $value
62
     * @param Tree   $tree
63
     *
64
     * @return string
65
     */
66
    public function edit(string $id, string $name, string $value, Tree $tree): string
67
    {
68
        $html = $this->editHidden($id, $name, $value);
69
70
        $html .= view('modules/GEDFact_assistant/select-census', [
71
            'census_places' => Censuses::censusPlaces(I18N::languageTag()),
72
        ]);
73
74
        $request = Registry::container()->get(ServerRequestInterface::class);
75
76
        $xref = Validator::attributes($request)->isXref()->string('xref', '');
77
78
        $module_service = Registry::container()->get(ModuleService::class);
79
80
        $census_assistant = $module_service->findByInterface(CensusAssistantModule::class)->first();
81
        $record           = Registry::individualFactory()->make($xref, $tree);
82
83
        if ($census_assistant instanceof CensusAssistantModule && $record instanceof Individual) {
84
            $html .= $census_assistant->createCensusAssistant($record);
85
        }
86
87
        return $html;
88
    }
89
}
90