Example #1
0
 function init()
 {
     global $PRIV_HIDE, $PRIV_PUBLIC, $ENABLE_CLIPPINGS_CART, $SCRIPT_NAME, $pgv_lang, $SERVER_URL, $CONTACT_EMAIL, $HOME_SITE_TEXT, $HOME_SITE_URL, $MEDIA_DIRECTORY;
     global $GEDCOM, $CHARACTER_SET, $cart;
     if (!isset($ENABLE_CLIPPINGS_CART)) {
         $ENABLE_CLIPPINGS_CART = $PRIV_HIDE;
     }
     if ($ENABLE_CLIPPINGS_CART === true) {
         $ENABLE_CLIPPING_CART = $PRIV_PUBLIC;
     }
     if ($ENABLE_CLIPPINGS_CART < PGV_USER_ACCESS_LEVEL) {
         header("Location: index.php");
         exit;
     }
     if (!isset($_SESSION['exportConvPath'])) {
         $_SESSION['exportConvPath'] = $MEDIA_DIRECTORY;
     }
     if (!isset($_SESSION['exportConvSlashes'])) {
         $_SESSION['exportConvSlashes'] = 'forward';
     }
     $this->action = safe_GET("action");
     $this->id = safe_GET('id');
     $remove = safe_GET('remove', "", "no");
     $convert = safe_GET('convert', "", "no");
     $this->Zip = safe_GET('Zip');
     $this->IncludeMedia = safe_GET('IncludeMedia');
     $this->conv_path = safe_GET('conv_path', PGV_REGEX_NOSCRIPT, $_SESSION['exportConvPath']);
     $this->conv_slashes = safe_GET('conv_slashes', array('forward', 'backward'), $_SESSION['exportConvSlashes']);
     $this->privatize_export = safe_GET('privatize_export', array('none', 'visitor', 'user', 'gedadmin', 'admin'));
     $this->filetype = safe_GET('filetype');
     $this->level1 = safe_GET('level1');
     $this->level2 = safe_GET('level2');
     $this->level3 = safe_GET('level3');
     if (empty($this->filetype)) {
         $this->filetype = "gedcom";
     }
     $others = safe_GET('others');
     $item = safe_GET('item');
     if (!isset($cart)) {
         $cart = $_SESSION['cart'];
     }
     $this->type = safe_GET('type');
     $this->conv_path = stripLRMRLM($this->conv_path);
     $_SESSION['exportConvPath'] = $this->conv_path;
     // remember this for the next Download
     $_SESSION['exportConvSlashes'] = $this->conv_slashes;
     if ($this->action == 'add') {
         if (empty($this->type) && !empty($this->id)) {
             $this->type = "";
             $obj = GedcomRecord::getInstance($this->id);
             if (is_null($obj)) {
                 $this->id = "";
                 $this->action = "";
             } else {
                 $this->type = strtolower($obj->getType());
             }
         } else {
             if (empty($this->id)) {
                 $this->action = "";
             }
         }
         if (!empty($this->id) && $this->type != 'fam' && $this->type != 'indi' && $this->type != 'sour') {
             $this->action = 'add1';
         }
     }
     if ($this->action == 'add1') {
         $clipping = array();
         $clipping['type'] = $this->type;
         $clipping['id'] = $this->id;
         $clipping['gedcom'] = $GEDCOM;
         $ret = $this->add_clipping($clipping);
         if ($ret) {
             if ($this->type == 'sour') {
                 if ($others == 'linked') {
                     foreach (fetch_linked_indi($this->id, 'SOUR', PGV_GED_ID) as $indi) {
                         if ($indi->canDisplayName()) {
                             $this->add_clipping(array('type' => 'indi', 'id' => $indi->getXref()));
                         }
                     }
                     foreach (fetch_linked_fam($this->id, 'SOUR', PGV_GED_ID) as $fam) {
                         if ($fam->canDisplayName()) {
                             $this->add_clipping(array('type' => 'fam', 'id' => $fam->getXref()));
                         }
                     }
                 }
             }
             if ($this->type == 'fam') {
                 if ($others == 'parents') {
                     $parents = find_parents($this->id);
                     if (!empty($parents["HUSB"])) {
                         $clipping = array();
                         $clipping['type'] = "indi";
                         $clipping['id'] = $parents["HUSB"];
                         $ret = $this->add_clipping($clipping);
                     }
                     if (!empty($parents["WIFE"])) {
                         $clipping = array();
                         $clipping['type'] = "indi";
                         $clipping['id'] = $parents["WIFE"];
                         $ret = $this->add_clipping($clipping);
                     }
                 } else {
                     if ($others == "members") {
                         $this->add_family_members($this->id);
                     } else {
                         if ($others == "descendants") {
                             $this->add_family_descendancy($this->id);
                         }
                     }
                 }
             } else {
                 if ($this->type == 'indi') {
                     if ($others == 'parents') {
                         $famids = find_family_ids($this->id);
                         foreach ($famids as $indexval => $famid) {
                             $clipping = array();
                             $clipping['type'] = "fam";
                             $clipping['id'] = $famid;
                             $ret = $this->add_clipping($clipping);
                             if ($ret) {
                                 $this->add_family_members($famid);
                             }
                         }
                     } else {
                         if ($others == 'ancestors') {
                             $this->add_ancestors_to_cart($this->id, $this->level1);
                         } else {
                             if ($others == 'ancestorsfamilies') {
                                 $this->add_ancestors_to_cart_families($this->id, $this->level2);
                             } else {
                                 if ($others == 'members') {
                                     $famids = find_sfamily_ids($this->id);
                                     foreach ($famids as $indexval => $famid) {
                                         $clipping = array();
                                         $clipping['type'] = "fam";
                                         $clipping['id'] = $famid;
                                         $ret = $this->add_clipping($clipping);
                                         if ($ret) {
                                             $this->add_family_members($famid);
                                         }
                                     }
                                 } else {
                                     if ($others == 'descendants') {
                                         $famids = find_sfamily_ids($this->id);
                                         foreach ($famids as $indexval => $famid) {
                                             $clipping = array();
                                             $clipping['type'] = "fam";
                                             $clipping['id'] = $famid;
                                             $ret = $this->add_clipping($clipping);
                                             if ($ret) {
                                                 $this->add_family_descendancy($famid, $this->level3);
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     } else {
         if ($this->action == 'remove') {
             $ct = count($cart);
             for ($i = $item + 1; $i < $ct; $i++) {
                 $cart[$i - 1] = $cart[$i];
             }
             unset($cart[$ct - 1]);
         } else {
             if ($this->action == 'empty') {
                 $cart = array();
                 $_SESSION["cart"] = $cart;
             } else {
                 if ($this->action == 'download') {
                     usort($cart, "same_group");
                     if ($this->filetype == "gedcom") {
                         $path = substr($SCRIPT_NAME, 0, strrpos($SCRIPT_NAME, "/"));
                         if (empty($path)) {
                             $path = "/";
                         }
                         if ($path[strlen($path) - 1] != "/") {
                             $path .= "/";
                         }
                         if ($SERVER_URL[strlen($SERVER_URL) - 1] == "/") {
                             $dSERVER_URL = substr($SERVER_URL, 0, strlen($SERVER_URL) - 1);
                         } else {
                             $dSERVER_URL = $SERVER_URL;
                         }
                         $media = array();
                         $mediacount = 0;
                         $ct = count($cart);
                         $filetext = "0 HEAD\n1 SOUR " . PGV_PHPGEDVIEW . "\n2 NAME " . PGV_PHPGEDVIEW . "\n2 VERS " . PGV_VERSION_TEXT . "\n1 DEST DISKETTE\n1 DATE " . date("j M Y") . "\n2 TIME " . date("H:i:s") . "\n";
                         $filetext .= "1 GEDC\n2 VERS 5.5\n2 FORM LINEAGE-LINKED\n1 CHAR {$CHARACTER_SET}\n";
                         $head = find_gedcom_record("HEAD");
                         $placeform = trim(get_sub_record(1, "1 PLAC", $head));
                         if (!empty($placeform)) {
                             $filetext .= $placeform . "\n";
                         } else {
                             $filetext .= "1 PLAC\n2 FORM " . "City, County, State/Province, Country" . "\n";
                         }
                         if ($convert == "yes") {
                             $filetext = preg_replace("/UTF-8/", "ANSI", $filetext);
                             $filetext = utf8_decode($filetext);
                         }
                         $tempUserID = '#ExPoRt#';
                         if ($this->privatize_export != 'none') {
                             // Create a temporary userid
                             $export_user_id = createTempUser($tempUserID, $this->privatize_export, $GEDCOM);
                             // Create a temporary userid
                             // Temporarily become this user
                             $_SESSION["org_user"] = $_SESSION["pgv_user"];
                             $_SESSION["pgv_user"] = $tempUserID;
                         }
                         for ($i = 0; $i < $ct; $i++) {
                             $clipping = $cart[$i];
                             if ($clipping['gedcom'] == $GEDCOM) {
                                 $record = find_gedcom_record($clipping['id']);
                                 $savedRecord = $record;
                                 // Save this for the "does this file exist" check
                                 if ($clipping['type'] == 'obje') {
                                     $record = convert_media_path($record, $this->conv_path, $this->conv_slashes);
                                 }
                                 $record = privatize_gedcom($record);
                                 $record = remove_custom_tags($record, $remove);
                                 if ($convert == "yes") {
                                     $record = utf8_decode($record);
                                 }
                                 switch ($clipping['type']) {
                                     case 'indi':
                                         $ft = preg_match_all("/1 FAMC @(.*)@/", $record, $match, PREG_SET_ORDER);
                                         for ($k = 0; $k < $ft; $k++) {
                                             if (!id_in_cart($match[$k][1])) {
                                                 $record = preg_replace("/1 FAMC @" . $match[$k][1] . "@.*/", "", $record);
                                             }
                                         }
                                         $ft = preg_match_all("/1 FAMS @(.*)@/", $record, $match, PREG_SET_ORDER);
                                         for ($k = 0; $k < $ft; $k++) {
                                             if (!id_in_cart($match[$k][1])) {
                                                 $record = preg_replace("/1 FAMS @" . $match[$k][1] . "@.*/", "", $record);
                                             }
                                         }
                                         $ft = preg_match_all("/\\d FILE (.*)/", $savedRecord, $match, PREG_SET_ORDER);
                                         for ($k = 0; $k < $ft; $k++) {
                                             $filename = $MEDIA_DIRECTORY . extract_filename(trim($match[$k][1]));
                                             if (file_exists($filename)) {
                                                 $media[$mediacount] = array(PCLZIP_ATT_FILE_NAME => $filename);
                                                 $mediacount++;
                                             }
                                             //								$record = preg_replace("|(\d FILE )" . addslashes($match[$k][1]) . "|", "$1" . $filename, $record);
                                         }
                                         $filetext .= trim($record) . "\n";
                                         $filetext .= "1 SOUR @SPGV1@\n";
                                         $filetext .= "2 PAGE " . $dSERVER_URL . "/individual.php?pid=" . $clipping['id'] . "\n";
                                         $filetext .= "2 DATA\n";
                                         $filetext .= "3 TEXT " . $pgv_lang["indi_downloaded_from"] . "\n";
                                         $filetext .= "4 CONT " . $dSERVER_URL . "/individual.php?pid=" . $clipping['id'] . "\n";
                                         break;
                                     case 'fam':
                                         $ft = preg_match_all("/1 CHIL @(.*)@/", $record, $match, PREG_SET_ORDER);
                                         for ($k = 0; $k < $ft; $k++) {
                                             if (!id_in_cart($match[$k][1])) {
                                                 /* if the child is not in the list delete the record of it */
                                                 $record = preg_replace("/1 CHIL @" . $match[$k][1] . "@.*/", "", $record);
                                             }
                                         }
                                         $ft = preg_match_all("/1 HUSB @(.*)@/", $record, $match, PREG_SET_ORDER);
                                         for ($k = 0; $k < $ft; $k++) {
                                             if (!id_in_cart($match[$k][1])) {
                                                 /* if the husband is not in the list delete the record of him */
                                                 $record = preg_replace("/1 HUSB @" . $match[$k][1] . "@.*/", "", $record);
                                             }
                                         }
                                         $ft = preg_match_all("/1 WIFE @(.*)@/", $record, $match, PREG_SET_ORDER);
                                         for ($k = 0; $k < $ft; $k++) {
                                             if (!id_in_cart($match[$k][1])) {
                                                 /* if the wife is not in the list delete the record of her */
                                                 $record = preg_replace("/1 WIFE @" . $match[$k][1] . "@.*/", "", $record);
                                             }
                                         }
                                         $ft = preg_match_all("/\\d FILE (.*)/", $savedRecord, $match, PREG_SET_ORDER);
                                         for ($k = 0; $k < $ft; $k++) {
                                             $filename = $MEDIA_DIRECTORY . extract_filename(trim($match[$k][1]));
                                             if (file_exists($filename)) {
                                                 $media[$mediacount] = array(PCLZIP_ATT_FILE_NAME => $filename);
                                                 $mediacount++;
                                             }
                                             //								$record = preg_replace("|(\d FILE )" . addslashes($match[$k][1]) . "|", "$1" . $filename, $record);
                                         }
                                         $filetext .= trim($record) . "\n";
                                         $filetext .= "1 SOUR @SPGV1@\n";
                                         $filetext .= "2 PAGE " . $dSERVER_URL . $path . "family.php?famid=" . $clipping['id'] . "\n";
                                         $filetext .= "2 DATA\n";
                                         $filetext .= "3 TEXT " . $pgv_lang["family_downloaded_from"] . "\n";
                                         $filetext .= "4 CONT " . $dSERVER_URL . "/family.php?famid=" . $clipping['id'] . "\n";
                                         break;
                                     case 'source':
                                         $ft = preg_match_all("/\\d FILE (.*)/", $savedRecord, $match, PREG_SET_ORDER);
                                         for ($k = 0; $k < $ft; $k++) {
                                             $filename = $MEDIA_DIRECTORY . extract_filename(trim($match[$k][1]));
                                             if (file_exists($filename)) {
                                                 $media[$mediacount] = array(PCLZIP_ATT_FILE_NAME => $filename);
                                                 $mediacount++;
                                             }
                                             //								$record = preg_replace("|(\d FILE )" . addslashes($match[$k][1]) . "|", "$1" . $filename, $record);
                                         }
                                         $filetext .= trim($record) . "\n";
                                         $filetext .= "1 NOTE " . $pgv_lang["source_downloaded_from"] . "\n";
                                         $filetext .= "2 CONT " . $dSERVER_URL . "/source.php?sid=" . $clipping['id'] . "\n";
                                         break;
                                     default:
                                         $ft = preg_match_all("/\\d FILE (.*)/", $savedRecord, $match, PREG_SET_ORDER);
                                         for ($k = 0; $k < $ft; $k++) {
                                             $filename = $MEDIA_DIRECTORY . extract_filename(trim($match[$k][1]));
                                             if (file_exists($filename)) {
                                                 $media[$mediacount] = array(PCLZIP_ATT_FILE_NAME => $filename);
                                                 $mediacount++;
                                             }
                                             //								$record = preg_replace("|(\d FILE )" . addslashes($match[$k][1]) . "|", "$1" . $filename, $record);
                                         }
                                         $filetext .= trim($record) . "\n";
                                         break;
                                 }
                             }
                         }
                         if ($this->privatize_export != 'none') {
                             $_SESSION["pgv_user"] = $_SESSION["org_user"];
                             delete_user($export_user_id);
                             AddToLog("deleted dummy user -> {$tempUserID} <-");
                         }
                         if ($this->IncludeMedia == "yes") {
                             $this->media_list = $media;
                         }
                         $filetext .= "0 @SPGV1@ SOUR\n";
                         if ($user_id = get_user_id($CONTACT_EMAIL)) {
                             $filetext .= "1 AUTH " . getUserFullName($user_id) . "\n";
                         }
                         $filetext .= "1 TITL " . $HOME_SITE_TEXT . "\n";
                         $filetext .= "1 ABBR " . $HOME_SITE_TEXT . "\n";
                         $filetext .= "1 PUBL " . $HOME_SITE_URL . "\n";
                         $filetext .= "0 TRLR\n";
                         //-- make sure the preferred line endings are used
                         $filetext = preg_replace("/[\r\n]+/", PGV_EOL, $filetext);
                         $this->download_data = $filetext;
                         $this->download_clipping();
                     } else {
                         if ($this->filetype == "gramps") {
                             // Sort the clippings cart because the export works better when the cart is sorted
                             usort($cart, "same_group");
                             require_once "includes/classes/class_geclippings.php";
                             $gramps_Exp = new GEClippings();
                             $gramps_Exp->begin_xml();
                             $ct = count($cart);
                             usort($cart, "same_group");
                             for ($i = 0; $i < $ct; $i++) {
                                 $clipping = $cart[$i];
                                 switch ($clipping['type']) {
                                     case 'indi':
                                         $rec = find_person_record($clipping['id']);
                                         $rec = remove_custom_tags($rec, $remove);
                                         if ($this->privatize_export != 'none') {
                                             $rec = privatize_gedcom($rec);
                                         }
                                         $gramps_Exp->create_person($rec, $clipping['id']);
                                         break;
                                     case 'fam':
                                         $rec = find_family_record($clipping['id']);
                                         $rec = remove_custom_tags($rec, $remove);
                                         if ($this->privatize_export != 'none') {
                                             $rec = privatize_gedcom($rec);
                                         }
                                         $gramps_Exp->create_family($rec, $clipping['id']);
                                         break;
                                     case 'source':
                                         $rec = find_source_record($clipping['id']);
                                         $rec = remove_custom_tags($rec, $remove);
                                         if ($this->privatize_export != 'none') {
                                             $rec = privatize_gedcom($rec);
                                         }
                                         $gramps_Exp->create_source($rec, $clipping['id']);
                                         break;
                                 }
                             }
                             $this->download_data = $gramps_Exp->dom->saveXML();
                             if ($convert) {
                                 $this->download_data = utf8_decode($this->download_data);
                             }
                             $this->media_list = $gramps_Exp->get_all_media();
                             $this->download_clipping();
                         }
                     }
                 }
             }
         }
     }
 }
Example #2
0
 /**
  * Accept any edit changes into the database
  * Also update the indirec we will use to generate the page
  */
 function acceptChanges()
 {
     global $GEDCOM;
     if (!PGV_USER_CAN_ACCEPT) {
         return;
     }
     if (accept_changes($this->pid . "_" . $GEDCOM)) {
         $this->show_changes = false;
         $this->accept_success = true;
         //-- delete the record from the cache and refresh it
         $indirec = find_person_record($this->pid);
         //-- check if we just deleted the record and redirect to index
         if (empty($indirec)) {
             header("Location: index.php?ctype=gedcom");
             exit;
         }
         $this->indi = new Person($indirec);
     }
 }
Example #3
0
 /**
  * Initialization function
  */
 function init()
 {
     global $GEDCOM_ID_PREFIX;
     $this->baseyear = date("Y");
     //-- new pid
     $newpid = safe_GET_xref('newpid');
     if ($newpid) {
         $indirec = find_person_record($newpid);
         if (empty($indirec) && $GEDCOM_ID_PREFIX) {
             if (stristr($newpid, $GEDCOM_ID_PREFIX) === false) {
                 $newpid = $GEDCOM_ID_PREFIX . $newpid;
             }
         }
     }
     if (safe_GET('clear', '1') == '1') {
         unset($_SESSION['timeline_pids']);
     } else {
         if (isset($_SESSION['timeline_pids'])) {
             $this->pids = $_SESSION['timeline_pids'];
         }
         //-- pids array
         $this->pids = safe_GET_xref('pids');
     }
     if (!is_array($this->pids)) {
         $this->pids = array();
     } else {
         //-- make sure that arrays are indexed by numbers
         $this->pids = array_values($this->pids);
     }
     if (!empty($newpid) && !in_array($newpid, $this->pids)) {
         $this->pids[] = $newpid;
     }
     if (count($this->pids) == 0) {
         $this->pids[] = check_rootid("");
     }
     $remove = safe_GET_xref('remove');
     //-- cleanup user input
     $newpids = array();
     foreach ($this->pids as $key => $value) {
         if ($value != $remove) {
             $newpids[] = $value;
             $person = Person::getInstance($value);
             if (!is_null($person)) {
                 $this->people[] = $person;
             }
         }
     }
     $this->pids = $newpids;
     $this->pidlinks = "";
     /* @var $indi Person */
     foreach ($this->people as $p => $indi) {
         if (!is_null($indi) && $indi->canDisplayDetails()) {
             //-- setup string of valid pids for links
             $this->pidlinks .= "pids[]=" . $indi->getXref() . "&amp;";
             $bdate = $indi->getBirthDate();
             if ($bdate->isOK()) {
                 $date = $bdate->MinDate();
                 $date = $date->convert_to_cal('gregorian');
                 if ($date->y) {
                     $this->birthyears[$indi->getXref()] = $date->y;
                     $this->birthmonths[$indi->getXref()] = max(1, $date->m);
                     $this->birthdays[$indi->getXref()] = max(1, $date->d);
                 }
             }
             // find all the fact information
             $indi->add_family_facts(false);
             foreach ($indi->getIndiFacts() as $event) {
                 //-- get the fact type
                 $fact = $event->getTag();
                 if (!in_array($fact, $this->nonfacts)) {
                     //-- check for a date
                     $date = $event->getDate();
                     $date = $date->MinDate();
                     $date = $date->convert_to_cal('gregorian');
                     if ($date->y) {
                         $this->baseyear = min($this->baseyear, $date->y);
                         $this->topyear = max($this->topyear, $date->y);
                         if (!$indi->isDead()) {
                             $this->topyear = max($this->topyear, date('Y'));
                         }
                         $event->temp = $p;
                         //-- do not add the same fact twice (prevents marriages from being added multiple times)
                         if (!in_array($event, $this->indifacts, true)) {
                             $this->indifacts[] = $event;
                         }
                     }
                 }
             }
         }
     }
     $_SESSION['timeline_pids'] = $this->pids;
     $scale = safe_GET_integer('scale', 0, 200, 0);
     if ($scale == 0) {
         $this->scale = round(($this->topyear - $this->baseyear) / 20 * count($this->indifacts) / 4);
         if ($this->scale < 6) {
             $this->scale = 6;
         }
     } else {
         $this->scale = $scale;
     }
     if ($this->scale < 2) {
         $this->scale = 2;
     }
     $this->baseyear -= 5;
     $this->topyear += 5;
 }
Example #4
0
/**
 * Get relationship between two individuals in the gedcom
 *
 * function to calculate the relationship between two people it uses hueristics based on the
 * individuals birthdate to try and calculate the shortest path between the two individuals
 * it uses a node cache to help speed up calculations when using relationship privacy
 * this cache is indexed using the string "$pid1-$pid2"
 * @param string $pid1 the ID of the first person to compute the relationship from
 * @param string $pid2 the ID of the second person to compute the relatiohip to
 * @param bool $followspouse whether to add spouses to the path
 * @param int $maxlenght the maximim length of path
 * @param bool $ignore_cache enable or disable the relationship cache
 * @param int $path_to_find which path in the relationship to find, 0 is the shortest path, 1 is the next shortest path, etc
 */
function get_relationship($pid1, $pid2, $followspouse = true, $maxlength = 0, $ignore_cache = false, $path_to_find = 0)
{
    global $TIME_LIMIT, $start_time, $pgv_lang, $NODE_CACHE, $NODE_CACHE_LENGTH, $USE_RELATIONSHIP_PRIVACY, $pgv_changes, $GEDCOM;
    $pid1 = strtoupper($pid1);
    $pid2 = strtoupper($pid2);
    if (isset($pgv_changes[$pid2 . "_" . $GEDCOM]) && PGV_USER_CAN_EDIT) {
        $indirec = find_updated_record($pid2);
    } else {
        $indirec = find_person_record($pid2);
    }
    //-- check the cache
    if ($USE_RELATIONSHIP_PRIVACY && !$ignore_cache) {
        if (isset($NODE_CACHE["{$pid1}-{$pid2}"])) {
            if ($NODE_CACHE["{$pid1}-{$pid2}"] == "NOT FOUND") {
                return false;
            }
            if ($maxlength == 0 || count($NODE_CACHE["{$pid1}-{$pid2}"]["path"]) - 1 <= $maxlength) {
                return $NODE_CACHE["{$pid1}-{$pid2}"];
            } else {
                return false;
            }
        }
        //-- check the cache for person 2's children
        $famids = array();
        $ct = preg_match_all("/1\\sFAMS\\s@(.*)@/", $indirec, $match, PREG_SET_ORDER);
        for ($i = 0; $i < $ct; $i++) {
            $famids[$i] = $match[$i][1];
        }
        foreach ($famids as $indexval => $fam) {
            if (isset($pgv_changes[$fam . "_" . $GEDCOM]) && PGV_USER_CAN_EDIT) {
                $famrec = find_updated_record($fam);
            } else {
                $famrec = find_family_record($fam);
            }
            $ct = preg_match_all("/1 CHIL @(.*)@/", $famrec, $match, PREG_SET_ORDER);
            for ($i = 0; $i < $ct; $i++) {
                $child = $match[$i][1];
                if (!empty($child)) {
                    if (isset($NODE_CACHE["{$pid1}-{$child}"])) {
                        if ($maxlength == 0 || count($NODE_CACHE["{$pid1}-{$child}"]["path"]) + 1 <= $maxlength) {
                            $node1 = $NODE_CACHE["{$pid1}-{$child}"];
                            if ($node1 != "NOT FOUND") {
                                $node1["path"][] = $pid2;
                                $node1["pid"] = $pid2;
                                $ct = preg_match("/1 SEX F/", $indirec, $match);
                                if ($ct > 0) {
                                    $node1["relations"][] = "mother";
                                } else {
                                    $node1["relations"][] = "father";
                                }
                            }
                            $NODE_CACHE["{$pid1}-{$pid2}"] = $node1;
                            if ($node1 == "NOT FOUND") {
                                return false;
                            }
                            return $node1;
                        } else {
                            return false;
                        }
                    }
                }
            }
        }
        if (!empty($NODE_CACHE_LENGTH) && $maxlength > 0) {
            if ($NODE_CACHE_LENGTH >= $maxlength) {
                return false;
            }
        }
    }
    //-- end cache checking
    //-- get the birth year of p2 for calculating heuristics
    $birthrec = get_sub_record(1, "1 BIRT", $indirec);
    $byear2 = -1;
    if ($birthrec !== false) {
        $dct = preg_match("/2 DATE .*(\\d\\d\\d\\d)/", $birthrec, $match);
        if ($dct > 0) {
            $byear2 = $match[1];
        }
    }
    if ($byear2 == -1) {
        $numfams = preg_match_all("/1\\s*FAMS\\s*@(.*)@/", $indirec, $fmatch, PREG_SET_ORDER);
        for ($j = 0; $j < $numfams; $j++) {
            // Get the family record
            if (isset($pgv_changes[$fmatch[$j][1] . "_" . $GEDCOM]) && PGV_USER_CAN_EDIT) {
                $famrec = find_updated_record($fmatch[$j][1]);
            } else {
                $famrec = find_family_record($fmatch[$j][1]);
            }
            // Get the set of children
            $ct = preg_match_all("/1 CHIL @(.*)@/", $famrec, $cmatch, PREG_SET_ORDER);
            for ($i = 0; $i < $ct; $i++) {
                // Get each child's record
                if (isset($pgv_changes[$cmatch[$i][1] . "_" . $GEDCOM]) && PGV_USER_CAN_EDIT) {
                    $childrec = find_updated_record($cmatch[$i][1]);
                } else {
                    $childrec = find_person_record($cmatch[$i][1]);
                }
                $birthrec = get_sub_record(1, "1 BIRT", $childrec);
                if ($birthrec !== false) {
                    $dct = preg_match("/2 DATE .*(\\d\\d\\d\\d)/", $birthrec, $bmatch);
                    if ($dct > 0) {
                        $byear2 = $bmatch[1] - 25;
                    }
                    if ($byear2 > 2100) {
                        $byear2 -= 3760;
                    }
                    // Crude conversion from jewish to gregorian
                }
            }
        }
    }
    //-- end of approximating birth year
    //-- current path nodes
    $p1nodes = array();
    //-- ids visited
    $visited = array();
    //-- set up first node for person1
    $node1 = array();
    $node1["path"] = array();
    $node1["path"][] = $pid1;
    $node1["length"] = 0;
    $node1["pid"] = $pid1;
    $node1["relations"] = array();
    $node1["relations"][] = "self";
    $p1nodes[] = $node1;
    $visited[$pid1] = true;
    $found = false;
    $count = 0;
    while (!$found) {
        //-- the following 2 lines ensure that the user can abort a long relationship calculation
        //-- refer to http://www.php.net/manual/en/features.connection-handling.php for more
        //-- information about why these lines are included
        if (headers_sent()) {
            print " ";
            if ($count % 100 == 0) {
                flush();
            }
        }
        $count++;
        $end_time = microtime(true);
        $exectime = $end_time - $start_time;
        if ($TIME_LIMIT > 1 && $exectime > $TIME_LIMIT - 1) {
            print "<span class=\"error\">" . $pgv_lang["timeout_error"] . "</span>\n";
            return false;
        }
        if (count($p1nodes) == 0) {
            if ($maxlength != 0) {
                if (!isset($NODE_CACHE_LENGTH)) {
                    $NODE_CACHE_LENGTH = $maxlength;
                } else {
                    if ($NODE_CACHE_LENGTH < $maxlength) {
                        $NODE_CACHE_LENGTH = $maxlength;
                    }
                }
            }
            if (headers_sent()) {
                print "\n<!-- Relationship {$pid1}-{$pid2} NOT FOUND | Visited " . count($visited) . " nodes | Required {$count} iterations.<br />\n";
                print_execution_stats();
                print "-->\n";
            }
            $NODE_CACHE["{$pid1}-{$pid2}"] = "NOT FOUND";
            return false;
        }
        //-- search the node list for the shortest path length
        $shortest = -1;
        foreach ($p1nodes as $index => $node) {
            if ($shortest == -1) {
                $shortest = $index;
            } else {
                $node1 = $p1nodes[$shortest];
                if ($node1["length"] > $node["length"]) {
                    $shortest = $index;
                }
            }
        }
        if ($shortest == -1) {
            return false;
        }
        $node = $p1nodes[$shortest];
        if ($maxlength == 0 || count($node["path"]) <= $maxlength) {
            if ($node["pid"] == $pid2) {
            } else {
                //-- hueristic values
                $fatherh = 1;
                $motherh = 1;
                $siblingh = 2;
                $spouseh = 2;
                $childh = 3;
                //-- generate heuristic values based of the birthdates of the current node and p2
                if (isset($pgv_changes[$node["pid"] . "_" . $GEDCOM]) && PGV_USER_CAN_EDIT) {
                    $indirec = find_updated_record($node["pid"]);
                } else {
                    $indirec = find_person_record($node["pid"]);
                }
                $byear1 = -1;
                $birthrec = get_sub_record(1, "1 BIRT", $indirec);
                if ($birthrec !== false) {
                    $dct = preg_match("/2 DATE .*(\\d\\d\\d\\d)/", $birthrec, $match);
                    if ($dct > 0) {
                        $byear1 = $match[1];
                    }
                    if ($byear1 > 2100) {
                        $byear1 -= 3760;
                    }
                    // Crude conversion from jewish to gregorian
                }
                if ($byear1 != -1 && $byear2 != -1) {
                    $yeardiff = $byear1 - $byear2;
                    if ($yeardiff < -140) {
                        $fatherh = 20;
                        $motherh = 20;
                        $siblingh = 15;
                        $spouseh = 15;
                        $childh = 1;
                    } else {
                        if ($yeardiff < -100) {
                            $fatherh = 15;
                            $motherh = 15;
                            $siblingh = 10;
                            $spouseh = 10;
                            $childh = 1;
                        } else {
                            if ($yeardiff < -60) {
                                $fatherh = 10;
                                $motherh = 10;
                                $siblingh = 5;
                                $spouseh = 5;
                                $childh = 1;
                            } else {
                                if ($yeardiff < -20) {
                                    $fatherh = 5;
                                    $motherh = 5;
                                    $siblingh = 3;
                                    $spouseh = 3;
                                    $childh = 1;
                                } else {
                                    if ($yeardiff < 20) {
                                        $fatherh = 3;
                                        $motherh = 3;
                                        $siblingh = 1;
                                        $spouseh = 1;
                                        $childh = 5;
                                    } else {
                                        if ($yeardiff < 60) {
                                            $fatherh = 1;
                                            $motherh = 1;
                                            $siblingh = 5;
                                            $spouseh = 2;
                                            $childh = 10;
                                        } else {
                                            if ($yeardiff < 100) {
                                                $fatherh = 1;
                                                $motherh = 1;
                                                $siblingh = 10;
                                                $spouseh = 3;
                                                $childh = 15;
                                            } else {
                                                $fatherh = 1;
                                                $motherh = 1;
                                                $siblingh = 15;
                                                $spouseh = 4;
                                                $childh = 20;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                //-- check all parents and siblings of this node
                $famids = array();
                $ct = preg_match_all("/1\\sFAMC\\s@(.*)@/", $indirec, $match, PREG_SET_ORDER);
                for ($i = 0; $i < $ct; $i++) {
                    if (!isset($visited[$match[$i][1]])) {
                        $famids[$i] = $match[$i][1];
                    }
                }
                foreach ($famids as $indexval => $fam) {
                    $visited[$fam] = true;
                    if (isset($pgv_changes[$fam . "_" . $GEDCOM]) && PGV_USER_CAN_EDIT) {
                        $famrec = find_updated_record($fam);
                    } else {
                        $famrec = find_family_record($fam);
                    }
                    $parents = find_parents_in_record($famrec);
                    if (!empty($parents["HUSB"]) && !isset($visited[$parents["HUSB"]])) {
                        $node1 = $node;
                        $node1["length"] += $fatherh;
                        $node1["path"][] = $parents["HUSB"];
                        $node1["pid"] = $parents["HUSB"];
                        $node1["relations"][] = "father";
                        $p1nodes[] = $node1;
                        if ($node1["pid"] == $pid2) {
                            if ($path_to_find > 0) {
                                $path_to_find--;
                            } else {
                                $found = true;
                                $resnode = $node1;
                            }
                        } else {
                            $visited[$parents["HUSB"]] = true;
                        }
                        if ($USE_RELATIONSHIP_PRIVACY) {
                            $NODE_CACHE["{$pid1}-" . $node1["pid"]] = $node1;
                        }
                    }
                    if (!empty($parents["WIFE"]) && !isset($visited[$parents["WIFE"]])) {
                        $node1 = $node;
                        $node1["length"] += $motherh;
                        $node1["path"][] = $parents["WIFE"];
                        $node1["pid"] = $parents["WIFE"];
                        $node1["relations"][] = "mother";
                        $p1nodes[] = $node1;
                        if ($node1["pid"] == $pid2) {
                            if ($path_to_find > 0) {
                                $path_to_find--;
                            } else {
                                $found = true;
                                $resnode = $node1;
                            }
                        } else {
                            $visited[$parents["WIFE"]] = true;
                        }
                        if ($USE_RELATIONSHIP_PRIVACY) {
                            $NODE_CACHE["{$pid1}-" . $node1["pid"]] = $node1;
                        }
                    }
                    $ct = preg_match_all("/1 CHIL @(.*)@/", $famrec, $match, PREG_SET_ORDER);
                    for ($i = 0; $i < $ct; $i++) {
                        $child = $match[$i][1];
                        if (!empty($child) && !isset($visited[$child])) {
                            $node1 = $node;
                            $node1["length"] += $siblingh;
                            $node1["path"][] = $child;
                            $node1["pid"] = $child;
                            $node1["relations"][] = "sibling";
                            $p1nodes[] = $node1;
                            if ($node1["pid"] == $pid2) {
                                if ($path_to_find > 0) {
                                    $path_to_find--;
                                } else {
                                    $found = true;
                                    $resnode = $node1;
                                }
                            } else {
                                $visited[$child] = true;
                            }
                            if ($USE_RELATIONSHIP_PRIVACY) {
                                $NODE_CACHE["{$pid1}-" . $node1["pid"]] = $node1;
                            }
                        }
                    }
                }
                //-- check all spouses and children of this node
                $famids = array();
                $ct = preg_match_all("/1\\sFAMS\\s@(.*)@/", $indirec, $match, PREG_SET_ORDER);
                for ($i = 0; $i < $ct; $i++) {
                    $famids[$i] = $match[$i][1];
                }
                foreach ($famids as $indexval => $fam) {
                    $visited[$fam] = true;
                    if (isset($pgv_changes[$fam . "_" . $GEDCOM]) && PGV_USER_CAN_EDIT) {
                        $famrec = find_updated_record($fam);
                    } else {
                        $famrec = find_family_record($fam);
                    }
                    if ($followspouse) {
                        $parents = find_parents_in_record($famrec);
                        if (!empty($parents["HUSB"]) && (!in_arrayr($parents["HUSB"], $node1) || !isset($visited[$parents["HUSB"]]))) {
                            $node1 = $node;
                            $node1["length"] += $spouseh;
                            $node1["path"][] = $parents["HUSB"];
                            $node1["pid"] = $parents["HUSB"];
                            $node1["relations"][] = "spouse";
                            $p1nodes[] = $node1;
                            if ($node1["pid"] == $pid2) {
                                if ($path_to_find > 0) {
                                    $path_to_find--;
                                } else {
                                    $found = true;
                                    $resnode = $node1;
                                }
                            } else {
                                $visited[$parents["HUSB"]] = true;
                            }
                            if ($USE_RELATIONSHIP_PRIVACY) {
                                $NODE_CACHE["{$pid1}-" . $node1["pid"]] = $node1;
                            }
                        }
                        if (!empty($parents["WIFE"]) && (!in_arrayr($parents["WIFE"], $node1) || !isset($visited[$parents["WIFE"]]))) {
                            $node1 = $node;
                            $node1["length"] += $spouseh;
                            $node1["path"][] = $parents["WIFE"];
                            $node1["pid"] = $parents["WIFE"];
                            $node1["relations"][] = "spouse";
                            $p1nodes[] = $node1;
                            if ($node1["pid"] == $pid2) {
                                if ($path_to_find > 0) {
                                    $path_to_find--;
                                } else {
                                    $found = true;
                                    $resnode = $node1;
                                }
                            } else {
                                $visited[$parents["WIFE"]] = true;
                            }
                            if ($USE_RELATIONSHIP_PRIVACY) {
                                $NODE_CACHE["{$pid1}-" . $node1["pid"]] = $node1;
                            }
                        }
                    }
                    $ct = preg_match_all("/1 CHIL @(.*)@/", $famrec, $match, PREG_SET_ORDER);
                    for ($i = 0; $i < $ct; $i++) {
                        $child = $match[$i][1];
                        if (!empty($child) && !isset($visited[$child])) {
                            $node1 = $node;
                            $node1["length"] += $childh;
                            $node1["path"][] = $child;
                            $node1["pid"] = $child;
                            $node1["relations"][] = "child";
                            $p1nodes[] = $node1;
                            if ($node1["pid"] == $pid2) {
                                if ($path_to_find > 0) {
                                    $path_to_find--;
                                } else {
                                    $found = true;
                                    $resnode = $node1;
                                }
                            } else {
                                $visited[$child] = true;
                            }
                            if ($USE_RELATIONSHIP_PRIVACY) {
                                $NODE_CACHE["{$pid1}-" . $node1["pid"]] = $node1;
                            }
                        }
                    }
                }
            }
        }
        unset($p1nodes[$shortest]);
    }
    //-- end while loop
    if (headers_sent()) {
        print "\n<!-- Relationship {$pid1}-{$pid2} | Visited " . count($visited) . " nodes | Required {$count} iterations.<br />\n";
        print_execution_stats();
        print "-->\n";
    }
    return $resnode;
}
Example #5
0
/**
* Delete a person and update all records that link to that person
* @param string $pid the id of the person to delete
* @param string $gedrec the gedcom record of the person to delete
* @return boolean true or false based on the successful completion of the deletion
*/
function delete_person($pid, $gedrec = '')
{
    // NOTE: $pgv_changes isn't a global.  Making it global appears to cause problems.
    global $pgv_lang, $GEDCOM;
    if (PGV_DEBUG) {
        phpinfo(INFO_VARIABLES);
        echo "<pre>{$gedrec}</pre>";
    }
    if (empty($gedrec)) {
        $gedrec = find_person_record($pid);
    }
    if (!empty($gedrec)) {
        $success = true;
        $ct = preg_match_all("/1 FAM. @(.*)@/", $gedrec, $match, PREG_SET_ORDER);
        for ($i = 0; $i < $ct; $i++) {
            $famid = $match[$i][1];
            if (!isset($pgv_changes[$famid . "_" . $GEDCOM])) {
                $famrec = find_gedcom_record($famid);
            } else {
                $famrec = find_updated_record($famid);
            }
            if (!empty($famrec)) {
                $lines = explode("\n", $famrec);
                $newfamrec = "";
                $lastlevel = -1;
                foreach ($lines as $indexval => $line) {
                    $ct = preg_match("/^(\\d+)/", $line, $levelmatch);
                    if ($ct > 0) {
                        $level = $levelmatch[1];
                    } else {
                        $level = 1;
                    }
                    //-- make sure we don't add any sublevel records
                    if ($level <= $lastlevel) {
                        $lastlevel = -1;
                    }
                    if (preg_match("/@{$pid}@/", $line) == 0 && $lastlevel == -1) {
                        $newfamrec .= $line . "\n";
                    } else {
                        $lastlevel = $level;
                    }
                }
                //-- if there is not at least two people in a family then the family is deleted
                $pt = preg_match_all("/1 (?:HUSB|WIFE|CHIL) @(.*)@/", $newfamrec, $pmatch, PREG_SET_ORDER);
                if ($pt < 2) {
                    for ($j = 0; $j < $pt; $j++) {
                        $xref = $pmatch[$j][1];
                        if ($xref != $pid) {
                            if (!isset($pgv_changes[$xref . "_" . $GEDCOM])) {
                                $indirec = find_gedcom_record($xref);
                            } else {
                                $indirec = find_updated_record($xref);
                            }
                            $indirec = preg_replace("/1.*@{$famid}@.*/", "", $indirec);
                            if (PGV_DEBUG) {
                                echo "<pre>{$indirec}</pre>";
                            }
                            replace_gedrec($xref, $indirec);
                        }
                    }
                    $success = $success && delete_gedrec($famid);
                } else {
                    $success = $success && replace_gedrec($famid, $newfamrec);
                }
            }
        }
        if ($success) {
            $success = $success && delete_gedrec($pid);
        }
        return $success;
    }
    return false;
}
             $pos1 = strpos($gedrec, "1 CHIL @" . $child->getXref() . "@");
             if ($pos1 !== false) {
                 $pos2 = strpos($gedrec, "\n1", $pos1 + 5);
                 if ($pos2 === false) {
                     $pos2 = strlen($gedrec);
                 } else {
                     $pos2++;
                 }
                 $gedrec = substr($gedrec, 0, $pos1) . substr($gedrec, $pos2);
                 $updated = true;
             }
             //-- remove the FAMC link from the child record
             if (isset($pgv_changes[$child->getXref() . "_" . PGV_GEDCOM])) {
                 $indirec = find_updated_record($child->getXref(), PGV_GED_ID);
             } else {
                 $indirec = find_person_record($child->getXref(), PGV_GED_ID);
             }
             $pos1 = strpos($indirec, "1 FAMC @{$famid}@");
             if ($pos1 !== false) {
                 $pos2 = strpos($indirec, "\n1", $pos1 + 5);
                 if ($pos2 === false) {
                     $pos2 = strlen($indirec);
                 } else {
                     $pos2++;
                 }
                 $indirec = substr($indirec, 0, $pos1) . substr($indirec, $pos2);
                 replace_gedrec($child->getXref(), $indirec, $update_CHAN);
             }
         }
     }
 }
Example #7
0
function print_descendency($pid, $count)
{
    global $show_spouse, $dgenerations, $bwidth, $bheight, $bhalfheight;
    global $TEXT_DIRECTION, $PGV_IMAGE_DIR, $PGV_IMAGES, $generations, $box_width, $view, $show_full, $pgv_lang;
    if ($count >= $dgenerations) {
        return 0;
    }
    print "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n";
    print "<tr>";
    print "<td width=\"" . ($bwidth - 2) . "\">\n";
    $numkids = 0;
    $famids = find_sfamily_ids($pid);
    if (count($famids) > 0) {
        $firstkids = 0;
        foreach ($famids as $indexval => $famid) {
            $famrec = find_family_record($famid, PGV_GED_ID);
            $ct = preg_match_all("/1 CHIL @(.*)@/", $famrec, $match, PREG_SET_ORDER);
            if ($ct > 0) {
                print "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n";
                for ($i = 0; $i < $ct; $i++) {
                    $rowspan = 2;
                    if ($i > 0 && $i < $ct - 1) {
                        $rowspan = 1;
                    }
                    $chil = trim($match[$i][1]);
                    print "<tr><td rowspan=\"{$rowspan}\" width=\"{$bwidth}\" style=\"padding-top: 2px;\">\n";
                    if ($count < $dgenerations - 1) {
                        $kids = print_descendency($chil, $count + 1);
                        if ($i == 0) {
                            $firstkids = $kids;
                        }
                        $numkids += $kids;
                    } else {
                        print_pedigree_person($chil);
                        $numkids++;
                    }
                    print "</td>\n";
                    $twidth = 7;
                    if ($ct == 1) {
                        $twidth += 3;
                    }
                    print "<td rowspan=\"{$rowspan}\"><img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["hline"]["other"] . "\" width=\"{$twidth}\" height=\"3\" alt=\"\" /></td>\n";
                    if ($ct > 1) {
                        if ($i == 0) {
                            print "<td height=\"" . ($bhalfheight + 3) . "\"><img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["spacer"]["other"] . "\" width=\"3\" alt=\"\" /></td></tr>\n";
                            print "<tr><td height=\"" . ($bhalfheight + 3) . "\" style=\"background: url('" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["vline"]["other"] . "');\"><img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["spacer"]["other"] . "\" width=\"3\" alt=\"\" /></td>\n";
                        } else {
                            if ($i == $ct - 1) {
                                print "<td height=\"" . ($bhalfheight + 4) . "\" style=\"background: url('" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["vline"]["other"] . "');\"><img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["spacer"]["other"] . "\" width=\"3\" alt=\"\" /></td></tr>\n";
                                print "<tr><td height=\"" . ($bhalfheight + 4) . "\"><img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["spacer"]["other"] . "\" width=\"3\" alt=\"\" /></td>\n";
                            } else {
                                print "<td style=\"background: url('" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["vline"]["other"] . "');\"><img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["spacer"]["other"] . "\" width=\"3\" alt=\"\" /></td>\n";
                            }
                        }
                    }
                    print "</tr>\n";
                }
                print "</table>\n";
            }
        }
        print "</td>\n";
        print "<td width=\"{$bwidth}\">\n";
    }
    // NOTE: If statement OK
    if ($numkids == 0) {
        $numkids = 1;
        $tbwidth = $bwidth + 16;
        for ($j = $count; $j < $dgenerations; $j++) {
            print "</td>\n<td width=\"{$bwidth}\">\n";
        }
    }
    //-- add offset divs to make things line up better
    if ($show_spouse) {
        foreach ($famids as $indexval => $famid) {
            $famrec = find_family_record($famid, PGV_GED_ID);
            if (!empty($famrec)) {
                $marrec = get_sub_record(1, "1 MARR", $famrec);
                if (!empty($marrec)) {
                    print "<br />";
                }
                print "<div style=\"height: " . $bheight . "px; width: " . $bwidth . "px;\"><br /></div>\n";
            }
        }
    }
    print_pedigree_person($pid);
    // NOTE: If statement OK
    if ($show_spouse) {
        foreach ($famids as $indexval => $famid) {
            $famrec = find_family_record($famid, PGV_GED_ID);
            if (!empty($famrec)) {
                $parents = find_parents_in_record($famrec);
                $marrec = get_sub_record(1, "1 MARR", $famrec);
                if (!empty($marrec)) {
                    print "<br />";
                    $marriage = new Event($marrec);
                    $marriage->print_simple_fact();
                }
                if ($parents["HUSB"] != $pid) {
                    print_pedigree_person($parents["HUSB"]);
                } else {
                    print_pedigree_person($parents["WIFE"]);
                }
            }
        }
    }
    // NOTE: If statement OK
    if ($count == 0) {
        $indirec = find_person_record($pid, PGV_GED_ID);
        // NOTE: If statement OK
        if (displayDetailsById($pid, 'INDI') || showLivingNameById($pid)) {
            // -- print left arrow for decendants so that we can move down the tree
            $famids = find_sfamily_ids($pid);
            //-- make sure there is more than 1 child in the family with parents
            $cfamids = find_family_ids($pid);
            $num = 0;
            // NOTE: For statement OK
            for ($f = 0; $f < count($cfamids); $f++) {
                $famrec = find_family_record($cfamids[$f], PGV_GED_ID);
                if ($famrec) {
                    $num += preg_match_all("/1\\s*CHIL\\s*@(.*)@/", $famrec, $smatch, PREG_SET_ORDER);
                }
            }
            // NOTE: If statement OK
            if ($famids || $num > 1) {
                print "\n\t\t<div class=\"center\" id=\"childarrow.{$pid}\" dir=\"" . $TEXT_DIRECTION . "\"";
                print " style=\"position:absolute; width:" . $bwidth . "px; \">";
                if ($view != "preview") {
                    print "<a href=\"javascript: " . $pgv_lang["show"] . "\" onclick=\"return togglechildrenbox('{$pid}');\" onmouseover=\"swap_image('larrow.{$pid}',3);\" onmouseout=\"swap_image('larrow.{$pid}',3);\">";
                    print "<img id=\"larrow.{$pid}\" src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["darrow"]["other"] . "\" border=\"0\" alt=\"\" />";
                    print "</a>";
                }
                print "\n\t\t<div id=\"childbox.{$pid}\" dir=\"" . $TEXT_DIRECTION . "\" style=\"width:" . $bwidth . "px; height:" . $bheight . "px; visibility: hidden;\">";
                print "\n\t\t\t<table class=\"person_box\"><tr><td>";
                for ($f = 0; $f < count($famids); $f++) {
                    $famrec = find_family_record(trim($famids[$f]), PGV_GED_ID);
                    if ($famrec) {
                        $parents = find_parents($famids[$f]);
                        if ($parents) {
                            if ($pid != $parents["HUSB"]) {
                                $spid = $parents["HUSB"];
                            } else {
                                $spid = $parents["WIFE"];
                            }
                            $spouse = Person::getInstance($spid);
                            if ($spouse) {
                                $name = $spouse->getFullName();
                                print "\n\t\t\t\t<a href=\"" . encode_url("familybook.php?pid={$spid}&show_spouse={$show_spouse}&show_full={$show_full}&generations={$generations}&box_width={$box_width}") . "\"><span class=\"";
                                if (hasRTLText($name)) {
                                    print "name2";
                                } else {
                                    print "name1";
                                }
                                print "\">";
                                print PrintReady($name);
                                print "<br /></span></a>";
                            }
                        }
                        $num = preg_match_all("/1\\s*CHIL\\s*@(.*)@/", $famrec, $smatch, PREG_SET_ORDER);
                        for ($i = 0; $i < $num; $i++) {
                            //-- add the following line to stop a bad PHP bug
                            if ($i >= $num) {
                                break;
                            }
                            $cid = $smatch[$i][1];
                            $child = Person::getInstance($cid);
                            $name = $child->getFullName();
                            print "\n\t\t\t\t&nbsp;&nbsp;<a href=\"" . encode_url("familybook.php?pid={$cid}&show_spouse={$show_spouse}&show_full={$show_full}&generations={$generations}&box_width={$box_width}") . "\"><span class=\"";
                            if (hasRTLText($name)) {
                                print "name2";
                            } else {
                                print "name1";
                            }
                            print "\">&lt; ";
                            print PrintReady($name);
                            print "<br /></span></a>";
                        }
                    }
                }
                //-- print the siblings
                for ($f = 0; $f < count($cfamids); $f++) {
                    $famrec = find_family_record($cfamids[$f], PGV_GED_ID);
                    if ($famrec) {
                        $parents = find_parents($cfamids[$f]);
                        if ($parents) {
                            print "<span class=\"name1\"><br />" . $pgv_lang["parents"] . "<br /></span>";
                            if (!empty($parents["HUSB"])) {
                                $spid = $parents["HUSB"];
                                $spouse = Person::getInstance($spid);
                                $name = $spouse->getFullName();
                                print "\n\t\t\t\t&nbsp;&nbsp;<a href=\"" . encode_url("familybook.php?pid={$spid}&show_spouse={$show_spouse}&show_full={$show_full}&generations={$generations}&box_width={$box_width}") . "\"><span class=\"";
                                if (hasRTLText($name)) {
                                    print "name2";
                                } else {
                                    print "name1";
                                }
                                print "\">";
                                print PrintReady($name);
                                print "<br /></span></a>";
                            }
                            if (!empty($parents["WIFE"])) {
                                $spid = $parents["WIFE"];
                                $spouse = Person::getInstance($spid);
                                $name = $spouse->getFullName();
                                print "\n\t\t\t\t&nbsp;&nbsp;<a href=\"" . encode_url("familybook.php?pid={$spid}&show_spouse={$show_spouse}&show_full={$show_full}&generations={$generations}&box_width={$box_width}") . "\"><span class=\"";
                                if (hasRTLText($name)) {
                                    print "name2";
                                } else {
                                    print "name1";
                                }
                                print "\">";
                                print PrintReady($name);
                                print "<br /></span></a>";
                            }
                        }
                        $num = preg_match_all("/1\\s*CHIL\\s*@(.*)@/", $famrec, $smatch, PREG_SET_ORDER);
                        if ($num > 2) {
                            print "<span class=\"name1\"><br />" . $pgv_lang["siblings"] . "<br /></span>";
                        }
                        if ($num == 2) {
                            print "<span class=\"name1\"><br />" . $pgv_lang["sibling"] . "<br /></span>";
                        }
                        for ($i = 0; $i < $num; $i++) {
                            //-- add the following line to stop a bad PHP bug
                            if ($i >= $num) {
                                break;
                            }
                            $cid = $smatch[$i][1];
                            if ($cid != $pid) {
                                $child = Person::getInstance($cid);
                                $name = $child->getFullName();
                                print "\n\t\t\t\t&nbsp;&nbsp;<a href=\"familybook.php?pid={$cid}&amp;show_spouse={$show_spouse}&amp;show_full={$show_full}&amp;generations={$generations}&amp;box_width={$box_width}\"><span class=\"";
                                if (hasRTLText($name)) {
                                    print "name2";
                                } else {
                                    print "name1";
                                }
                                print "\"> ";
                                print PrintReady($name);
                                print "<br /></span></a>";
                            }
                        }
                    }
                }
                print "\n\t\t\t</td></tr></table>";
                print "\n\t\t</div>";
                print "\n\t\t</div>";
            }
        }
    }
    print "</td></tr>\n";
    print "</table>\n";
    return $numkids;
}
function print_gedcom_favorites($block = true, $config = "", $side, $index)
{
    global $pgv_lang, $factarray, $PGV_IMAGE_DIR, $PGV_IMAGES, $ctype, $TEXT_DIRECTION;
    global $show_full, $PEDIGREE_FULL_DETAILS, $BROWSERTYPE, $ENABLE_AUTOCOMPLETE;
    // Override GEDCOM configuration temporarily
    if (isset($show_full)) {
        $saveShowFull = $show_full;
    }
    $savePedigreeFullDetails = $PEDIGREE_FULL_DETAILS;
    $show_full = 1;
    $PEDIGREE_FULL_DETAILS = 1;
    $userfavs = getUserFavorites(PGV_GEDCOM);
    if (!is_array($userfavs)) {
        $userfavs = array();
    }
    $id = "gedcom_favorites";
    $title = print_help_link("index_favorites_help", "qm", "", false, true);
    $title .= $pgv_lang["gedcom_favorites"] . "&nbsp;&nbsp;";
    if ($TEXT_DIRECTION == "rtl") {
        $title .= getRLM();
    }
    $title .= "(" . count($userfavs) . ")";
    if ($TEXT_DIRECTION == "rtl") {
        $title .= getRLM();
    }
    if (PGV_USER_IS_ADMIN && $ENABLE_AUTOCOMPLETE) {
        $content = '<script type="text/javascript" src="js/jquery/jquery.min.js"></script>
		<script type="text/javascript" src="js/jquery/jquery.autocomplete.js"></script>
		<script type="text/javascript" src="js/jquery/jquery.ajaxQueue.js"></script>
		<script type="text/javascript">
		jQuery.noConflict(); // @see http://docs.jquery.com/Using_jQuery_with_Other_Libraries/
		jQuery(document).ready(function($){
			$("input[name^=gid]").autocomplete("autocomplete.php", {
				extraParams: {field:"IFSRO"},
				formatItem: function(row, i) {
					return row[0] + " (" + row[1] + ")";
				},
				formatResult: function(row) {
					return row[1];
				},
				width: 400,
				minChars: 2
			});
		});
		</script>';
    } else {
        $content = '';
    }
    if ($block) {
        $style = 2;
        // 1 means "regular box", 2 means "wide box"
        $tableWidth = $BROWSERTYPE == "msie" ? "95%" : "99%";
        // IE needs to have room for vertical scroll bar inside the box
        $cellSpacing = "1px";
    } else {
        $style = 2;
        $tableWidth = "99%";
        $cellSpacing = "3px";
    }
    if (count($userfavs) == 0) {
        if (PGV_USER_GEDCOM_ADMIN) {
            $content .= print_text("no_favorites", 0, 1);
        } else {
            $content .= print_text("no_gedcom_favorites", 0, 1);
        }
    } else {
        $content .= "<table width=\"{$tableWidth}\" style=\"border:none\" cellspacing=\"{$cellSpacing}\" class=\"center {$TEXT_DIRECTION}\">";
        foreach ($userfavs as $key => $favorite) {
            if (isset($favorite["id"])) {
                $key = $favorite["id"];
            }
            $removeFavourite = "<a class=\"font9\" href=\"" . encode_url("index.php?ctype={$ctype}&action=deletefav&fv_id={$key}") . "\" onclick=\"return confirm('" . $pgv_lang["confirm_fav_remove"] . "');\">" . $pgv_lang["remove"] . "</a><br />\n";
            $content .= "<tr><td>";
            if ($favorite["type"] == "URL") {
                $content .= "<div id=\"boxurl" . $key . ".0\" class=\"person_box\">\n";
                if ($ctype == "user" || PGV_USER_GEDCOM_ADMIN) {
                    $content .= $removeFavourite;
                }
                $content .= "<a href=\"" . $favorite["url"] . "\"><b>" . PrintReady($favorite["title"]) . "</b></a>";
                $content .= "<br />" . PrintReady($favorite["note"]);
                $content .= "</div>\n";
            } else {
                if (displayDetailsById($favorite["gid"], $favorite["type"])) {
                    if ($favorite["type"] == "INDI") {
                        $indirec = find_person_record($favorite["gid"], PGV_GED_ID);
                        $content .= "<div id=\"box" . $favorite["gid"] . ".0\" class=\"person_box";
                        if (strpos($indirec, "\n1 SEX F") !== false) {
                            $content .= "F";
                        } elseif (strpos($indirec, "\n1 SEX M") !== false) {
                            $content .= "";
                        } else {
                            $content .= "NN";
                        }
                        $content .= "\">\n";
                        if ($ctype == "user" || PGV_USER_GEDCOM_ADMIN) {
                            $content .= $removeFavourite;
                        }
                        ob_start();
                        print_pedigree_person($favorite["gid"], $style, 1, $key);
                        $content .= ob_get_clean();
                        $content .= PrintReady($favorite["note"]);
                        $content .= "</div>\n";
                    } else {
                        $record = GedcomRecord::getInstance($favorite['gid']);
                        $content .= "<div id=\"box" . $favorite["gid"] . ".0\" class=\"person_box\">";
                        if ($ctype == "user" || PGV_USER_GEDCOM_ADMIN) {
                            $content .= $removeFavourite;
                        }
                        if ($record) {
                            $content .= $record->format_list('span');
                        } else {
                            $content .= $pgv_lang['invalid_id'];
                        }
                        $content .= "<br />" . PrintReady($favorite["note"]);
                        $content .= "</div>";
                    }
                }
            }
            $content .= "</td></tr>\n";
        }
        $content .= "</table>\n";
    }
    if (PGV_USER_GEDCOM_ADMIN) {
        $content .= '
		<script language="JavaScript" type="text/javascript">
		<!--
		var pastefield;
		function paste_id(value) {
			pastefield.value=value;
		}
		-->
		</script>
		<br />
		';
        $uniqueID = floor(microtime() * 1000000);
        $content .= print_help_link("index_add_favorites_help", "qm", "", false, true);
        $content .= "<b><a href=\"javascript://" . $pgv_lang["add_favorite"] . " \" onclick=\"expand_layer('add_ged_fav'); return false;\"><img id=\"add_ged_fav_img\" src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["plus"]["other"] . "\" border=\"0\" alt=\"\" />&nbsp;" . $pgv_lang["add_favorite"] . "</a></b>";
        $content .= "<br /><div id=\"add_ged_fav\" style=\"display: none;\">\n";
        $content .= "<form name=\"addgfavform\" method=\"post\" action=\"index.php\">\n";
        $content .= "<input type=\"hidden\" name=\"action\" value=\"addfav\" />\n";
        $content .= "<input type=\"hidden\" name=\"ctype\" value=\"{$ctype}\" />\n";
        $content .= "<input type=\"hidden\" name=\"favtype\" value=\"gedcom\" />\n";
        $content .= "<input type=\"hidden\" name=\"ged\" value=\"" . PGV_GEDCOM . "\" />\n";
        $content .= "<table width=\"{$tableWidth}\" style=\"border:none\" cellspacing=\"{$cellSpacing}\" class=\"center {$TEXT_DIRECTION}\">";
        $content .= "<tr><td>" . $pgv_lang["add_fav_enter_id"] . " <br />";
        $content .= "<input class=\"pedigree_form\" type=\"text\" name=\"gid\" id=\"gid{$uniqueID}\" size=\"5\" value=\"\" />";
        $content .= print_findindi_link("gid{$uniqueID}", '', true) . "\n";
        $content .= print_findfamily_link("gid{$uniqueID}", '', true) . "\n";
        $content .= print_findsource_link("gid{$uniqueID}", '', true) . "\n";
        $content .= print_findrepository_link("gid{$uniqueID}", '', true) . "\n";
        $content .= print_findnote_link("gid{$uniqueID}", '', true) . "\n";
        $content .= print_findmedia_link("gid{$uniqueID}", '1', '', true) . "\n";
        $content .= "\n<br />" . $pgv_lang["add_fav_or_enter_url"];
        $content .= "\n<table><tr><td>" . $pgv_lang["url"] . "</td><td><input type=\"text\" name=\"url\" size=\"40\" value=\"\" /></td></tr>";
        $content .= "\n<tr><td>" . $pgv_lang["title"] . "</td><td><input type=\"text\" name=\"favtitle\" size=\"40\" value=\"\" /></td></tr></table>";
        if ($block) {
            $content .= "\n</td></tr><tr><td><br />";
        } else {
            $content .= "\n</td><td>";
        }
        $content .= "\n" . $pgv_lang["add_fav_enter_note"];
        $content .= "\n<br /><textarea name=\"favnote\" rows=\"6\" cols=\"50\"></textarea>";
        $content .= "</td></tr></table>\n";
        $content .= "\n<br /><input type=\"submit\" value=\"" . $pgv_lang["add"] . "\" style=\"font-size: 8pt; \" />";
        $content .= "\n</form></div>\n";
    }
    global $THEME_DIR;
    if ($block) {
        require $THEME_DIR . 'templates/block_small_temp.php';
    } else {
        require $THEME_DIR . 'templates/block_main_temp.php';
    }
    // Restore GEDCOM configuration
    unset($show_full);
    if (isset($saveShowFull)) {
        $show_full = $saveShowFull;
    }
    $PEDIGREE_FULL_DETAILS = $savePedigreeFullDetails;
}
        ?>
</td>
	</tr>
			<?php 
        foreach ($chil as $c => $child) {
            $person = Person::getInstance($child);
            echo "<tr><td class=\"optionbox\">";
            $name = $person->getFullName();
            if ($SHOW_ID_NUMBERS) {
                $name .= " (" . $child . ")";
            }
            $name .= " [" . $pgv_lang["edit"] . "]";
            echo "<a href=\"#\" onclick=\"return quickEdit('", $child, "', '', '", PGV_GEDCOM, "');\">";
            echo PrintReady(stripLRMRLM($name));
            echo "</a>";
            $childrec = find_person_record($child, PGV_GED_ID);
            echo "</td>\n<td class=\"optionbox center\">";
            if ($disp) {
                $sex = $person->getSex();
                if ($sex == 'M') {
                    echo Person::sexImage('M', 'small'), $pgv_lang['male'];
                } else {
                    if ($sex == 'F') {
                        echo Person::sexImage('F', 'small'), $pgv_lang['female'];
                    } else {
                        echo Person::sexImage('U', 'small'), $pgv_lang['unknown'];
                    }
                }
            }
            echo "</td>\n<td class=\"optionbox\">";
            if ($disp) {
Example #10
0
function getRelationshipText_de($relationshipDescription, $node, $pid1, $pid2)
{
    global $pgv_lang, $lang_short_cut, $LANGUAGE;
    $started = false;
    $finished = false;
    $numberOfSiblings = 0;
    $generationsOlder = 0;
    $generationsYounger = 0;
    $sosa = 1;
    $bosa = 1;
    $numberOfSpouses = 0;
    $lastRelationshipIsSpouse = false;
    // sanity check - helps to prevent the possibility of recursing too deeply
    if ($pid1 == $pid2) {
        return false;
    }
    foreach ($node["path"] as $index => $pid) {
        // only start looking for relationships from the first pid passed in
        if ($pid == $pid1) {
            $started = true;
            continue;
        }
        if ($started) {
            $lastRelationshipIsSpouse = false;
            // look to see if we can find a relationship
            switch ($node["relations"][$index]) {
                case "self":
                    break;
                case "sister":
                case "brother":
                    $numberOfSiblings++;
                    break;
                case "mother":
                    $generationsOlder++;
                    $sosa = $sosa * 2 + 1;
                    break;
                case "father":
                    $generationsOlder++;
                    $sosa = $sosa * 2;
                    break;
                case "son":
                    $generationsYounger++;
                    $bosa = $bosa * 2;
                    break;
                case "daughter":
                    $generationsYounger++;
                    $bosa = $bosa * 2 + 1;
                    break;
                case "husband":
                case "wife":
                    $numberOfSpouses++;
                    $lastRelationshipIsSpouse = true;
                    break;
            }
        }
        if ($pid == $pid2) {
            // we have found the second individual - look no further
            $finished = true;
            break;
        }
    }
    // sanity check
    if (!$started || !$finished) {
        // passed in pid's are not found in the array!!!
        return false;
    }
    $person2 = find_person_record($_SESSION["pid2"]);
    $person1 = find_person_record($_SESSION["pid1"]);
    $mf = "NN";
    if (preg_match("/1 SEX F/", $person2, $smatch) > 0) {
        $mf = "F";
    }
    if (preg_match("/1 SEX M/", $person2, $smatch) > 0) {
        $mf = "M";
    }
    //checks for nth cousin n times removed
    if ($numberOfSpouses == 0 && $numberOfSiblings == 1 && $generationsYounger > 0 && $generationsOlder > 0 && $generationsYounger != $generationsOlder) {
        $degree = min($generationsOlder, $generationsYounger);
        if ($mf == "F") {
            $relName = "female_cousin_" . $degree;
        } else {
            $relName = "male_cousin_" . $degree;
        }
        if (isset($pgv_lang[$relName])) {
            $relationshipDescription = $pgv_lang[$relName];
        }
        if ($relationshipDescription != false) {
            $removed = $generationsOlder - $generationsYounger;
            if ($removed != 0) {
                // relationship description should already be set for the Nth cousin
                if ($removed > 0) {
                    $relRemoved = "removed_ascending_" . $removed;
                } else {
                    $relRemoved = "removed_descending_" . -$removed;
                }
                if (isset($pgv_lang[$relRemoved])) {
                    $relationshipDescription .= $pgv_lang[$relRemoved];
                }
            }
        }
    }
    if ($relationshipDescription != false) {
        return $relationshipDescription;
    }
    return false;
}
 /**
  * Creates the Family element and all of it's child elements, and appends it to the
  * Families element.  This function will search through the DOMDocument looking
  * for people in the family. If they are not created yet and they are in the clippings
  * cart, they will be created and ther hlink added to the family element.
  *
  * @param string $frec - the full FAM GEDCOM record of the family to be created
  * @param string $fid = the ID (F1, F2, F3) of the family that is being created
  */
 function create_family($frec, $fid)
 {
     $check = $this->query_dom("./families/family[@id=\"{$fid}\"]/@id");
     if (($check == null || $check != $fid) && id_in_cart($fid)) {
         $famrec = $frec;
         $eFamily = $this->dom->createElement("family");
         $eFamily->setAttribute("id", $fid);
         $eFamily->setAttribute("handle", $this->generateHandle());
         $eFamily->setAttribute("change", time());
         $eFamily = $this->eFams->appendChild($eFamily);
         // Add the <father> element
         $id = get_gedcom_value("HUSB", 1, $famrec);
         $pers = $this->query_dom("./people/person[@id=\"{$id}\"]/@handle");
         if (!isset($pers) && id_in_cart($id)) {
             /*
              *
              * If the person does not exist and their ID is in the clippings cart,
              * you must create the person before you can query them in the dom to get
              * their hlink. The hlink is generated when the person element is created.
              * This causes overhead creating objects that are never added to the XML file
              * perhaps there is some other way this can be done reducing the overhead?
              *
              */
             $this->create_person(find_person_record($id), $id);
             $pers = $this->query_dom("./people/person[@id=\"{$id}\"]/@handle");
         }
         if (isset($id) && trim($id) && id_in_cart($id)) {
             $eFather = $this->dom->createElement("father");
             $eFather->setAttribute("hlink", $pers);
             $eFather = $eFamily->appendChild($eFather);
         }
         // Add the <mother> element
         $id = get_gedcom_value("WIFE", 1, $famrec);
         $pers = $this->query_dom("./people/person[@id=\"{$id}\"]/@handle");
         if (!isset($pers) && id_in_cart($id)) {
             /*
              *
              * If the person does not exist and their ID is in the clippings cart,
              * you must create the person before you can query them in the dom to get
              * their hlink. The hlink is generated when the person element is created.
              * This causes overhead creating objects that are never added to the XML file
              * perhaps there is some other way this can be done reducing the overhead?
              *
              */
             $this->create_person(find_person_record($id), $id);
             $pers = $this->query_dom("./people/person[@id=\"{$id}\"]/@handle");
         }
         if (isset($id) && trim($id) != "" && $id != null && id_in_cart($id)) {
             $eMother = $this->dom->createElement("mother");
             $eMother->setAttribute("hlink", $pers);
             $eMother = $eFamily->appendChild($eMother);
         }
         foreach ($this->familyevents as $event) {
             $this->create_event_ref($eFamily, $frec, $event);
         }
         // Add the <child> element
         $childrenIds = find_children_in_record($famrec);
         foreach ($childrenIds as $id) {
             $pers = $this->query_dom("./people/person[@id=\"{$id}\"]/@handle");
             global $type;
             if (isset($id) && isset($pers) && (id_in_cart($id) || $type == 1)) {
                 $eChild = $this->dom->createElement("childref");
                 $eChild->setAttribute("hlink", $pers);
                 $eChild = $eFamily->appendChild($eChild);
             }
         }
         if (($note = get_sub_record(1, "1 NOTE", $frec)) != null) {
             $this->create_note($eFamily, $note, 1);
         }
         $num = 1;
         while (($sourcerefRec = get_sub_record(1, "1 SOUR", $frec, $num)) != null) {
             $this->create_sourceref($eFamily, $sourcerefRec, 1);
             $num++;
         }
         $num = 1;
         while (($nameSource = get_sub_record(1, "1 OBJE", $frec, $num)) != null) {
             $this->create_mediaref($eFamily, $nameSource, 1);
             $num++;
         }
     }
 }
Example #12
0
 function addLink()
 {
     global $pgv_lang, $GEDCOM;
     switch ($this->form_location) {
         case 'remote':
             $serverID = $this->addRemoteServer($this->form_txtTitle, $this->form_txtURL, $this->form_txtGID, $this->form_txtUsername, $this->form_txtPassword);
             break;
         case 'local':
             $serverID = $this->addLocalServer($this->form_txtCB_Title, $this->form_txtCB_GID);
             break;
         case 'existing':
             $serverID = $this->form_cbExistingServers;
             break;
         case "FamilySearch":
             //TODO: Make sure that it is merging correctly
             $serverID = $this->addFamilySearchServer($this->form_txtFS_URL, $this->form_txtFS_URL, $this->form_txtFS_GID, $this->form_txtFS_Username, $this->form_txtFS_Password);
             break;
     }
     $link_pid = $this->form_txtPID;
     $relation_type = $this->form_cbRelationship;
     if ($serverID && $link_pid) {
         if (isset($pgv_changes[$this->pid . "_" . $GEDCOM])) {
             $indirec = find_updated_record($this->pid);
         } else {
             $indirec = find_person_record($this->pid);
         }
         switch ($relation_type) {
             case "father":
                 $indistub = "0 @new@ INDI\n1 SOUR @{$serverID}@\n2 PAGE {$link_pid}\n1 RFN {$serverID}:{$link_pid}";
                 $stub_id = append_gedrec($indistub, false);
                 $indistub = find_updated_record($stub_id);
                 $gedcom_fam = "0 @new@ FAM\n1 HUSB @{$stub_id}@\n1 CHIL @{$this->pid}@";
                 $fam_id = append_gedrec($gedcom_fam);
                 $indirec .= "\n1 FAMC @{$fam_id}@";
                 replace_gedrec($this->pid, $indirec);
                 $serviceClient = ServiceClient::getInstance($serverID);
                 $indistub = $serviceClient->mergeGedcomRecord($link_pid, $indistub, true, true);
                 $indistub .= "\n1 FAMS @{$fam_id}@";
                 replace_gedrec($stub_id, $indistub, false);
                 break;
             case "mother":
                 $indistub = "0 @new@ INDI\n1 SOUR @{$serverID}@\n2 PAGE {$link_pid}\n1 RFN {$serverID}:{$link_pid}";
                 $stub_id = append_gedrec($indistub, false);
                 $indistub = find_updated_record($stub_id);
                 $gedcom_fam = "0 @new@ FAM\n1 WIFE @{$stub_id}@\n1 CHIL @{$this->pid}@";
                 $fam_id = append_gedrec($gedcom_fam);
                 $indirec .= "\n1 FAMC @{$fam_id}@";
                 replace_gedrec($this->pid, $indirec);
                 $serviceClient = ServiceClient::getInstance($serverID);
                 $indistub = $serviceClient->mergeGedcomRecord($link_pid, $indistub, true, true);
                 $indistub .= "\n1 FAMS @" . $fam_id . "@";
                 replace_gedrec($stub_id, $indistub, false);
                 break;
             case "husband":
                 $indistub = "0 @new@ INDI\n1 SOUR @{$serverID}@\n2 PAGE {$link_pid}\n1 RFN {$serverID}:{$link_pid}";
                 $stub_id = append_gedrec($indistub, false);
                 $indistub = find_updated_record($stub_id);
                 $gedcom_fam = "0 @new@ FAM\n1 MARR Y\n1 WIFE @{$this->pid}@\n1 HUSB @{$stub_id}@\n";
                 $fam_id = append_gedrec($gedcom_fam);
                 $indirec .= "\n1 FAMS @{$fam_id}@";
                 replace_gedrec($this->pid, $indirec);
                 $serviceClient = ServiceClient::getInstance($serverID);
                 $indistub = $serviceClient->mergeGedcomRecord($link_pid, $indistub, true, true);
                 $indistub .= "\n1 FAMS @{$fam_id}@";
                 replace_gedrec($stub_id, $indistub, false);
                 break;
             case "wife":
                 $indistub = "0 @new@ INDI\n1 SOUR @{$serverID}@\n2 PAGE {$link_pid}\n1 RFN {$serverID}:{$link_pid}";
                 $stub_id = append_gedrec($indistub, false);
                 $indistub = find_updated_record($stub_id);
                 $gedcom_fam = "0 @new@ FAM\n1 MARR Y\n1 WIFE @{$stub_id}@\n1 HUSB @{$this->pid}@";
                 $fam_id = append_gedrec($gedcom_fam);
                 $indirec .= "\n1 FAMS @{$fam_id}@";
                 replace_gedrec($this->pid, $indirec);
                 $serviceClient = ServiceClient::getInstance($serverID);
                 $indistub = $serviceClient->mergeGedcomRecord($link_pid, $indistub, true, true);
                 $indistub .= "\n1 FAMS @{$fam_id}@\n";
                 replace_gedrec($stub_id, $indistub, false);
                 break;
             case "son":
             case "daughter":
                 $indistub = "0 @new@ INDI\n1 SOUR @{$serverID}@\n2 PAGE {$link_pid}\n1 RFN {$serverID}:{$link_pid}";
                 $stub_id = append_gedrec($indistub, false);
                 $indistub = find_updated_record($stub_id);
                 if (get_gedcom_value('SEX', 1, $indirec, '', false) == 'F') {
                     $gedcom_fam = "0 @new@ FAM\n1 WIFE @{$this->pid}@\n1 CHIL @{$stub_id}@";
                 } else {
                     $gedcom_fam = "0 @new@ FAM\n1 HUSB @{$this->pid}@\n1 CHIL @{$stub_id}@";
                 }
                 $fam_id = append_gedrec($gedcom_fam);
                 $indirec .= "\n1 FAMS @{$fam_id}@";
                 replace_gedrec($this->pid, $indirec);
                 $serviceClient = ServiceClient::getInstance($serverID);
                 $indistub = $serviceClient->mergeGedcomRecord($link_pid, $indistub, true, true);
                 $indistub .= "\n1 FAMC @" . $fam_id . "@";
                 replace_gedrec($stub_id, $indistub, false);
                 break;
             case 'current_person':
                 $indirec .= "\n1 RFN {$serverID}:{$link_pid}\n1 SOUR @{$serverID}@\n2 PAGE {$link_pid}";
                 $serviceClient = ServiceClient::getInstance($serverID);
                 if (!is_null($serviceClient)) {
                     //-- get rid of change date
                     $pos1 = strpos($indirec, "\n1 CHAN");
                     if ($pos1 !== false) {
                         $pos2 = strpos($indirec, "\n1", $pos1 + 5);
                         $indirec = substr($indirec, 0, $pos1) . substr($indirec, $pos2);
                     }
                     $indirec = $serviceClient->mergeGedcomRecord($link_pid, $indirec, true, true);
                 } else {
                     echo 'Unable to find server';
                 }
                 break;
         }
         echo '<b>', $pgv_lang['link_success'], '</b>';
         return true;
     }
     return false;
 }
Example #13
0
        ?>
</td>
	</tr>
			<?php 
        foreach ($chil as $c => $child) {
            $person = Person::getInstance($child);
            echo "<tr><td class=\"optionbox\">";
            $name = $person->getFullName();
            if ($SHOW_ID_NUMBERS) {
                $name .= " (" . $child . ")";
            }
            $name .= " [" . $pgv_lang["edit"] . "]";
            echo "<a href=\"#\" onclick=\"return quickEdit('" . $child . "','','{$GEDCOM}');\">";
            echo PrintReady(stripLRMRLM($name));
            echo "</a>";
            $childrec = find_person_record($child);
            echo "</td>\n<td class=\"optionbox center\">";
            if ($disp) {
                $sex = $person->getSex();
                if ($sex == 'M') {
                    echo Person::sexImage('M', 'small'), $pgv_lang['male'];
                } else {
                    if ($sex == 'F') {
                        echo Person::sexImage('F', 'small'), $pgv_lang['female'];
                    } else {
                        echo Person::sexImage('U', 'small'), $pgv_lang['unknown'];
                    }
                }
            }
            echo "</td>\n<td class=\"optionbox\">";
            if ($disp) {
Example #14
0
    static function _getFavorites($isged = true)
    {
        global $GEDCOM, $pgv_lang;
        global $pgv_lang, $factarray, $PGV_IMAGE_DIR, $PGV_IMAGES, $GEDCOM, $ctype, $TEXT_DIRECTION, $INDEX_DIRECTORY;
        global $show_full, $PEDIGREE_FULL_DETAILS, $BROWSERTYPE;
        // Override GEDCOM configuration temporarily
        if (isset($show_full)) {
            $saveShowFull = $show_full;
        }
        $savePedigreeFullDetails = $PEDIGREE_FULL_DETAILS;
        $show_full = 1;
        $PEDIGREE_FULL_DETAILS = 1;
        if ($isged) {
            $userfavs = getUserFavorites($GEDCOM);
        } else {
            $userfavs = getUserFavorites(PGV_USER_ID);
        }
        $content = '';
        if (!count($userfavs)) {
            if ($isged) {
                if (PGV_USER_GEDCOM_ADMIN) {
                    $content .= print_text('no_favorites', 0, 1);
                } else {
                    $content .= print_text('no_gedcom_favorites', 0, 1);
                }
            } else {
                print_text('no_favorites', 0, 1);
            }
        } else {
            if (!$isged) {
                $mygedcom = $GEDCOM;
                $current_gedcom = $GEDCOM;
            }
            $content .= "<table width=\"99%\" style=\"border:none\" cellspacing=\"3px\" class=\"center {$TEXT_DIRECTION}\">";
            foreach ($userfavs as $k => $favorite) {
                if (isset($favorite['id'])) {
                    $k = $favorite['id'];
                }
                $removeFavourite = "<a class=\"font9\" href=\"" . encode_url("index.php?ctype={$ctype}&action=deletefav&fv_id={$k}") . "\" onclick=\"return confirm('{$pgv_lang['confirm_fav_remove']}');\">{$pgv_lang['remove']}</a><br />\n";
                if (!$isged) {
                    $current_gedcom = $GEDCOM;
                    $GEDCOM = $favorite['file'];
                }
                $content .= '<tr><td>';
                if ($favorite['type'] == 'URL') {
                    $content .= "<div id=\"boxurl{$k}.0\" class=\"person_box\">\n";
                    if ($ctype == 'user' || PGV_USER_GEDCOM_ADMIN) {
                        $content .= $removeFavourite;
                    }
                    $content .= "<a href=\"{$favorite['url']}\"><b>" . PrintReady($favorite['title']) . '</b></a>';
                    $content .= "<br />\n" . PrintReady($favorite['note'], false, true);
                    $content .= "</div>\n";
                } else {
                    if (displayDetailsById($favorite['gid'], $favorite['type'])) {
                        require "{$INDEX_DIRECTORY}{$GEDCOM}_conf.php";
                        switch ($favorite['type']) {
                            case 'INDI':
                                $indirec = find_person_record($favorite['gid']);
                                $content .= "<div id=\"box{$favorite['gid']}.0\" class=\"person_box";
                                if (preg_match("/1 SEX F/", $indirec) > 0) {
                                    $content .= 'F';
                                } elseif (preg_match("/1 SEX M/", $indirec) > 0) {
                                    $content .= '';
                                } else {
                                    $content .= 'NN';
                                }
                                $content .= "\">\n";
                                if ($ctype == 'user' || PGV_USER_GEDCOM_ADMIN) {
                                    $content .= $removeFavourite;
                                }
                                ob_start();
                                print_pedigree_person($favorite['gid'], 2, 1, $k);
                                $content .= ob_get_clean();
                                $content .= PrintReady($favorite['note'], false, true);
                                $content .= "</div>\n";
                                break;
                            default:
                                $record = GedcomRecord::getInstance($favorite['gid']);
                                $content .= "<div id=\"box{$favorite['gid']}.0\" class=\"person_box\">\n";
                                if ($ctype == 'user' || PGV_USER_GEDCOM_ADMIN) {
                                    $content .= $removeFavourite;
                                }
                                $content .= $record->format_list('span');
                                $content .= "<br />\n" . PrintReady($favorite['note'], false, true);
                                $content .= "</div>\n";
                                break;
                        }
                        if (!$isged) {
                            $GEDCOM = $mygedcom;
                            require "{$INDEX_DIRECTORY}{$GEDCOM}_conf.php";
                        }
                    }
                }
                $content .= "</div>\n" . "</td></tr>\n";
            }
            $content .= "</table>\n";
        }
        if ($isged && PGV_USER_GEDCOM_ADMIN || !$isged) {
            $content .= '
				<script language="JavaScript" type="text/javascript">
				var pastefield;
				function paste_id(value) {
					pastefield.value=value;
				}
				</script>
				<br />
				';
            $uniqueID = floor(microtime() * 1000000);
            if ($isged) {
                $content .= print_help_link('index_add_favorites_help', 'qm', '', false, true) . "<b><a href=\"javascript://{$pgv_lang['add_favorite']} \" onclick=\"expand_layer('add_ged_fav'); return false;\"><img id=\"add_ged_fav_img\" src=\"{$PGV_IMAGE_DIR}/{$PGV_IMAGES['plus']['other']}\" border=\"0\" alt=\"\" />&nbsp;{$pgv_lang['add_favorite']}</a></b>" . "<br />\n<div id=\"add_ged_fav\" style=\"display: none;\">\n" . "<form name=\"addgfavform\" method=\"post\" action=\"index.php\">\n" . "<input type=\"hidden\" name=\"favtype\" value=\"gedcom\" />\n";
            } else {
                $content .= print_help_link('index_add_favorites_help', 'qm', '', false, true) . "<b><a href=\"javascript://{$pgv_lang['add_favorite']} \" onclick=\"expand_layer('add_user_fav'); return false;\"><img id=\"add_user_fav_img\" src=\"{$PGV_IMAGE_DIR}/{$PGV_IMAGES['plus']['other']}\" border=\"0\" alt=\"\" />&nbsp;{$pgv_lang['add_favorite']}</a></b>" . "<br />\n<div id=\"add_user_fav\" style=\"display: none;\">\n" . "<form name=\"addufavform\" method=\"post\" action=\"index.php\">\n" . "<input type=\"hidden\" name=\"favtype\" value=\"user\" />\n";
            }
            $content .= "<input type=\"hidden\" name=\"action\" value=\"addfav\" />\n" . "<input type=\"hidden\" name=\"ctype\" value=\"{$ctype}\" />\n" . "<input type=\"hidden\" name=\"ged\" value=\"{$GEDCOM}\" />\n" . "<table width=\"99%\" style=\"border:none\" cellspacing=\"3px\" class=\"center {$TEXT_DIRECTION}\">" . "<tr><td>{$pgv_lang['add_fav_enter_id']}<br />\n" . "<input class=\"pedigree_form\" type=\"text\" name=\"gid\" id=\"gid{$uniqueID}\" size=\"5\" value=\"\" />" . print_findindi_link("gid{$uniqueID}", '', true) . print_findfamily_link("gid{$uniqueID}", '', true) . print_findsource_link("gid{$uniqueID}", '', true) . print_findrepository_link("gid{$uniqueID}", '', true) . print_findnote_link("gid{$uniqueID}", '', true) . print_findmedia_link("gid{$uniqueID}", '1', '', true) . "<br />\n{$pgv_lang['add_fav_or_enter_url']}" . "<table><tr><td>{$pgv_lang['url']}</td><td><input type=\"text\" name=\"url\" size=\"40\" value=\"\" /></td></tr>" . "<tr><td>{$pgv_lang['title']}</td><td><input type=\"text\" name=\"favtitle\" size=\"40\" value=\"\" /></td></tr></table>" . "\n</td><td>" . "\n{$pgv_lang['add_fav_enter_note']}" . "<br />\n<textarea name=\"favnote\" rows=\"6\" cols=\"50\"></textarea>" . "</td></tr></table>\n" . "<br />\n<input type=\"submit\" value=\"{$pgv_lang['add']}\" style=\"font-size: 8pt; \" />" . "\n</form></div>\n";
        }
        // Restore GEDCOM configuration
        unset($show_full);
        if (isset($saveShowFull)) {
            $show_full = $saveShowFull;
        }
        $PEDIGREE_FULL_DETAILS = $savePedigreeFullDetails;
        return $content;
    }
Example #15
0
/**
 * print ancestors on a fan chart
 *
 * @param array $treeid ancestry pid
 * @param int $fanw fan width in px (default=640)
 * @param int $fandeg fan size in deg (default=270)
 */
function print_fan_chart($treeid, $fanw = 640, $fandeg = 270)
{
    global $PEDIGREE_GENERATIONS, $fan_width, $fan_style;
    global $name, $pgv_lang, $SHOW_ID_NUMBERS, $view, $TEXT_DIRECTION;
    global $stylesheet, $print_stylesheet;
    global $PGV_IMAGE_DIR, $PGV_IMAGES, $LINK_ICONS, $GEDCOM;
    // check for GD 2.x library
    if (!defined("IMG_ARC_PIE")) {
        print "<span class=\"error\">" . $pgv_lang["gd_library"] . "</span>";
        print " <a href=\"" . $pgv_lang["gd_helplink"] . "\"><img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["help"]["small"] . "\" class=\"icon\" alt=\"\" /></a><br /><br />";
        return false;
    }
    if (!function_exists("ImageTtfBbox")) {
        print "<span class=\"error\">" . $pgv_lang["gd_freetype"] . "</span>";
        print " <a href=\"" . $pgv_lang["gd_helplink"] . "\"><img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["help"]["small"] . "\" class=\"icon\" alt=\"\" /></a><br /><br />";
        return false;
    }
    // parse CSS file
    include "includes/cssparser.inc.php";
    $css = new cssparser(false);
    if ($view == "preview") {
        $css->Parse($print_stylesheet);
    } else {
        $css->Parse($stylesheet);
    }
    // check for fontfile
    $fontfile = $css->Get(".fan_chart", "font-family");
    $fontsize = $css->Get(".fan_chart", "font-size");
    $fontfile = str_replace("url(", "", $fontfile);
    $fontfile = str_replace(")", "", $fontfile);
    if (!file_exists($fontfile)) {
        if (!empty($fontfile)) {
            print "<span class=\"error\">" . $pgv_lang["fontfile_error"] . " : {$fontfile}</span>";
        }
        $fontfile = "./includes/fonts/DejaVuSans.ttf";
    }
    if ($fontfile[0] != '/') {
        $fontfile = dirname(__FILE__) . "/" . $fontfile;
    }
    if (!file_exists($fontfile)) {
        print "<span class=\"error\">" . $pgv_lang["fontfile_error"] . " : {$fontfile}</span>";
        return false;
    }
    if (intval($fontsize) < 2) {
        $fontsize = 7;
    }
    $treesize = count($treeid);
    if ($treesize < 1) {
        return;
    }
    // generations count
    $gen = log($treesize) / log(2) - 1;
    $sosa = $treesize - 1;
    // fan size
    if ($fandeg == 0) {
        $fandeg = 360;
    }
    $fandeg = min($fandeg, 360);
    $fandeg = max($fandeg, 90);
    $cx = $fanw / 2 - 1;
    // center x
    $cy = $cx;
    // center y
    $rx = $fanw - 1;
    $rw = $fanw / ($gen + 1);
    $fanh = $fanw;
    // fan height
    if ($fandeg == 180) {
        $fanh = round($fanh * ($gen + 1) / ($gen * 2));
    }
    if ($fandeg == 270) {
        $fanh = round($fanh * 0.86);
    }
    $scale = $fanw / 640;
    // image init
    $image = ImageCreate($fanw, $fanh);
    $black = ImageColorAllocate($image, 0, 0, 0);
    $white = ImageColorAllocate($image, 0xff, 0xff, 0xff);
    ImageFilledRectangle($image, 0, 0, $fanw, $fanh, $white);
    ImageColorTransparent($image, $white);
    $rgb = $css->Get(".fan_chart", "color");
    if (empty($rgb)) {
        $rgb = "#000000";
    }
    $color = ImageColorAllocate($image, hexdec(substr($rgb, 1, 2)), hexdec(substr($rgb, 3, 2)), hexdec(substr($rgb, 5, 2)));
    $rgb = $css->Get(".fan_chart", "background-color");
    if (empty($rgb)) {
        $rgb = "#EEEEEE";
    }
    $bgcolor = ImageColorAllocate($image, hexdec(substr($rgb, 1, 2)), hexdec(substr($rgb, 3, 2)), hexdec(substr($rgb, 5, 2)));
    $rgb = $css->Get(".fan_chart_box", "background-color");
    if (empty($rgb)) {
        $rgb = "#D0D0AC";
    }
    $bgcolorM = ImageColorAllocate($image, hexdec(substr($rgb, 1, 2)), hexdec(substr($rgb, 3, 2)), hexdec(substr($rgb, 5, 2)));
    $rgb = $css->Get(".fan_chart_boxF", "background-color");
    if (empty($rgb)) {
        $rgb = "#D0ACD0";
    }
    $bgcolorF = ImageColorAllocate($image, hexdec(substr($rgb, 1, 2)), hexdec(substr($rgb, 3, 2)), hexdec(substr($rgb, 5, 2)));
    // imagemap
    $imagemap = "<map id=\"fanmap\" name=\"fanmap\">";
    // loop to create fan cells
    while ($gen >= 0) {
        // clean current generation area
        $deg2 = 360 + ($fandeg - 180) / 2;
        $deg1 = $deg2 - $fandeg;
        ImageFilledArc($image, $cx, $cy, $rx, $rx, $deg1, $deg2, $bgcolor, IMG_ARC_PIE);
        $rx -= 3;
        // calculate new angle
        $p2 = pow(2, $gen);
        $angle = $fandeg / $p2;
        $deg2 = 360 + ($fandeg - 180) / 2;
        $deg1 = $deg2 - $angle;
        // special case for rootid cell
        if ($gen == 0) {
            $deg1 = 90;
            $deg2 = 360 + $deg1;
        }
        // draw each cell
        while ($sosa >= $p2) {
            $pid = $treeid[$sosa];
            if (!empty($pid)) {
                $indirec = find_person_record($pid);
                if (!$indirec) {
                    $indirec = find_updated_record($pid);
                }
                if ($sosa % 2) {
                    $bg = $bgcolorF;
                } else {
                    $bg = $bgcolorM;
                }
                if ($sosa == 1) {
                    $bg = $bgcolor;
                    // sex unknown
                    if (preg_match("/1 SEX F/", $indirec) > 0) {
                        $bg = $bgcolorF;
                    } else {
                        if (preg_match("/1 SEX M/", $indirec) > 0) {
                            $bg = $bgcolorM;
                        }
                    }
                }
                ImageFilledArc($image, $cx, $cy, $rx, $rx, $deg1, $deg2, $bg, IMG_ARC_PIE);
                $person = Person::getInstance($pid);
                $name = $person->getFullName();
                $addname = $person->getAddName();
                //$name = str_replace(array('<span class="starredname">', '</span>'), '', $name);
                //$addname = str_replace(array('<span class="starredname">', '</span>'), '', $addname);
                //$name = str_replace(array('<span class="starredname">', '</span>'), array('<u>', '</u>'), $name); //@@
                //$addname = str_replace(array('<span class="starredname">', '</span>'), array('<u>', '</u>'), $addname); //@@
                // ToDo - print starred names underlined - 1985154
                // Todo - print Arabic letters combined - 1360209
                $text = reverseText($name) . "\n";
                if (!empty($addname)) {
                    $text .= reverseText($addname) . "\n";
                }
                if (displayDetailsById($pid)) {
                    $birthrec = get_sub_record(1, "1 BIRT", $indirec);
                    $ct = preg_match("/2 DATE.*(\\d\\d\\d\\d)/", $birthrec, $match);
                    if ($ct > 0) {
                        $text .= trim($match[1]);
                    }
                    $deathrec = get_sub_record(1, "1 DEAT", $indirec);
                    $ct = preg_match("/2 DATE.*(\\d\\d\\d\\d)/", $deathrec, $match);
                    if ($ct > 0) {
                        $text .= "-" . trim($match[1]);
                    }
                }
                $text = unhtmlentitiesrtl($text);
                $text = strip_tags($text);
                //Do we still need?
                // split and center text by lines
                $wmax = floor($angle * 7 / $fontsize * $scale);
                $wmax = min($wmax, 35 * $scale);
                if ($gen == 0) {
                    $wmax = min($wmax, 17 * $scale);
                }
                $text = split_align_text($text, $wmax);
                // text angle
                $tangle = 270 - ($deg1 + $angle / 2);
                if ($gen == 0) {
                    $tangle = 0;
                }
                // calculate text position
                $bbox = ImageTtfBbox((double) $fontsize, 0, $fontfile, $text);
                $textwidth = $bbox[4];
                $deg = $deg1 + 0.44;
                if ($deg2 - $deg1 > 40) {
                    $deg = $deg1 + ($deg2 - $deg1) / 11;
                }
                if ($deg2 - $deg1 > 80) {
                    $deg = $deg1 + ($deg2 - $deg1) / 7;
                }
                if ($deg2 - $deg1 > 140) {
                    $deg = $deg1 + ($deg2 - $deg1) / 4;
                }
                if ($gen == 0) {
                    $deg = 180;
                }
                $rad = deg2rad($deg);
                $mr = ($rx - $rw / 4) / 2;
                if ($gen > 0 and $deg2 - $deg1 > 80) {
                    $mr = $rx / 2;
                }
                $tx = $cx + $mr * cos($rad);
                $ty = $cy - $mr * -sin($rad);
                if ($sosa == 1) {
                    $ty -= $mr / 2;
                }
                // print text
                ImageTtfText($image, (double) $fontsize, $tangle, $tx, $ty, $color, $fontfile, $text);
                $imagemap .= "<area shape=\"poly\" coords=\"";
                // plot upper points
                $mr = $rx / 2;
                $deg = $deg1;
                while ($deg <= $deg2) {
                    $rad = deg2rad($deg);
                    $tx = round($cx + $mr * cos($rad));
                    $ty = round($cy - $mr * -sin($rad));
                    $imagemap .= "{$tx}, {$ty}, ";
                    $deg += ($deg2 - $deg1) / 6;
                }
                // plot lower points
                $mr = ($rx - $rw) / 2;
                $deg = $deg2;
                while ($deg >= $deg1) {
                    $rad = deg2rad($deg);
                    $tx = round($cx + $mr * cos($rad));
                    $ty = round($cy - $mr * -sin($rad));
                    $imagemap .= "{$tx}, {$ty}, ";
                    $deg -= ($deg2 - $deg1) / 6;
                }
                // join first point
                $mr = $rx / 2;
                $deg = $deg1;
                $rad = deg2rad($deg);
                $tx = round($cx + $mr * cos($rad));
                $ty = round($cy - $mr * -sin($rad));
                $imagemap .= "{$tx}, {$ty}";
                // add action url
                $tempURL = "javascript://" . htmlspecialchars(strip_tags($name));
                if ($SHOW_ID_NUMBERS) {
                    $tempURL .= " (" . $pid . ")";
                }
                $imagemap .= "\" href=\"{$tempURL}\" ";
                $tempURL = "fanchart.php?rootid={$pid}&PEDIGREE_GENERATIONS={$PEDIGREE_GENERATIONS}&fan_width={$fan_width}&fan_style={$fan_style}";
                if (!empty($view)) {
                    $tempURL .= "&view={$view}";
                }
                $count = 0;
                $lbwidth = 200;
                print "<div id=\"I" . $pid . "." . $count . "links\" style=\"position:absolute; >";
                print "left:" . $tx . "px; top:" . $ty . "px; width: " . $lbwidth . "px; visibility:hidden; z-index:'100';\">";
                print "<table class=\"person_box\"><tr><td class=\"details1\">";
                print "<a href=\"individual.php?pid={$pid}\" class=\"name1\">" . PrintReady($name);
                if (!empty($addname)) {
                    print "<br />" . PrintReady($addname);
                }
                print "</a>";
                print "<br /><a href=\"pedigree.php?rootid={$pid}\" >" . $pgv_lang["index_header"] . "</a>";
                print "<br /><a href=\"descendancy.php?pid={$pid}\" >" . $pgv_lang["descend_chart"] . "</a>";
                if (PGV_USER_GEDCOM_ID) {
                    print "<br /><a href=\"" . encode_url("relationship.php?pid1=" . PGV_USER_GEDCOM_ID . "&pid2={$pid}&ged={$GEDCOM}") . "\" onmouseover=\"clear_family_box_timeout('" . $pid . "." . $count . "');\" onmouseout=\"family_box_timeout('" . $pid . "." . $count . "');\">" . $pgv_lang["relationship_to_me"] . "</a>";
                }
                print "<br /><a href=\"ancestry.php?rootid={$pid}\" onmouseover=\"clear_family_box_timeout('" . $pid . "." . $count . "');\" onmouseout=\"family_box_timeout('" . $pid . "." . $count . "');\">" . $pgv_lang["ancestry_chart"] . "</a>";
                print "<br /><a href=\"compact.php?rootid={$pid}\" onmouseover=\"clear_family_box_timeout('" . $pid . "." . $count . "');\" onmouseout=\"family_box_timeout('" . $pid . "." . $count . "');\">" . $pgv_lang["compact_chart"] . "</a>";
                print "<br /><a href=\"" . encode_url($tempURL) . "\" onmouseover=\"clear_family_box_timeout('" . $pid . "." . $count . "');\" onmouseout=\"family_box_timeout('" . $pid . "." . $count . "');\">" . $pgv_lang["fan_chart"] . "</a>";
                print "<br /><a href=\"hourglass.php?pid={$pid}\" onmouseover=\"clear_family_box_timeout('" . $pid . "." . $count . "');\" onmouseout=\"family_box_timeout('" . $pid . "." . $count . "');\">" . $pgv_lang["hourglass_chart"] . "</a>";
                if ($sosa >= 1) {
                    $famids = find_sfamily_ids($pid);
                    //-- make sure there is more than 1 child in the family with parents
                    $cfamids = find_family_ids($pid);
                    $num = 0;
                    for ($f = 0; $f < count($cfamids); $f++) {
                        $famrec = find_family_record($cfamids[$f]);
                        if ($famrec) {
                            $num += preg_match_all("/1\\s*CHIL\\s*@(.*)@/", $famrec, $smatch, PREG_SET_ORDER);
                        }
                    }
                    if ($famids || $num > 1) {
                        //-- spouse(s) and children
                        for ($f = 0; $f < count($famids); $f++) {
                            $famrec = find_family_record(trim($famids[$f]));
                            if ($famrec) {
                                $parents = find_parents($famids[$f]);
                                if ($parents) {
                                    if ($pid != $parents["HUSB"]) {
                                        $spid = $parents["HUSB"];
                                    } else {
                                        $spid = $parents["WIFE"];
                                    }
                                    $person = Person::getInstance($spid);
                                    if ($person) {
                                        echo '<br /><a href="', $person->getLinkUrl(), '" class="name1">', $person->getFullName(), '</a>';
                                    }
                                }
                                $num = preg_match_all("/1\\s*CHIL\\s*@(.*)@/", $famrec, $smatch, PREG_SET_ORDER);
                                for ($i = 0; $i < $num; $i++) {
                                    $person = Person::getInstance($smatch[$i][1]);
                                    if ($person) {
                                        echo '<br />&nbsp;&nbsp;<a href="', $person->getLinkUrl(), '" class="name1">&lt; ', $person->getFullName(), '</a>';
                                    }
                                }
                            }
                        }
                        //-- siblings
                        for ($f = 0; $f < count($cfamids); $f++) {
                            $famrec = find_family_record($cfamids[$f]);
                            if ($famrec) {
                                $num = preg_match_all("/1\\s*CHIL\\s*@(.*)@/", $famrec, $smatch, PREG_SET_ORDER);
                                if ($num > 2) {
                                    print "<br /><span class=\"name1\">" . $pgv_lang["siblings"] . "</span>";
                                }
                                if ($num == 2) {
                                    print "<br /><span class=\"name1\">" . $pgv_lang["sibling"] . "</span>";
                                }
                                for ($i = 0; $i < $num; $i++) {
                                    $cpid = $smatch[$i][1];
                                    if ($cpid != $pid) {
                                        $person = Person::getInstance($cpid);
                                        if ($person) {
                                            echo '<br />&nbsp;&nbsp;<a href="', $person->getLinkUrl(), '" class="name1"> ', $person->getFullName(), '</a>';
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                print "</td></tr></table>";
                print "</div>";
                $imagemap .= " onclick=\"show_family_box('" . $pid . "." . $count . "', 'relatives'); return false;\"";
                $imagemap .= " onmouseout=\"family_box_timeout('" . $pid . "." . $count . "'); return false;\"";
                $imagemap .= " alt=\"" . PrintReady(strip_tags($name)) . "\" title=\"" . PrintReady(strip_tags($name)) . "\" />";
            }
            $deg1 -= $angle;
            $deg2 -= $angle;
            $sosa--;
        }
        $rx -= $rw;
        $gen--;
    }
    $imagemap .= "</map>";
    echo $imagemap;
    // PGV banner ;-)
    ImageStringUp($image, 1, $fanw - 10, $fanh / 3, PGV_PHPGEDVIEW_URL, $color);
    // here we cannot send image to browser ('header already sent')
    // and we dont want to use a tmp file
    // step 1. save image data in a session variable
    ob_start();
    ImagePng($image);
    $image_data = ob_get_contents();
    ob_end_clean();
    $image_data = serialize($image_data);
    unset($_SESSION['image_data']);
    $_SESSION['image_data'] = $image_data;
    // step 2. call imageflush.php to read this session variable and display image
    // note: arg "image_name=" is to avoid image miscaching
    $image_name = "V" . time();
    unset($_SESSION[$image_name]);
    // statisticsplot.php uses this to hold a file name to send to browser
    $image_title = preg_replace("~<.*>~", "", $name) . " " . $pgv_lang["fan_chart"];
    echo "<p align=\"center\" >";
    echo "<img src=\"imageflush.php?image_type=png&amp;image_name={$image_name}&amp;height={$fanh}&amp;width={$fanw}\" width=\"{$fanw}\" height=\"{$fanh}\" border=\"0\" alt=\"{$image_title}\" title=\"{$image_title}\" usemap=\"#fanmap\" />";
    echo "</p>";
    ImageDestroy($image);
}
Example #16
0
/**
 * check root id for pedigree tree
 *
 * @param string $rootid root ID
 * @return string $rootid validated root ID
 */
function check_rootid($rootid)
{
    global $PEDIGREE_ROOT_ID, $USE_RIN, $gGedcom;
    // -- if the $rootid is not already there then find the first person in the file and make him the root
    if (!find_person_record($rootid)) {
        if (find_person_record($gGedcom->mRootId)) {
            $rootid = $gGedcom->mRootId;
        } else {
            // TODO - Add options for user gedcom id's'
            if (find_person_record($gGedcom->mRootId)) {
                $rootid = $gGedcom->mRootId;
            } else {
                if (find_person_record(trim($PEDIGREE_ROOT_ID))) {
                    $rootid = trim($PEDIGREE_ROOT_ID);
                } else {
                    $rootid = get_first_xref('INDI', $gGedcom->mGEDCOMId);
                    // If there are no users in the gedcom, do something.
                    if (!$rootid) {
                        $rootid = 'I1';
                    }
                }
            }
        }
    }
    if ($USE_RIN) {
        $indirec = find_person_record($rootid);
        if ($indirec == false) {
            $rootid = find_rin_id($rootid);
        }
    }
    return $rootid;
}
Example #17
0
/**
 * print first major fact for an Individual
 *
 * @param string $key	indi pid
 */
function print_first_major_fact($key, $majorfacts = array("BIRT", "CHR", "BAPM", "DEAT", "BURI", "BAPL", "ADOP"))
{
    global $pgv_lang, $factarray, $LANGUAGE, $TEXT_DIRECTION;
    $indirec = find_person_record($key);
    if (!$indirec) {
        $indirec = find_family_record($key);
    }
    foreach ($majorfacts as $indexval => $fact) {
        $factrec = get_sub_record(1, "1 {$fact}", $indirec);
        if (strlen($factrec) > 7 and showFact("{$fact}", $key) and !FactViewRestricted($key, $factrec)) {
            print "<span dir=\"{$TEXT_DIRECTION}\">";
            echo "<br /><i>";
            //print " -- <i>";
            if (isset($pgv_lang[$fact])) {
                print $pgv_lang[$fact];
            } else {
                if (isset($factarray[$fact])) {
                    print $factarray[$fact];
                } else {
                    print $fact;
                }
            }
            print " ";
            print_fact_date($factrec);
            print_fact_place($factrec);
            print "</i>";
            print "</span>";
            break;
        }
    }
    return $fact;
}
Example #18
0
             $pos1 = strpos($gedrec, "1 CHIL @" . $child->getXref() . "@");
             if ($pos1 !== false) {
                 $pos2 = strpos($gedrec, "\n1", $pos1 + 5);
                 if ($pos2 === false) {
                     $pos2 = strlen($gedrec);
                 } else {
                     $pos2++;
                 }
                 $gedrec = substr($gedrec, 0, $pos1) . substr($gedrec, $pos2);
                 $updated = true;
             }
             //-- remove the FAMC link from the child record
             if (isset($pgv_changes[$child->getXref() . "_" . $GEDCOM])) {
                 $indirec = find_updated_record($child->getXref());
             } else {
                 $indirec = find_person_record($child->getXref());
             }
             $pos1 = strpos($indirec, "1 FAMC @{$famid}@");
             if ($pos1 !== false) {
                 $pos2 = strpos($indirec, "\n1", $pos1 + 5);
                 if ($pos2 === false) {
                     $pos2 = strlen($indirec);
                 } else {
                     $pos2++;
                 }
                 $indirec = substr($indirec, 0, $pos1) . substr($indirec, $pos2);
                 replace_gedrec($child->getXref(), $indirec);
             }
         }
     }
 }