xref: /webtrees/app/Module/CloudsTheme.php (revision 8d897fd11a9a8845d8456cb9eaad33b9c9d5a225)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2019 webtrees development team
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17declare(strict_types=1);
18
19namespace Fisharebest\Webtrees\Module;
20
21use Fisharebest\Webtrees\I18N;
22use Fisharebest\Webtrees\Menu;
23use Fisharebest\Webtrees\Tree;
24
25/**
26 * The clouds theme.
27 */
28class CloudsTheme extends AbstractModule implements ModuleThemeInterface
29{
30    use ModuleThemeTrait {
31        genealogyMenu as baseGenealogyMenu;
32    }
33
34    /**
35     * How should this module be identified in the control panel, etc.?
36     *
37     * @return string
38     */
39    public function title(): string
40    {
41        /* I18N: Name of a theme. */
42        return I18N::translate('clouds');
43    }
44
45    /**
46     * Misecellaneous dimensions, fonts, styles, etc.
47     *
48     * @param string $parameter_name
49     *
50     * @return string|int|float
51     */
52    public function parameter($parameter_name)
53    {
54        $parameters = [
55            'chart-background-f'             => 'e9daf1',
56            'chart-background-m'             => 'b1cff0',
57            'chart-background-u'             => 'eeeeee',
58            'chart-box-x'                    => 260,
59            'chart-box-y'                    => 85,
60            'chart-font-color'               => '000000',
61            'chart-spacing-x'                => 4,
62            'chart-spacing-y'                => 10,
63            'compact-chart-box-x'            => 240,
64            'compact-chart-box-y'            => 50,
65            'distribution-chart-high-values' => '95b8e0',
66            'distribution-chart-low-values'  => 'c8e7ff',
67            'distribution-chart-no-values'   => 'ffffff',
68        ];
69
70        return $parameters[$parameter_name];
71    }
72
73    /**
74     * Generate a list of items for the main menu.
75     *
76     * @param Tree|null $tree
77     *
78     * @return Menu[]
79     */
80    public function genealogyMenu(?Tree $tree): array
81    {
82        $primary_menu = $this->baseGenealogyMenu($tree);
83
84        foreach ($primary_menu as $menu) {
85            $submenus = $menu->getSubmenus();
86
87            if (!empty($submenus)) {
88                // Insert a dummy menu / label into the submenu
89                array_unshift($submenus, new Menu($menu->getLabel(), '#', '', ['onclick' => 'return false;']));
90                $menu->setSubmenus($submenus);
91            }
92        }
93
94        return $primary_menu;
95    }
96
97    /**
98     * A list of CSS files to include for this page.
99     *
100     * @return string[]
101     */
102    public function stylesheets(): array
103    {
104        return [
105            asset('css/clouds.min.css'),
106        ];
107    }
108}
109