1<?php 2 3/** 4 * webtrees: online genealogy 5 * Copyright (C) 2019 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 <http://www.gnu.org/licenses/>. 16 */ 17declare(strict_types=1); 18 19namespace Fisharebest\Webtrees\Module; 20 21use Fisharebest\Webtrees\Auth; 22use Fisharebest\Webtrees\I18N; 23use Fisharebest\Webtrees\Individual; 24use Illuminate\Support\Collection; 25 26/** 27 * Class RelativesTabModule 28 */ 29class RelativesTabModule extends AbstractModule implements ModuleTabInterface 30{ 31 use ModuleTabTrait; 32 33 /** 34 * How should this module be identified in the control panel, etc.? 35 * 36 * @return string 37 */ 38 public function title(): string 39 { 40 /* I18N: Name of a module */ 41 return I18N::translate('Families'); 42 } 43 44 /** 45 * A sentence describing what this module does. 46 * 47 * @return string 48 */ 49 public function description(): string 50 { 51 /* I18N: Description of the “Families” module */ 52 return I18N::translate('A tab showing the close relatives of an individual.'); 53 } 54 55 /** 56 * The default position for this tab. It can be changed in the control panel. 57 * 58 * @return int 59 */ 60 public function defaultTabOrder(): int 61 { 62 return 2; 63 } 64 65 /** 66 * Generate the HTML content of this tab. 67 * 68 * @param Individual $individual 69 * 70 * @return string 71 */ 72 public function getTabContent(Individual $individual): string 73 { 74 $tree = $individual->tree(); 75 if ($tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS')) { 76 $fam_access_level = Auth::PRIV_HIDE; 77 } else { 78 $fam_access_level = Auth::accessLevel($tree); 79 } 80 81 return view('modules/relatives/tab', [ 82 'fam_access_level' => $fam_access_level, 83 'can_edit' => $individual->canEdit(), 84 'individual' => $individual, 85 'parent_families' => $individual->childFamilies(), 86 'spouse_families' => $individual->spouseFamilies(), 87 'step_child_familiess' => $individual->spouseStepFamilies(), 88 'step_parent_families' => $individual->childStepFamilies(), 89 ]); 90 } 91 92 /** 93 * Is this tab empty? If so, we don't always need to display it. 94 * 95 * @param Individual $individual 96 * 97 * @return bool 98 */ 99 public function hasTabContent(Individual $individual): bool 100 { 101 return true; 102 } 103 104 /** 105 * A greyed out tab has no actual content, but may perhaps have 106 * options to create content. 107 * 108 * @param Individual $individual 109 * 110 * @return bool 111 */ 112 public function isGrayedOut(Individual $individual): bool 113 { 114 return false; 115 } 116 117 /** 118 * Can this tab load asynchronously? 119 * 120 * @return bool 121 */ 122 public function canLoadAjax(): bool 123 { 124 return false; 125 } 126 127 /** 128 * This module handles the following facts - so don't show them on the "Facts and events" tab. 129 * 130 * @return Collection 131 */ 132 public function supportedFacts(): Collection 133 { 134 return new Collection(['FAMC', 'FAMS', 'HUSB', 'WIFE', 'CHIL']); 135 } 136} 137