diff options
Diffstat (limited to 'app/Module')
| -rw-r--r-- | app/Module/FamilyTreeStatisticsModule.php | 146 |
1 files changed, 40 insertions, 106 deletions
diff --git a/app/Module/FamilyTreeStatisticsModule.php b/app/Module/FamilyTreeStatisticsModule.php index b4cf69b6d0..cdae708335 100644 --- a/app/Module/FamilyTreeStatisticsModule.php +++ b/app/Module/FamilyTreeStatisticsModule.php @@ -35,12 +35,14 @@ class FamilyTreeStatisticsModule extends AbstractModule implements ModuleBlockIn /** {@inheritdoc} */ public function getTitle() { - return /* I18N: Name of a module */ I18N::translate('Statistics'); + return /* I18N: Name of a module */ + I18N::translate('Statistics'); } /** {@inheritdoc} */ public function getDescription() { - return /* I18N: Description of “Statistics” module */ I18N::translate('The size of the family tree, earliest and latest events, common names, etc.'); + return /* I18N: Description of “Statistics” module */ + I18N::translate('The size of the family tree, earliest and latest events, common names, etc.'); } /** @@ -81,94 +83,6 @@ class FamilyTreeStatisticsModule extends AbstractModule implements ModuleBlockIn } } - $stats = new Stats($WT_TREE); - - $content = ''; - - if ($show_last_update) { - $content .= '<p>' . /* I18N: %s is a date */ - I18N::translate('This family tree was last updated on %s.', strip_tags($stats->gedcomUpdated())) . '</p>'; - } - - /** Responsive Design */ - $content .= '<div class="stat-table1">'; - if ($stat_indi) { - $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&ged=' . $WT_TREE->getNameUrl() . '">' . $stats->totalIndividuals() . '</a></div></div>'; - $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>'; - $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>'; - } - if ($stat_surname) { - $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&surname_sublist=yes&ged=' . $WT_TREE->getNameUrl() . '">' . $stats->totalSurnames() . '</a></div></div>'; - } - if ($stat_fam) { - $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>'; - } - if ($stat_sour) { - $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>'; - } - if ($stat_media) { - $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>'; - } - if ($stat_repo) { - $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>'; - } - if ($stat_events) { - $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>'; - } - if ($stat_users) { - $content .= '<div class="stat-row"><div class="facts_label stat-cell">' . I18N::translate('Total users') . '</div><div class="facts_value stats_value stat-cell">'; - if (Auth::isManager($WT_TREE)) { - $content .= '<a href="admin_users.php">' . $stats->totalUsers() . '</a>'; - } else { - $content .= $stats->totalUsers(); - } - $content .= '</div></div>'; - } - $content .= '</div><div class="facts_table stat-table2">'; - if ($stat_first_birth) { - $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>'; - $content .= '<div class="facts_value stat-cell left">' . $stats->firstBirth() . '</div>'; - $content .= '</div>'; - } - if ($stat_last_birth) { - $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>'; - $content .= '<div class="facts_value stat-cell left">' . $stats->lastBirth() . '</div>'; - $content .= '</div>'; - } - if ($stat_first_death) { - $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>'; - $content .= '<div class="facts_value stat-cell left">' . $stats->firstDeath() . '</div>'; - $content .= '</div>'; - } - if ($stat_last_death) { - $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>'; - $content .= '<div class="facts_value stat-cell left">' . $stats->lastDeath() . '</div>'; - $content .= '</div>'; - } - if ($stat_long_life) { - $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>'; - $content .= '<div class="facts_value stat-cell left">' . $stats->longestLife() . '</div>'; - $content .= '</div>'; - } - if ($stat_avg_life) { - $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>'; - $content .= '<div class="facts_value stat-cell left">' . I18N::translate('Males') . ': ' . $stats->averageLifespanMale(); - $content .= ' ' . I18N::translate('Females') . ': ' . $stats->averageLifespanFemale() . '</div>'; - $content .= '</div>'; - } - - if ($stat_most_chil) { - $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>'; - $content .= '<div class="facts_value stat-cell left">' . $stats->largestFamily() . '</div>'; - $content .= '</div>'; - } - if ($stat_avg_chil) { - $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>'; - $content .= '<div class="facts_value stat-cell left"></div>'; - $content .= '</div>'; - } - $content .= '</div>'; - if ($show_common_surnames) { $surnames = FunctionsDb::getTopSurnames($WT_TREE->getTreeId(), 0, (int) $number_of_surnames); @@ -176,19 +90,37 @@ class FamilyTreeStatisticsModule extends AbstractModule implements ModuleBlockIn foreach (array_keys($surnames) as $surname) { $all_surnames = array_merge($all_surnames, QueryName::surnames($WT_TREE, $surname, '', false, false)); } + ksort($all_surnames); - if (!empty($surnames)) { - ksort($all_surnames); - $content .= '<div class="clearfloat">'; - $content .= '<p>'; - $content .= '<strong>' . I18N::translate('Most common surnames') . '</strong>'; - $content .= '<br>'; - $content .= '<span class="common_surnames">' . FunctionsPrintLists::surnameList($all_surnames, 2, false, 'indilist.php', $WT_TREE) . '</span>'; - $content .= '</p>'; - $content .= '</div>'; - } + $surnames = FunctionsPrintLists::surnameList($all_surnames, 2, false, 'indilist.php', $WT_TREE); + } else { + $surnames = ''; } + $content = View::make('blocks/family-tree-statistics', [ + 'show_last_update' => $show_last_update, + 'show_common_surnames' => $show_common_surnames, + 'number_of_surnames' => $number_of_surnames, + 'stat_indi' => $stat_indi, + 'stat_fam' => $stat_fam, + 'stat_sour' => $stat_sour, + 'stat_media' => $stat_media, + 'stat_repo' => $stat_repo, + 'stat_surname' => $stat_surname, + 'stat_events' => $stat_events, + 'stat_users' => $stat_users, + 'stat_first_birth' => $stat_first_birth, + 'stat_last_birth' => $stat_last_birth, + 'stat_first_death' => $stat_first_death, + 'stat_last_death' => $stat_last_death, + 'stat_long_life' => $stat_long_life, + 'stat_avg_life' => $stat_avg_life, + 'stat_most_chil' => $stat_most_chil, + 'stat_avg_chil' => $stat_avg_chil, + 'stats' => new Stats($WT_TREE), + 'surnames' => $surnames, + ]); + if ($template) { if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) { $config_url = Html::url('block_edit.php', ['block_id' => $block_id, 'ged' => $WT_TREE->getName()]); @@ -279,7 +211,8 @@ class FamilyTreeStatisticsModule extends AbstractModule implements ModuleBlockIn <?= I18N::translate('Last change') ?> </legend> <div class="col-sm-9"> - <?= Bootstrap4::checkbox(/* I18N: label for yes/no option */ I18N::translate('Show date of last update'), false, ['name' => 'show_last_update', 'checked' => (bool) $show_last_update]) ?> + <?= Bootstrap4::checkbox(/* I18N: label for yes/no option */ + I18N::translate('Show date of last update'), false, ['name' => 'show_last_update', 'checked' => (bool) $show_last_update]) ?> </div> </div> </fieldset> @@ -298,10 +231,10 @@ class FamilyTreeStatisticsModule extends AbstractModule implements ModuleBlockIn <?= Bootstrap4::checkbox(I18N::translate('Repositories'), false, ['name' => 'stat_repo', 'checked' => (bool) $stat_repo]) ?> <?= Bootstrap4::checkbox(I18N::translate('Total events'), false, ['name' => 'stat_events', 'checked' => (bool) $stat_events]) ?> <?= Bootstrap4::checkbox(I18N::translate('Total users'), false, ['name' => 'stat_users', 'checked' => (bool) $stat_users]) ?> - <?= Bootstrap4::checkbox(I18N::translate('Earliest birth year'), false, ['name' => 'stat_first_birth', 'checked' => (bool) $stat_first_birth]) ?> - <?= Bootstrap4::checkbox(I18N::translate('Latest birth year'), false, ['name' => 'stat_last_birth', 'checked' => (bool) $stat_last_birth]) ?> - <?= Bootstrap4::checkbox(I18N::translate('Earliest death year'), false, ['name' => 'stat_first_death', 'checked' => (bool) $stat_first_death]) ?> - <?= Bootstrap4::checkbox(I18N::translate('Latest death year'), false, ['name' => 'stat_last_death', 'checked' => (bool) $stat_last_death]) ?> + <?= Bootstrap4::checkbox(I18N::translate('Earliest birth'), false, ['name' => 'stat_first_birth', 'checked' => (bool) $stat_first_birth]) ?> + <?= Bootstrap4::checkbox(I18N::translate('Latest birth'), false, ['name' => 'stat_last_birth', 'checked' => (bool) $stat_last_birth]) ?> + <?= Bootstrap4::checkbox(I18N::translate('Earliest death'), false, ['name' => 'stat_first_death', 'checked' => (bool) $stat_first_death]) ?> + <?= Bootstrap4::checkbox(I18N::translate('Latest death'), false, ['name' => 'stat_last_death', 'checked' => (bool) $stat_last_death]) ?> <?= Bootstrap4::checkbox(I18N::translate('Individual who lived the longest'), false, ['name' => 'stat_long_life', 'checked' => (bool) $stat_long_life]) ?> <?= Bootstrap4::checkbox(I18N::translate('Average age at death'), false, ['name' => 'stat_avg_life', 'checked' => (bool) $stat_avg_life]) ?> <?= Bootstrap4::checkbox(I18N::translate('Family with the most children'), false, ['name' => 'stat_most_chil', 'checked' => (bool) $stat_most_chil]) ?> @@ -320,7 +253,8 @@ class FamilyTreeStatisticsModule extends AbstractModule implements ModuleBlockIn <div class="col-sm-9"> <?= Bootstrap4::checkbox(I18N::translate('Most common surnames'), false, ['name' => 'show_common_surnames', 'checked' => (bool) $show_common_surnames]) ?> <label for="number_of_surnames"> - <?= /* I18N: ... to show in a list */ I18N::translate('Number of surnames') ?> + <?= /* I18N: ... to show in a list */ + I18N::translate('Number of surnames') ?> <input class="form-control" id="number_of_surnames" |
