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