xref: /webtrees/app/Module/CloudsTheme.php (revision 1ff45046fabc22237b5d0d8e489c96f031fc598d)
1ade503dfSGreg Roach<?php
23976b470SGreg Roach
3ade503dfSGreg Roach/**
4ade503dfSGreg Roach * webtrees: online genealogy
5d11be702SGreg Roach * Copyright (C) 2023 webtrees development team
6ade503dfSGreg Roach * This program is free software: you can redistribute it and/or modify
7ade503dfSGreg Roach * it under the terms of the GNU General Public License as published by
8ade503dfSGreg Roach * the Free Software Foundation, either version 3 of the License, or
9ade503dfSGreg Roach * (at your option) any later version.
10ade503dfSGreg Roach * This program is distributed in the hope that it will be useful,
11ade503dfSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
12ade503dfSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13ade503dfSGreg Roach * GNU General Public License for more details.
14ade503dfSGreg Roach * You should have received a copy of the GNU General Public License
1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>.
16ade503dfSGreg Roach */
17fcfa147eSGreg Roach
18ade503dfSGreg Roachdeclare(strict_types=1);
19ade503dfSGreg Roach
20ade503dfSGreg Roachnamespace Fisharebest\Webtrees\Module;
21ade503dfSGreg Roach
22ade503dfSGreg Roachuse Fisharebest\Webtrees\I18N;
23ade503dfSGreg Roachuse Fisharebest\Webtrees\Menu;
240c8c69d4SGreg Roachuse Fisharebest\Webtrees\Tree;
25ade503dfSGreg Roach
26ade503dfSGreg Roach/**
27ade503dfSGreg Roach * The clouds theme.
28ade503dfSGreg Roach */
29ade503dfSGreg Roachclass CloudsTheme extends AbstractModule implements ModuleThemeInterface
30ade503dfSGreg Roach{
31ade503dfSGreg Roach    use ModuleThemeTrait {
320c8c69d4SGreg Roach        genealogyMenu as baseGenealogyMenu;
33ade503dfSGreg Roach    }
34ade503dfSGreg Roach
35ade503dfSGreg Roach    /**
360cfd6963SGreg Roach     * How should this module be identified in the control panel, etc.?
37ade503dfSGreg Roach     *
38ade503dfSGreg Roach     * @return string
39ade503dfSGreg Roach     */
40ade503dfSGreg Roach    public function title(): string
41ade503dfSGreg Roach    {
42ade503dfSGreg Roach        /* I18N: Name of a theme. */
43ade503dfSGreg Roach        return I18N::translate('clouds');
44ade503dfSGreg Roach    }
45ade503dfSGreg Roach
46ade503dfSGreg Roach    /**
47ade503dfSGreg Roach     * Generate a list of items for the main menu.
48ade503dfSGreg Roach     *
490c8c69d4SGreg Roach     * @param Tree|null $tree
500c8c69d4SGreg Roach     *
5109482a55SGreg Roach     * @return array<Menu>
52ade503dfSGreg Roach     */
53*1ff45046SGreg Roach    public function genealogyMenu(Tree|null $tree): array
54ade503dfSGreg Roach    {
550c8c69d4SGreg Roach        $primary_menu = $this->baseGenealogyMenu($tree);
56ade503dfSGreg Roach
57ade503dfSGreg Roach        foreach ($primary_menu as $menu) {
58ade503dfSGreg Roach            $submenus = $menu->getSubmenus();
59ade503dfSGreg Roach
60a91af26aSGreg Roach            if ($submenus !== []) {
611f244d77SGreg Roach                // Insert a fake menu / label into the submenu
62ade503dfSGreg Roach                array_unshift($submenus, new Menu($menu->getLabel(), '#', '', ['onclick' => 'return false;']));
63ade503dfSGreg Roach                $menu->setSubmenus($submenus);
64ade503dfSGreg Roach            }
65ade503dfSGreg Roach        }
66ade503dfSGreg Roach
67ade503dfSGreg Roach        return $primary_menu;
68ade503dfSGreg Roach    }
69ade503dfSGreg Roach
70ade503dfSGreg Roach    /**
71ade503dfSGreg Roach     * A list of CSS files to include for this page.
72ade503dfSGreg Roach     *
7324f2a3afSGreg Roach     * @return array<string>
74ade503dfSGreg Roach     */
75ade503dfSGreg Roach    public function stylesheets(): array
76ade503dfSGreg Roach    {
77ade503dfSGreg Roach        return [
78e837ff07SGreg Roach            asset('css/clouds.min.css'),
79ade503dfSGreg Roach        ];
80ade503dfSGreg Roach    }
81ade503dfSGreg Roach}
82