i18n::translate('Top 10 Given Names'),
'type'=>'both',
'descr'=>i18n::translate('This block shows a table of the 10 most frequently occurring given names in the database. The actual number of given names shown in this block is configurable.'),
'canconfig'=>true,
'config'=>array(
'cache'=>7,
'num'=>10,
'infoStyle'=>'style2',
'showUnknown'=>true
)
);
/**
* Print First Names Block
*/
function print_block_givn_top10($block=true, $config="", $side, $index) {
global $TEXT_DIRECTION, $WT_BLOCKS, $ctype, $WT_IMAGES, $WT_IMAGE_DIR;
if (empty($config)) $config = $WT_BLOCKS["print_block_givn_top10"]["config"];
if (isset($config["infoStyle"])) $infoStyle = $config["infoStyle"]; // "style1" or "style2"
else $infoStyle = "style2";
if (isset($config["showUnknown"])) $showUnknown = $config["showUnknown"];
else $showUnknown = true;
$stats=new Stats(WT_GEDCOM);
//Print block header
$id="top10givennames";
$title='';
if ($WT_BLOCKS["print_block_givn_top10"]["canconfig"]) {
if ($ctype=="gedcom" && WT_USER_GEDCOM_ADMIN || $ctype=="user" && WT_USER_ID) {
if ($ctype=="gedcom") {
$name = WT_GEDCOM;
} else {
$name = WT_USER_NAME;
}
$title .= "";
$title .= "";
}
}
// I18N: There are separate lists of male/female names, containing %d names each
$title .= i18n::plural('Top Given Name', 'Top %d Given Names', $config['num'], $config['num']);
$title .= help_link('index_common_given_names');
$content = '
';
//Select List or Table
switch ($infoStyle) {
case "style1": // Output style 1: Simple list style. Better suited to left side of page.
if ($TEXT_DIRECTION=='ltr') $padding = 'padding-left: 15px';
else $padding = 'padding-right: 15px';
$params=array(1,$config['num'],'rcount');
//List Female names
$totals=$stats->commonGivenFemaleTotals($params);
if ($totals) {
$content.=''.i18n::translate('Female').'
'.$totals.'
';
}
//List Male names
$totals=$stats->commonGivenMaleTotals($params);
if ($totals) {
$content.=''.i18n::translate('Male').'
';
}
break;
case "style2": // Style 2: Tabular format. Narrow, 2 or 3 column table, good on right side of page
$params=array(1,$config['num'],'rcount');
$content.='
'.$stats->commonGivenFemaleTable($params).'
';
$content.='
'.$stats->commonGivenMaleTable($params).'
';
if ($showUnknown) {
$content.='
'.$stats->commonGivenUnknownTable($params).'
';
}
$content.='
';
break;
}
$content .= "
";
global $THEME_DIR;
if ($block) {
require $THEME_DIR.'templates/block_small_temp.php';
} else {
require $THEME_DIR.'templates/block_main_temp.php';
}
}
function print_block_givn_top10_config($config) {
global $ctype, $WT_BLOCKS, $TEXT_DIRECTION;
if (empty($config)) $config = $WT_BLOCKS["print_block_givn_top10"]["config"];
if (!isset($config["cache"])) $config["cache"] = $WT_BLOCKS["print_block_givn_top10"]["config"]["cache"];
if (!isset($config["infoStyle"])) $config["infoStyle"] = "style2";
if (!isset($config["showUnknown"])) $config["showUnknown"] = true;
print "