xref: /webtrees/app/Module/ThemeSelectModule.php (revision 63276d8f3b702807b282100a6302f3d6329b2617)
18c2e8227SGreg Roach<?php
28c2e8227SGreg Roach/**
38c2e8227SGreg Roach * webtrees: online genealogy
48fcd0d32SGreg Roach * Copyright (C) 2019 webtrees development team
58c2e8227SGreg Roach * This program is free software: you can redistribute it and/or modify
68c2e8227SGreg Roach * it under the terms of the GNU General Public License as published by
78c2e8227SGreg Roach * the Free Software Foundation, either version 3 of the License, or
88c2e8227SGreg Roach * (at your option) any later version.
98c2e8227SGreg Roach * This program is distributed in the hope that it will be useful,
108c2e8227SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
118c2e8227SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
128c2e8227SGreg Roach * GNU General Public License for more details.
138c2e8227SGreg Roach * You should have received a copy of the GNU General Public License
148c2e8227SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
158c2e8227SGreg Roach */
16e7f56f2aSGreg Roachdeclare(strict_types=1);
17e7f56f2aSGreg Roach
1876692c8bSGreg Roachnamespace Fisharebest\Webtrees\Module;
1976692c8bSGreg Roach
200e62c4b8SGreg Roachuse Fisharebest\Webtrees\I18N;
210e62c4b8SGreg Roachuse Fisharebest\Webtrees\Theme;
22e490cd80SGreg Roachuse Fisharebest\Webtrees\Tree;
23a45f9889SGreg Roachuse Symfony\Component\HttpFoundation\Request;
248c2e8227SGreg Roach
258c2e8227SGreg Roach/**
268c2e8227SGreg Roach * Class ThemeSelectModule
278c2e8227SGreg Roach */
2849a243cbSGreg Roachclass ThemeSelectModule extends AbstractModule implements ModuleInterface, ModuleBlockInterface
29c1010edaSGreg Roach{
3049a243cbSGreg Roach    use ModuleBlockTrait;
3149a243cbSGreg Roach
32961ec755SGreg Roach    /**
33961ec755SGreg Roach     * How should this module be labelled on tabs, menus, etc.?
34961ec755SGreg Roach     *
35961ec755SGreg Roach     * @return string
36961ec755SGreg Roach     */
3749a243cbSGreg Roach    public function title(): string
38c1010edaSGreg Roach    {
39bbb76c12SGreg Roach        /* I18N: Name of a module */
40bbb76c12SGreg Roach        return I18N::translate('Theme change');
418c2e8227SGreg Roach    }
428c2e8227SGreg Roach
43961ec755SGreg Roach    /**
44961ec755SGreg Roach     * A sentence describing what this module does.
45961ec755SGreg Roach     *
46961ec755SGreg Roach     * @return string
47961ec755SGreg Roach     */
4849a243cbSGreg Roach    public function description(): string
49c1010edaSGreg Roach    {
50bbb76c12SGreg Roach        /* I18N: Description of the “Theme change” module */
51bbb76c12SGreg Roach        return I18N::translate('An alternative way to select a new theme.');
528c2e8227SGreg Roach    }
538c2e8227SGreg Roach
5476692c8bSGreg Roach    /**
5576692c8bSGreg Roach     * Generate the HTML content of this block.
5676692c8bSGreg Roach     *
57e490cd80SGreg Roach     * @param Tree     $tree
5876692c8bSGreg Roach     * @param int      $block_id
595f2ae573SGreg Roach     * @param string   $ctype
60727f238cSGreg Roach     * @param string[] $cfg
6176692c8bSGreg Roach     *
6276692c8bSGreg Roach     * @return string
6376692c8bSGreg Roach     */
645f2ae573SGreg Roach    public function getBlock(Tree $tree, int $block_id, string $ctype = '', array $cfg = []): string
65c1010edaSGreg Roach    {
668c2e8227SGreg Roach        $menu = Theme::theme()->menuThemes();
678c2e8227SGreg Roach
688c2e8227SGreg Roach        if ($menu) {
6915d603e7SGreg Roach            $content = '<ul class="nav text-justify">' . $menu->bootstrap4() . '</ul>';
708c2e8227SGreg Roach
716a8879feSGreg Roach            if ($ctype !== '') {
72147e99aaSGreg Roach                return view('modules/block-template', [
7326684e68SGreg Roach                    'block'      => str_replace('_', '-', $this->name()),
749c6524dcSGreg Roach                    'id'         => $block_id,
759c6524dcSGreg Roach                    'config_url' => '',
7649a243cbSGreg Roach                    'title'      => $this->title(),
779c6524dcSGreg Roach                    'content'    => $content,
789c6524dcSGreg Roach                ]);
79b2ce94c6SRico Sonntag            }
80b2ce94c6SRico Sonntag
818c2e8227SGreg Roach            return $content;
828c2e8227SGreg Roach        }
83b2ce94c6SRico Sonntag
848c2e8227SGreg Roach        return '';
858c2e8227SGreg Roach    }
868c2e8227SGreg Roach
878c2e8227SGreg Roach    /** {@inheritdoc} */
88c1010edaSGreg Roach    public function loadAjax(): bool
89c1010edaSGreg Roach    {
908c2e8227SGreg Roach        return false;
918c2e8227SGreg Roach    }
928c2e8227SGreg Roach
938c2e8227SGreg Roach    /** {@inheritdoc} */
94c1010edaSGreg Roach    public function isUserBlock(): bool
95c1010edaSGreg Roach    {
968c2e8227SGreg Roach        return true;
978c2e8227SGreg Roach    }
988c2e8227SGreg Roach
998c2e8227SGreg Roach    /** {@inheritdoc} */
100*63276d8fSGreg Roach    public function isTreeBlock(): bool
101c1010edaSGreg Roach    {
1028c2e8227SGreg Roach        return true;
1038c2e8227SGreg Roach    }
1048c2e8227SGreg Roach
10576692c8bSGreg Roach    /**
106a45f9889SGreg Roach     * Update the configuration for a block.
107a45f9889SGreg Roach     *
108a45f9889SGreg Roach     * @param Request $request
109a45f9889SGreg Roach     * @param int     $block_id
110a45f9889SGreg Roach     *
111a45f9889SGreg Roach     * @return void
112a45f9889SGreg Roach     */
113a45f9889SGreg Roach    public function saveBlockConfiguration(Request $request, int $block_id)
114a45f9889SGreg Roach    {
115a45f9889SGreg Roach    }
116a45f9889SGreg Roach
117a45f9889SGreg Roach    /**
11876692c8bSGreg Roach     * An HTML form to edit block settings
11976692c8bSGreg Roach     *
120e490cd80SGreg Roach     * @param Tree $tree
12176692c8bSGreg Roach     * @param int  $block_id
122a9430be8SGreg Roach     *
123a9430be8SGreg Roach     * @return void
12476692c8bSGreg Roach     */
125a45f9889SGreg Roach    public function editBlockConfiguration(Tree $tree, int $block_id)
126c1010edaSGreg Roach    {
1278c2e8227SGreg Roach    }
1288c2e8227SGreg Roach}
129