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 */ 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 /** 31e284d69fSGreg Roach * @return string 32e284d69fSGreg Roach */ 33e284d69fSGreg Roach abstract public function name(): string; 34e284d69fSGreg Roach 35e284d69fSGreg Roach /** 36e284d69fSGreg Roach * @return string 37e284d69fSGreg Roach */ 38e284d69fSGreg Roach abstract public function title(): string; 39e284d69fSGreg Roach 40e284d69fSGreg Roach /** 41377a2979SGreg Roach * A menu item for this chart for an individual box in a chart. 42377a2979SGreg Roach * 43377a2979SGreg Roach * @param Individual $individual 44377a2979SGreg Roach * 45377a2979SGreg Roach * @return Menu|null 46377a2979SGreg Roach */ 47377a2979SGreg Roach public function chartBoxMenu(Individual $individual): ?Menu 48377a2979SGreg Roach { 49377a2979SGreg Roach return null; 50377a2979SGreg Roach } 51377a2979SGreg Roach 52377a2979SGreg Roach /** 53e6562982SGreg Roach * A main menu item for this chart. 5449a243cbSGreg Roach * 5549a243cbSGreg Roach * @param Individual $individual 5649a243cbSGreg Roach * 57e6562982SGreg Roach * @return Menu 5849a243cbSGreg Roach */ 59e6562982SGreg Roach public function chartMenu(Individual $individual): Menu 60e6562982SGreg Roach { 61e6562982SGreg Roach return new Menu( 62e6562982SGreg Roach $this->title(), 63e6562982SGreg Roach $this->chartUrl($individual), 64377a2979SGreg Roach $this->chartMenuClass(), 65e6562982SGreg Roach $this->chartUrlAttributes() 66e6562982SGreg Roach ); 67e6562982SGreg Roach } 68e6562982SGreg Roach 69e6562982SGreg Roach /** 70377a2979SGreg Roach * CSS class for the menu. 71e6562982SGreg Roach * 72377a2979SGreg Roach * @return string 73e6562982SGreg Roach */ 74377a2979SGreg Roach public function chartMenuClass(): string 7549a243cbSGreg Roach { 76377a2979SGreg Roach return ''; 7749a243cbSGreg Roach } 7849a243cbSGreg Roach 7949a243cbSGreg Roach /** 80e6562982SGreg Roach * The title for a specific instance of this chart. 8149a243cbSGreg Roach * 8249a243cbSGreg Roach * @param Individual $individual 8349a243cbSGreg Roach * 84e6562982SGreg Roach * @return string 8549a243cbSGreg Roach */ 86e6562982SGreg Roach public function chartTitle(Individual $individual): string 8749a243cbSGreg Roach { 88e6562982SGreg Roach return $this->title(); 89e6562982SGreg Roach } 90e6562982SGreg Roach 91e6562982SGreg Roach /** 92e539f5c6SGreg Roach * The URL for a page showing chart options. 93e6562982SGreg Roach * 94e6562982SGreg Roach * @param Individual $individual 95*59597b37SGreg Roach * @param mixed[] $parameters 96e6562982SGreg Roach * 97e6562982SGreg Roach * @return string 98e6562982SGreg Roach */ 99e6562982SGreg Roach public function chartUrl(Individual $individual, array $parameters = []): string 100e6562982SGreg Roach { 101e539f5c6SGreg Roach return route('module', [ 10226684e68SGreg Roach 'module' => $this->name(), 103e539f5c6SGreg Roach 'action' => 'Chart', 104e539f5c6SGreg Roach 'xref' => $individual->xref(), 105d72b284aSGreg Roach 'tree' => $individual->tree()->name(), 106e539f5c6SGreg Roach ] + $parameters); 107e6562982SGreg Roach } 108e6562982SGreg Roach 109e6562982SGreg Roach /** 110e6562982SGreg Roach * Attributes for the URL. 111e6562982SGreg Roach * 112e6562982SGreg Roach * @return string[] 113e6562982SGreg Roach */ 114e6562982SGreg Roach public function chartUrlAttributes(): array 115e6562982SGreg Roach { 116e6562982SGreg Roach return ['rel' => 'nofollow']; 117e6562982SGreg Roach } 11849a243cbSGreg Roach} 119