/**
  * Generate the HTML content of this block.
  *
  * @param int      $block_id
  * @param bool     $template
  * @param string[] $cfg
  *
  * @return string
  */
 public function getBlock($block_id, $template = true, $cfg = array())
 {
     global $WT_TREE, $ctype;
     $show_last_update = $this->getBlockSetting($block_id, 'show_last_update', '1');
     $show_common_surnames = $this->getBlockSetting($block_id, 'show_common_surnames', '1');
     $stat_indi = $this->getBlockSetting($block_id, 'stat_indi', '1');
     $stat_fam = $this->getBlockSetting($block_id, 'stat_fam', '1');
     $stat_sour = $this->getBlockSetting($block_id, 'stat_sour', '1');
     $stat_media = $this->getBlockSetting($block_id, 'stat_media', '1');
     $stat_repo = $this->getBlockSetting($block_id, 'stat_repo', '1');
     $stat_surname = $this->getBlockSetting($block_id, 'stat_surname', '1');
     $stat_events = $this->getBlockSetting($block_id, 'stat_events', '1');
     $stat_users = $this->getBlockSetting($block_id, 'stat_users', '1');
     $stat_first_birth = $this->getBlockSetting($block_id, 'stat_first_birth', '1');
     $stat_last_birth = $this->getBlockSetting($block_id, 'stat_last_birth', '1');
     $stat_first_death = $this->getBlockSetting($block_id, 'stat_first_death', '1');
     $stat_last_death = $this->getBlockSetting($block_id, 'stat_last_death', '1');
     $stat_long_life = $this->getBlockSetting($block_id, 'stat_long_life', '1');
     $stat_avg_life = $this->getBlockSetting($block_id, 'stat_avg_life', '1');
     $stat_most_chil = $this->getBlockSetting($block_id, 'stat_most_chil', '1');
     $stat_avg_chil = $this->getBlockSetting($block_id, 'stat_avg_chil', '1');
     // This can be overriden when embedding in an HTML block
     $block = '0';
     $stat_link = '1';
     foreach (array('show_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', 'stat_link', 'block') as $name) {
         if (array_key_exists($name, $cfg)) {
             ${$name} = $cfg[$name];
         }
     }
     $id = $this->getName() . $block_id;
     $class = $this->getName() . '_block';
     if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) {
         $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>';
     } else {
         $title = '';
     }
     $title .= $this->getTitle();
     $stats = new Stats($WT_TREE);
     $content = '<b>' . $WT_TREE->getTitleHtml() . '</b><br>';
     if ($show_last_update) {
         $content .= '<div>' . I18N::translate('This family tree was last updated on %s.', strip_tags($stats->gedcomUpdated())) . '</div>';
     }
     /** 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&amp;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&amp;surname_sublist=yes&amp;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>';
     }
     if (!$block) {
         $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>';
         if (!$block) {
             $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>';
         if (!$block) {
             $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>';
         if (!$block) {
             $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>';
         if (!$block) {
             $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>';
         if (!$block) {
             $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>';
         if (!$block) {
             $content .= '<div class="facts_value stat-cell left">' . I18N::translate('Males') . ':&nbsp;' . $stats->averageLifespanMale();
             $content .= '&nbsp;&nbsp;&nbsp;' . I18N::translate('Females') . ':&nbsp;' . $stats->averageLifespanFemale() . '</div>';
         }
         $content .= '</div>';
     }
     if ($stat_most_chil && !$block) {
         $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>';
         if (!$block) {
             $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>';
         if (!$block) {
             $content .= '<div class="facts_value stat-cell left"></div>';
         }
         $content .= '</div>';
     }
     $content .= '</div>';
     if ($stat_link) {
         $content .= '<div class="clearfloat"><a href="statistics.php?ged=' . $WT_TREE->getNameUrl() . '" rel="nofollow"><b>' . I18N::translate('View statistics as graphs') . '</b></a></div>';
     }
     if ($show_common_surnames) {
         $surnames = FunctionsDb::getCommonSurnames($WT_TREE->getPreference('COMMON_NAMES_THRESHOLD'), $WT_TREE);
         if (count($surnames) > 0) {
             $content .= '<div class="clearfloat"><p><b>' . I18N::translate('Most common surnames') . '</b></p>';
             $content .= '<div class="common_surnames">';
             $i = 0;
             foreach ($surnames as $indexval => $surname) {
                 if (stristr($surname['name'], '@N.N') === false) {
                     if ($i > 0) {
                         $content .= ', ';
                     }
                     $content .= '<a href="' . "indilist.php?ged=" . $WT_TREE->getNameUrl() . "&amp;surname=" . rawurlencode($surname['name']) . '">' . $surname['name'] . '</a>';
                     $i++;
                 }
             }
             $content .= '</div>';
         }
     }
     if ($template) {
         return Theme::theme()->formatBlock($id, $title, $class, $content);
     } else {
         return $content;
     }
 }
 /**
  * Generate the HTML content of this block.
  *
  * @param int      $block_id
  * @param bool     $template
  * @param string[] $cfg
  *
  * @return string
  */
 public function getBlock($block_id, $template = true, $cfg = array())
 {
     global $WT_TREE, $ctype;
     $show_last_update = $this->getBlockSetting($block_id, 'show_last_update', '1');
     $show_common_surnames = $this->getBlockSetting($block_id, 'show_common_surnames', '1');
     $number_of_surnames = $this->getBlockSetting($block_id, 'number_of_surnames', self::DEFAULT_NUMBER_OF_SURNAMES);
     $stat_indi = $this->getBlockSetting($block_id, 'stat_indi', '1');
     $stat_fam = $this->getBlockSetting($block_id, 'stat_fam', '1');
     $stat_sour = $this->getBlockSetting($block_id, 'stat_sour', '1');
     $stat_media = $this->getBlockSetting($block_id, 'stat_media', '1');
     $stat_repo = $this->getBlockSetting($block_id, 'stat_repo', '1');
     $stat_surname = $this->getBlockSetting($block_id, 'stat_surname', '1');
     $stat_events = $this->getBlockSetting($block_id, 'stat_events', '1');
     $stat_users = $this->getBlockSetting($block_id, 'stat_users', '1');
     $stat_first_birth = $this->getBlockSetting($block_id, 'stat_first_birth', '1');
     $stat_last_birth = $this->getBlockSetting($block_id, 'stat_last_birth', '1');
     $stat_first_death = $this->getBlockSetting($block_id, 'stat_first_death', '1');
     $stat_last_death = $this->getBlockSetting($block_id, 'stat_last_death', '1');
     $stat_long_life = $this->getBlockSetting($block_id, 'stat_long_life', '1');
     $stat_avg_life = $this->getBlockSetting($block_id, 'stat_avg_life', '1');
     $stat_most_chil = $this->getBlockSetting($block_id, 'stat_most_chil', '1');
     $stat_avg_chil = $this->getBlockSetting($block_id, 'stat_avg_chil', '1');
     // This can be overriden when embedding in an HTML block
     $block = '0';
     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) {
         if (array_key_exists($name, $cfg)) {
             ${$name} = $cfg[$name];
         }
     }
     $id = $this->getName() . $block_id;
     $class = $this->getName() . '_block';
     if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) {
         $title = '<a class="icon-admin" title="' . I18N::translate('Preferences') . '" href="block_edit.php?block_id=' . $block_id . '&amp;ged=' . $WT_TREE->getNameHtml() . '&amp;ctype=' . $ctype . '"></a>';
     } else {
         $title = '';
     }
     $title .= $this->getTitle() . ' — ' . $WT_TREE->getTitleHtml();
     $stats = new Stats($WT_TREE);
     $content = '';
     if ($show_last_update) {
         $content .= '<p>' . 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&amp;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&amp;surname_sublist=yes&amp;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>';
     }
     if (!$block) {
         $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>';
         if (!$block) {
             $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>';
         if (!$block) {
             $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>';
         if (!$block) {
             $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>';
         if (!$block) {
             $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>';
         if (!$block) {
             $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>';
         if (!$block) {
             $content .= '<div class="facts_value stat-cell left">' . I18N::translate('Males') . ':&nbsp;' . $stats->averageLifespanMale();
             $content .= '&nbsp;&nbsp;&nbsp;' . I18N::translate('Females') . ':&nbsp;' . $stats->averageLifespanFemale() . '</div>';
         }
         $content .= '</div>';
     }
     if ($stat_most_chil && !$block) {
         $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>';
         if (!$block) {
             $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>';
         if (!$block) {
             $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);
         $all_surnames = array();
         foreach (array_keys($surnames) as $surname) {
             $all_surnames = array_merge($all_surnames, QueryName::surnames($WT_TREE, $surname, '', false, false));
         }
         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>';
         }
     }
     if ($template) {
         return Theme::theme()->formatBlock($id, $title, $class, $content);
     } else {
         return $content;
     }
 }
Пример #3
0
 /**
  * {@inheritDoc}
  * @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\AbstractTask::executeSteps()
  */
 protected function executeSteps()
 {
     $res = false;
     // Get the number of days to take into account, either last 7 days or since last check
     $interval_sincelast = 0;
     if ($this->last_updated) {
         $tmpInt = $this->last_updated->diff(new \DateTime('now'), true);
         $interval_sincelast = ($tmpInt->days * 24 + $tmpInt->h) * 60 + $tmpInt->i;
     }
     $interval = max($this->frequency, $interval_sincelast);
     $nbdays = ceil($interval / (24 * 60));
     // Check for updates
     $latest_version_txt = Functions::fetchLatestVersion();
     if (preg_match('/^[0-9.]+\\|[0-9.]+\\|/', $latest_version_txt)) {
         list($latest_version, , $download_url) = explode('|', $latest_version_txt);
     } else {
         // Cannot determine the latest version
         list($latest_version, , $download_url) = explode('|', '||');
     }
     // Users statistics
     $warnusers = 0;
     $nverusers = 0;
     $applusers = 0;
     foreach (User::all() as $user) {
         if (date("U") - (int) $user->getPreference('reg_timestamp') > 604800 && !$user->getPreference('verified')) {
             $warnusers++;
         }
         if (!$user->getPreference('verified_by_admin') && $user->getPreference('verified')) {
             $nverusers++;
         }
         if (!$user->getPreference('verified')) {
             $applusers++;
         }
     }
     // Tree specifics checks
     $one_tree_done = false;
     foreach (Tree::getAll() as $tree) {
         $isTreeEnabled = $tree->getPreference('MAJ_AT_' . $this->getName() . '_ENABLED');
         if ((is_null($isTreeEnabled) || $isTreeEnabled) && ($webmaster = User::find($tree->getPreference('WEBMASTER_USER_ID')))) {
             I18N::init($webmaster->getPreference('language'));
             $subject = I18N::translate('Health Check Report') . ' - ' . I18N::translate('Tree %s', $tree->getTitle());
             $message = I18N::translate('Health Check Report for the last %d days', $nbdays) . Mail::EOL . Mail::EOL . I18N::translate('Tree %s', $tree->getTitle()) . Mail::EOL . '==========================================' . Mail::EOL . Mail::EOL;
             // News
             $message_version = '';
             if ($latest_version && version_compare(WT_VERSION, $latest_version) < 0) {
                 $message_version = I18N::translate('News') . Mail::EOL . '-------------' . Mail::EOL . I18N::translate('A new version of *webtrees* is available: %s. Upgrade as soon as possible.', $latest_version) . Mail::EOL . I18N::translate('Download it here: %s.', $download_url) . Mail::EOL . Mail::EOL;
             }
             $message .= $message_version;
             // Statistics users
             $message_users = I18N::translate('Users') . Mail::EOL . '-------------' . Mail::EOL . WT_BASE_URL . 'admin_users.php' . Mail::EOL . I18N::translate('Total number of users') . "\t\t" . User::count() . Mail::EOL . I18N::translate('Not verified by the user') . "\t\t" . $applusers . Mail::EOL . I18N::translate('Not approved by an administrator') . "\t" . $nverusers . Mail::EOL . Mail::EOL;
             $message .= $message_users;
             // Statistics tree:
             $stats = new Stats($tree);
             $sql = 'SELECT ged_type AS type, COUNT(change_id) AS chgcount FROM wt_change' . ' JOIN (' . ' SELECT "indi" AS ged_type, i_id AS ged_id, i_file AS ged_file FROM wt_individuals' . ' UNION SELECT "fam" AS ged_type, f_id AS ged_id, f_file AS ged_file FROM wt_families' . ' UNION SELECT "sour" AS ged_type, s_id AS ged_id, s_file AS ged_file FROM wt_sources' . ' UNION SELECT "media" AS ged_type, m_id AS ged_id, m_file AS ged_file FROM wt_media' . ' UNION SELECT LOWER(o_type) AS ged_type, o_id AS ged_id, o_file AS ged_file FROM wt_other' . ') AS gedrecords ON (xref = ged_id AND gedcom_id = ged_file)' . ' WHERE change_time >= DATE_ADD( NOW(), INTERVAL - :nb_days DAY)' . ' AND status = :status AND gedcom_id = :gedcom_id' . ' GROUP BY ged_type';
             $changes = Database::prepare($sql)->execute(array('status' => 'accepted', 'gedcom_id' => $tree->getTreeId(), 'nb_days' => $nbdays))->fetchAssoc();
             $message_gedcom = I18N::translate('Tree statistics') . Mail::EOL . '-------------' . Mail::EOL . sprintf('%-25s', I18N::translate('Records')) . "\t" . sprintf('%15s', I18N::translate('Count')) . "\t" . sprintf('%15s', I18N::translate('Changes')) . Mail::EOL . sprintf('%-25s', I18N::translate('Individuals')) . "\t" . sprintf('%15s', $stats->totalIndividuals()) . "\t" . sprintf('%15s', isset($changes['indi']) ? $changes['indi'] : 0) . Mail::EOL . sprintf('%-25s', I18N::translate('Families')) . "\t" . sprintf('%15s', $stats->totalFamilies()) . "\t" . sprintf('%15s', isset($changes['fam']) ? $changes['fam'] : 0) . Mail::EOL . sprintf('%-25s', I18N::translate('Sources')) . "\t" . sprintf('%15s', $stats->totalSources()) . "\t" . sprintf('%15s', isset($changes['sour']) ? $changes['sour'] : 0) . Mail::EOL . sprintf('%-25s', I18N::translate('Repositories')) . "\t" . sprintf('%15s', $stats->totalRepositories()) . "\t" . sprintf('%15s', isset($changes['repo']) ? $changes['repo'] : 0) . Mail::EOL . sprintf('%-25s', I18N::translate('Media objects')) . "\t" . sprintf('%15s', $stats->totalMedia()) . "\t" . sprintf('%15s', isset($changes['media']) ? $changes['media'] : 0) . Mail::EOL . sprintf('%-25s', I18N::translate('Notes')) . "\t" . sprintf('%15s', $stats->totalNotes()) . "\t" . sprintf('%15s', isset($changes['note']) ? $changes['note'] : 0) . Mail::EOL . Mail::EOL;
             $message .= $message_gedcom;
             //Errors
             $sql = 'SELECT SQL_CACHE log_message, gedcom_id, COUNT(log_id) as nblogs, MAX(log_time) as lastoccurred' . ' FROM `##log`' . ' WHERE log_type = :log_type AND (gedcom_id = :gedcom_id OR ISNULL(gedcom_id))' . ' AND log_time >= DATE_ADD( NOW(), INTERVAL - :nb_days DAY)' . ' GROUP BY log_message, gedcom_id' . ' ORDER BY lastoccurred DESC';
             $errors = Database::prepare($sql)->execute(array('log_type' => Log::TYPE_ERROR, 'gedcom_id' => $tree->getTreeId(), 'nb_days' => $nbdays))->fetchAll();
             $nb_errors = 0;
             $tmp_message = '';
             $nb_char_count_title = strlen(I18N::translate('Count'));
             $nb_char_type = max(strlen(I18N::translate('Type')), strlen(I18N::translate('Site')), strlen(I18N::translate('Tree')));
             foreach ($errors as $error) {
                 $tmp_message .= sprintf('%' . $nb_char_count_title . 'd', $error->nblogs) . "\t";
                 $tmp_message .= sprintf('%' . $nb_char_type . 's', is_null($error->gedcom_id) ? I18N::translate('Site') : I18N::translate('Tree'));
                 $tmp_message .= "\t" . sprintf('%20s', $error->lastoccurred) . "\t";
                 $tmp_message .= str_replace("\n", "\n\t\t\t\t\t\t", $error->log_message) . Mail::EOL;
                 $nb_errors += $error->nblogs;
             }
             if ($nb_errors > 0) {
                 $message .= I18N::translate('Errors [%d]', $nb_errors) . Mail::EOL . '-------------' . Mail::EOL . WT_BASE_URL . 'admin_site_logs.php' . Mail::EOL . I18N::translate('Count') . "\t" . sprintf('%-' . $nb_char_type . 's', I18N::translate('Type')) . "\t" . sprintf('%-20s', I18N::translate('Last occurrence')) . "\t" . I18N::translate('Error') . Mail::EOL . str_repeat('-', $nb_char_count_title) . "\t" . str_repeat('-', $nb_char_type) . "\t" . str_repeat('-', 20) . "\t" . str_repeat('-', strlen(I18N::translate('Error'))) . Mail::EOL . $tmp_message . Mail::EOL;
             } else {
                 $message .= I18N::translate('No errors', $nb_errors) . Mail::EOL . Mail::EOL;
             }
             $tmpres = true;
             if ($webmaster->getPreference('contactmethod') !== 'messaging' && $webmaster->getPreference('contactmethod') !== 'none') {
                 $tmpres = Mail::systemMessage($tree, $webmaster, $subject, $message);
             }
             $res = $tmpres && (!$one_tree_done || $one_tree_done && $res);
             $one_tree_done = true;
         }
     }
     return $res;
 }
Пример #4
0
				<td class="facts_value" align="center">', $stats->totalSurnames(), '</td>
				<td class="facts_value" align="center">', $stats->totalGivennames(), '</td>
			</tr>
			<tr>
				<td class="facts_label">', I18N::translate('Top surnames'), '</td>
				<td class="facts_label">', I18N::translate('Top given names'), '</td>
			</tr>
			<tr>
				<td class="facts_value statistics-page">', $stats->chartCommonSurnames(), '</td>
				<td class="facts_value statistics-page">', $stats->chartCommonGiven(), '</td>
			</tr>
		</table>
		</fieldset>';
    } elseif ($tab == 1) {
        echo '<fieldset>
		<legend>', I18N::translate('Total families: %s', $stats->totalFamilies()), '</legend>
		<b>', I18N::translate('Events'), '</b>
		<table class="facts_table">
			<tr>
				<td class="facts_label">', I18N::translate('Total marriages'), '</td>
				<td class="facts_label">', I18N::translate('Total divorces'), '</td>
			</tr>
			<tr>
				<td class="facts_value" align="center">', $stats->totalMarriages(), '</td>
				<td class="facts_value" align="center">', $stats->totalDivorces(), '</td>
			</tr>
			<tr>
				<td class="facts_label">', I18N::translate('Marriages by century'), '</td>
				<td class="facts_label">', I18N::translate('Divorces by century'), '</td>
			</tr>
			<tr>