예제 #1
0
function format_indi_table($datalist, $option = '')
{
    global $GEDCOM, $SHOW_LAST_CHANGE, $SEARCH_SPIDER, $MAX_ALIVE_AGE, $controller;
    $table_id = 'table-indi-' . Uuid::uuid4();
    // lists requires a unique ID in case there are multiple lists per page
    $SHOW_EST_LIST_DATES = get_gedcom_setting(WT_GED_ID, 'SHOW_EST_LIST_DATES');
    $controller->addExternalJavascript(WT_JQUERY_DATATABLES_URL)->addInlineJavascript('
			jQuery.fn.dataTableExt.oSort["unicode-asc"  ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))};
			jQuery.fn.dataTableExt.oSort["unicode-desc" ]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))};
			jQuery.fn.dataTableExt.oSort["num-html-asc" ]=function(a,b) {a=parseFloat(a.replace(/<[^<]*>/, "")); b=parseFloat(b.replace(/<[^<]*>/, "")); return (a<b) ? -1 : (a>b ? 1 : 0);};
			jQuery.fn.dataTableExt.oSort["num-html-desc"]=function(a,b) {a=parseFloat(a.replace(/<[^<]*>/, "")); b=parseFloat(b.replace(/<[^<]*>/, "")); return (a>b) ? -1 : (a<b ? 1 : 0);};
			jQuery("#' . $table_id . '").dataTable( {
				dom: \'<"H"<"filtersH_' . $table_id . '">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_' . $table_id . '">>\',
				' . WT_I18N::datatablesI18N() . ',
				jQueryUI: true,
				autoWidth: false,
				processing: true,
				retrieve: true,
				columns: [
					/*  0 givn      */ { dataSort: 2 },
					/*  1 surn      */ { dataSort: 3 },
					/*  2 GIVN,SURN */ { type: "unicode", visible: false },
					/*  3 SURN,GIVN */ { type: "unicode", visible: false },
					/*  4 sosa      */ { dataSort: 5, class: "center", visible: ' . ($option == 'sosa' ? 'true' : 'false') . ' },
					/*  5 SOSA      */ { type: "num", visible: false },
					/*  6 birt date */ { dataSort: 7 },
					/*  7 BIRT:DATE */ { visible: false },
					/*  8 anniv     */ { dataSort: 7, class: "center" },
					/*  9 birt plac */ { type: "unicode" },
					/* 10 children  */ { dataSort: 11, class: "center" },
					/* 11 children  */ { type: "num", visible: false },
					/* 12 deat date */ { dataSort: 13 },
					/* 13 DEAT:DATE */ { visible: false },
					/* 14 anniv     */ { dataSort: 13, class: "center" },
					/* 15 age       */ { dataSort: 16, class: "center" },
					/* 16 AGE       */ { type: "num", visible: false },
					/* 17 deat plac */ { type: "unicode" },
					/* 18 CHAN      */ { dataSort: 19, visible: ' . ($SHOW_LAST_CHANGE ? 'true' : 'false') . ' },
					/* 19 CHAN_sort */ { visible: false },
					/* 20 SEX       */ { visible: false },
					/* 21 BIRT      */ { visible: false },
					/* 22 DEAT      */ { visible: false },
					/* 23 TREE      */ { visible: false }
				],
				sorting: [[' . ($option == 'sosa' ? '4, "asc"' : '1, "asc"') . ']],
				displayLength: 20,
				pagingType: "full_numbers"
			});

			jQuery("#' . $table_id . '")
			/* Hide/show parents */
			.on("click", ".btn-toggle-parents", function() {
				jQuery(this).toggleClass("ui-state-active");
				jQuery(".parents", jQuery(this).closest("table").DataTable().rows().nodes()).slideToggle();
			})
			/* Hide/show statistics */
			.on("click", ".btn-toggle-statistics", function() {
				jQuery(this).toggleClass("ui-state-active");
				jQuery("#indi_list_table-charts_' . $table_id . '").slideToggle();
			})
			/* Filter buttons in table header */
			.on("click", "button[data-filter-column]", function() {
				var btn = jQuery(this);
				// De-activate the other buttons in this button group
				btn.siblings().removeClass("ui-state-active");
				// Apply (or clear) this filter
				var col = jQuery("#' . $table_id . '").DataTable().column(btn.data("filter-column"));
				if (btn.hasClass("ui-state-active")) {
					btn.removeClass("ui-state-active");
					col.search("").draw();
				} else {
					btn.addClass("ui-state-active");
					col.search(btn.data("filter-value")).draw();
				}
			});

			jQuery(".indi-list").css("visibility", "visible");
			jQuery(".loading-image").css("display", "none");
		');
    $stats = new WT_Stats($GEDCOM);
    // Bad data can cause "longest life" to be huge, blowing memory limits
    $max_age = min($MAX_ALIVE_AGE, $stats->LongestLifeAge()) + 1;
    // Inititialise chart data
    for ($age = 0; $age <= $max_age; $age++) {
        $deat_by_age[$age] = '';
    }
    for ($year = 1550; $year < 2030; $year += 10) {
        $birt_by_decade[$year] = '';
        $deat_by_decade[$year] = '';
    }
    $html = '
		<div class="loading-image">&nbsp;</div>
		<div class="indi-list">
			<table id="' . $table_id . '">
				<thead>
					<tr>
						<th colspan="24">
							<div class="btn-toolbar">
								<div class="btn-group">
									<button
										class="ui-state-default"
										data-filter-column="20"
										data-filter-value="M"
										title="' . WT_I18N::translate('Show only males.') . '"
										type="button"
									>
									 	' . WT_Individual::sexImage('M', 'large') . '
									</button>
									<button
										class="ui-state-default"
										data-filter-column="20"
										data-filter-value="F"
										title="' . WT_I18N::translate('Show only females.') . '"
										type="button"
									>
										' . WT_Individual::sexImage('F', 'large') . '
									</button>
									<button
										class="ui-state-default"
										data-filter-column="20"
										data-filter-value="U"
										title="' . WT_I18N::translate('Show only individuals for whom the gender is not known.') . '"
										type="button"
									>
										' . WT_Individual::sexImage('U', 'large') . '
									</button>
								</div>
								<div class="btn-group">
									<button
										class="ui-state-default"
										data-filter-column="22"
										data-filter-value="N"
										title="' . WT_I18N::translate('Show individuals who are alive or couples where both partners are alive.') . '"
										type="button"
									>
										' . WT_I18N::translate('Alive') . '
									</button>
									<button
										class="ui-state-default"
										data-filter-column="22"
										data-filter-value="Y"
										title="' . WT_I18N::translate('Show individuals who are dead or couples where both partners are deceased.') . '"
										type="button"
									>
										' . WT_I18N::translate('Dead') . '
									</button>
									<button
										class="ui-state-default"
										data-filter-column="22"
										data-filter-value="YES"
										title="' . WT_I18N::translate('Show individuals who died more than 100 years ago.') . '"
										type="button"
									>
										' . WT_Gedcom_Tag::getLabel('DEAT') . '&gt;100
									</button>
									<button
										class="ui-state-default"
										data-filter-column="22"
										data-filter-value="Y100"
										title="' . WT_I18N::translate('Show individuals who died within the last 100 years.') . '"
										type="button"
									>
										' . WT_Gedcom_Tag::getLabel('DEAT') . '&lt;=100
									</button>
								</div>
								<div class="btn-group">
									<button
										class="ui-state-default"
										data-filter-column="21"
										data-filter-value="YES"
										title="' . WT_I18N::translate('Show individuals born more than 100 years ago.') . '"
										type="button"
									>
										' . WT_Gedcom_Tag::getLabel('BIRT') . '&gt;100
									</button>
									<button
										class="ui-state-default"
										data-filter-column="21"
										data-filter-value="Y100"
										title="' . WT_I18N::translate('Show individuals born within the last 100 years.') . '"
										type="button"
									>
										' . WT_Gedcom_Tag::getLabel('BIRT') . '&lt;=100
									</button>
								</div>
								<div class="btn-group">
									<button
										class="ui-state-default"
										data-filter-column="23"
										data-filter-value="R"
										title="' . WT_I18N::translate('Show “roots” couples or individuals.  These individuals may also be called “patriarchs”.  They are individuals who have no parents recorded in the database.') . '"
										type="button"
									>
										' . WT_I18N::translate('Roots') . '
									</button>
									<button
										class="ui-state-default"
										data-filter-column="23"
										data-filter-value="L"
										title="' . WT_I18N::translate('Show “leaves” couples or individuals.  These are individuals who are alive but have no children recorded in the database.') . '"
										type="button"
									>
										' . WT_I18N::translate('Leaves') . '
									</button>
								</div>
							</div>
						</th>
					</tr>
					<tr>
						<th>' . WT_Gedcom_Tag::getLabel('GIVN') . '</th>
						<th>' . WT_Gedcom_Tag::getLabel('SURN') . '</th>
						<th>GIVN</th>
						<th>SURN</th>
						<th>' . WT_I18N::translate('Sosa') . '</th>
						<th>SOSA</th>
						<th>' . WT_Gedcom_Tag::getLabel('BIRT') . '</th>
						<th>SORT_BIRT</th>
						<th><i class="icon-reminder" title="' . WT_I18N::translate('Anniversary') . '"></i></th>
						<th>' . WT_Gedcom_Tag::getLabel('PLAC') . '</th>
						<th><i class="icon-children" title="' . WT_I18N::translate('Children') . '"></i></th>
						<th>NCHI</th>
						<th>' . WT_Gedcom_Tag::getLabel('DEAT') . '</th>
						<th>SORT_DEAT</th>
						<th><i class="icon-reminder" title="' . WT_I18N::translate('Anniversary') . '"></i></th>
						<th>' . WT_Gedcom_Tag::getLabel('AGE') . '</th>
						<th>AGE</th>
						<th>' . WT_Gedcom_Tag::getLabel('PLAC') . '</th>
						<th>' . WT_Gedcom_Tag::getLabel('CHAN') . '</th>
						<th>CHAN</th>
						<th>SEX</th>
						<th>BIRT</th>
						<th>DEAT</th>
						<th>TREE</th>
					</tr>
				</thead>
				<tfoot>
					<tr>
						<th colspan="24">
							<div class="btn-toolbar">
								<div class="btn-group">
									<button type="button" class="ui-state-default btn-toggle-parents">
										' . WT_I18N::translate('Show parents') . '
									</button>
									<button type="button" class="ui-state-default btn-toggle-statistics">
										' . WT_I18N::translate('Show statistics charts') . '
									</button>
								</div>
							</div>
						</th>
					</tr>
				</tfoot>
				<tbody>';
    $d100y = new WT_Date(date('Y') - 100);
    // 100 years ago
    $unique_indis = array();
    // Don't double-count indis with multiple names.
    foreach ($datalist as $key => $value) {
        if (is_object($value)) {
            // Array of objects
            $person = $value;
        } elseif (!is_array($value)) {
            // Array of IDs
            $person = WT_Individual::getInstance($value);
        } else {
            // Array of search results
            $gid = $key;
            if (isset($value['gid'])) {
                $gid = $value['gid'];
            }
            // from indilist
            if (isset($value[4])) {
                $gid = $value[4];
            }
            // from indilist ALL
            $person = WT_Individual::getInstance($gid);
        }
        if (!$person || !$person->canShowName()) {
            continue;
        }
        if ($person->isNew()) {
            $class = ' class="new"';
        } elseif ($person->isOld()) {
            $class = ' class="old"';
        } else {
            $class = '';
        }
        $html .= '<tr' . $class . '>';
        //-- Indi name(s)
        $html .= '<td colspan="2">';
        foreach ($person->getAllNames() as $num => $name) {
            if ($name['type'] == 'NAME') {
                $title = '';
            } else {
                $title = 'title="' . strip_tags(WT_Gedcom_Tag::getLabel($name['type'], $person)) . '"';
            }
            if ($num == $person->getPrimaryName()) {
                $class = ' class="name2"';
                $sex_image = $person->getSexImage();
                list($surn, $givn) = explode(',', $name['sort']);
            } else {
                $class = '';
                $sex_image = '';
            }
            $html .= '<a ' . $title . ' href="' . $person->getHtmlUrl() . '"' . $class . '>' . highlight_search_hits($name['full']) . '</a>' . $sex_image . '<br>';
        }
        // Indi parents
        $html .= $person->getPrimaryParentsNames('parents details1', 'none');
        $html .= '</td>';
        // Dummy column to match colspan in header
        $html .= '<td style="display:none;"></td>';
        //-- GIVN/SURN
        // Use "AAAA" as a separator (instead of ",") as Javascript.localeCompare() ignores
        // punctuation and "ANN,ROACH" would sort after "ANNE,ROACH", instead of before it.
        // Similarly, @N.N. would sort as NN.
        $html .= '<td>' . WT_Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)) . 'AAAA' . WT_Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)) . '</td>';
        $html .= '<td>' . WT_Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)) . 'AAAA' . WT_Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)) . '</td>';
        //-- SOSA
        if ($option == 'sosa') {
            $html .= '<td><a href="relationship.php?pid1=' . $datalist[1] . '&amp;pid2=' . $person->getXref() . '" title="' . WT_I18N::translate('Relationships') . '">' . WT_I18N::number($key) . '</a></td><td>' . $key . '</td>';
        } else {
            $html .= '<td>&nbsp;</td><td>0</td>';
        }
        //-- Birth date
        $html .= '<td>';
        if ($birth_dates = $person->getAllBirthDates()) {
            foreach ($birth_dates as $num => $birth_date) {
                if ($num) {
                    $html .= '<br>';
                }
                $html .= $birth_date->Display(!$SEARCH_SPIDER);
            }
            if ($birth_dates[0]->gregorianYear() >= 1550 && $birth_dates[0]->gregorianYear() < 2030 && !isset($unique_indis[$person->getXref()])) {
                $birt_by_decade[(int) ($birth_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex();
            }
        } else {
            $birth_date = $person->getEstimatedBirthDate();
            if ($SHOW_EST_LIST_DATES) {
                $html .= $birth_date->Display(!$SEARCH_SPIDER);
            } else {
                $html .= '&nbsp;';
            }
            $birth_dates[0] = new WT_Date('');
        }
        $html .= '</td>';
        //-- Event date (sortable)hidden by datatables code
        $html .= '<td>' . $birth_date->JD() . '</td>';
        //-- Birth anniversary
        $html .= '<td>' . WT_Date::getAge($birth_dates[0], null, 2) . '</td>';
        //-- Birth place
        $html .= '<td>';
        foreach ($person->getAllBirthPlaces() as $n => $birth_place) {
            $tmp = new WT_Place($birth_place, WT_GED_ID);
            if ($n) {
                $html .= '<br>';
            }
            if ($SEARCH_SPIDER) {
                $html .= $tmp->getShortName();
            } else {
                $html .= '<a href="' . $tmp->getURL() . '" title="' . strip_tags($tmp->getFullName()) . '">';
                $html .= highlight_search_hits($tmp->getShortName()) . '</a>';
            }
        }
        $html .= '</td>';
        //-- Number of children
        $nchi = $person->getNumberOfChildren();
        $html .= '<td>' . WT_I18N::number($nchi) . '</td><td>' . $nchi . '</td>';
        //-- Death date
        $html .= '<td>';
        if ($death_dates = $person->getAllDeathDates()) {
            foreach ($death_dates as $num => $death_date) {
                if ($num) {
                    $html .= '<br>';
                }
                $html .= $death_date->Display(!$SEARCH_SPIDER);
            }
            if ($death_dates[0]->gregorianYear() >= 1550 && $death_dates[0]->gregorianYear() < 2030 && !isset($unique_indis[$person->getXref()])) {
                $deat_by_decade[(int) ($death_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex();
            }
        } else {
            $death_date = $person->getEstimatedDeathDate();
            if ($SHOW_EST_LIST_DATES) {
                $html .= $death_date->Display(!$SEARCH_SPIDER);
            } else {
                if ($person->isDead()) {
                    $html .= WT_I18N::translate('yes');
                } else {
                    $html .= '&nbsp;';
                }
            }
            $death_dates[0] = new WT_Date('');
        }
        $html .= '</td>';
        //-- Event date (sortable)hidden by datatables code
        $html .= '<td>' . $death_date->JD() . '</td>';
        //-- Death anniversary
        $html .= '<td>' . WT_Date::getAge($death_dates[0], null, 2) . '</td>';
        //-- Age at death
        $age = WT_Date::getAge($birth_dates[0], $death_dates[0], 0);
        if (!isset($unique_indis[$person->getXref()]) && $age >= 0 && $age <= $max_age) {
            $deat_by_age[$age] .= $person->getSex();
        }
        // Need both display and sortable age
        $html .= '<td>' . WT_Date::getAge($birth_dates[0], $death_dates[0], 2) . '</td><td>' . WT_Date::getAge($birth_dates[0], $death_dates[0], 1) . '</td>';
        //-- Death place
        $html .= '<td>';
        foreach ($person->getAllDeathPlaces() as $n => $death_place) {
            $tmp = new WT_Place($death_place, WT_GED_ID);
            if ($n) {
                $html .= '<br>';
            }
            if ($SEARCH_SPIDER) {
                $html .= $tmp->getShortName();
            } else {
                $html .= '<a href="' . $tmp->getURL() . '" title="' . strip_tags($tmp->getFullName()) . '">';
                $html .= highlight_search_hits($tmp->getShortName()) . '</a>';
            }
        }
        $html .= '</td>';
        //-- Last change
        if ($SHOW_LAST_CHANGE) {
            $html .= '<td>' . $person->lastChangeTimestamp() . '</td>';
        } else {
            $html .= '<td>&nbsp;</td>';
        }
        //-- Last change hidden sort column
        if ($SHOW_LAST_CHANGE) {
            $html .= '<td>' . $person->lastChangeTimestamp(true) . '</td>';
        } else {
            $html .= '<td>&nbsp;</td>';
        }
        //-- Sorting by gender
        $html .= '<td>';
        $html .= $person->getSex();
        $html .= '</td>';
        //-- Filtering by birth date
        $html .= '<td>';
        if (!$person->canShow() || WT_Date::Compare($birth_date, $d100y) > 0) {
            $html .= 'Y100';
        } else {
            $html .= 'YES';
        }
        $html .= '</td>';
        //-- Filtering by death date
        $html .= '<td>';
        // Died in last 100 years?  Died?  Not dead?
        if (WT_Date::Compare($death_date, $d100y) > 0) {
            $html .= 'Y100';
        } elseif ($death_date->minJD() || $person->isDead()) {
            $html .= 'YES';
        } else {
            $html .= 'N';
        }
        $html .= '</td>';
        //-- Roots or Leaves ?
        $html .= '<td>';
        if (!$person->getChildFamilies()) {
            $html .= 'R';
        } elseif (!$person->isDead() && $person->getNumberOfChildren() < 1) {
            $html .= 'L';
        } else {
            $html .= '&nbsp;';
        }
        $html .= '</td>';
        $html .= '</tr>';
        $unique_indis[$person->getXref()] = true;
    }
    $html .= '
				</tbody>
			</table>
			<div id="indi_list_table-charts_' . $table_id . '" style="display:none">
				<table class="list-charts">
					<tr>
						<td>
							' . print_chart_by_decade($birt_by_decade, WT_I18N::translate('Decade of birth')) . '
						</td>
						<td>
							' . print_chart_by_decade($deat_by_decade, WT_I18N::translate('Decade of death')) . '
						</td>
					</tr>
					<tr>
						<td colspan="2">
							' . print_chart_by_age($deat_by_age, WT_I18N::translate('Age related to death year')) . '
						</td>
					</tr>
				</table>
			</div>
		</div>';
    return $html;
}
예제 #2
0
    public function getBlock($block_id, $template = true, $cfg = null)
    {
        global $ctype, $top10_block_present;
        $show_last_update = get_block_setting($block_id, 'show_last_update', true);
        $show_common_surnames = get_block_setting($block_id, 'show_common_surnames', true);
        $stat_indi = get_block_setting($block_id, 'stat_indi', true);
        $stat_fam = get_block_setting($block_id, 'stat_fam', true);
        $stat_sour = get_block_setting($block_id, 'stat_sour', true);
        $stat_media = get_block_setting($block_id, 'stat_media', true);
        $stat_repo = get_block_setting($block_id, 'stat_repo', true);
        $stat_surname = get_block_setting($block_id, 'stat_surname', true);
        $stat_events = get_block_setting($block_id, 'stat_events', true);
        $stat_users = get_block_setting($block_id, 'stat_users', true);
        $stat_first_birth = get_block_setting($block_id, 'stat_first_birth', true);
        $stat_last_birth = get_block_setting($block_id, 'stat_last_birth', true);
        $stat_first_death = get_block_setting($block_id, 'stat_first_death', true);
        $stat_last_death = get_block_setting($block_id, 'stat_last_death', true);
        $stat_long_life = get_block_setting($block_id, 'stat_long_life', true);
        $stat_avg_life = get_block_setting($block_id, 'stat_avg_life', true);
        $stat_most_chil = get_block_setting($block_id, 'stat_most_chil', true);
        $stat_avg_chil = get_block_setting($block_id, 'stat_avg_chil', true);
        $stat_link = get_block_setting($block_id, 'stat_link', true);
        $block = get_block_setting($block_id, 'block', false);
        if ($cfg) {
            foreach (array('show_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', 'stat_link', 'block') as $name) {
                if (array_key_exists($name, $cfg)) {
                    ${$name} = $cfg[$name];
                }
            }
        }
        $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 = '';
        }
        $title .= $this->getTitle();
        $stats = new WT_Stats(WT_GEDCOM);
        $content = '<b>' . WT_TREE_TITLE . '</b><br>';
        if ($show_last_update) {
            $content .= '<div>' . WT_I18N::translate('This family tree was last updated on %s.', strip_tags($stats->gedcomUpdated())) . '</div>';
        }
        $content .= '<table><tr><td class="width20"><table class="facts_table">';
        if ($stat_indi) {
            $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Individuals') . '</td><td class="facts_value stats_value"><a href="' . "indilist.php?surname_sublist=no&amp;ged=" . WT_GEDURL . '">' . $stats->totalIndividuals() . '</a></td></tr>';
            $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Males') . '</td><td class="facts_value stats_value">' . $stats->totalSexMales() . '<br>' . $stats->totalSexMalesPercentage() . '</td></tr>';
            $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Females') . '</td><td class="facts_value stats_value">' . $stats->totalSexFemales() . '<br>' . $stats->totalSexFemalesPercentage() . '</td></tr>';
        }
        if ($stat_surname) {
            $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Total surnames') . '</td><td class="facts_value stats_value"><a href="indilist.php?show_all=yes&amp;surname_sublist=yes&amp;ged=' . WT_GEDURL . '">' . $stats->totalSurnames() . '</a></td></tr>';
        }
        if ($stat_fam) {
            $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Families') . '</td><td class="facts_value stats_value"><a href="famlist.php?ged=' . WT_GEDURL . '">' . $stats->totalFamilies() . '</a></td></tr>';
        }
        if ($stat_sour) {
            $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Sources') . '</td><td class="facts_value stats_value"><a href="sourcelist.php?ged=' . WT_GEDURL . '">' . $stats->totalSources() . '</a></td></tr>';
        }
        if ($stat_media) {
            $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Media objects') . '</td><td class="facts_value stats_value"><a href="medialist.php?ged=' . WT_GEDURL . '">' . $stats->totalMedia() . '</a></td></tr>';
        }
        if ($stat_repo) {
            $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Repositories') . '</td><td class="facts_value stats_value"><a href="repolist.php?ged=' . WT_GEDURL . '">' . $stats->totalRepositories() . '</a></td></tr>';
        }
        if ($stat_events) {
            $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Total events') . '</td><td class="facts_value stats_value">' . $stats->totalEvents() . '</td></tr>';
        }
        if ($stat_users) {
            $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Total users') . '</td><td class="facts_value stats_value">';
            if (WT_USER_GEDCOM_ADMIN) {
                $content .= '<a href="admin_users.php">' . $stats->totalUsers() . '</a>';
            } else {
                $content .= $stats->totalUsers();
            }
            $content .= '</td></tr>';
        }
        if (!$block) {
            $content .= '</table></td><td><table class="facts_table">';
        }
        if ($stat_first_birth) {
            $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Earliest birth year') . '</td><td class="facts_value stats_value">' . $stats->firstBirthYear() . '</td>';
            if (!$block) {
                $content .= '<td class="facts_value">' . $stats->firstBirth() . '</td>';
            }
            $content .= '</tr>';
        }
        if ($stat_last_birth) {
            $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Latest birth year') . '</td><td class="facts_value stats_value">' . $stats->lastBirthYear() . '</td>';
            if (!$block) {
                $content .= '<td class="facts_value">' . $stats->lastBirth() . '</td>';
            }
            $content .= '</tr>';
        }
        if ($stat_first_death) {
            $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Earliest death year') . '</td><td class="facts_value stats_value">' . $stats->firstDeathYear() . '</td>';
            if (!$block) {
                $content .= '<td class="facts_value">' . $stats->firstDeath() . '</td>';
            }
            $content .= '</tr>';
        }
        if ($stat_last_death) {
            $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Latest death year') . '</td><td class="facts_value stats_value">' . $stats->lastDeathYear() . '
	</td>';
            if (!$block) {
                $content .= '<td class="facts_value">' . $stats->lastDeath() . '</td>';
            }
            $content .= '</tr>';
        }
        if ($stat_long_life) {
            $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Individual who lived the longest') . '</td><td class="facts_value stats_value">' . $stats->LongestLifeAge() . '</td>';
            if (!$block) {
                $content .= '<td class="facts_value">' . $stats->LongestLife() . '</td>';
            }
            $content .= '</tr>';
        }
        if ($stat_avg_life) {
            $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Average age at death') . '</td><td class="facts_value stats_value">' . $stats->averageLifespan() . '</td>';
            if (!$block) {
                $content .= '<td class="facts_value">' . WT_I18N::translate('Males') . ':&nbsp;' . $stats->averageLifespanMale();
                $content .= '&nbsp;&nbsp;&nbsp;' . WT_I18N::translate('Females') . ':&nbsp;' . $stats->averageLifespanFemale() . '</td>';
            }
            $content .= '</tr>';
        }
        if ($stat_most_chil && !$block) {
            $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Family with the most children') . '</td><td class="facts_value stats_value">' . $stats->largestFamilySize() . '</td>';
            if (!$block) {
                $content .= '<td class="facts_value">' . $stats->largestFamily() . '</td>';
            }
            $content .= '</tr>';
        }
        if ($stat_avg_chil) {
            $content .= '<tr><td class="facts_label">' . WT_I18N::translate('Average number of children per family') . '</td><td class="facts_value stats_value">' . $stats->averageChildren() . '</td>';
            if (!$block) {
                $content .= '<td class="facts_value">&nbsp;</td>';
            }
            $content .= '</tr>';
        }
        $content .= '</table></td></tr></table>';
        if ($stat_link) {
            $content .= '<a href="statistics.php?ged=' . WT_GEDURL . '"><b>' . WT_I18N::translate('View statistics as graphs') . '</b></a><br>';
        }
        // NOTE: Print the most common surnames
        if ($show_common_surnames) {
            $surnames = get_common_surnames(get_gedcom_setting(WT_GED_ID, 'COMMON_NAMES_THRESHOLD'));
            if (count($surnames) > 0) {
                $content .= '<p><b>' . WT_I18N::translate('Most common surnames') . '</b></p>';
                $content .= '<div class="common_surnames">';
                $i = 0;
                foreach ($surnames as $indexval => $surname) {
                    if (stristr($surname['name'], '@N.N') === false) {
                        if ($i > 0) {
                            $content .= ', ';
                        }
                        $content .= '<a href="' . "indilist.php?ged=" . WT_GEDURL . "&amp;surname=" . rawurlencode($surname['name']) . '">' . $surname['name'] . '</a>';
                        $i++;
                    }
                }
                $content .= '</div>';
            }
        }
        if ($template) {
            require WT_THEME_DIR . 'templates/block_main_temp.php';
        } else {
            return $content;
        }
    }