<?php
/**
 * Parses gedcom file and displays information about a family.
 *
 * You must supply a $famid value with the identifier for the family.
 *
 * phpGedView: Genealogy Viewer
 * Copyright (C) 2002 to 2003  John Finlay and Others
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * $Id: family.php,v 1.94 2004/12/01 18:28:50 yalnifj Exp $
 * @package PhpGedView
 * @subpackage Charts
 */

require("config.php");
require("functions_charts.php");
require($PGV_BASE_DIRECTORY.$factsfile["english"]);
if (file_exists($PGV_BASE_DIRECTORY . $factsfile[$LANGUAGE])) require $PGV_BASE_DIRECTORY . $factsfile[$LANGUAGE];

$bwidth=$Dbwidth;
$pbwidth = $bwidth+12;
$pbheight = $bheight+14;

$show_famlink = true;
if ((isset($view)) && ($view == "preview")) {
    $show_famlink = false;
} 

if (!isset($famid)) $famid="";
$famid = clean_input($famid);
$display = displayDetailsByID($famid, "FAM");
$showLivingHusb=true;
$showLivingWife=true;
$parents = find_parents($famid);
//-- check if we can display both parents
if (!$display) {
	$showLivingHusb=showLivingNameByID($parents["HUSB"]);
	$showLivingWife=showLivingNameByID($parents["WIFE"]);
}
$famrec = find_family_record($famid);

if (!$showLivingHusb && !$showLivingWife) {
	print_header($pgv_lang["private"]." ".$pgv_lang["family_info"]);
	print_privacy_error($CONTACT_EMAIL);
	print_footer();
	exit;
}
$none=1;
if (!empty($parents["HUSB"])){
	if (get_person_name($parents["HUSB"]) !== "Individual ") {
		print_header(get_person_name($parents["HUSB"])." ".$pgv_lang["family_info"]);
		$none=0;
	}
	else if (get_person_name($parents["WIFE"]) !== "Individual ") {
		print_header(get_person_name($parents["WIFE"])." ".$pgv_lang["family_info"]);
		$none=0;
	}
}
if ($none) print_header($pgv_lang["family_info"]);
if (empty($parents["HUSB"]) || empty($parents["WIFE"])) $link_relation=0;
else $link_relation=1;
?>

<script language="JavaScript" type="text/javascript">
<!--
	function show_gedcom_record() {
		var recwin = window.open("gedrecord.php?pid=<?php print $famid ?>", "", "top=50,left=50,width=300,height=400,scrollbars=1,scrollable=1,resizable=1");
	}
	function showchanges() {
		window.location = '<?php print $PHP_SELF."?".preg_replace("/&amp;/", "&", $QUERY_STRING)."&show_changes=yes"; ?>';
	}
//-->
</script>
<?php
if ($view!="preview") {
    if (userCanEdit(getUserName())&&($view!="preview") && $display) {
      if (isset($pgv_changes[$famid."_".$GEDCOM])) print "<a href=\"#\" onclick=\"showchanges();\">".$pgv_lang["show_changes"]."</a><br />\n";
      print "<a href=\"#\" onclick=\"return edit_raw('$famid');\">".$pgv_lang["edit_raw"]."</a>";
	  print_help_link("edit_raw_gedcom_help", "qm");
	  print "<br />\n";
    //  print "<a href=\"#\" onclick=\"return deleteperson('$famid');\">".$pgv_lang["delete_person"]."</a><br />\n";
   }
    $height = 134 + 133 * ( $SHOW_GEDCOM_RECORD + ($ENABLE_CLIPPINGS_CART>=getUserAccessLevel()) );
	print "\n\t<table border=\"0\" align=\"" . ($TEXT_DIRECTION == "rtl" ? "left" : "right") ."\">";
	if ($link_relation) {
	    if (displayDetails(find_person_record($parents["HUSB"])) || displayDetails(find_person_record($parents["WIFE"])))	{
			print "\n\t\t<tr><td align=\"center\" valign=\"top\"><a href=\"timeline.php?pids[0]=".$parents['HUSB']."&amp;pids[1]=".$parents['WIFE']."\"><img src=\"".$PGV_IMAGE_DIR."/".$PGV_IMAGES["timeline"]["small"]."\" border=\"0\" alt=\"\" class=\"icon\" /><br /><font size=\"1\">".$pgv_lang['parents_timeline']."</font></a>";
			print_help_link("show_fam_timeline_help", "qm");
			print "</td></tr>";
		}
	}
	if ( $SHOW_GEDCOM_RECORD && $display) {
		print "\n\t\t<tr><td align=\"center\" valign=\"top\"><span class=\"link\"><a href=\"javascript:show_gedcom_record();\"><img src=\"".$PGV_IMAGE_DIR."/".$PGV_IMAGES["gedcom"]["small"]."\" border=\"0\" alt=\"\" class=\"icon\" /><br />".$pgv_lang["view_gedcom"]."</a>";
		print_help_link("show_fam_gedcom_help", "qm");
		print "</span></td></tr>";
	}
	if ( ($ENABLE_CLIPPINGS_CART>=getUserAccessLevel()) && $display) {
		print "\n\t\t<tr><td align=\"center\" valign=\"top\"><span class=\"link\"><a href=\"clippings.php?action=add&amp;id=$famid&amp;type=fam\"><img src=\"".$PGV_IMAGE_DIR."/".$PGV_IMAGES["clippings"]["small"]."\" border=\"0\" alt=\"\" class=\"icon\" /><br />".$pgv_lang["add_to_cart"]."</a>";
		print_help_link("add_fam_clip_help", "qm");
		print "</span></td></tr>";
	}
	print "</table>";
}

print_family_parents($famid);
print "\n\t<br />\n";
//print "<table width=\"95%\"><tr><td valign=\"top\">\n";
print "<table width=\"95%\"><tr><td valign=\"top\" style=\"width: " . ($pbwidth) . "px;\">\n";
print_family_children($famid);
//print "</td><td valign=\"top\" width=\"100%\">";
print "</td><td valign=\"top\">";
print_family_facts($famid);
print "</td></tr></table>\n";
print "<br />";
print_footer();

?>
