xref: /webtrees/app/Module/DescendancyChartModule.php (revision 377a29797a07fe877e9e6e01be7acab2085830fe)
1168ff6f3Sric2016<?php
2168ff6f3Sric2016/**
3168ff6f3Sric2016 * webtrees: online genealogy
48fcd0d32SGreg Roach * Copyright (C) 2019 webtrees development team
5168ff6f3Sric2016 * This program is free software: you can redistribute it and/or modify
6168ff6f3Sric2016 * it under the terms of the GNU General Public License as published by
7168ff6f3Sric2016 * the Free Software Foundation, either version 3 of the License, or
8168ff6f3Sric2016 * (at your option) any later version.
9168ff6f3Sric2016 * This program is distributed in the hope that it will be useful,
10168ff6f3Sric2016 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11168ff6f3Sric2016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12168ff6f3Sric2016 * GNU General Public License for more details.
13168ff6f3Sric2016 * You should have received a copy of the GNU General Public License
14168ff6f3Sric2016 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15168ff6f3Sric2016 */
16e7f56f2aSGreg Roachdeclare(strict_types=1);
17e7f56f2aSGreg Roach
18168ff6f3Sric2016namespace Fisharebest\Webtrees\Module;
19168ff6f3Sric2016
20168ff6f3Sric2016use Fisharebest\Webtrees\I18N;
21168ff6f3Sric2016use Fisharebest\Webtrees\Individual;
22e46b0479SScrutinizer Auto-Fixeruse Fisharebest\Webtrees\Menu;
23168ff6f3Sric2016
24168ff6f3Sric2016/**
25168ff6f3Sric2016 * Class DescendancyChartModule
26168ff6f3Sric2016 */
2749a243cbSGreg Roachclass DescendancyChartModule extends AbstractModule implements ModuleInterface, ModuleChartInterface
28c1010edaSGreg Roach{
2949a243cbSGreg Roach    use ModuleChartTrait;
3049a243cbSGreg Roach
31168ff6f3Sric2016    /**
32168ff6f3Sric2016     * How should this module be labelled on tabs, menus, etc.?
33168ff6f3Sric2016     *
34168ff6f3Sric2016     * @return string
35168ff6f3Sric2016     */
3649a243cbSGreg Roach    public function title(): string
37c1010edaSGreg Roach    {
38bbb76c12SGreg Roach        /* I18N: Name of a module/chart */
39bbb76c12SGreg Roach        return I18N::translate('Descendants');
40168ff6f3Sric2016    }
41168ff6f3Sric2016
42168ff6f3Sric2016    /**
43168ff6f3Sric2016     * A sentence describing what this module does.
44168ff6f3Sric2016     *
45168ff6f3Sric2016     * @return string
46168ff6f3Sric2016     */
4749a243cbSGreg Roach    public function description(): string
48c1010edaSGreg Roach    {
49bbb76c12SGreg Roach        /* I18N: Description of the “DescendancyChart” module */
50bbb76c12SGreg Roach        return I18N::translate('A chart of an individual’s descendants.');
51168ff6f3Sric2016    }
52168ff6f3Sric2016
53168ff6f3Sric2016    /**
54*377a2979SGreg Roach     * CSS class for the URL.
55*377a2979SGreg Roach     *
56*377a2979SGreg Roach     * @return string
57*377a2979SGreg Roach     */
58*377a2979SGreg Roach    public function chartMenuClass(): string
59*377a2979SGreg Roach    {
60*377a2979SGreg Roach        return 'menu-chart-descendants';
61*377a2979SGreg Roach    }
62*377a2979SGreg Roach
63*377a2979SGreg Roach    /**
644eb71cfaSGreg Roach     * Return a menu item for this chart - for use in individual boxes.
654eb71cfaSGreg Roach     *
6660bc3e3fSGreg Roach     * @param Individual $individual
6760bc3e3fSGreg Roach     *
684eb71cfaSGreg Roach     * @return Menu|null
694eb71cfaSGreg Roach     */
70*377a2979SGreg Roach    public function chartBoxMenu(Individual $individual): ?Menu
71c1010edaSGreg Roach    {
72e6562982SGreg Roach        return $this->chartMenu($individual);
73e6562982SGreg Roach    }
74e6562982SGreg Roach
75e6562982SGreg Roach    /**
76e6562982SGreg Roach     * The title for a specific instance of this chart.
77e6562982SGreg Roach     *
78e6562982SGreg Roach     * @param Individual $individual
79e6562982SGreg Roach     *
80e6562982SGreg Roach     * @return string
81e6562982SGreg Roach     */
82e6562982SGreg Roach    public function chartTitle(Individual $individual): string
83e6562982SGreg Roach    {
84e6562982SGreg Roach        /* I18N: %s is an individual’s name */
85e6562982SGreg Roach        return I18N::translate('Descendants of %s', $individual->getFullName());
86e6562982SGreg Roach    }
87e6562982SGreg Roach
88e6562982SGreg Roach    /**
89e6562982SGreg Roach     * The URL for this chart.
90e6562982SGreg Roach     *
91e6562982SGreg Roach     * @param Individual $individual
92e6562982SGreg Roach     * @param string[]   $parameters
93e6562982SGreg Roach     *
94e6562982SGreg Roach     * @return string
95e6562982SGreg Roach     */
96e6562982SGreg Roach    public function chartUrl(Individual $individual, array $parameters = []): string
97e6562982SGreg Roach    {
98e6562982SGreg Roach        return route('descendants', [
99e6562982SGreg Roach            'ged'  => $individual->tree()->name(),
100e6562982SGreg Roach            'xref' => $individual->xref(),
101e6562982SGreg Roach        ] + $parameters);
102e6562982SGreg Roach    }
103168ff6f3Sric2016}
104