1<?php 2 3/** 4 * webtrees: online genealogy 5 * Copyright (C) 2023 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 18declare(strict_types=1); 19 20namespace Fisharebest\Webtrees\Elements; 21 22use Fisharebest\Webtrees\Family; 23use Fisharebest\Webtrees\I18N; 24use Fisharebest\Webtrees\Individual; 25use Fisharebest\Webtrees\Registry; 26 27use function uasort; 28 29/** 30 * EVENT_OR_FACT_CLASSIFICATION := {Size=1:15} 31 * [ <EVENT_ATTRIBUTE_TYPE> ] 32 * A code that indicates the type of event which was responsible for the source 33 * entry being recorded. For example, if the entry was created to record a 34 * birth of a child, then the type would be BIRT regardless of the assertions 35 * made from that record, such as the mother's name or mother's birth date. 36 * This will allow a prioritized best view choice and a determination of the 37 * certainty associated with the source used in asserting the cited fact. 38 */ 39class EventTypeCitedFrom extends AbstractElement 40{ 41 protected const MAXIMUM_LENGTH = 15; 42 43 protected const SUBTAGS = [ 44 'ROLE' => '0:1', 45 ]; 46 47 protected const FAMILY_EVENTS = [ 48 'ANUL', 49 'CENS', 50 'DIV', 51 'DIVF', 52 'ENGA', 53 'MARR', 54 'MARB', 55 'MARC', 56 'MARL', 57 'MARS', 58 'EVEN', 59 ]; 60 61 protected const INDIVIDUAL_EVENTS = [ 62 'ADOP', 63 'BIRT', 64 'BAPM', 65 'BARM', 66 'BASM', 67 'BLES', 68 'BURI', 69 'CENS', 70 'CHR', 71 'CHRA', 72 'CONF', 73 'CREM', 74 'DEAT', 75 'EMIG', 76 'FCOM', 77 'GRAD', 78 'IMMI', 79 'NATU', 80 'ORDN', 81 'RETI', 82 'PROB', 83 'WILL', 84 'EVEN', 85 ]; 86 87 protected const ATTRIBUTE_TYPES = [ 88 'CAST', 89 'EDUC', 90 'NATI', 91 'OCCU', 92 'PROP', 93 'RELI', 94 'RESI', 95 'TITL', 96 'FACT', 97 ]; 98 99 /** 100 * A list of controlled values for this element 101 * 102 * @return array<int|string,string> 103 */ 104 public function values(): array 105 { 106 $data = [ 107 Family::RECORD_TYPE => static::FAMILY_EVENTS, 108 Individual::RECORD_TYPE => array_merge(static::INDIVIDUAL_EVENTS, static::ATTRIBUTE_TYPES), 109 ]; 110 111 $values = ['' => '']; 112 113 foreach ($data as $record_type => $subtags) { 114 foreach ($subtags as $subtag) { 115 $element = Registry::elementFactory()->make($record_type . ':' . $subtag); 116 117 if (!$element instanceof UnknownElement) { 118 $values[$subtag] = $element->label(); 119 } 120 } 121 } 122 123 uasort($values, I18N::comparator()); 124 125 return $values; 126 } 127} 128