xref: /webtrees/app/Module/WelcomeBlockModule.php (revision 15d603e7c7c15d20f055d3d9c38d6b133453c5be)
1<?php
2/**
3 * webtrees: online genealogy
4 * Copyright (C) 2017 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\Theme;
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 */ I18N::translate('Home page');
31	}
32
33	/** {@inheritdoc} */
34	public function getDescription() {
35		return /* I18N: Description of the “Home page” module */ I18N::translate('A greeting message for site visitors.');
36	}
37
38	/**
39	 * Generate the HTML content of this block.
40	 *
41	 * @param int      $block_id
42	 * @param bool     $template
43	 * @param string[] $cfg
44	 *
45	 * @return string
46	 */
47	public function getBlock($block_id, $template = true, $cfg = []) {
48		global $controller, $WT_TREE;
49
50		$indi_xref = $controller->getSignificantIndividual()->getXref();
51		$id        = $this->getName() . $block_id;
52		$class     = $this->getName() . '_block';
53		$title     = $WT_TREE->getTitleHtml();
54		$content   = '<div class="row">';
55		if (Module::isActiveChart($WT_TREE, 'pedigree_chart')) {
56			$content .= '<div class="col"><a href="pedigree.php?rootid=' . $indi_xref . '&amp;ged=' . $WT_TREE->getNameUrl() . '"><i class="icon-pedigree"></i><br>' . I18N::translate('Default chart') . '</a></div>';
57		}
58		$content .= '<div class="col"><a href="individual.php?pid=' . $indi_xref . '&amp;ged=' . $WT_TREE->getNameUrl() . '"><i class="icon-indis"></i><br>' . I18N::translate('Default individual') . '</a></div>';
59		if (Site::getPreference('USE_REGISTRATION_MODULE') === '1' && !Auth::check()) {
60			$content .= '<div class="col"><a href="' . WT_LOGIN_URL . '?action=register"><i class="icon-user_add"></i><br>' . I18N::translate('Request a new user account') . '</a></div>';
61		}
62		$content .= '</div>';
63
64		if ($template) {
65			return Theme::theme()->formatBlock($id, $title, $class, $content);
66		} else {
67			return $content;
68		}
69	}
70
71	/** {@inheritdoc} */
72	public function loadAjax() {
73		return false;
74	}
75
76	/** {@inheritdoc} */
77	public function isUserBlock() {
78		return false;
79	}
80
81	/** {@inheritdoc} */
82	public function isGedcomBlock() {
83		return true;
84	}
85
86	/**
87	 * An HTML form to edit block settings
88	 *
89	 * @param int $block_id
90	 */
91	public function configureBlock($block_id) {
92	}
93}
94