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