xref: /webtrees/app/Module/ThemeSelectModule.php (revision 727f238cd22e70e36392127f0b2bce4f7aec649a)
1<?php
2/**
3 * webtrees: online genealogy
4 * Copyright (C) 2015 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 = array()) {
45		$id    = $this->getName() . $block_id;
46		$class = $this->getName() . '_block';
47		$title = $this->getTitle();
48		$menu  = Theme::theme()->menuThemes();
49
50		if ($menu) {
51			$content = '<div class="center theme_form">' . $menu . '</div><br>';
52
53			if ($template) {
54				return Theme::theme()->formatBlock($id, $title, $class, $content);
55			} else {
56				return $content;
57			}
58		} else {
59			return '';
60		}
61	}
62
63	/** {@inheritdoc} */
64	public function loadAjax() {
65		return false;
66	}
67
68	/** {@inheritdoc} */
69	public function isUserBlock() {
70		return true;
71	}
72
73	/** {@inheritdoc} */
74	public function isGedcomBlock() {
75		return true;
76	}
77
78	/**
79	 * An HTML form to edit block settings
80	 *
81	 * @param int $block_id
82	 */
83	public function configureBlock($block_id) {
84	}
85}
86