xref: /webtrees/app/Module/FanChartModule.php (revision 0ea23b7829d8bd38dc862b61285e14b0e1858a16)
1<?php
2/**
3 * webtrees: online genealogy
4 * Copyright (C) 2018 webtrees development team
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16namespace Fisharebest\Webtrees\Module;
17
18use Fisharebest\Webtrees\Auth;
19use Fisharebest\Webtrees\I18N;
20use Fisharebest\Webtrees\Individual;
21use Fisharebest\Webtrees\Menu;
22
23/**
24 * Class FanChartModule
25 */
26class FanChartModule extends AbstractModule implements ModuleChartInterface
27{
28    /**
29     * How should this module be labelled on tabs, menus, etc.?
30     *
31     * @return string
32     */
33    public function getTitle(): string
34    {
35        /* I18N: Name of a module/chart */
36        return I18N::translate('Fan chart');
37    }
38
39    /**
40     * A sentence describing what this module does.
41     *
42     * @return string
43     */
44    public function getDescription(): string
45    {
46        /* I18N: Description of the “Fan Chart” module */
47        return I18N::translate('A fan chart of an individual’s ancestors.');
48    }
49
50    /**
51     * What is the default access level for this module?
52     *
53     * Some modules are aimed at admins or managers, and are not generally shown to users.
54     *
55     * @return int
56     */
57    public function defaultAccessLevel(): int
58    {
59        return Auth::PRIV_PRIVATE;
60    }
61
62    /**
63     * Return a menu item for this chart.
64     *
65     * We can only do this if the GD2 library is installed with TrueType support.
66     *
67     * @param Individual $individual
68     *
69     * @return Menu|null
70     */
71    public function getChartMenu(Individual $individual)
72    {
73        if (function_exists('imagettftext')) {
74            return new Menu(
75                $this->getTitle(),
76                route('fan', [
77                    'xref' => $individual->getXref(),
78                    'ged'  => $individual->getTree()->getName(),
79                ]),
80                'menu-chart-fanchart',
81                ['rel' => 'nofollow']
82            );
83        }
84
85        return null;
86    }
87
88    /**
89     * Return a menu item for this chart - for use in individual boxes.
90     *
91     * @param Individual $individual
92     *
93     * @return Menu|null
94     */
95    public function getBoxChartMenu(Individual $individual)
96    {
97        return $this->getChartMenu($individual);
98    }
99}
100