function print_block_name_top10($block = true, $config = "", $side, $index)
{
    global $pgv_lang, $COMMON_NAMES_ADD, $COMMON_NAMES_REMOVE, $COMMON_NAMES_THRESHOLD, $PGV_BLOCKS, $ctype, $PGV_IMAGES, $PGV_IMAGE_DIR, $SURNAME_LIST_STYLE;
    if (empty($config)) {
        $config = $PGV_BLOCKS["print_block_name_top10"]["config"];
    }
    // This next function is a bit out of date, and doesn't cope well with surname variants
    $top_surnames = get_top_surnames(PGV_GED_ID, 1, $config["num"]);
    $all_surnames = array();
    foreach (array_keys($top_surnames) as $top_surname) {
        $all_surnames = array_merge($all_surnames, get_indilist_surns($top_surname, '', false, false, PGV_GED_ID));
    }
    // Insert from the "Add Names" list if not already in there
    if ($COMMON_NAMES_ADD) {
        foreach (preg_split('/[,; ]+/', $COMMON_NAMES_ADD) as $addname) {
            $ADDNAME = UTF8_strtoupper($addname);
            if (isset($all_surnames[$ADDNAME])) {
                $SURNAME = $ADDNAME;
                foreach (array_keys($all_surnames[$ADDNAME]) as $surname) {
                    if ($SURNAME != $surname && $SURNAME == UTF8_strtoupper($surname)) {
                        $all_surnames[$ADDNAME][$SURNAME] = $all_surnames[$ADDNAME][$surname];
                        unset($all_surnames[$ADDNAME][$surname]);
                    }
                }
                if (isset($all_surnames[$ADDNAME][$SURNAME])) {
                    $n = count($all_surnames[$ADDNAME][$SURNAME]);
                    $all_surnames[$ADDNAME][$SURNAME] = array_fill(0, max($n, $COMMON_NAMES_THRESHOLD), true);
                } else {
                    $all_surnames[$ADDNAME][$SURNAME] = array_fill(0, $COMMON_NAMES_THRESHOLD, true);
                }
            } else {
                $all_surnames[$ADDNAME][$ADDNAME] = array_fill(0, $COMMON_NAMES_THRESHOLD, true);
            }
        }
    }
    // Remove names found in the "Remove Names" list
    if ($COMMON_NAMES_REMOVE) {
        foreach (preg_split("/[,; ]+/", $COMMON_NAMES_REMOVE) as $delname) {
            unset($all_surnames[UTF8_strtoupper($delname)]);
        }
    }
    $id = "top10surnames";
    $title = print_help_link("index_common_names_help", "qm", "", false, true);
    if ($PGV_BLOCKS["print_block_name_top10"]["canconfig"]) {
        if ($ctype == "gedcom" && PGV_USER_GEDCOM_ADMIN || $ctype == "user" && PGV_USER_ID) {
            if ($ctype == "gedcom") {
                $name = PGV_GEDCOM;
            } else {
                $name = PGV_USER_NAME;
            }
            $title .= "<a href=\"javascript: configure block\" onclick=\"window.open('" . encode_url("index_edit.php?name={$name}&ctype={$ctype}&action=configure&side={$side}&index={$index}") . "', '_blank', 'top=50,left=50,width=600,height=350,scrollbars=1,resizable=1'); return false;\">";
            $title .= "<img class=\"adminicon\" src=\"{$PGV_IMAGE_DIR}/" . $PGV_IMAGES["admin"]["small"] . "\" width=\"15\" height=\"15\" border=\"0\" alt=\"" . $pgv_lang["config_block"] . "\" /></a>";
        }
    }
    $title .= str_replace("10", $config["num"], $pgv_lang["block_top10_title"]);
    switch ($SURNAME_LIST_STYLE) {
        case 'style3':
            uksort($all_surnames, 'stringsort');
            $content = format_surname_tagcloud($all_surnames, 'indilist', true);
            break;
        case 'style2':
        default:
            uasort($all_surnames, "top_surname_sort");
            $content = format_surname_table($all_surnames, 'indilist');
            break;
    }
    global $THEME_DIR;
    if ($block) {
        require $THEME_DIR . 'templates/block_small_temp.php';
    } else {
        require $THEME_DIR . 'templates/block_main_temp.php';
    }
}
Beispiel #2
0
$ged = safe_GET('ged');
if (empty($ged)) {
    $ged = $GEDCOM;
}
//-- rootid
$rootid = "";
if (PGV_USER_ID) {
    $rootid = PGV_USER_ROOT_ID;
    if (empty($_SESSION['user_ancestors']) || $_SESSION['user_ancestors'][1] !== $rootid) {
        unset($_SESSION['user_ancestors']);
        load_ancestors_array($rootid);
    }
}
//-- random surname
if ($surn == '*') {
    $surn = array_rand(get_indilist_surns("", "", false, true, PGV_GED_ID));
}
//-- form
print_header($pgv_lang["branch_list"] . " - " . $surn);
if ($ENABLE_AUTOCOMPLETE) {
    require PGV_ROOT . '/js/autocomplete.js.htm';
}
?>
<form name="surnlist" id="surnlist" action="?">
	<table class="center facts_table width50">
		<tr>
			<td class="descriptionbox <?php 
echo $TEXT_DIRECTION;
?>
">
				<?php 
Beispiel #3
0
 function chartCommonSurnames($params = null)
 {
     global $pgv_lang, $COMMON_NAMES_THRESHOLD, $PGV_STATS_CHART_COLOR1, $PGV_STATS_CHART_COLOR2, $PGV_STATS_S_CHART_X, $PGV_STATS_S_CHART_Y;
     if ($params === null) {
         $params = array();
     }
     if (isset($params[0]) && $params[0] != '') {
         $size = strtolower($params[0]);
     } else {
         $size = $PGV_STATS_S_CHART_X . "x" . $PGV_STATS_S_CHART_Y;
     }
     if (isset($params[1]) && $params[1] != '') {
         $color_from = strtolower($params[1]);
     } else {
         $color_from = $PGV_STATS_CHART_COLOR1;
     }
     if (isset($params[2]) && $params[2] != '') {
         $color_to = strtolower($params[2]);
     } else {
         $color_to = $PGV_STATS_CHART_COLOR2;
     }
     if (isset($params[3]) && $params[3] != '') {
         $threshold = strtolower($params[3]);
     } else {
         $threshold = $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);
     uasort($surnames, array('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, get_indilist_surns(UTF8_strtoupper($surname), '', false, false, PGV_GED_ID));
     }
     if (count($surnames) <= 0) {
         return '';
     }
     $tot = 0;
     foreach ($surnames as $indexval => $surname) {
         $tot += $surname['match'];
     }
     $chart_title = "";
     $chd = '';
     $chl = array();
     foreach ($all_surnames as $surn => $surns) {
         foreach ($surns as $spfxsurn => $indis) {
             if ($tot == 0) {
                 $per = 0;
             } else {
                 $per = round(100 * count($indis) / $tot_indi, 0);
             }
             $chd .= self::_array_to_extended_encoding($per);
             $chl[] = $spfxsurn . ' - ' . count($indis);
             $chart_title .= $spfxsurn . ' [' . count($indis) . '], ';
         }
     }
     $per = round(100 * ($tot_indi - $tot) / $tot_indi, 0);
     $chd .= self::_array_to_extended_encoding($per);
     $chl[] = $pgv_lang["other"] . ' - ' . ($tot_indi - $tot);
     $chart_title .= $pgv_lang["other"] . ' [' . ($tot_indi - $tot) . ']';
     $chl = join('|', $chl);
     return "<img src=\"" . encode_url("http://chart.apis.google.com/chart?cht=p3&amp;chd=e:{$chd}&amp;chs={$size}&amp;chco={$color_from},{$color_to}&amp;chf=bg,s,ffffff00&amp;chl={$chl}") . "\" width=\"{$sizes[0]}\" height=\"{$sizes[1]}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />";
 }