149a243cbSGreg Roach<?php 23976b470SGreg Roach 349a243cbSGreg Roach/** 449a243cbSGreg Roach * webtrees: online genealogy 5*89f7189bSGreg Roach * Copyright (C) 2021 webtrees development team 649a243cbSGreg Roach * This program is free software: you can redistribute it and/or modify 749a243cbSGreg Roach * it under the terms of the GNU General Public License as published by 849a243cbSGreg Roach * the Free Software Foundation, either version 3 of the License, or 949a243cbSGreg Roach * (at your option) any later version. 1049a243cbSGreg Roach * This program is distributed in the hope that it will be useful, 1149a243cbSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 1249a243cbSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1349a243cbSGreg Roach * GNU General Public License for more details. 1449a243cbSGreg Roach * You should have received a copy of the GNU General Public License 15*89f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>. 1649a243cbSGreg Roach */ 17fcfa147eSGreg Roach 1849a243cbSGreg Roachdeclare(strict_types=1); 1949a243cbSGreg Roach 2049a243cbSGreg Roachnamespace Fisharebest\Webtrees\Module; 2149a243cbSGreg Roach 2249a243cbSGreg Roachuse Fisharebest\Webtrees\Individual; 2349a243cbSGreg Roachuse Fisharebest\Webtrees\Menu; 2449a243cbSGreg Roach 2549a243cbSGreg Roach/** 2649a243cbSGreg Roach * Trait ModuleChartTrait - default implementation of ModuleChartInterface 2749a243cbSGreg Roach */ 2849a243cbSGreg Roachtrait ModuleChartTrait 2949a243cbSGreg Roach{ 3049a243cbSGreg Roach /** 31377a2979SGreg Roach * A menu item for this chart for an individual box in a chart. 32377a2979SGreg Roach * 33377a2979SGreg Roach * @param Individual $individual 34377a2979SGreg Roach * 35377a2979SGreg Roach * @return Menu|null 36377a2979SGreg Roach */ 37377a2979SGreg Roach public function chartBoxMenu(Individual $individual): ?Menu 38377a2979SGreg Roach { 39377a2979SGreg Roach return null; 40377a2979SGreg Roach } 41377a2979SGreg Roach 42377a2979SGreg Roach /** 43e6562982SGreg Roach * A main menu item for this chart. 4449a243cbSGreg Roach * 4549a243cbSGreg Roach * @param Individual $individual 4649a243cbSGreg Roach * 47e6562982SGreg Roach * @return Menu 4849a243cbSGreg Roach */ 49e6562982SGreg Roach public function chartMenu(Individual $individual): Menu 50e6562982SGreg Roach { 51e6562982SGreg Roach return new Menu( 52e6562982SGreg Roach $this->title(), 53e6562982SGreg Roach $this->chartUrl($individual), 54377a2979SGreg Roach $this->chartMenuClass(), 55e6562982SGreg Roach $this->chartUrlAttributes() 56e6562982SGreg Roach ); 57e6562982SGreg Roach } 58e6562982SGreg Roach 59e6562982SGreg Roach /** 60377a2979SGreg Roach * CSS class for the menu. 61e6562982SGreg Roach * 62377a2979SGreg Roach * @return string 63e6562982SGreg Roach */ 64377a2979SGreg Roach public function chartMenuClass(): string 6549a243cbSGreg Roach { 66377a2979SGreg Roach return ''; 6749a243cbSGreg Roach } 6849a243cbSGreg Roach 6949a243cbSGreg Roach /** 70e6562982SGreg Roach * The title for a specific instance of this chart. 7149a243cbSGreg Roach * 7249a243cbSGreg Roach * @param Individual $individual 7349a243cbSGreg Roach * 74e6562982SGreg Roach * @return string 7549a243cbSGreg Roach */ 76e6562982SGreg Roach public function chartTitle(Individual $individual): string 7749a243cbSGreg Roach { 78e6562982SGreg Roach return $this->title(); 79e6562982SGreg Roach } 80e6562982SGreg Roach 81e6562982SGreg Roach /** 82e539f5c6SGreg Roach * The URL for a page showing chart options. 83e6562982SGreg Roach * 84e6562982SGreg Roach * @param Individual $individual 8559597b37SGreg Roach * @param mixed[] $parameters 86e6562982SGreg Roach * 87e6562982SGreg Roach * @return string 88e6562982SGreg Roach */ 89e6562982SGreg Roach public function chartUrl(Individual $individual, array $parameters = []): string 90e6562982SGreg Roach { 91e539f5c6SGreg Roach return route('module', [ 9226684e68SGreg Roach 'module' => $this->name(), 93e539f5c6SGreg Roach 'action' => 'Chart', 94e539f5c6SGreg Roach 'xref' => $individual->xref(), 95d72b284aSGreg Roach 'tree' => $individual->tree()->name(), 96e539f5c6SGreg Roach ] + $parameters); 97e6562982SGreg Roach } 98e6562982SGreg Roach 99e6562982SGreg Roach /** 100e6562982SGreg Roach * Attributes for the URL. 101e6562982SGreg Roach * 102e6562982SGreg Roach * @return string[] 103e6562982SGreg Roach */ 104e6562982SGreg Roach public function chartUrlAttributes(): array 105e6562982SGreg Roach { 106e6562982SGreg Roach return ['rel' => 'nofollow']; 107e6562982SGreg Roach } 10849a243cbSGreg Roach} 109