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