echo '<a href="', $url, '&show=' . $show . '&show_marnm=no">', WT_I18N::translate('Exclude individuals with “%s” as a married name', $legend), '</a>'; } else { echo '<a href="', $url, '&show=' . $show . '&show_marnm=yes">', WT_I18N::translate('Include individuals with “%s” as a married name', $legend), '</a>'; } if ($alpha != '@' && $alpha != ',' && !$surname) { if ($show == 'surn') { echo '<br><a href="', $url, '&show=indi">', WT_I18N::translate('Show the list of individuals'), '</a>'; } else { echo '<br><a href="', $url, '&show=surn">', WT_I18N::translate('Show the list of surnames'), '</a>'; } } } echo '</p>'; } if ($show == 'indi' || $show == 'surn') { $surns = WT_Query_Name::surnames($surname, $alpha, $show_marnm, true, WT_GED_ID); if ($show == 'surn') { // Show the surname list switch ($SURNAME_LIST_STYLE) { case 'style1': echo format_surname_list($surns, 3, true, WT_SCRIPT_NAME); break; case 'style3': echo format_surname_tagcloud($surns, WT_SCRIPT_NAME, true); break; case 'style2': default: echo format_surname_table($surns, WT_SCRIPT_NAME); break; } } else {
function chartCommonSurnames($params = null) { global $WT_STATS_CHART_COLOR1, $WT_STATS_CHART_COLOR2, $WT_STATS_S_CHART_X, $WT_STATS_S_CHART_Y; if ($params === null) { $params = array(); } if (isset($params[0]) && $params[0] != '') { $size = strtolower($params[0]); } else { $size = $WT_STATS_S_CHART_X . "x" . $WT_STATS_S_CHART_Y; } if (isset($params[1]) && $params[1] != '') { $color_from = strtolower($params[1]); } else { $color_from = $WT_STATS_CHART_COLOR1; } if (isset($params[2]) && $params[2] != '') { $color_to = strtolower($params[2]); } else { $color_to = $WT_STATS_CHART_COLOR2; } if (isset($params[3]) && $params[3] != '') { $threshold = strtolower($params[3]); } else { $threshold = get_gedcom_setting($this->_ged_id, 'COMMON_NAMES_THRESHOLD'); } if (isset($params[4]) && $params[4] != '') { $maxtoshow = strtolower($params[4]); } else { $maxtoshow = 7; } $sizes = explode('x', $size); $tot_indi = $this->_totalIndividuals(); $surnames = get_common_surnames($threshold); if (count($surnames) <= 0) { return ''; } $SURNAME_TRADITION = get_gedcom_setting(WT_GED_ID, 'SURNAME_TRADITION'); uasort($surnames, array('WT_Stats', '_name_total_rsort')); $surnames = array_slice($surnames, 0, $maxtoshow); $all_surnames = array(); foreach (array_keys($surnames) as $n => $surname) { if ($n >= $maxtoshow) { break; } $all_surnames = array_merge($all_surnames, WT_Query_Name::surnames(WT_I18N::strtoupper($surname), '', false, false, WT_GED_ID)); } $tot = 0; foreach ($surnames as $surname) { $tot += $surname['match']; } $chd = ''; $chl = array(); foreach ($all_surnames as $surns) { $count_per = 0; $max_name = 0; foreach ($surns as $spfxsurn => $indis) { $per = count($indis); $count_per += $per; // select most common surname from all variants if ($per > $max_name) { $max_name = $per; $top_name = $spfxsurn; } } switch ($SURNAME_TRADITION) { case 'polish': // most common surname should be in male variant (Kowalski, not Kowalska) $top_name = preg_replace(array('/ska$/', '/cka$/', '/dzka$/', '/żka$/'), array('ski', 'cki', 'dzki', 'żki'), $top_name); } $per = round(100 * $count_per / $tot_indi, 0); $chd .= self::_array_to_extended_encoding($per); //ToDo: RTL names are often printed LTR when also LTR names are present $chl[] = $top_name . ' - ' . WT_I18N::number($count_per); } $per = round(100 * ($tot_indi - $tot) / $tot_indi, 0); $chd .= self::_array_to_extended_encoding($per); $chl[] = WT_I18N::translate('Other') . ' - ' . WT_I18N::number($tot_indi - $tot); $chart_title = implode(WT_I18N::$list_separator, $chl); $chl = implode('|', $chl); return '<img src="https://chart.googleapis.com/chart?cht=p3&chd=e:' . $chd . '&chs=' . $size . '&chco=' . $color_from . ',' . $color_to . '&chf=bg,s,ffffff00&chl=' . rawurlencode($chl) . '" width="' . $sizes[0] . '" height="' . $sizes[1] . '" alt="' . $chart_title . '" title="' . $chart_title . '" />'; }
public function getBlock($block_id, $template = true, $cfg = null) { global $ctype, $SURNAME_LIST_STYLE; require_once WT_ROOT . 'includes/functions/functions_print_lists.php'; $COMMON_NAMES_REMOVE = get_gedcom_setting(WT_GED_ID, 'COMMON_NAMES_REMOVE'); $COMMON_NAMES_THRESHOLD = get_gedcom_setting(WT_GED_ID, 'COMMON_NAMES_THRESHOLD'); $num = get_block_setting($block_id, 'num', 10); $infoStyle = get_block_setting($block_id, 'infoStyle', 'table'); $block = get_block_setting($block_id, 'block', false); if ($cfg) { foreach (array('num', 'infoStyle', 'block') as $name) { if (array_key_exists($name, $cfg)) { ${$name} = $cfg[$name]; } } } // This next function is a bit out of date, and doesn't cope well with surname variants $top_surnames = get_top_surnames(WT_GED_ID, $COMMON_NAMES_THRESHOLD, $num); // Remove names found in the "Remove Names" list if ($COMMON_NAMES_REMOVE) { foreach (preg_split("/[,; ]+/", $COMMON_NAMES_REMOVE) as $delname) { unset($top_surnames[$delname]); unset($top_surnames[WT_I18N::strtoupper($delname)]); } } $all_surnames = array(); $i = 0; foreach (array_keys($top_surnames) as $top_surname) { $all_surnames = array_merge($all_surnames, WT_Query_Name::surnames($top_surname, '', false, false, WT_GED_ID)); if (++$i == $num) { break; } } if ($i < $num) { $num = $i; } $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; if ($ctype == 'gedcom' && WT_USER_GEDCOM_ADMIN || $ctype == 'user' && WT_USER_ID) { $title = '<i class="icon-admin" title="' . WT_I18N::translate('Configure') . '" onclick="modalDialog(\'block_edit.php?block_id=' . $block_id . '\', \'' . $this->getTitle() . '\');"></i>'; } else { $title = ''; } if ($num == 1) { // I18N: i.e. most popular surname. $title .= WT_I18N::translate('Top surname'); } else { // I18N: Title for a list of the most common surnames, %s is a number. Note that a separate translation exists when %s is 1 $title .= WT_I18N::plural('Top %s surname', 'Top %s surnames', $num, WT_I18N::number($num)); } switch ($infoStyle) { case 'tagcloud': uksort($all_surnames, array('WT_I18N', 'strcasecmp')); $content = format_surname_tagcloud($all_surnames, 'indilist.php', true); break; case 'list': uasort($all_surnames, array('top10_surnames_WT_Module', 'top_surname_sort')); $content = format_surname_list($all_surnames, '1', true, 'indilist.php'); break; case 'array': uasort($all_surnames, array('top10_surnames_WT_Module', 'top_surname_sort')); $content = format_surname_list($all_surnames, '2', true, 'indilist.php'); break; case 'table': default: uasort($all_surnames, array('top10_surnames_WT_Module', 'top_surname_sort')); $content = format_surname_table($all_surnames, 'indilist.php'); break; } if ($template) { if ($block) { require WT_THEME_DIR . 'templates/block_small_temp.php'; } else { require WT_THEME_DIR . 'templates/block_main_temp.php'; } } else { return $content; } }
public function getAlphaSurnames($alpha, $surname1 = '') { $surnames = WT_Query_Name::surnames('', $alpha, true, false, WT_GED_ID); $out = '<ul>'; foreach (array_keys($surnames) as $surname) { $out .= '<li id="sb_indi_' . $surname . '" class="sb_indi_surname_li"><a href="' . $surname . '" title="' . $surname . '" alt="' . $alpha . '" class="sb_indi_surname">' . $surname . '</a>'; if (!empty($surname1) && $surname1 == $surname) { $out .= '<div class="name_tree_div_visible">'; $out .= $this->getSurnameIndis($alpha, $surname1); $out .= '</div>'; } else { $out .= '<div class="name_tree_div"></div>'; } $out .= '</li>'; } $out .= '</ul>'; return $out; }