xref: /webtrees/app/Module/ThemeSelectModule.php (revision 225e381f36d59b49c8cdac0060465fa5af2fc308)
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\I18N;
19use Fisharebest\Webtrees\Theme;
20
21/**
22 * Class ThemeSelectModule
23 */
24class ThemeSelectModule extends AbstractModule implements ModuleBlockInterface {
25	/** {@inheritdoc} */
26	public function getTitle() {
27		return /* I18N: Name of a module */ I18N::translate('Theme change');
28	}
29
30	/** {@inheritdoc} */
31	public function getDescription() {
32		return /* I18N: Description of the “Theme change” module */ I18N::translate('An alternative way to select a new theme.');
33	}
34
35	/**
36	 * Generate the HTML content of this block.
37	 *
38	 * @param int      $block_id
39	 * @param bool     $template
40	 * @param string[] $cfg
41	 *
42	 * @return string
43	 */
44	public function getBlock($block_id, $template = true, $cfg = []): string {
45		$menu = Theme::theme()->menuThemes();
46
47		if ($menu) {
48			$content = '<ul class="nav text-justify">' . $menu->bootstrap4() . '</ul>';
49
50			if ($template) {
51				return view('blocks/template', [
52					'block'      => str_replace('_', '-', $this->getName()),
53					'id'         => $block_id,
54					'config_url' => '',
55					'title'      => $this->getTitle(),
56					'content'    => $content,
57				]);
58			} else {
59				return $content;
60			}
61		} else {
62			return '';
63		}
64	}
65
66	/** {@inheritdoc} */
67	public function loadAjax(): bool {
68		return false;
69	}
70
71	/** {@inheritdoc} */
72	public function isUserBlock(): bool {
73		return true;
74	}
75
76	/** {@inheritdoc} */
77	public function isGedcomBlock(): bool {
78		return true;
79	}
80
81	/**
82	 * An HTML form to edit block settings
83	 *
84	 * @param int $block_id
85	 *
86	 * @return void
87	 */
88	public function configureBlock($block_id) {
89	}
90}
91