xref: /webtrees/app/Module/FamilyTreeStatisticsModule.php (revision f36626dbc06faf6e61af35fd18604d82d86c966f)
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;
19*f36626dbSGreg Roachuse Fisharebest\Webtrees\Database;
200e62c4b8SGreg Roachuse Fisharebest\Webtrees\Filter;
213d7a8a4cSGreg Roachuse Fisharebest\Webtrees\Functions\FunctionsDb;
223d7a8a4cSGreg Roachuse Fisharebest\Webtrees\Functions\FunctionsEdit;
23*f36626dbSGreg Roachuse Fisharebest\Webtrees\Functions\FunctionsPrintLists;
240e62c4b8SGreg Roachuse Fisharebest\Webtrees\I18N;
254eb71cfaSGreg Roachuse Fisharebest\Webtrees\Module;
26*f36626dbSGreg Roachuse Fisharebest\Webtrees\Query\QueryName;
270e62c4b8SGreg Roachuse Fisharebest\Webtrees\Stats;
280e62c4b8SGreg Roachuse Fisharebest\Webtrees\Theme;
29*f36626dbSGreg Roachuse Fisharebest\Webtrees\Tree;
308c2e8227SGreg Roach
318c2e8227SGreg Roach/**
328c2e8227SGreg Roach * Class FamilyTreeStatisticsModule
338c2e8227SGreg Roach */
34e2a378d3SGreg Roachclass FamilyTreeStatisticsModule extends AbstractModule implements ModuleBlockInterface {
35*f36626dbSGreg Roach	/** Show this number of surnames by default */
36*f36626dbSGreg Roach	const DEFAULT_NUMBER_OF_SURNAMES = 10;
37*f36626dbSGreg Roach
388c2e8227SGreg Roach	/** {@inheritdoc} */
398c2e8227SGreg Roach	public function getTitle() {
408c2e8227SGreg Roach		return /* I18N: Name of a module */ I18N::translate('Statistics');
418c2e8227SGreg Roach	}
428c2e8227SGreg Roach
438c2e8227SGreg Roach	/** {@inheritdoc} */
448c2e8227SGreg Roach	public function getDescription() {
458c2e8227SGreg Roach		return /* I18N: Description of “Statistics” module */ I18N::translate('The size of the family tree, earliest and latest events, common names, etc.');
468c2e8227SGreg Roach	}
478c2e8227SGreg Roach
4876692c8bSGreg Roach	/**
4976692c8bSGreg Roach	 * Generate the HTML content of this block.
5076692c8bSGreg Roach	 *
5176692c8bSGreg Roach	 * @param int      $block_id
5276692c8bSGreg Roach	 * @param bool     $template
53727f238cSGreg Roach	 * @param string[] $cfg
5476692c8bSGreg Roach	 *
5576692c8bSGreg Roach	 * @return string
5676692c8bSGreg Roach	 */
5776692c8bSGreg Roach	public function getBlock($block_id, $template = true, $cfg = array()) {
588c2e8227SGreg Roach		global $WT_TREE, $ctype;
598c2e8227SGreg Roach
60e2a378d3SGreg Roach		$show_last_update     = $this->getBlockSetting($block_id, 'show_last_update', '1');
61e2a378d3SGreg Roach		$show_common_surnames = $this->getBlockSetting($block_id, 'show_common_surnames', '1');
62*f36626dbSGreg Roach		$number_of_surnames   = $this->getBlockSetting($block_id, 'number_of_surnames', self::DEFAULT_NUMBER_OF_SURNAMES);
63e2a378d3SGreg Roach		$stat_indi            = $this->getBlockSetting($block_id, 'stat_indi', '1');
64e2a378d3SGreg Roach		$stat_fam             = $this->getBlockSetting($block_id, 'stat_fam', '1');
65e2a378d3SGreg Roach		$stat_sour            = $this->getBlockSetting($block_id, 'stat_sour', '1');
66e2a378d3SGreg Roach		$stat_media           = $this->getBlockSetting($block_id, 'stat_media', '1');
67e2a378d3SGreg Roach		$stat_repo            = $this->getBlockSetting($block_id, 'stat_repo', '1');
68e2a378d3SGreg Roach		$stat_surname         = $this->getBlockSetting($block_id, 'stat_surname', '1');
69e2a378d3SGreg Roach		$stat_events          = $this->getBlockSetting($block_id, 'stat_events', '1');
70e2a378d3SGreg Roach		$stat_users           = $this->getBlockSetting($block_id, 'stat_users', '1');
71e2a378d3SGreg Roach		$stat_first_birth     = $this->getBlockSetting($block_id, 'stat_first_birth', '1');
72e2a378d3SGreg Roach		$stat_last_birth      = $this->getBlockSetting($block_id, 'stat_last_birth', '1');
73e2a378d3SGreg Roach		$stat_first_death     = $this->getBlockSetting($block_id, 'stat_first_death', '1');
74e2a378d3SGreg Roach		$stat_last_death      = $this->getBlockSetting($block_id, 'stat_last_death', '1');
75e2a378d3SGreg Roach		$stat_long_life       = $this->getBlockSetting($block_id, 'stat_long_life', '1');
76e2a378d3SGreg Roach		$stat_avg_life        = $this->getBlockSetting($block_id, 'stat_avg_life', '1');
77e2a378d3SGreg Roach		$stat_most_chil       = $this->getBlockSetting($block_id, 'stat_most_chil', '1');
78e2a378d3SGreg Roach		$stat_avg_chil        = $this->getBlockSetting($block_id, 'stat_avg_chil', '1');
798c2e8227SGreg Roach
808c2e8227SGreg Roach		// This can be overriden when embedding in an HTML block
818c2e8227SGreg Roach		$block     = '0';
828c2e8227SGreg Roach
83*f36626dbSGreg Roach		foreach (array('show_common_surnames', 'number_common_surnames', 'stat_indi', 'stat_fam', 'stat_sour', 'stat_media', 'stat_surname', 'stat_events', 'stat_users', 'stat_first_birth', 'stat_last_birth', 'stat_first_death', 'stat_last_death', 'stat_long_life', 'stat_avg_life', 'stat_most_chil', 'stat_avg_chil', 'block') as $name) {
848c2e8227SGreg Roach			if (array_key_exists($name, $cfg)) {
858c2e8227SGreg Roach				$$name = $cfg[$name];
868c2e8227SGreg Roach			}
878c2e8227SGreg Roach		}
888c2e8227SGreg Roach
898c2e8227SGreg Roach		$id    = $this->getName() . $block_id;
908c2e8227SGreg Roach		$class = $this->getName() . '_block';
914b9ff166SGreg Roach		if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) {
929353052eSGreg Roach			$title = '<a class="icon-admin" title="' . I18N::translate('Configure') . '" href="block_edit.php?block_id=' . $block_id . '&amp;ged=' . $WT_TREE->getNameHtml() . '&amp;ctype=' . $ctype . '"></a>';
938c2e8227SGreg Roach		} else {
948c2e8227SGreg Roach			$title = '';
958c2e8227SGreg Roach		}
96d93f11b5SGreg Roach		$title .= $this->getTitle() . ' — ' . $WT_TREE->getTitleHtml();
978c2e8227SGreg Roach
988c2e8227SGreg Roach		$stats = new Stats($WT_TREE);
998c2e8227SGreg Roach
100d93f11b5SGreg Roach		$content = '';
1018c2e8227SGreg Roach
1028c2e8227SGreg Roach		if ($show_last_update) {
103d93f11b5SGreg Roach			$content .= '<p>' . /* I18N: %s is a date */
104d93f11b5SGreg Roach				I18N::translate('This family tree was last updated on %s.', strip_tags($stats->gedcomUpdated())) . '</p>';
1058c2e8227SGreg Roach		}
1068c2e8227SGreg Roach
107d93f11b5SGreg Roach		/** Responsive Design */
1088c2e8227SGreg Roach		$content .= '<div class="stat-table1">';
1098c2e8227SGreg Roach		if ($stat_indi) {
1104b9ff166SGreg Roach			$content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Individuals') . '</div><div class="facts_value stats_value stat-cell"><a href="' . "indilist.php?surname_sublist=no&amp;ged=" . $WT_TREE->getNameUrl() . '">' . $stats->totalIndividuals() . '</a></div></div>';
1114a0f15aaSGreg Roach			$content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Males') . '</div><div class="facts_value stats_value stat-cell">' . $stats->totalSexMales() . '<br>' . $stats->totalSexMalesPercentage() . '</div></div>';
1124a0f15aaSGreg Roach			$content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Females') . '</div><div class="facts_value stats_value stat-cell">' . $stats->totalSexFemales() . '<br>' . $stats->totalSexFemalesPercentage() . '</div></div>';
1138c2e8227SGreg Roach		}
1148c2e8227SGreg Roach		if ($stat_surname) {
1154b9ff166SGreg Roach			$content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Total surnames') . '</div><div class="facts_value stats_value stat-cell"><a href="indilist.php?show_all=yes&amp;surname_sublist=yes&amp;ged=' . $WT_TREE->getNameUrl() . '">' . $stats->totalSurnames() . '</a></div></div>';
1168c2e8227SGreg Roach		}
1178c2e8227SGreg Roach		if ($stat_fam) {
1184b9ff166SGreg Roach			$content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Families') . '</div><div class="facts_value stats_value stat-cell"><a href="famlist.php?ged=' . $WT_TREE->getNameUrl() . '">' . $stats->totalFamilies() . '</a></div></div>';
1198c2e8227SGreg Roach		}
1208c2e8227SGreg Roach		if ($stat_sour) {
1214b9ff166SGreg Roach			$content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Sources') . '</div><div class="facts_value stats_value stat-cell"><a href="sourcelist.php?ged=' . $WT_TREE->getNameUrl() . '">' . $stats->totalSources() . '</a></div></div>';
1228c2e8227SGreg Roach		}
1238c2e8227SGreg Roach		if ($stat_media) {
1244b9ff166SGreg Roach			$content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Media objects') . '</div><div class="facts_value stats_value stat-cell"><a href="medialist.php?ged=' . $WT_TREE->getNameUrl() . '">' . $stats->totalMedia() . '</a></div></div>';
1258c2e8227SGreg Roach		}
1268c2e8227SGreg Roach		if ($stat_repo) {
1274b9ff166SGreg Roach			$content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Repositories') . '</div><div class="facts_value stats_value stat-cell"><a href="repolist.php?ged=' . $WT_TREE->getNameUrl() . '">' . $stats->totalRepositories() . '</a></div></div>';
1288c2e8227SGreg Roach		}
1298c2e8227SGreg Roach		if ($stat_events) {
1308c2e8227SGreg Roach			$content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Total events') . '</div><div class="facts_value stats_value stat-cell">' . $stats->totalEvents() . '</div></div>';
1318c2e8227SGreg Roach		}
1328c2e8227SGreg Roach		if ($stat_users) {
1338c2e8227SGreg Roach			$content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Total users') . '</div><div class="facts_value stats_value stat-cell">';
1344b9ff166SGreg Roach			if (Auth::isManager($WT_TREE)) {
1358c2e8227SGreg Roach				$content .= '<a href="admin_users.php">' . $stats->totalUsers() . '</a>';
1368c2e8227SGreg Roach			} else {
1378c2e8227SGreg Roach				$content .= $stats->totalUsers();
1388c2e8227SGreg Roach			}
1398c2e8227SGreg Roach			$content .= '</div></div>';
1408c2e8227SGreg Roach		}
1418c2e8227SGreg Roach		if (!$block) {
1428c2e8227SGreg Roach			$content .= '</div><div class="facts_table stat-table2">';
1438c2e8227SGreg Roach		}
1448c2e8227SGreg Roach		if ($stat_first_birth) {
1458c2e8227SGreg Roach			$content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Earliest birth year') . '</div><div class="facts_value stats_value stat-cell">' . $stats->firstBirthYear() . '</div>';
1468c2e8227SGreg Roach			if (!$block) {
1478c2e8227SGreg Roach				$content .= '<div class="facts_value stat-cell left">' . $stats->firstBirth() . '</div>';
1488c2e8227SGreg Roach			}
1498c2e8227SGreg Roach			$content .= '</div>';
1508c2e8227SGreg Roach		}
1518c2e8227SGreg Roach		if ($stat_last_birth) {
1528c2e8227SGreg Roach			$content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Latest birth year') . '</div><div class="facts_value stats_value stat-cell">' . $stats->lastBirthYear() . '</div>';
1538c2e8227SGreg Roach			if (!$block) {
1548c2e8227SGreg Roach				$content .= '<div class="facts_value stat-cell left">' . $stats->lastBirth() . '</div>';
1558c2e8227SGreg Roach			}
1568c2e8227SGreg Roach			$content .= '</div>';
1578c2e8227SGreg Roach		}
1588c2e8227SGreg Roach		if ($stat_first_death) {
1598c2e8227SGreg Roach			$content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Earliest death year') . '</div><div class="facts_value stats_value stat-cell">' . $stats->firstDeathYear() . '</div>';
1608c2e8227SGreg Roach			if (!$block) {
1618c2e8227SGreg Roach				$content .= '<div class="facts_value stat-cell left">' . $stats->firstDeath() . '</div>';
1628c2e8227SGreg Roach			}
1638c2e8227SGreg Roach			$content .= '</div>';
1648c2e8227SGreg Roach		}
1658c2e8227SGreg Roach		if ($stat_last_death) {
1668c2e8227SGreg Roach			$content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Latest death year') . '</div><div class="facts_value stats_value stat-cell">' . $stats->lastDeathYear() . '</div>';
1678c2e8227SGreg Roach			if (!$block) {
1688c2e8227SGreg Roach				$content .= '<div class="facts_value stat-cell left">' . $stats->lastDeath() . '</div>';
1698c2e8227SGreg Roach			}
1708c2e8227SGreg Roach			$content .= '</div>';
1718c2e8227SGreg Roach		}
1728c2e8227SGreg Roach		if ($stat_long_life) {
1737820e4d7SGreg Roach			$content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Individual who lived the longest') . '</div><div class="facts_value stats_value stat-cell">' . $stats->longestLifeAge() . '</div>';
1748c2e8227SGreg Roach			if (!$block) {
1757820e4d7SGreg Roach				$content .= '<div class="facts_value stat-cell left">' . $stats->longestLife() . '</div>';
1768c2e8227SGreg Roach			}
1778c2e8227SGreg Roach			$content .= '</div>';
1788c2e8227SGreg Roach		}
1798c2e8227SGreg Roach		if ($stat_avg_life) {
1808c2e8227SGreg Roach			$content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Average age at death') . '</div><div class="facts_value stats_value stat-cell">' . $stats->averageLifespan() . '</div>';
1818c2e8227SGreg Roach			if (!$block) {
1828c2e8227SGreg Roach				$content .= '<div class="facts_value stat-cell left">' . I18N::translate('Males') . ':&nbsp;' . $stats->averageLifespanMale();
1838c2e8227SGreg Roach				$content .= '&nbsp;&nbsp;&nbsp;' . I18N::translate('Females') . ':&nbsp;' . $stats->averageLifespanFemale() . '</div>';
1848c2e8227SGreg Roach			}
1858c2e8227SGreg Roach			$content .= '</div>';
1868c2e8227SGreg Roach		}
1878c2e8227SGreg Roach
1888c2e8227SGreg Roach		if ($stat_most_chil && !$block) {
1898c2e8227SGreg Roach			$content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Family with the most children') . '</div><div class="facts_value stats_value stat-cell">' . $stats->largestFamilySize() . '</div>';
1908c2e8227SGreg Roach			if (!$block) {
1918c2e8227SGreg Roach				$content .= '<div class="facts_value stat-cell left">' . $stats->largestFamily() . '</div>';
1928c2e8227SGreg Roach			}
1938c2e8227SGreg Roach			$content .= '</div>';
1948c2e8227SGreg Roach		}
1958c2e8227SGreg Roach		if ($stat_avg_chil) {
1968c2e8227SGreg Roach			$content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Average number of children per family') . '</div><div class="facts_value stats_value stat-cell">' . $stats->averageChildren() . '</div>';
1978c2e8227SGreg Roach			if (!$block) {
1988c2e8227SGreg Roach				$content .= '<div class="facts_value stat-cell left"></div>';
1998c2e8227SGreg Roach			}
2000fd21fdaSmakitso			$content .= '</div>';
2018c2e8227SGreg Roach		}
20228941e3cSGreg Roach		$content .= '</div>';
203e85991caSGreg Roach
2048c2e8227SGreg Roach		if ($show_common_surnames) {
205*f36626dbSGreg Roach			$surnames = FunctionsDb::getTopSurnames($WT_TREE->getTreeId(), 0, (int) $number_of_surnames);
206e0275e5bSGreg Roach
207*f36626dbSGreg Roach			$all_surnames = array();
208*f36626dbSGreg Roach			foreach (array_keys($surnames) as $surname) {
209*f36626dbSGreg Roach				$all_surnames = array_merge($all_surnames, QueryName::surnames($WT_TREE, $surname, '', false, false));
210*f36626dbSGreg Roach			}
211*f36626dbSGreg Roach
212*f36626dbSGreg Roach			if (!empty($surnames)) {
213*f36626dbSGreg Roach				ksort($all_surnames);
214e0275e5bSGreg Roach				$content .= '<div class="clearfloat">';
215d93f11b5SGreg Roach				$content .= '<p>';
216d93f11b5SGreg Roach				$content .= '<strong>' . I18N::translate('Most common surnames') . '</strong>';
217d93f11b5SGreg Roach				$content .= '<br>';
218*f36626dbSGreg Roach				$content .= '<span class="common_surnames">' . FunctionsPrintLists::surnameList($all_surnames, 2, false, 'indilist.php', $WT_TREE) . '</span>';
219d93f11b5SGreg Roach				$content .= '</p>';
220e0275e5bSGreg Roach				$content .= '</div>';
2218c2e8227SGreg Roach			}
2228c2e8227SGreg Roach		}
22328941e3cSGreg Roach
2248c2e8227SGreg Roach		if ($template) {
2258c2e8227SGreg Roach			return Theme::theme()->formatBlock($id, $title, $class, $content);
2268c2e8227SGreg Roach		} else {
2278c2e8227SGreg Roach			return $content;
2288c2e8227SGreg Roach		}
2298c2e8227SGreg Roach	}
2308c2e8227SGreg Roach
2318c2e8227SGreg Roach	/** {@inheritdoc} */
2328c2e8227SGreg Roach	public function loadAjax() {
2338c2e8227SGreg Roach		return true;
2348c2e8227SGreg Roach	}
2358c2e8227SGreg Roach
2368c2e8227SGreg Roach	/** {@inheritdoc} */
2378c2e8227SGreg Roach	public function isUserBlock() {
2388c2e8227SGreg Roach		return true;
2398c2e8227SGreg Roach	}
2408c2e8227SGreg Roach
2418c2e8227SGreg Roach	/** {@inheritdoc} */
2428c2e8227SGreg Roach	public function isGedcomBlock() {
2438c2e8227SGreg Roach		return true;
2448c2e8227SGreg Roach	}
2458c2e8227SGreg Roach
24676692c8bSGreg Roach	/**
24776692c8bSGreg Roach	 * An HTML form to edit block settings
24876692c8bSGreg Roach	 *
24976692c8bSGreg Roach	 * @param int $block_id
25076692c8bSGreg Roach	 */
2518c2e8227SGreg Roach	public function configureBlock($block_id) {
2528c2e8227SGreg Roach		if (Filter::postBool('save') && Filter::checkCsrf()) {
253e2a378d3SGreg Roach			$this->setBlockSetting($block_id, 'show_last_update', Filter::postBool('show_last_update'));
254e2a378d3SGreg Roach			$this->setBlockSetting($block_id, 'show_common_surnames', Filter::postBool('show_common_surnames'));
255*f36626dbSGreg Roach			$this->setBlockSetting($block_id, 'number_of_surnames', Filter::postInteger('number_of_surnames'));
256e2a378d3SGreg Roach			$this->setBlockSetting($block_id, 'stat_indi', Filter::postBool('stat_indi'));
257e2a378d3SGreg Roach			$this->setBlockSetting($block_id, 'stat_fam', Filter::postBool('stat_fam'));
258e2a378d3SGreg Roach			$this->setBlockSetting($block_id, 'stat_sour', Filter::postBool('stat_sour'));
259e2a378d3SGreg Roach			$this->setBlockSetting($block_id, 'stat_other', Filter::postBool('stat_other'));
260e2a378d3SGreg Roach			$this->setBlockSetting($block_id, 'stat_media', Filter::postBool('stat_media'));
261e2a378d3SGreg Roach			$this->setBlockSetting($block_id, 'stat_repo', Filter::postBool('stat_repo'));
262e2a378d3SGreg Roach			$this->setBlockSetting($block_id, 'stat_surname', Filter::postBool('stat_surname'));
263e2a378d3SGreg Roach			$this->setBlockSetting($block_id, 'stat_events', Filter::postBool('stat_events'));
264e2a378d3SGreg Roach			$this->setBlockSetting($block_id, 'stat_users', Filter::postBool('stat_users'));
265e2a378d3SGreg Roach			$this->setBlockSetting($block_id, 'stat_first_birth', Filter::postBool('stat_first_birth'));
266e2a378d3SGreg Roach			$this->setBlockSetting($block_id, 'stat_last_birth', Filter::postBool('stat_last_birth'));
267e2a378d3SGreg Roach			$this->setBlockSetting($block_id, 'stat_first_death', Filter::postBool('stat_first_death'));
268e2a378d3SGreg Roach			$this->setBlockSetting($block_id, 'stat_last_death', Filter::postBool('stat_last_death'));
269e2a378d3SGreg Roach			$this->setBlockSetting($block_id, 'stat_long_life', Filter::postBool('stat_long_life'));
270e2a378d3SGreg Roach			$this->setBlockSetting($block_id, 'stat_avg_life', Filter::postBool('stat_avg_life'));
271e2a378d3SGreg Roach			$this->setBlockSetting($block_id, 'stat_most_chil', Filter::postBool('stat_most_chil'));
272e2a378d3SGreg Roach			$this->setBlockSetting($block_id, 'stat_avg_chil', Filter::postBool('stat_avg_chil'));
2738c2e8227SGreg Roach		}
2748c2e8227SGreg Roach
275e2a378d3SGreg Roach		$show_last_update     = $this->getBlockSetting($block_id, 'show_last_update', '1');
276e2a378d3SGreg Roach		$show_common_surnames = $this->getBlockSetting($block_id, 'show_common_surnames', '1');
277*f36626dbSGreg Roach		$number_of_surnames   = $this->getBlockSetting($block_id, 'number_of_surnames', self::DEFAULT_NUMBER_OF_SURNAMES);
278e2a378d3SGreg Roach		$stat_indi            = $this->getBlockSetting($block_id, 'stat_indi', '1');
279e2a378d3SGreg Roach		$stat_fam             = $this->getBlockSetting($block_id, 'stat_fam', '1');
280e2a378d3SGreg Roach		$stat_sour            = $this->getBlockSetting($block_id, 'stat_sour', '1');
281e2a378d3SGreg Roach		$stat_media           = $this->getBlockSetting($block_id, 'stat_media', '1');
282e2a378d3SGreg Roach		$stat_repo            = $this->getBlockSetting($block_id, 'stat_repo', '1');
283e2a378d3SGreg Roach		$stat_surname         = $this->getBlockSetting($block_id, 'stat_surname', '1');
284e2a378d3SGreg Roach		$stat_events          = $this->getBlockSetting($block_id, 'stat_events', '1');
285e2a378d3SGreg Roach		$stat_users           = $this->getBlockSetting($block_id, 'stat_users', '1');
286e2a378d3SGreg Roach		$stat_first_birth     = $this->getBlockSetting($block_id, 'stat_first_birth', '1');
287e2a378d3SGreg Roach		$stat_last_birth      = $this->getBlockSetting($block_id, 'stat_last_birth', '1');
288e2a378d3SGreg Roach		$stat_first_death     = $this->getBlockSetting($block_id, 'stat_first_death', '1');
289e2a378d3SGreg Roach		$stat_last_death      = $this->getBlockSetting($block_id, 'stat_last_death', '1');
290e2a378d3SGreg Roach		$stat_long_life       = $this->getBlockSetting($block_id, 'stat_long_life', '1');
291e2a378d3SGreg Roach		$stat_avg_life        = $this->getBlockSetting($block_id, 'stat_avg_life', '1');
292e2a378d3SGreg Roach		$stat_most_chil       = $this->getBlockSetting($block_id, 'stat_most_chil', '1');
293e2a378d3SGreg Roach		$stat_avg_chil        = $this->getBlockSetting($block_id, 'stat_avg_chil', '1');
2948c2e8227SGreg Roach
2958c2e8227SGreg Roach		?>
2968c2e8227SGreg Roach		<tr>
297e85991caSGreg Roach			<td class="descriptionbox wrap width33">
298*f36626dbSGreg Roach				<label for="show-last-update">
299*f36626dbSGreg Roach					<?php echo /* I18N: label for yes/no option */ I18N::translate('Show date of last update') ?>
300*f36626dbSGreg Roach				</label>
301e85991caSGreg Roach			</td>
302e85991caSGreg Roach			<td class="optionbox">
303*f36626dbSGreg Roach				<input type="checkbox" value="yes" id="show-last-update" name="show_last_update" <?php echo $show_last_update ? 'checked' : ''; ?>>
304e85991caSGreg Roach			</td>
305e85991caSGreg Roach		</tr>
306e85991caSGreg Roach		<tr>
307e85991caSGreg Roach			<td class="descriptionbox wrap width33">
308*f36626dbSGreg Roach				<?php echo I18N::translate('Statistics'); ?>
309e85991caSGreg Roach			</td>
310e85991caSGreg Roach			<td class="optionbox">
3118c2e8227SGreg Roach				<table>
3128c2e8227SGreg Roach					<tbody>
3138c2e8227SGreg Roach						<tr>
3148c2e8227SGreg Roach							<td>
3158c2e8227SGreg Roach								<label>
3168c2e8227SGreg Roach									<input type="checkbox" value="yes" name="stat_indi" <?php echo $stat_indi ? 'checked' : ''; ?>>
3178c2e8227SGreg Roach									<?php echo I18N::translate('Individuals'); ?>
3188c2e8227SGreg Roach								</label>
3198c2e8227SGreg Roach							</td>
3208c2e8227SGreg Roach							<td>
3218c2e8227SGreg Roach								<label>
3228c2e8227SGreg Roach									<input type="checkbox" value="yes" name="stat_first_birth" <?php echo $stat_first_birth ? 'checked' : ''; ?>>
3238c2e8227SGreg Roach									<?php echo I18N::translate('Earliest birth year'); ?>
3248c2e8227SGreg Roach								</label>
3258c2e8227SGreg Roach							</td>
3268c2e8227SGreg Roach						</tr>
3278c2e8227SGreg Roach						<tr>
3288c2e8227SGreg Roach							<td>
3298c2e8227SGreg Roach								<label>
3308c2e8227SGreg Roach									<input type="checkbox" value="yes" name="stat_surname" <?php echo $stat_surname ? 'checked' : ''; ?>>
3318c2e8227SGreg Roach									<?php echo I18N::translate('Total surnames'); ?>
3328c2e8227SGreg Roach								</label>
3338c2e8227SGreg Roach							</td>
3348c2e8227SGreg Roach							<td>
3358c2e8227SGreg Roach								<label>
3368c2e8227SGreg Roach									<input type="checkbox" value="yes" name="stat_last_birth" <?php echo $stat_last_birth ? 'checked' : ''; ?>>
3378c2e8227SGreg Roach									<?php echo I18N::translate('Latest birth year'); ?>
3388c2e8227SGreg Roach								</label>
3398c2e8227SGreg Roach							</td>
3408c2e8227SGreg Roach						</tr>
3418c2e8227SGreg Roach						<tr>
3428c2e8227SGreg Roach							<td>
3438c2e8227SGreg Roach								<label>
3448c2e8227SGreg Roach									<input type="checkbox" value="yes" name="stat_fam" <?php echo $stat_fam ? 'checked' : ''; ?>>
3458c2e8227SGreg Roach									<?php echo I18N::translate('Families'); ?>
3468c2e8227SGreg Roach								</label>
3478c2e8227SGreg Roach							</td>
3488c2e8227SGreg Roach							<td>
3498c2e8227SGreg Roach								<label>
3508c2e8227SGreg Roach									<input type="checkbox" value="yes" name="stat_first_death" <?php echo $stat_first_death ? 'checked' : ''; ?>>
3518c2e8227SGreg Roach									<?php echo I18N::translate('Earliest death year'); ?>
3528c2e8227SGreg Roach								</label>
3538c2e8227SGreg Roach							</td>
3548c2e8227SGreg Roach						</tr>
3558c2e8227SGreg Roach						<tr>
3568c2e8227SGreg Roach							<td>
3578c2e8227SGreg Roach								<label>
3588c2e8227SGreg Roach									<input type="checkbox" value="yes" name="stat_sour" <?php echo $stat_sour ? 'checked' : ''; ?>>
3598c2e8227SGreg Roach									<?php echo I18N::translate('Sources'); ?>
3608c2e8227SGreg Roach								</label>
3618c2e8227SGreg Roach							</td>
3628c2e8227SGreg Roach							<td>
3638c2e8227SGreg Roach								<label>
3648c2e8227SGreg Roach									<input type="checkbox" value="yes" name="stat_last_death" <?php echo $stat_last_death ? 'checked' : ''; ?>>
3658c2e8227SGreg Roach									<?php echo I18N::translate('Latest death year'); ?>
3668c2e8227SGreg Roach								</label>
3678c2e8227SGreg Roach							</td>
3688c2e8227SGreg Roach						</tr>
3698c2e8227SGreg Roach						<tr>
3708c2e8227SGreg Roach							<td>
3718c2e8227SGreg Roach								<label>
3728c2e8227SGreg Roach									<input type="checkbox" value="yes" name="stat_media" <?php echo $stat_media ? 'checked' : ''; ?>>
3738c2e8227SGreg Roach									<?php echo I18N::translate('Media objects'); ?>
3748c2e8227SGreg Roach								</label>
3758c2e8227SGreg Roach							</td>
3768c2e8227SGreg Roach							<td>
3778c2e8227SGreg Roach								<label>
3788c2e8227SGreg Roach									<input type="checkbox" value="yes" name="stat_long_life" <?php echo $stat_long_life ? 'checked' : ''; ?>>
3798c2e8227SGreg Roach									<?php echo I18N::translate('Individual who lived the longest'); ?>
3808c2e8227SGreg Roach								</label>
3818c2e8227SGreg Roach							</td>
3828c2e8227SGreg Roach						</tr>
3838c2e8227SGreg Roach						<tr>
3848c2e8227SGreg Roach							<td>
3858c2e8227SGreg Roach								<label>
3868c2e8227SGreg Roach									<input type="checkbox" value="yes" name="stat_repo" <?php echo $stat_repo ? 'checked' : ''; ?>>
3878c2e8227SGreg Roach									<?php echo I18N::translate('Repositories'); ?>
3888c2e8227SGreg Roach								</label>
3898c2e8227SGreg Roach							</td>
3908c2e8227SGreg Roach							<td>
3918c2e8227SGreg Roach								<label>
3928c2e8227SGreg Roach									<input type="checkbox" value="yes" name="stat_avg_life" <?php echo $stat_avg_life ? 'checked' : ''; ?>>
3938c2e8227SGreg Roach									<?php echo I18N::translate('Average age at death'); ?>
3948c2e8227SGreg Roach								</label>
3958c2e8227SGreg Roach							</td>
3968c2e8227SGreg Roach						</tr>
3978c2e8227SGreg Roach						<tr>
3988c2e8227SGreg Roach							<td>
3998c2e8227SGreg Roach								<label>
4008c2e8227SGreg Roach									<input type="checkbox" value="yes" name="stat_events" <?php echo $stat_events ? 'checked' : ''; ?>>
4018c2e8227SGreg Roach									<?php echo I18N::translate('Total events'); ?>
4028c2e8227SGreg Roach								</label>
4038c2e8227SGreg Roach							</td>
4048c2e8227SGreg Roach							<td>
4058c2e8227SGreg Roach								<label>
4068c2e8227SGreg Roach									<input type="checkbox" value="yes" name="stat_most_chil" <?php echo $stat_most_chil ? 'checked' : ''; ?>>
4078c2e8227SGreg Roach									<?php echo I18N::translate('Family with the most children'); ?>
4088c2e8227SGreg Roach								</label>
4098c2e8227SGreg Roach							</td>
4108c2e8227SGreg Roach						</tr>
4118c2e8227SGreg Roach						<tr>
4128c2e8227SGreg Roach							<td>
4138c2e8227SGreg Roach								<label>
4148c2e8227SGreg Roach									<input type="checkbox" value="yes" name="stat_users" <?php echo $stat_users ? 'checked' : ''; ?>>
4158c2e8227SGreg Roach									<?php echo I18N::translate('Total users'); ?>
4168c2e8227SGreg Roach								</label>
4178c2e8227SGreg Roach							</td>
4188c2e8227SGreg Roach							<td>
4198c2e8227SGreg Roach								<label>
4208c2e8227SGreg Roach									<input type="checkbox" value="yes" name="stat_avg_chil" <?php echo $stat_avg_chil ? 'checked' : ''; ?>>
4218c2e8227SGreg Roach									<?php echo I18N::translate('Average number of children per family'); ?>
4228c2e8227SGreg Roach								</label>
4238c2e8227SGreg Roach							</td>
4248c2e8227SGreg Roach						</tr>
4258c2e8227SGreg Roach					</tbody>
4268c2e8227SGreg Roach				</table>
4278c2e8227SGreg Roach			</td>
4288c2e8227SGreg Roach		</tr>
429*f36626dbSGreg Roach		<tr>
430*f36626dbSGreg Roach			<td class="descriptionbox wrap width33">
431*f36626dbSGreg Roach				<label for="show-common-surnames">
432*f36626dbSGreg Roach					<?php echo I18N::translate('Most common surnames') ?>
433*f36626dbSGreg Roach				</label>
434*f36626dbSGreg Roach			</td>
435*f36626dbSGreg Roach			<td class="optionbox">
436*f36626dbSGreg Roach				<input type="checkbox" value="yes" id="show-common-surnames" name="show_common_surnames" <?php echo $show_common_surnames ? 'checked' : ''; ?>>
437*f36626dbSGreg Roach			</td>
438*f36626dbSGreg Roach		</tr>
439*f36626dbSGreg Roach		<tr>
440*f36626dbSGreg Roach			<td class="descriptionbox wrap width33">
441*f36626dbSGreg Roach				<label for="number-of-surnames">
442*f36626dbSGreg Roach					<?php echo I18N::translate('Number of surnames') ?>
443*f36626dbSGreg Roach				</label>
444*f36626dbSGreg Roach			</td>
445*f36626dbSGreg Roach			<td class="optionbox">
446*f36626dbSGreg Roach				<input
447*f36626dbSGreg Roach					id="number-of-surnames"
448*f36626dbSGreg Roach					maxlength="5"
449*f36626dbSGreg Roach					name="number_of_surnames"
450*f36626dbSGreg Roach					pattern="[1-9][0-9]*"
451*f36626dbSGreg Roach					required
452*f36626dbSGreg Roach					type="text"
453*f36626dbSGreg Roach					value="<?php echo Filter::escapeHtml($number_of_surnames); ?>"
454*f36626dbSGreg Roach				>
455*f36626dbSGreg Roach			</td>
456*f36626dbSGreg Roach		</tr>
4578c2e8227SGreg Roach		<?php
4588c2e8227SGreg Roach	}
4598c2e8227SGreg Roach}
460