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 { // Show the list $count = 0; foreach ($surns as $surnames) { foreach ($surnames as $list) { $count += count($list);
static function _commonSurnamesQuery($type = 'list', $show_tot = false, $params = null) { global $GEDCOM; $ged_id = get_id_from_gedcom($GEDCOM); if (is_array($params) && isset($params[0]) && $params[0] != '') { $threshold = strtolower($params[0]); } else { $threshold = get_gedcom_setting($ged_id, 'COMMON_NAMES_THRESHOLD'); } if (is_array($params) && isset($params[1]) && $params[1] != '' && $params[1] >= 0) { $maxtoshow = strtolower($params[1]); } else { $maxtoshow = false; } if (is_array($params) && isset($params[2]) && $params[2] != '') { $sorting = strtolower($params[2]); } else { $sorting = 'alpha'; } $surname_list = get_common_surnames($threshold); if (count($surname_list) == 0) { return ''; } uasort($surname_list, array('WT_Stats', '_name_total_rsort')); if ($maxtoshow > 0) { $surname_list = array_slice($surname_list, 0, $maxtoshow); } switch ($sorting) { default: case 'alpha': uksort($surname_list, array('WT_I18N', 'strcasecmp')); break; case 'count': uasort($surname_list, array('WT_Stats', '_name_total_sort')); break; case 'rcount': uasort($surname_list, array('WT_Stats', '_name_total_rsort')); break; } // Note that we count/display SPFX SURN, but sort/group under just SURN $surnames = array(); foreach (array_keys($surname_list) as $surname) { $surnames = array_merge($surnames, WT_Query_Name::surnames($surname, '', false, false, WT_GED_ID)); } return format_surname_list($surnames, $type == 'list' ? 1 : 2, $show_tot, 'indilist.php'); }
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; } }
static function _commonSurnamesQuery($type = 'list', $show_tot = false, $params = null) { global $TEXT_DIRECTION, $COMMON_NAMES_THRESHOLD, $SURNAME_LIST_STYLE; if (is_array($params) && isset($params[0]) && $params[0] != '') { $threshold = strtolower($params[0]); } else { $threshold = $COMMON_NAMES_THRESHOLD; } if (is_array($params) && isset($params[1]) && $params[1] != '' && $params[1] >= 0) { $maxtoshow = strtolower($params[1]); } else { $maxtoshow = false; } if (is_array($params) && isset($params[2]) && $params[2] != '') { $sorting = strtolower($params[2]); } else { $sorting = 'alpha'; } $surname_list = get_common_surnames($threshold); if (count($surname_list) == 0) { return ''; } uasort($surname_list, array('stats', '_name_total_rsort')); if ($maxtoshow > 0) { $surname_list = array_slice($surname_list, 0, $maxtoshow); } switch ($sorting) { default: case 'alpha': uasort($surname_list, array('stats', '_name_name_sort')); break; case 'ralpha': uasort($surname_list, array('stats', '_name_name_rsort')); break; case 'count': uasort($surname_list, array('stats', '_name_total_sort')); break; case 'rcount': uasort($surname_list, array('stats', '_name_total_rsort')); break; } // Note that we count/display SPFX SURN, but sort/group under just SURN $surnames = array(); foreach (array_keys($surname_list) as $surname) { $surnames = array_merge($surnames, get_indilist_surns($surname, '', false, false, PGV_GED_ID)); } return format_surname_list($surnames, $type == 'list' ? 1 : 2, $show_tot); }