surnameList() public static method

Print a list of surnames.
public static surnameList ( string[][] $surnames, integer $style, boolean $totals, string $script, Fisharebest\Webtrees\Tree $tree ) : string
$surnames string[][] array (of SURN, of array of SPFX_SURN, of array of PID)
$style integer 1=bullet list, 2=semicolon-separated list, 3=tabulated list with up to 4 columns
$totals boolean show totals after each name
$script string indilist or famlist
$tree Fisharebest\Webtrees\Tree Link back to the individual list in this tree
return string
Exemplo n.º 1
0
 /**
  * {@inhericDoc}
  * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent()
  */
 protected function renderContent()
 {
     /** @var \Fisharebest\Webtrees\Tree $tree */
     $tree = $this->data->get('tree');
     echo '<h2 class="center">', $this->data->get('title'), '</h2>';
     echo '<p class="center alpha_index">', implode(' | ', $this->getInitialLettersList()), '</p>';
     if ($this->data->get('issurnames', false)) {
         $surns = $this->data->get('surnameslist', array());
         $extra_params = array('mod' => Constants::MODULE_MAJ_PATROLIN_NAME, 'mod_action' => 'Lineage');
         // Show the surname list
         switch ($tree->getPreference('SURNAME_LIST_STYLE')) {
             case 'style1':
                 echo FunctionsPrintLists::surnameList($surns, 3, true, WT_SCRIPT_NAME, $tree, $extra_params);
                 break;
             case 'style3':
                 echo FunctionsPrintLists::surnameTagCloud($surns, WT_SCRIPT_NAME, true, $tree, $extra_params);
                 break;
             case 'style2':
             default:
                 echo FunctionsPrintLists::surnameTable($surns, WT_SCRIPT_NAME, $tree, $extra_params);
                 break;
         }
     } else {
         if ($this->data->get('islineages', false)) {
             //Link to indilist
             echo '<p class="center"><strong>' . '<a href="indilist.php?ged=' . $tree->getNameUrl() . '&surname=' . rawurlencode($this->data->get('surname')) . '">' . I18N::translate('Go to the list of individuals with surname %s', $this->data->get('legend')) . '</a></strong></p>';
             $lineages = $this->data->get('lineages', null);
             $nb_lineages = count($lineages);
             if (is_null($lineages) || $nb_lineages == 0) {
                 echo '<p class="center"><span class="warning">', I18N::translate('No individuals with surname %s has been found. Please try another name.', '<span dir="auto">' . $this->data->get('legend') . '</span>'), '</span></p>';
             } else {
                 echo '<div id="patronymiclineages">' . '<div class="list_label">', $this->data->get('table_title'), '</div>';
                 echo '<div class="list_value_wrap">';
                 foreach ($lineages as $i => $lineage) {
                     $this->printRootLineage($lineage);
                     if ($i < $nb_lineages - 1) {
                         echo '<hr />';
                     }
                 }
                 echo '</div>';
                 echo '<div class="list_label">', I18N::translate('%s lineages found', $nb_lineages), '</div>' . '</div>';
             }
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Find common surnames.
  *
  * @param string   $type
  * @param bool     $show_tot
  * @param string[] $params
  *
  * @return string
  */
 private function commonSurnamesQuery($type = 'list', $show_tot = false, $params = array())
 {
     if (isset($params[0]) && $params[0] > 0) {
         $threshold = (int) $params[0];
     } else {
         $threshold = $this->tree->getPreference('COMMON_NAMES_THRESHOLD');
     }
     if (isset($params[1])) {
         $maxtoshow = (int) $params[1];
     } else {
         $maxtoshow = 0;
     }
     if (isset($params[2])) {
         $sorting = $params[2];
     } else {
         $sorting = 'alpha';
     }
     $surname_list = FunctionsDb::getCommonSurnames($threshold, $this->tree);
     if (count($surname_list) == 0) {
         return '';
     }
     uasort($surname_list, '\\Fisharebest\\Webtrees\\Stats::nameTotalReverseSort');
     if ($maxtoshow > 0) {
         $surname_list = array_slice($surname_list, 0, $maxtoshow);
     }
     switch ($sorting) {
         default:
         case 'alpha':
             uksort($surname_list, '\\Fisharebest\\Webtrees\\I18N::strcasecmp');
             break;
         case 'count':
             uasort($surname_list, '\\Fisharebest\\Webtrees\\Stats::nameTotalSort');
             break;
         case 'rcount':
             uasort($surname_list, '\\Fisharebest\\Webtrees\\Stats::nameTotalReverseSort');
             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, QueryName::surnames($this->tree, $surname, '', false, false));
     }
     return FunctionsPrintLists::surnameList($surnames, $type == 'list' ? 1 : 2, $show_tot, 'indilist.php', $this->tree);
 }
Exemplo n.º 3
0
            if ($show === 'surn') {
                echo '<br><a href="', $url, '&amp;show=indi">', I18N::translate('Show the list of individuals'), '</a>';
            } else {
                echo '<br><a href="', $url, '&amp;show=surn">', I18N::translate('Show the list of surnames'), '</a>';
            }
        }
    }
    echo '</p>';
}
if ($show === 'indi' || $show === 'surn') {
    $surns = QueryName::surnames($WT_TREE, $surname, $alpha, $show_marnm === 'yes', false);
    if ($show === 'surn') {
        // Show the surname list
        switch ($WT_TREE->getPreference('SURNAME_LIST_STYLE')) {
            case 'style1':
                echo FunctionsPrintLists::surnameList($surns, 3, true, WT_SCRIPT_NAME, $WT_TREE);
                break;
            case 'style3':
                echo FunctionsPrintLists::surnameTagCloud($surns, WT_SCRIPT_NAME, true, $WT_TREE);
                break;
            case 'style2':
            default:
                echo FunctionsPrintLists::surnameTable($surns, WT_SCRIPT_NAME, $WT_TREE);
                break;
        }
    } else {
        // Show the list
        $count = 0;
        foreach ($surns as $surnames) {
            foreach ($surnames as $list) {
                $count += count($list);
Exemplo n.º 4
0
 /**
  * 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;
     $COMMON_NAMES_REMOVE = $WT_TREE->getPreference('COMMON_NAMES_REMOVE');
     $COMMON_NAMES_THRESHOLD = $WT_TREE->getPreference('COMMON_NAMES_THRESHOLD');
     $num = $this->getBlockSetting($block_id, 'num', '10');
     $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', 'table');
     $block = $this->getBlockSetting($block_id, 'block', '0');
     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 = FunctionsDb::getTopSurnames($WT_TREE->getTreeId(), $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[I18N::strtoupper($delname)]);
         }
     }
     $all_surnames = array();
     $i = 0;
     foreach (array_keys($top_surnames) as $top_surname) {
         $all_surnames = array_merge($all_surnames, QueryName::surnames($WT_TREE, $top_surname, '', false, false));
         if (++$i == $num) {
             break;
         }
     }
     if ($i < $num) {
         $num = $i;
     }
     $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 = '';
     }
     if ($num == 1) {
         // I18N: i.e. most popular surname.
         $title .= 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 .= I18N::plural('Top %s surname', 'Top %s surnames', $num, I18N::number($num));
     }
     switch ($infoStyle) {
         case 'tagcloud':
             uksort($all_surnames, '\\Fisharebest\\Webtrees\\I18N::strcasecmp');
             $content = FunctionsPrintLists::surnameTagCloud($all_surnames, 'indilist.php', true, $WT_TREE);
             break;
         case 'list':
             uasort($all_surnames, '\\Fisharebest\\Webtrees\\Module\\TopSurnamesModule::surnameCountSort');
             $content = FunctionsPrintLists::surnameList($all_surnames, '1', true, 'indilist.php', $WT_TREE);
             break;
         case 'array':
             uasort($all_surnames, '\\Fisharebest\\Webtrees\\Module\\TopSurnamesModule::surnameCountSort');
             $content = FunctionsPrintLists::surnameList($all_surnames, '2', true, 'indilist.php', $WT_TREE);
             break;
         case 'table':
         default:
             uasort($all_surnames, '\\Fisharebest\\Webtrees\\Module\\TopSurnamesModule::surnameCountSort');
             $content = FunctionsPrintLists::surnameTable($all_surnames, 'indilist.php', $WT_TREE);
             break;
     }
     if ($template) {
         if ($block) {
             $class .= ' small_inner_block';
         }
         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;
     }
 }
Exemplo n.º 6
0
 /**
  * Find common surnames.
  *
  * @param string   $type
  * @param bool     $show_tot
  * @param string[] $params
  *
  * @return string
  */
 private function commonSurnamesQuery($type = 'list', $show_tot = false, $params = array())
 {
     $threshold = empty($params[0]) ? 10 : (int) $params[0];
     $number_of_surnames = empty($params[1]) ? 10 : (int) $params[1];
     $sorting = empty($params[2]) ? 'alpha' : $params[2];
     $surname_list = FunctionsDb::getTopSurnames($this->tree->getTreeId(), $threshold, $number_of_surnames);
     if (empty($surname_list)) {
         return '';
     }
     switch ($sorting) {
         default:
         case 'alpha':
             uksort($surname_list, '\\Fisharebest\\Webtrees\\I18N::strcasecmp');
             break;
         case 'count':
             asort($surname_list);
             break;
         case 'rcount':
             arsort($surname_list);
             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, QueryName::surnames($this->tree, $surname, '', false, false));
     }
     return FunctionsPrintLists::surnameList($surnames, $type == 'list' ? 1 : 2, $show_tot, 'indilist.php', $this->tree);
 }
Exemplo n.º 7
0
 /**
  * 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;
     $COMMON_NAMES_REMOVE = $WT_TREE->getPreference('COMMON_NAMES_REMOVE');
     $COMMON_NAMES_THRESHOLD = $WT_TREE->getPreference('COMMON_NAMES_THRESHOLD');
     $num = $this->getBlockSetting($block_id, 'num', '10');
     // The “Minimum number of occurrences” input field from Control Panel’s Preferences page
     // has to be copied here otherwise user doesn't understand why the result is different
     // than expected (input of add and remove surnames may also be copied to make this module
     // indenpendent from module statistics; it is not copied yet).  The data of original input
     // field is still used in the bottom of the statistics module
     $threshold = $this->getBlockSetting($block_id, 'threshold', '5');
     $infoStyle = $this->getBlockSetting($block_id, 'infoStyle', 'table');
     $block = $this->getBlockSetting($block_id, 'block', '0');
     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
     // First defining the upper limit of surname occurrences to get at least one row in
     // result list if user sets too high number in “Minimum number of occurrences” field.
     // Without this definition a short message “No data available in table” appears by
     // webtrees\packages\datatables-1.10.7\js\jquery.dataTables.min.js JavaScript file
     // without the possibility of translating (and only if presentation style is table;
     // all other styles result no message at all)
     $top_surnames_in_DB = FunctionsDb::getCommonSurnames($WT_TREE->getPreference('COMMON_NAMES_THRESHOLD'), $WT_TREE);
     $max_occurrences = 0;
     foreach ($top_surnames_in_DB as $array) {
         if ($array['match'] > $max_occurrences) {
             $max_occurrences = $array['match'];
         }
     }
     if ($threshold > $max_occurrences) {
         $threshold = $max_occurrences;
     }
     $top_surnames = FunctionsDb::getTopSurnames($WT_TREE->getTreeId(), $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[I18N::strtoupper($delname)]);
         }
     }
     $all_surnames = array();
     $i = 0;
     foreach (array_keys($top_surnames) as $top_surname) {
         $all_surnames = array_merge($all_surnames, QueryName::surnames($WT_TREE, $top_surname, '', false, false));
         if (++$i == $num) {
             break;
         }
     }
     if ($i < $num) {
         $num = $i;
     }
     $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 = '';
     }
     if ($num == 1) {
         // I18N: i.e. most popular surname.
         $title .= 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 .= I18N::plural('Top %s surname', 'Top %s surnames', $num, I18N::number($num));
     }
     switch ($infoStyle) {
         case 'tagcloud':
             uksort($all_surnames, '\\Fisharebest\\Webtrees\\I18N::strcasecmp');
             $content = FunctionsPrintLists::surnameTagCloud($all_surnames, 'indilist.php', true, $WT_TREE);
             break;
         case 'list':
             uasort($all_surnames, '\\Fisharebest\\Webtrees\\Module\\TopSurnamesModule::surnameCountSort');
             $content = FunctionsPrintLists::surnameList($all_surnames, '1', true, 'indilist.php', $WT_TREE);
             break;
         case 'array':
             uasort($all_surnames, '\\Fisharebest\\Webtrees\\Module\\TopSurnamesModule::surnameCountSort');
             $content = FunctionsPrintLists::surnameList($all_surnames, '2', true, 'indilist.php', $WT_TREE);
             break;
         case 'table':
         default:
             uasort($all_surnames, '\\Fisharebest\\Webtrees\\Module\\TopSurnamesModule::surnameCountSort');
             $content = FunctionsPrintLists::surnameTable($all_surnames, 'indilist.php', $WT_TREE);
             break;
     }
     if ($template) {
         if ($block) {
             $class .= ' small_inner_block';
         }
         return Theme::theme()->formatBlock($id, $title, $class, $content);
     } else {
         return $content;
     }
 }