149a243cbSGreg Roach<?php 23976b470SGreg Roach 349a243cbSGreg Roach/** 449a243cbSGreg Roach * webtrees: online genealogy 549a243cbSGreg Roach * Copyright (C) 2019 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 1549a243cbSGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 1649a243cbSGreg Roach */ 1749a243cbSGreg Roachdeclare(strict_types=1); 1849a243cbSGreg Roach 1949a243cbSGreg Roachnamespace Fisharebest\Webtrees\Module; 2049a243cbSGreg Roach 2149a243cbSGreg Roachuse Fisharebest\Webtrees\Individual; 2249a243cbSGreg Roachuse Fisharebest\Webtrees\Menu; 2349a243cbSGreg Roach 2449a243cbSGreg Roach/** 2549a243cbSGreg Roach * Trait ModuleChartTrait - default implementation of ModuleChartInterface 2649a243cbSGreg Roach */ 2749a243cbSGreg Roachtrait ModuleChartTrait 2849a243cbSGreg Roach{ 2949a243cbSGreg Roach /** 30e284d69fSGreg Roach * @return string 31e284d69fSGreg Roach */ 32e284d69fSGreg Roach abstract public function name(): string; 33e284d69fSGreg Roach 34e284d69fSGreg Roach /** 35e284d69fSGreg Roach * @return string 36e284d69fSGreg Roach */ 37e284d69fSGreg Roach abstract public function title(): string; 38e284d69fSGreg Roach 39e284d69fSGreg Roach /** 40377a2979SGreg Roach * A menu item for this chart for an individual box in a chart. 41377a2979SGreg Roach * 42377a2979SGreg Roach * @param Individual $individual 43377a2979SGreg Roach * 44377a2979SGreg Roach * @return Menu|null 45377a2979SGreg Roach */ 46377a2979SGreg Roach public function chartBoxMenu(Individual $individual): ?Menu 47377a2979SGreg Roach { 48377a2979SGreg Roach return null; 49377a2979SGreg Roach } 50377a2979SGreg Roach 51377a2979SGreg Roach /** 52e6562982SGreg Roach * A main menu item for this chart. 5349a243cbSGreg Roach * 5449a243cbSGreg Roach * @param Individual $individual 5549a243cbSGreg Roach * 56e6562982SGreg Roach * @return Menu 5749a243cbSGreg Roach */ 58e6562982SGreg Roach public function chartMenu(Individual $individual): Menu 59e6562982SGreg Roach { 60e6562982SGreg Roach return new Menu( 61e6562982SGreg Roach $this->title(), 62e6562982SGreg Roach $this->chartUrl($individual), 63377a2979SGreg Roach $this->chartMenuClass(), 64e6562982SGreg Roach $this->chartUrlAttributes() 65e6562982SGreg Roach ); 66e6562982SGreg Roach } 67e6562982SGreg Roach 68e6562982SGreg Roach /** 69377a2979SGreg Roach * CSS class for the menu. 70e6562982SGreg Roach * 71377a2979SGreg Roach * @return string 72e6562982SGreg Roach */ 73377a2979SGreg Roach public function chartMenuClass(): string 7449a243cbSGreg Roach { 75377a2979SGreg Roach return ''; 7649a243cbSGreg Roach } 7749a243cbSGreg Roach 7849a243cbSGreg Roach /** 79e6562982SGreg Roach * The title for a specific instance of this chart. 8049a243cbSGreg Roach * 8149a243cbSGreg Roach * @param Individual $individual 8249a243cbSGreg Roach * 83e6562982SGreg Roach * @return string 8449a243cbSGreg Roach */ 85e6562982SGreg Roach public function chartTitle(Individual $individual): string 8649a243cbSGreg Roach { 87e6562982SGreg Roach return $this->title(); 88e6562982SGreg Roach } 89e6562982SGreg Roach 90e6562982SGreg Roach /** 91e539f5c6SGreg Roach * The URL for a page showing chart options. 92e6562982SGreg Roach * 93e6562982SGreg Roach * @param Individual $individual 94e6562982SGreg Roach * @param string[] $parameters 95e6562982SGreg Roach * 96e6562982SGreg Roach * @return string 97e6562982SGreg Roach */ 98e6562982SGreg Roach public function chartUrl(Individual $individual, array $parameters = []): string 99e6562982SGreg Roach { 100e539f5c6SGreg Roach return route('module', [ 10126684e68SGreg Roach 'module' => $this->name(), 102e539f5c6SGreg Roach 'action' => 'Chart', 103e539f5c6SGreg Roach 'xref' => $individual->xref(), 104*d72b284aSGreg Roach 'tree' => $individual->tree()->name(), 105e539f5c6SGreg Roach ] + $parameters); 106e6562982SGreg Roach } 107e6562982SGreg Roach 108e6562982SGreg Roach /** 109e6562982SGreg Roach * Attributes for the URL. 110e6562982SGreg Roach * 111e6562982SGreg Roach * @return string[] 112e6562982SGreg Roach */ 113e6562982SGreg Roach public function chartUrlAttributes(): array 114e6562982SGreg Roach { 115e6562982SGreg Roach return ['rel' => 'nofollow']; 116e6562982SGreg Roach } 11749a243cbSGreg Roach} 118