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; 20use Fisharebest\Webtrees\Tree; 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 Tree $tree 40 * @param int $block_id 41 * @param bool $template 42 * @param string[] $cfg 43 * 44 * @return string 45 */ 46 public function getBlock(Tree $tree, int $block_id, bool $template = true, array $cfg = []): string { 47 $menu = Theme::theme()->menuThemes(); 48 49 if ($menu) { 50 $content = '<ul class="nav text-justify">' . $menu->bootstrap4() . '</ul>'; 51 52 if ($template) { 53 return view('modules/block-template', [ 54 'block' => str_replace('_', '-', $this->getName()), 55 'id' => $block_id, 56 'config_url' => '', 57 'title' => $this->getTitle(), 58 'content' => $content, 59 ]); 60 } else { 61 return $content; 62 } 63 } else { 64 return ''; 65 } 66 } 67 68 /** {@inheritdoc} */ 69 public function loadAjax(): bool { 70 return false; 71 } 72 73 /** {@inheritdoc} */ 74 public function isUserBlock(): bool { 75 return true; 76 } 77 78 /** {@inheritdoc} */ 79 public function isGedcomBlock(): bool { 80 return true; 81 } 82 83 /** 84 * An HTML form to edit block settings 85 * 86 * @param Tree $tree 87 * @param int $block_id 88 * 89 * @return void 90 */ 91 public function configureBlock(Tree $tree, int $block_id) { 92 } 93} 94