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