xref: /webtrees/app/Module/CompactTreeChartModule.php (revision 8fcd0d32e56ee262912bbdb593202cfd1cbc1615)
1168ff6f3Sric2016<?php
2168ff6f3Sric2016/**
3168ff6f3Sric2016 * webtrees: online genealogy
4*8fcd0d32SGreg 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\Auth;
21168ff6f3Sric2016use Fisharebest\Webtrees\I18N;
22168ff6f3Sric2016use Fisharebest\Webtrees\Individual;
23e46b0479SScrutinizer Auto-Fixeruse Fisharebest\Webtrees\Menu;
24168ff6f3Sric2016
25168ff6f3Sric2016/**
26168ff6f3Sric2016 * Class CompactTreeChartModule
27168ff6f3Sric2016 */
28c1010edaSGreg Roachclass CompactTreeChartModule extends AbstractModule implements ModuleChartInterface
29c1010edaSGreg Roach{
30168ff6f3Sric2016    /**
31168ff6f3Sric2016     * How should this module be labelled on tabs, menus, etc.?
32168ff6f3Sric2016     *
33168ff6f3Sric2016     * @return string
34168ff6f3Sric2016     */
358f53f488SRico Sonntag    public function getTitle(): string
36c1010edaSGreg Roach    {
37bbb76c12SGreg Roach        /* I18N: Name of a module/chart */
38bbb76c12SGreg Roach        return I18N::translate('Compact tree');
39168ff6f3Sric2016    }
40168ff6f3Sric2016
41168ff6f3Sric2016    /**
42168ff6f3Sric2016     * A sentence describing what this module does.
43168ff6f3Sric2016     *
44168ff6f3Sric2016     * @return string
45168ff6f3Sric2016     */
468f53f488SRico Sonntag    public function getDescription(): string
47c1010edaSGreg Roach    {
48bbb76c12SGreg Roach        /* I18N: Description of the “CompactTreeChart” module */
49bbb76c12SGreg Roach        return I18N::translate('A chart of an individual’s ancestors, as a compact tree.');
50168ff6f3Sric2016    }
51168ff6f3Sric2016
52168ff6f3Sric2016    /**
53168ff6f3Sric2016     * What is the default access level for this module?
54168ff6f3Sric2016     *
55168ff6f3Sric2016     * Some modules are aimed at admins or managers, and are not generally shown to users.
56168ff6f3Sric2016     *
57168ff6f3Sric2016     * @return int
58168ff6f3Sric2016     */
598f53f488SRico Sonntag    public function defaultAccessLevel(): int
60c1010edaSGreg Roach    {
61168ff6f3Sric2016        return Auth::PRIV_PRIVATE;
62168ff6f3Sric2016    }
63168ff6f3Sric2016
64168ff6f3Sric2016    /**
65168ff6f3Sric2016     * Return a menu item for this chart.
66168ff6f3Sric2016     *
6760bc3e3fSGreg Roach     * @param Individual $individual
6860bc3e3fSGreg Roach     *
694eb71cfaSGreg Roach     * @return Menu|null
70168ff6f3Sric2016     */
71c1010edaSGreg Roach    public function getChartMenu(Individual $individual)
72c1010edaSGreg Roach    {
73168ff6f3Sric2016        return new Menu(
74168ff6f3Sric2016            $this->getTitle(),
75c1010edaSGreg Roach            route('compact-tree', [
76c0935879SGreg Roach                'xref' => $individual->xref(),
77f4afa648SGreg Roach                'ged'  => $individual->tree()->name(),
78c1010edaSGreg Roach            ]),
79168ff6f3Sric2016            'menu-chart-compact',
8013abd6f3SGreg Roach            ['rel' => 'nofollow']
81168ff6f3Sric2016        );
82168ff6f3Sric2016    }
83168ff6f3Sric2016
844eb71cfaSGreg Roach    /**
854eb71cfaSGreg Roach     * Return a menu item for this chart - for use in individual boxes.
864eb71cfaSGreg Roach     *
8760bc3e3fSGreg Roach     * @param Individual $individual
8860bc3e3fSGreg Roach     *
894eb71cfaSGreg Roach     * @return Menu|null
904eb71cfaSGreg Roach     */
91c1010edaSGreg Roach    public function getBoxChartMenu(Individual $individual)
92c1010edaSGreg Roach    {
93168ff6f3Sric2016        return $this->getChartMenu($individual);
94168ff6f3Sric2016    }
95168ff6f3Sric2016}
96