xref: /webtrees/app/Module/WelcomeBlockModule.php (revision 13abd6f3a37322f885d85df150e105d27ad81f8d)
18c2e8227SGreg Roach<?php
28c2e8227SGreg Roach/**
38c2e8227SGreg Roach * webtrees: online genealogy
4369c0ce6SGreg Roach * Copyright (C) 2016 webtrees development team
58c2e8227SGreg Roach * This program is free software: you can redistribute it and/or modify
68c2e8227SGreg Roach * it under the terms of the GNU General Public License as published by
78c2e8227SGreg Roach * the Free Software Foundation, either version 3 of the License, or
88c2e8227SGreg Roach * (at your option) any later version.
98c2e8227SGreg Roach * This program is distributed in the hope that it will be useful,
108c2e8227SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
118c2e8227SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
128c2e8227SGreg Roach * GNU General Public License for more details.
138c2e8227SGreg Roach * You should have received a copy of the GNU General Public License
148c2e8227SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
158c2e8227SGreg Roach */
1676692c8bSGreg Roachnamespace Fisharebest\Webtrees\Module;
1776692c8bSGreg Roach
180e62c4b8SGreg Roachuse Fisharebest\Webtrees\Auth;
190e62c4b8SGreg Roachuse Fisharebest\Webtrees\I18N;
204eb71cfaSGreg Roachuse Fisharebest\Webtrees\Module;
210e62c4b8SGreg Roachuse Fisharebest\Webtrees\Site;
220e62c4b8SGreg Roachuse Fisharebest\Webtrees\Theme;
238c2e8227SGreg Roach
248c2e8227SGreg Roach/**
258c2e8227SGreg Roach * Class WelcomeBlockModule
268c2e8227SGreg Roach */
27e2a378d3SGreg Roachclass WelcomeBlockModule extends AbstractModule implements ModuleBlockInterface {
288c2e8227SGreg Roach	/** {@inheritdoc} */
298c2e8227SGreg Roach	public function getTitle() {
308c2e8227SGreg Roach		return /* I18N: Name of a module */ I18N::translate('Home page');
318c2e8227SGreg Roach	}
328c2e8227SGreg Roach
338c2e8227SGreg Roach	/** {@inheritdoc} */
348c2e8227SGreg Roach	public function getDescription() {
358c2e8227SGreg Roach		return /* I18N: Description of the “Home page” module */ I18N::translate('A greeting message for site visitors.');
368c2e8227SGreg Roach	}
378c2e8227SGreg Roach
3876692c8bSGreg Roach	/**
3976692c8bSGreg Roach	 * Generate the HTML content of this block.
4076692c8bSGreg Roach	 *
4176692c8bSGreg Roach	 * @param int      $block_id
4276692c8bSGreg Roach	 * @param bool     $template
43727f238cSGreg Roach	 * @param string[] $cfg
4476692c8bSGreg Roach	 *
4576692c8bSGreg Roach	 * @return string
4676692c8bSGreg Roach	 */
47*13abd6f3SGreg Roach	public function getBlock($block_id, $template = true, $cfg = []) {
484b9ff166SGreg Roach		global $controller, $WT_TREE;
498c2e8227SGreg Roach
508c2e8227SGreg Roach		$indi_xref = $controller->getSignificantIndividual()->getXref();
518c2e8227SGreg Roach		$id        = $this->getName() . $block_id;
528c2e8227SGreg Roach		$class     = $this->getName() . '_block';
5340465963SGreg Roach		$title     = $WT_TREE->getTitleHtml();
548c2e8227SGreg Roach		$content   = '<table><tr>';
554eb71cfaSGreg Roach		if (Module::isActiveChart($WT_TREE, 'pedigree_chart')) {
564b9ff166SGreg Roach			$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>';
574eb71cfaSGreg Roach		}
584b9ff166SGreg Roach		$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>';
598c2e8227SGreg Roach		if (Site::getPreference('USE_REGISTRATION_MODULE') && !Auth::check()) {
60cdc90107SGreg Roach			$content .= '<td><a href="' . WT_LOGIN_URL . '?action=register"><i class="icon-user_add"></i><br>' . I18N::translate('Request a new user account') . '</a></td>';
618c2e8227SGreg Roach		}
628c2e8227SGreg Roach		$content .= "</tr>";
638c2e8227SGreg Roach		$content .= "</table>";
648c2e8227SGreg Roach
658c2e8227SGreg Roach		if ($template) {
668c2e8227SGreg Roach			return Theme::theme()->formatBlock($id, $title, $class, $content);
678c2e8227SGreg Roach		} else {
688c2e8227SGreg Roach			return $content;
698c2e8227SGreg Roach		}
708c2e8227SGreg Roach	}
718c2e8227SGreg Roach
728c2e8227SGreg Roach	/** {@inheritdoc} */
738c2e8227SGreg Roach	public function loadAjax() {
748c2e8227SGreg Roach		return false;
758c2e8227SGreg Roach	}
768c2e8227SGreg Roach
778c2e8227SGreg Roach	/** {@inheritdoc} */
788c2e8227SGreg Roach	public function isUserBlock() {
798c2e8227SGreg Roach		return false;
808c2e8227SGreg Roach	}
818c2e8227SGreg Roach
828c2e8227SGreg Roach	/** {@inheritdoc} */
838c2e8227SGreg Roach	public function isGedcomBlock() {
848c2e8227SGreg Roach		return true;
858c2e8227SGreg Roach	}
868c2e8227SGreg Roach
8776692c8bSGreg Roach	/**
8876692c8bSGreg Roach	 * An HTML form to edit block settings
8976692c8bSGreg Roach	 *
9076692c8bSGreg Roach	 * @param int $block_id
9176692c8bSGreg Roach	 */
928c2e8227SGreg Roach	public function configureBlock($block_id) {
938c2e8227SGreg Roach	}
948c2e8227SGreg Roach}
95