public function getSurnameIndis($alpha, $surname) { $indis = WT_Query_Name::individuals($surname, $alpha, '', true, false, WT_GED_ID); $out = '<ul>'; foreach ($indis as $person) { if ($person->canShowName()) { $out .= '<li><a href="' . $person->getHtmlUrl() . '">' . $person->getSexImage() . ' ' . $person->getFullName() . ' '; if ($person->canShow()) { $bd = $person->getLifeSpan(); if (!empty($bd)) { $out .= ' (' . $bd . ')'; } } $out .= '</a></li>'; } } $out .= '</ul>'; return $out; }
function chartDistribution($params = null) { global $WT_STATS_CHART_COLOR1, $WT_STATS_CHART_COLOR2, $WT_STATS_CHART_COLOR3, $WT_STATS_MAP_X, $WT_STATS_MAP_Y; if ($params !== null && isset($params[0])) { $chart_shows = $params[0]; } else { $chart_shows = 'world'; } if ($params !== null && isset($params[1])) { $chart_type = $params[1]; } else { $chart_type = ''; } if ($params !== null && isset($params[2])) { $surname = $params[2]; } else { $surname = ''; } if ($this->_totalPlaces() == 0) { return ''; } // Get the country names for each language $country_to_iso3166 = array(); foreach (WT_I18N::installed_languages() as $code => $lang) { WT_I18N::init($code); $countries = self::get_all_countries(); foreach (self::iso3166() as $three => $two) { $country_to_iso3166[$three] = $two; $country_to_iso3166[$countries[$three]] = $two; } } WT_I18N::init(WT_LOCALE); switch ($chart_type) { case 'surname_distribution_chart': if ($surname == "") { $surname = $this->getCommonSurname(); } $chart_title = WT_I18N::translate('Surname distribution chart') . ': ' . $surname; // Count how many people are events in each country $surn_countries = array(); $indis = WT_Query_Name::individuals(WT_I18N::strtoupper($surname), '', '', false, false, WT_GED_ID); foreach ($indis as $person) { if (preg_match_all('/^2 PLAC (?:.*, *)*(.*)/m', $person->getGedcom(), $matches)) { // webtrees uses 3 letter country codes and localised country names, but google uses 2 letter codes. foreach ($matches[1] as $country) { if (array_key_exists($country, $country_to_iso3166)) { if (array_key_exists($country_to_iso3166[$country], $surn_countries)) { $surn_countries[$country_to_iso3166[$country]]++; } else { $surn_countries[$country_to_iso3166[$country]] = 1; } } } } } break; case 'birth_distribution_chart': $chart_title = WT_I18N::translate('Birth by country'); // Count how many people were born in each country $surn_countries = array(); $b_countries = $this->_statsPlaces('INDI', 'BIRT', 0, true); foreach ($b_countries as $place => $count) { $country = $place; if (array_key_exists($country, $country_to_iso3166)) { if (!isset($surn_countries[$country_to_iso3166[$country]])) { $surn_countries[$country_to_iso3166[$country]] = $count; } else { $surn_countries[$country_to_iso3166[$country]] += $count; } } } break; case 'death_distribution_chart': $chart_title = WT_I18N::translate('Death by country'); // Count how many people were death in each country $surn_countries = array(); $d_countries = $this->_statsPlaces('INDI', 'DEAT', 0, true); foreach ($d_countries as $place => $count) { $country = $place; if (array_key_exists($country, $country_to_iso3166)) { if (!isset($surn_countries[$country_to_iso3166[$country]])) { $surn_countries[$country_to_iso3166[$country]] = $count; } else { $surn_countries[$country_to_iso3166[$country]] += $count; } } } break; case 'marriage_distribution_chart': $chart_title = WT_I18N::translate('Marriage by country'); // Count how many families got marriage in each country $surn_countries = array(); $m_countries = $this->_statsPlaces('FAM'); // webtrees uses 3 letter country codes and localised country names, but google uses 2 letter codes. foreach ($m_countries as $place) { $country = $place['country']; if (array_key_exists($country, $country_to_iso3166)) { if (!isset($surn_countries[$country_to_iso3166[$country]])) { $surn_countries[$country_to_iso3166[$country]] = $place['tot']; } else { $surn_countries[$country_to_iso3166[$country]] += $place['tot']; } } } break; case 'indi_distribution_chart': default: $chart_title = WT_I18N::translate('Individual distribution chart'); // Count how many people are events in each country $surn_countries = array(); $a_countries = $this->_statsPlaces('INDI'); // webtrees uses 3 letter country codes and localised country names, but google uses 2 letter codes. foreach ($a_countries as $place) { $country = $place['country']; if (array_key_exists($country, $country_to_iso3166)) { if (!isset($surn_countries[$country_to_iso3166[$country]])) { $surn_countries[$country_to_iso3166[$country]] = $place['tot']; } else { $surn_countries[$country_to_iso3166[$country]] += $place['tot']; } } } break; } $chart_url = "https://chart.googleapis.com/chart?cht=t&chtm=" . $chart_shows; $chart_url .= "&chco=" . $WT_STATS_CHART_COLOR1 . "," . $WT_STATS_CHART_COLOR3 . "," . $WT_STATS_CHART_COLOR2; // country colours $chart_url .= "&chf=bg,s,ECF5FF"; // sea colour $chart_url .= "&chs=" . $WT_STATS_MAP_X . "x" . $WT_STATS_MAP_Y; $chart_url .= "&chld=" . implode('', array_keys($surn_countries)) . "&chd=s:"; foreach ($surn_countries as $count) { $chart_url .= substr(WT_GOOGLE_CHART_ENCODING, (int) ($count / max($surn_countries) * 61), 1); } $chart = '<div id="google_charts" class="center">'; $chart .= '<b>' . $chart_title . '</b><br><br>'; $chart .= '<div align="center"><img src="' . $chart_url . '" alt="' . $chart_title . '" title="' . $chart_title . '" class="gchart" /><br>'; $chart .= '<table align="center" border="0" cellpadding="1" cellspacing="1"><tr>'; $chart .= '<td bgcolor="#' . $WT_STATS_CHART_COLOR2 . '" width="12"></td><td>' . WT_I18N::translate('Highest population') . ' </td>'; $chart .= '<td bgcolor="#' . $WT_STATS_CHART_COLOR3 . '" width="12"></td><td>' . WT_I18N::translate('Lowest population') . ' </td>'; $chart .= '<td bgcolor="#' . $WT_STATS_CHART_COLOR1 . '" width="12"></td><td>' . WT_I18N::translate('Nobody at all') . ' </td>'; $chart .= '</tr></table></div></div>'; return $chart; }
break; } if ($count) { if ($show == 'indi' && $givn_initial == $falpha && $show_all_firstnames == 'no') { $list[] = '<a class="warning" href="' . $url . '&falpha=' . rawurlencode($givn_initial) . '" title="' . WT_I18N::number($count) . '">' . $html . '</a>'; } else { $list[] = '<a href="' . $url . '&falpha=' . rawurlencode($givn_initial) . '" title="' . WT_I18N::number($count) . '">' . $html . '</a>'; } } else { $list[] = $html; } } // Search spiders don't get the "show all" option as the other links give them everything. if (!$SEARCH_SPIDER) { if ($show_all_firstnames == 'yes') { $list[] = '<span class="warning">' . WT_I18N::translate('All') . '</span>'; } else { $list[] = '<a href="' . $url . '&show_all_firstnames=yes">' . WT_I18N::translate('All') . '</a>'; } } if ($show_all == 'no') { echo '<h2 class="center">', WT_I18N::translate('Individuals with surname %s', $legend), '</h2>'; } echo '<p class="center alpha_index">', join(' | ', $list), '</p>'; } } if ($show == 'indi') { echo format_indi_table(WT_Query_Name::individuals($surname, $alpha, $falpha, $show_marnm, false, WT_GED_ID)); } } }