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 */ 16declare(strict_types=1); 17 18namespace Fisharebest\Webtrees\Module; 19 20use Fisharebest\Webtrees\Auth; 21use Fisharebest\Webtrees\I18N; 22use Fisharebest\Webtrees\Module; 23use Fisharebest\Webtrees\Site; 24use Fisharebest\Webtrees\Tree; 25use Symfony\Component\HttpFoundation\Request; 26 27/** 28 * Class WelcomeBlockModule 29 */ 30class WelcomeBlockModule extends AbstractModule implements ModuleBlockInterface 31{ 32 /** {@inheritdoc} */ 33 public function getTitle(): string 34 { 35 /* I18N: Name of a module */ 36 return I18N::translate('Home page'); 37 } 38 39 /** {@inheritdoc} */ 40 public function getDescription(): string 41 { 42 /* I18N: Description of the “Home page” module */ 43 return I18N::translate('A greeting message for site visitors.'); 44 } 45 46 /** 47 * Generate the HTML content of this block. 48 * 49 * @param Tree $tree 50 * @param int $block_id 51 * @param string $ctype 52 * @param string[] $cfg 53 * 54 * @return string 55 */ 56 public function getBlock(Tree $tree, int $block_id, string $ctype = '', array $cfg = []): string 57 { 58 $individual = $tree->getSignificantIndividual(); 59 60 $links = []; 61 62 if (Module::isActiveChart($individual->tree(), 'pedigree_chart')) { 63 $links[] = [ 64 'url' => route('pedigree', [ 65 'xref' => $individual->xref(), 66 'ged' => $individual->tree()->name(), 67 ]), 68 'title' => I18N::translate('Default chart'), 69 'icon' => 'icon-pedigree', 70 ]; 71 } 72 73 $links[] = [ 74 'url' => $individual->url(), 75 'title' => I18N::translate('Default individual'), 76 'icon' => 'icon-indis', 77 ]; 78 79 if (Site::getPreference('USE_REGISTRATION_MODULE') === '1' && !Auth::check()) { 80 $links[] = [ 81 'url' => route('register'), 82 'title' => I18N::translate('Request a new user account'), 83 'icon' => 'icon-user_add', 84 ]; 85 } 86 87 $content = view('modules/gedcom_block/welcome', ['links' => $links]); 88 89 if ($ctype) { 90 return view('modules/block-template', [ 91 'block' => str_replace('_', '-', $this->getName()), 92 'id' => $block_id, 93 'config_url' => '', 94 'title' => $individual->tree()->title(), 95 'content' => $content, 96 ]); 97 } 98 99 return $content; 100 } 101 102 /** {@inheritdoc} */ 103 public function loadAjax(): bool 104 { 105 return false; 106 } 107 108 /** {@inheritdoc} */ 109 public function isUserBlock(): bool 110 { 111 return false; 112 } 113 114 /** {@inheritdoc} */ 115 public function isGedcomBlock(): bool 116 { 117 return true; 118 } 119 120 /** 121 * Update the configuration for a block. 122 * 123 * @param Request $request 124 * @param int $block_id 125 * 126 * @return void 127 */ 128 public function saveBlockConfiguration(Request $request, int $block_id) 129 { 130 } 131 132 /** 133 * An HTML form to edit block settings 134 * 135 * @param Tree $tree 136 * @param int $block_id 137 * 138 * @return void 139 */ 140 public function editBlockConfiguration(Tree $tree, int $block_id) 141 { 142 } 143} 144