Пример #1
0
 /**
  * merge a local gedcom record with the information from the remote site
  * @param string $xref		the remote ID to merge with
  * @param string $localrec	the local gedcom record to merge the remote record with
  * @param boolean $isStub	whether or not this is a stub record
  * @param boolean $firstLink	is this the first time this record is being linked
  */
 function mergeGedcomRecord($xref, $localrec, $isStub = false, $firstLink = false)
 {
     //-- get the record from the database
     $gedrec = find_gedcom_record($xref, $this->gedfile);
     $gedrec = preg_replace("/@(.*)@/", "@" . $this->xref . ":\$1@", $gedrec);
     $gedrec = $this->checkIds($gedrec);
     if (empty($localrec)) {
         return $gedrec;
     }
     $localrec = $this->_merge($localrec, $gedrec);
     //-- used to force an update on the first time linking a person
     if ($firstLink) {
         include_once "includes/functions/functions_edit.php";
         $ct = preg_match("/0 @(.*)@/", $localrec, $match);
         if ($ct > 0) {
             $pid = trim($match[1]);
             $localrec = $this->UpdateFamily($localrec, $gedrec);
             //-- restore the correct id since it may have been changed by the UpdateFamily method
             $localrec = preg_replace("/0 @(.*)@/", "0 @{$pid}@", $localrec);
             replace_gedrec($pid, $localrec);
         }
     }
     return $localrec;
 }
Пример #2
0
             $gedrec = privatize_gedcom($gedrec);
         }
         addDebugLog($action . " xref={$xref} SUCCESS\n" . trim($gedrec));
         print "SUCCESS\n" . trim($gedrec);
     } else {
         addDebugLog($action . " ERROR 3: No gedcom id specified.  Please specify a xref.");
         print "ERROR 3: No gedcom id specified.  Please specify a xref.\n";
     }
     exit;
 case 'getprev':
     $xref = safe_REQUEST($_REQUEST, 'xref', PGV_REGEX_XREF);
     if ($xref) {
         $xref1 = get_prev_xref($xref, $GED_ID);
         $gedrec = find_updated_record($xref1);
         if (!$gedrec) {
             $gedrec = find_gedcom_record($xref1);
         }
         if (!displayDetailsById($xref1)) {
             //-- do not have full access to this record, so privatize it
             $gedrec = privatize_gedcom($gedrec);
         }
         addDebugLog($action . " xref={$xref} SUCCESS\n" . trim($gedrec));
         print "SUCCESS\n" . trim($gedrec);
     } else {
         addDebugLog($action . " ERROR 3: No gedcom id specified.  Please specify a xref.");
         print "ERROR 3: No gedcom id specified.  Please specify a xref.\n";
     }
     exit;
 case 'search':
     $query = safe_REQUEST($_REQUEST, 'query');
     if ($query) {
Пример #3
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_family($pid, $gedrec = '')
{
    // NOTE: $pgv_changes isn't a global.  Making it global appears to cause problems.
    global $GEDCOM, $pgv_lang;
    if (empty($gedrec)) {
        $gedrec = find_family_record($pid);
    }
    if (!empty($gedrec)) {
        $success = true;
        $ct = preg_match_all("/1 (\\w+) @(.*)@/", $gedrec, $match, PREG_SET_ORDER);
        for ($i = 0; $i < $ct; $i++) {
            $type = $match[$i][1];
            $id = $match[$i][2];
            if (PGV_DEBUG) {
                echo $type . " " . $id . " ";
            }
            if (!isset($pgv_changes[$id . "_" . $GEDCOM])) {
                $indirec = find_gedcom_record($id);
            } else {
                $indirec = find_updated_record($id);
            }
            if (!empty($indirec)) {
                $lines = explode("\n", $indirec);
                $newindirec = "";
                $lastlevel = -1;
                foreach ($lines as $indexval => $line) {
                    $lct = preg_match("/^(\\d+)/", $line, $levelmatch);
                    if ($lct > 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) {
                        $newindirec .= $line . "\n";
                    } else {
                        $lastlevel = $level;
                    }
                }
                $success = $success && replace_gedrec($id, $newindirec);
            }
        }
        if ($success) {
            $success = $success && delete_gedrec($pid);
        }
        return $success;
    }
    return false;
}
Пример #4
0
             $gedrec = privatize_gedcom($gedrec);
         }
         addDebugLog($action . " xref={$xref} SUCCESS\n" . trim($gedrec));
         print "SUCCESS\n" . trim($gedrec);
     } else {
         addDebugLog($action . " ERROR 3: No gedcom id specified.  Please specify a xref.");
         print "ERROR 3: No gedcom id specified.  Please specify a xref.\n";
     }
     exit;
 case 'getprev':
     $xref = safe_REQUEST($_REQUEST, 'xref', PGV_REGEX_XREF);
     if ($xref) {
         $xref1 = get_prev_xref($xref, $GED_ID);
         $gedrec = find_updated_record($xref1, $GED_ID);
         if (!$gedrec) {
             $gedrec = find_gedcom_record($xref1, $GED_ID);
         }
         if (!displayDetailsById($xref1)) {
             //-- do not have full access to this record, so privatize it
             $gedrec = privatize_gedcom($gedrec);
         }
         addDebugLog($action . " xref={$xref} SUCCESS\n" . trim($gedrec));
         print "SUCCESS\n" . trim($gedrec);
     } else {
         addDebugLog($action . " ERROR 3: No gedcom id specified.  Please specify a xref.");
         print "ERROR 3: No gedcom id specified.  Please specify a xref.\n";
     }
     exit;
 case 'search':
     $query = safe_REQUEST($_REQUEST, 'query');
     if ($query) {
Пример #5
0
/**
 * get the next available xref
 * calculates the next available XREF id for the given type of record
 * @param string $type	the type of record, defaults to 'INDI'
 * @return string
 */
function get_new_xref($type = 'INDI', $use_cache = false)
{
    global $fcontents, $SOURCE_ID_PREFIX, $REPO_ID_PREFIX, $pgv_changes, $GEDCOM, $TBLPREFIX, $GEDCOMS;
    global $MEDIA_ID_PREFIX, $FAM_ID_PREFIX, $GEDCOM_ID_PREFIX, $FILE, $MAX_IDS;
    global $gBitDb;
    //-- during online updates $FILE comes through as an array for some odd reason
    if (!empty($FILE) && !is_array($FILE)) {
        $gedid = $GEDCOMS[$FILE]["id"];
    } else {
        $gedid = $GEDCOMS[$GEDCOM]["id"];
    }
    $num = null;
    //-- check if an id is stored in MAX_IDS used mainly during the import
    //-- the number stored in the max_id is the next number to use... no need to increment it
    if ($use_cache && !empty($MAX_IDS) && isset($MAX_IDS[$type])) {
        $num = 1;
        $num = $MAX_IDS[$type];
        $MAX_IDS[$type] = $num + 1;
    } else {
        //-- check for the id in the nextid table
        $num = $gBitDb->getOne("SELECT ni_id FROM {$TBLPREFIX}nextid WHERE ni_type=? AND ni_gedfile=?", array($type, $gedid));
        //-- the id was not found in the table so try and find it in the file
        if (is_null($num) && !empty($fcontents)) {
            $ct = preg_match_all("/0 @(.*)@ {$type}/", $fcontents, $match, PREG_SET_ORDER);
            $num = 0;
            for ($i = 0; $i < $ct; $i++) {
                $ckey = $match[$i][1];
                $bt = preg_match("/(\\d+)/", $ckey, $bmatch);
                if ($bt > 0) {
                    $bnum = trim($bmatch[1]);
                    if ($num < $bnum) {
                        $num = $bnum;
                    }
                }
            }
            $num++;
        }
        //-- type wasn't found in database or in file so make a new one
        if (is_null($num)) {
            $num = 1;
            $gBitDb->query("INSERT INTO {$TBLPREFIX}nextid VALUES(?, ?, ?)", array($num + 1, $type, $gedid));
        }
    }
    switch ($type) {
        case "INDI":
            $prefix = $GEDCOM_ID_PREFIX;
            break;
        case "FAM":
            $prefix = $FAM_ID_PREFIX;
            break;
        case "OBJE":
            $prefix = $MEDIA_ID_PREFIX;
            break;
        case "SOUR":
            $prefix = $SOURCE_ID_PREFIX;
            break;
        case "REPO":
            $prefix = $REPO_ID_PREFIX;
            break;
        default:
            $prefix = $type[0];
            break;
    }
    //-- make sure this number has not already been used
    if ($num >= 2147483647 || $num <= 0) {
        // Popular databases are only 32 bits (signed)
        $num = 1;
    }
    while (find_gedcom_record($prefix . $num) || find_updated_record($prefix . $num)) {
        ++$num;
        if ($num >= 2147483647 || $num <= 0) {
            // Popular databases are only 32 bits (signed)
            $num = 1;
        }
    }
    //-- the key is the prefix and the number
    $key = $prefix . $num;
    //-- during the import we won't update the database at this time so return now
    if ($use_cache && isset($MAX_IDS[$type])) {
        return $key;
    }
    //-- update the next id number in the DB table
    $gBitDb->query("UPDATE {$TBLPREFIX}nextid SET ni_id=? WHERE ni_type=? AND ni_gedfile=?", array($num + 1, $type, $gedid));
    return $key;
}
Пример #6
0
            $famrec = find_updated_record($famid, PGV_GED_ID);
        }
        if (preg_match("/1 (HUSB|WIFE|CHIL) @{$pid}@/", $famrec)) {
            $related = true;
            break;
        }
    }
    if (!$related) {
        echo $pgv_lang["access_denied"];
        print_simple_footer();
        exit;
    }
}
//-- find the latest gedrec for the individual
if (!isset($pgv_changes[$pid . "_" . PGV_GEDCOM])) {
    $gedrec = find_gedcom_record($pid, PGV_GED_ID);
} else {
    $gedrec = find_updated_record($pid, PGV_GED_ID);
}
// Don't allow edits if the record has changed since the edit-link was created
checkChangeTime($pid, $gedrec, safe_GET('accesstime', PGV_REGEX_INTEGER));
//-- only allow edit of individual records
$disp = true;
$ct = preg_match("/0 @{$pid}@ (.*)/", $gedrec, $match);
if ($ct > 0) {
    $type = trim($match[1]);
    if ($type == "INDI") {
        $disp = displayDetailsById($pid);
    } else {
        echo $pgv_lang["access_denied"];
        print_simple_footer();
Пример #7
0
 case 'deleterepo':
     if (isset($_REQUEST['action'])) {
         $action = $_REQUEST['action'];
     }
     if (PGV_DEBUG) {
         phpinfo(INFO_VARIABLES);
         echo "<pre>{$gedrec}</pre>";
     }
     if (!empty($gedrec)) {
         $success = true;
         // Delete links to this record
         foreach (fetch_all_links($pid, PGV_GED_ID) as $xref) {
             if (isset($pgv_changes[$xref . '_' . PGV_GEDCOM])) {
                 $gedrec = find_updated_record($xref, PGV_GED_ID);
             } else {
                 $gedrec = find_gedcom_record($xref, PGV_GED_ID);
             }
             $lines = explode("\n", $gedrec);
             $newrec = "";
             $skipline = false;
             $glevel = 0;
             foreach ($lines as $indexval => $line) {
                 if (preg_match("/^\\d " . PGV_REGEX_TAG . " @{$pid}@/", $line) == 0 && !$skipline) {
                     $newrec .= $line . "\n";
                 } else {
                     if (!$skipline) {
                         $glevel = $line[0];
                         $skipline = true;
                     } else {
                         if ($line[0] <= $glevel) {
                             $skipline = false;
Пример #8
0
/**
 * print ASSO RELA information
 *
 * Ex1:
 * <code>1 ASSO @I1@
 * 2 RELA Twin</code>
 *
 * Ex2:
 * <code>1 CHR
 * 2 ASSO @I1@
 * 3 RELA Godfather
 * 2 ASSO @I2@
 * 3 RELA Godmother</code>
 *
 * @param string $pid		person or family ID
 * @param string $factrec	the raw gedcom record to print
 * @param string $linebr 	optional linebreak
 */
function print_asso_rela_record($pid, $factrec, $linebr = false)
{
    global $GEDCOM, $SHOW_ID_NUMBERS, $TEXT_DIRECTION, $pgv_lang, $factarray, $PGV_IMAGE_DIR, $PGV_IMAGES, $view;
    // get ASSOciate(s) ID(s)
    $ct = preg_match_all("/\\d ASSO @(.*)@/", $factrec, $match, PREG_SET_ORDER);
    for ($i = 0; $i < $ct; $i++) {
        $level = substr($match[$i][0], 0, 1);
        $pid2 = $match[$i][1];
        // get RELAtionship field
        $assorec = get_sub_record($level, "{$level} ASSO ", $factrec, $i + 1);
        //		if (substr($_SERVER["SCRIPT_NAME"],1) == "pedigree.php") {
        $rct = preg_match("/\\d RELA (.*)/", $assorec, $rmatch);
        if ($rct > 0) {
            // RELAtionship name in user language
            $key = strtolower(trim($rmatch[1]));
            $cr = preg_match_all("/sosa_(.*)/", $key, $relamatch, PREG_SET_ORDER);
            if ($cr > 0) {
                $rela = get_sosa_name($relamatch[0][1]);
            } else {
                if (isset($pgv_lang["{$key}"])) {
                    $rela = $pgv_lang[$key];
                } else {
                    $rela = $rmatch[1];
                }
            }
            $p = strpos($rela, "(=");
            if ($p > 0) {
                $rela = trim(substr($rela, 0, $p));
            }
            if ($pid2 == $pid) {
                print "<span class=\"details_label\">";
            }
            print $rela . ": ";
            if ($pid2 == $pid) {
                print "</span>";
            }
        } else {
            $rela = $factarray["RELA"];
        }
        // default
        //		}
        // ASSOciate ID link
        $gedrec = find_gedcom_record($pid2);
        if (strstr($gedrec, "@ INDI") !== false or strstr($gedrec, "@ SUBM") !== false) {
            // ID name
            if (DisplayDetailsByID($pid2) || showLivingNameByID($pid2)) {
                $name = get_person_name($pid2);
                $addname = get_add_person_name($pid2);
            } else {
                $name = $pgv_lang["private"];
                $addname = "";
            }
            print "<a href=\"individual.php?pid={$pid2}&amp;ged={$GEDCOM}\">" . PrintReady($name);
            //			if (!empty($addname)) print "<br />" . PrintReady($addname);
            if (!empty($addname)) {
                print " - " . PrintReady($addname);
            }
            if ($SHOW_ID_NUMBERS) {
                print "&nbsp;&nbsp;";
                if ($TEXT_DIRECTION == "rtl") {
                    print "&rlm;";
                }
                print "(" . $pid2 . ")";
                if ($TEXT_DIRECTION == "rtl") {
                    print "&rlm;";
                }
            }
            print "</a>";
            // ID age
            if (!strstr($factrec, "_BIRT_")) {
                $dct = preg_match("/2 DATE (.*)/", $factrec, $dmatch);
                if ($dct > 0) {
                    print " <span class=\"age\">" . get_age($gedrec, $dmatch[1]) . "</span>";
                }
            }
            // RELAtionship calculation : for a family print relationship to both spouses
            if ($view != "preview") {
                $famrec = find_family_record($pid);
                if ($famrec) {
                    $parents = find_parents_in_record($famrec);
                    $pid1 = $parents["HUSB"];
                    if ($pid1 and $pid1 != $pid2) {
                        print " - <a href=\"relationship.php?pid1={$pid1}&amp;pid2={$pid2}&amp;followspouse=1&amp;ged={$GEDCOM}\">[" . $pgv_lang["relationship_chart"] . "<img src=\"{$PGV_IMAGE_DIR}/" . $PGV_IMAGES["sex"]["small"] . "\" title=\"" . $pgv_lang["husband"] . "\" alt=\"" . $pgv_lang["husband"] . "\" class=\"sex_image\" />]</a>";
                    }
                    $pid1 = $parents["WIFE"];
                    if ($pid1 and $pid1 != $pid2) {
                        print " - <a href=\"relationship.php?pid1={$pid1}&amp;pid2={$pid2}&amp;followspouse=1&amp;ged={$GEDCOM}\">[" . $pgv_lang["relationship_chart"] . "<img src=\"{$PGV_IMAGE_DIR}/" . $PGV_IMAGES["sexf"]["small"] . "\" title=\"" . $pgv_lang["wife"] . "\" alt=\"" . $pgv_lang["wife"] . "\" class=\"sex_image\" />]</a>";
                    }
                } else {
                    if ($pid != $pid2) {
                        print " - <a href=\"relationship.php?pid1={$pid}&amp;pid2={$pid2}&amp;followspouse=1&amp;ged={$GEDCOM}\">[" . $pgv_lang["relationship_chart"] . "]</a>";
                    }
                }
            }
        } else {
            if (strstr($gedrec, "@ FAM") !== false) {
                print "<a href=\"family.php?famid={$pid2}\">";
                if ($TEXT_DIRECTION == "ltr") {
                    print " &lrm;";
                } else {
                    print " &rlm;";
                }
                print "[" . $pgv_lang["view_family"];
                if ($SHOW_ID_NUMBERS) {
                    print " &lrm;({$pid2})&lrm;";
                }
                if ($TEXT_DIRECTION == "ltr") {
                    print "&lrm;]</a>\n";
                } else {
                    print "&rlm;]</a>\n";
                }
            } else {
                print $pgv_lang["unknown"];
                if ($SHOW_ID_NUMBERS) {
                    print "&nbsp;&nbsp;";
                    if ($TEXT_DIRECTION == "rtl") {
                        print "&rlm;";
                    }
                    print "(" . $pid2 . ")";
                    if ($TEXT_DIRECTION == "rtl") {
                        print "&rlm;";
                    }
                }
            }
        }
        if ($linebr) {
            print "<br />\n";
        }
        print_fact_notes($assorec, $level + 1);
        if (substr($_SERVER["SCRIPT_NAME"], 1) == "pedigree.php") {
            print "<br />";
            if (function_exists('print_fact_sources')) {
                print_fact_sources($assorec, $level + 1);
            }
        }
    }
}
Пример #9
0
    $varnames = array();
} else {
    $varnames = $_REQUEST['varnames'];
}
if (!isset($_REQUEST['$type'])) {
    $type = array();
} else {
    $type = $_REQUEST['type'];
}
//-- setup the arrays
$newvars = array();
foreach ($vars as $name => $var) {
    $var = clean_input($var);
    $newvars[$name]["id"] = $var;
    if (!empty($type[$name]) && ($type[$name] == "INDI" || $type[$name] == "FAM" || $type[$name] == "SOUR")) {
        $gedcom = find_gedcom_record($var);
        if (empty($gedcom)) {
            $action = "setup";
        }
        if ($type[$name] == "FAM") {
            if (preg_match("/0 @.*@ INDI/", $gedcom) > 0) {
                $fams = find_sfamily_ids($var);
                if (!empty($fams[0])) {
                    $gedcom = find_family_record($fams[0]);
                    if (!empty($gedcom)) {
                        $vars[$name] = $fams[0];
                    } else {
                        $action = "setup";
                    }
                }
            }
Пример #10
0
 /**
  * get a singleton instance of this client
  * @return ServiceClient
  */
 static function &getInstance($id)
 {
     global $PGV_SERVERS, $SERVER_URL, $GEDCOM;
     if (isset($PGV_SERVERS[$id])) {
         return $PGV_SERVERS[$id];
     }
     $gedrec = find_gedcom_record($id);
     if (empty($gedrec)) {
         $gedrec = find_updated_record($id);
     }
     if (!empty($gedrec)) {
         $url = get_gedcom_value("URL", 1, $gedrec);
         $gedfile = get_gedcom_value("_DBID", 1, $gedrec);
         if (empty($url) && empty($gedfile)) {
             return null;
         }
         if (!empty($url) && strtolower($url) != strtolower($SERVER_URL)) {
             $server = new ServiceClient($gedrec);
         } else {
             include_once 'includes/classes/class_localclient.php';
             $server = new LocalClient($gedrec);
         }
         $PGV_SERVERS[$id] = $server;
         return $server;
     }
     return null;
 }
Пример #11
0
    function print_random_media($block = true, $config = "", $side, $index)
    {
        global $pgv_lang, $foundlist, $MULTI_MEDIA, $TEXT_DIRECTION, $PGV_IMAGE_DIR, $PGV_IMAGES;
        global $MEDIA_EXTERNAL, $MEDIA_DIRECTORY, $SHOW_SOURCES;
        global $MEDIATYPE, $THUMBNAIL_WIDTH, $USE_MEDIA_VIEWER;
        global $PGV_BLOCKS, $ctype, $action;
        global $PGV_IMAGE_DIR, $PGV_IMAGES;
        if (!$MULTI_MEDIA) {
            return;
        }
        if (empty($config)) {
            $config = $PGV_BLOCKS["print_random_media"]["config"];
        }
        if (isset($config["filter"])) {
            $filter = $config["filter"];
        } else {
            $filter = "all";
        }
        if (!isset($config['controls'])) {
            $config['controls'] = "yes";
        }
        if (!isset($config['start'])) {
            $config['start'] = "no";
        }
        $medialist = array();
        $foundlist = array();
        $medialist = get_medialist(false, '', true, true);
        $ct = count($medialist);
        if ($ct > 0) {
            $i = 0;
            $disp = false;
            //-- try up to 40 times to get a media to display
            while ($i < 40) {
                $error = false;
                $value = array_rand($medialist);
                if (PGV_DEBUG) {
                    print "<br />";
                    print_r($medialist[$value]);
                    print "<br />";
                    print "Trying " . $medialist[$value]["XREF"] . "<br />";
                }
                $links = $medialist[$value]["LINKS"];
                $disp = $medialist[$value]["EXISTS"] > 0 && $medialist[$value]["LINKED"] && $medialist[$value]["CHANGE"] != "delete";
                if (PGV_DEBUG && !$disp && !$error) {
                    $error = true;
                    print "<span class=\"error\">" . $medialist[$value]["XREF"] . " File does not exist, or is not linked to anyone, or is marked for deletion.</span><br />";
                }
                $disp &= displayDetailsById($medialist[$value]["XREF"], "OBJE");
                $disp &= !FactViewRestricted($medialist[$value]["XREF"], $medialist[$value]["GEDCOM"]);
                if (PGV_DEBUG && !$disp && !$error) {
                    $error = true;
                    print "<span class=\"error\">" . $medialist[$value]["XREF"] . " Failed to pass privacy</span><br />";
                }
                $isExternal = isFileExternal($medialist[$value]["FILE"]);
                if ($block && !$isExternal) {
                    $disp &= $medialist[$value]["THUMBEXISTS"] > 0;
                }
                if (PGV_DEBUG && !$disp && !$error) {
                    $error = true;
                    print "<span class=\"error\">" . $medialist[$value]["XREF"] . " thumbnail file could not be found</span><br />";
                }
                // Filter according to format and type  (Default: unless configured otherwise, don't filter)
                if (!empty($medialist[$value]["FORM"]) && isset($config["filter_" . $medialist[$value]["FORM"]]) && $config["filter_" . $medialist[$value]["FORM"]] != "yes") {
                    $disp = false;
                }
                if (!empty($medialist[$value]["TYPE"]) && isset($config["filter_" . $medialist[$value]["TYPE"]]) && $config["filter_" . $medialist[$value]["TYPE"]] != "yes") {
                    $disp = false;
                }
                if (PGV_DEBUG && !$disp && !$error) {
                    $error = true;
                    print "<span class=\"error\">" . $medialist[$value]["XREF"] . " failed Format or Type filters</span><br />";
                }
                if ($disp && count($links) != 0) {
                    /** link privacy allready checked in displayDetailsById
                    				foreach($links as $key=>$type) {
                    					$gedrec = find_gedcom_record($key, PGV_GED_ID);
                    					$disp &= !empty($gedrec);
                    					//-- source privacy is now available through the display details by id method
                    					// $disp &= $type!="SOUR";
                    					$disp &= displayDetailsById($key, $type);
                    				}
                    				if (PGV_DEBUG && !$disp && !$error) {$error = true; print "<span class=\"error\">".$medialist[$value]["XREF"]." failed link privacy</span><br />";}
                    				*/
                    if ($disp && $filter != "all") {
                        // Apply filter criteria
                        $ct = preg_match("/0\\s(@.*@)\\sOBJE/", $medialist[$value]["GEDCOM"], $match);
                        $objectID = $match[1];
                        //-- we could probably use the database for this filter
                        foreach ($links as $key => $type) {
                            $gedrec = find_gedcom_record($key, PGV_GED_ID);
                            $ct2 = preg_match("/(\\d)\\sOBJE\\s{$objectID}/", $gedrec, $match2);
                            if ($ct2 > 0) {
                                $objectRefLevel = $match2[1];
                                if ($filter == "indi" && $objectRefLevel != "1") {
                                    $disp = false;
                                }
                                if ($filter == "event" && $objectRefLevel == "1") {
                                    $disp = false;
                                }
                                if (PGV_DEBUG && !$disp && !$error) {
                                    $error = true;
                                    print "<span class=\"error\">" . $medialist[$value]["XREF"] . " failed to pass config filter</span><br />";
                                }
                            } else {
                                $disp = false;
                            }
                        }
                    }
                }
                //-- leave the loop if we find an image that works
                if ($disp) {
                    break;
                } else {
                    if (PGV_DEBUG) {
                        print "<span class=\"error\">" . $medialist[$value]["XREF"] . " Will not be shown</span><br />";
                    }
                    unset($medialist[$value]);
                }
                //-- if there are no more media items, then try to get some more
                if (count($medialist) == 0) {
                    $medialist = get_medialist(false, '', true, true);
                }
                $i++;
            }
            if (!$disp) {
                return false;
            }
            $content = "";
            $id = "";
            $id = "random_picture{$index}";
            $title = print_help_link("index_media_help", "qm", "random_picture", false, true);
            if ($PGV_BLOCKS["print_random_media"]["canconfig"]) {
                if ($ctype == "gedcom" && PGV_USER_GEDCOM_ADMIN || $ctype == "user" && PGV_USER_ID) {
                    if ($ctype == "gedcom") {
                        $name = PGV_GEDCOM;
                    } else {
                        $name = PGV_USER_NAME;
                    }
                    $title .= "<a href=\"javascript: configure block\" onclick=\"window.open('" . encode_url("index_edit.php?name={$name}&ctype={$ctype}&action=configure&side={$side}&index={$index}") . "', '_blank', 'top=50,left=50,width=600,height=350,scrollbars=1,resizable=1'); return false;\">";
                    $title .= "<img class=\"adminicon\" src=\"{$PGV_IMAGE_DIR}/{$PGV_IMAGES['admin']['small']}\" width=\"15\" height=\"15\" border=\"0\" alt=\"{$pgv_lang['config_block']}\" /></a>";
                }
            }
            $title .= $pgv_lang["random_picture"];
            $content = "<div id=\"random_picture_container{$index}\">";
            if ($config['controls'] == 'yes') {
                if ($config['start'] == 'yes' || isset($_COOKIE['rmblockplay']) && $_COOKIE['rmblockplay'] == 'true') {
                    $image = "stop";
                } else {
                    $image = "rarrow";
                }
                $linkNextImage = "<a href=\"javascript: " . $pgv_lang["next_image"] . "\" onclick=\"return ajaxBlock('random_picture{$index}', 'print_random_media', '{$side}', {$index}, '{$ctype}', true);\"><img src=\"{$PGV_IMAGE_DIR}/{$PGV_IMAGES['rdarrow']['other']}\" border=\"0\" alt=\"{$pgv_lang['next_image']}\" title=\"{$pgv_lang['next_image']}\" /></a>";
                $content .= "<div class=\"center\" id=\"random_picture_controls{$index}\"><br />";
                if ($TEXT_DIRECTION == "rtl") {
                    $content .= $linkNextImage;
                }
                $content .= "<a href=\"javascript: " . $pgv_lang["play"] . "/" . $pgv_lang["stop"] . "\" onclick=\"togglePlay(); return false;\">";
                if (isset($PGV_IMAGES[$image]['other'])) {
                    $content .= "<img id=\"play_stop\" src=\"{$PGV_IMAGE_DIR}/{$PGV_IMAGES[$image]['other']}\" border=\"0\" alt=\"{$pgv_lang['play']}/{$pgv_lang['stop']}\" title=\"{$pgv_lang['play']}/{$pgv_lang['stop']}\" />";
                } else {
                    $content .= $pgv_lang["play"] . "/" . $pgv_lang["stop"];
                }
                $content .= "</a>";
                if ($TEXT_DIRECTION == "ltr") {
                    $content .= $linkNextImage;
                }
                $content .= '
					</div>
					<script language="JavaScript" type="text/javascript">
					<!--
						var play = false;
						function togglePlay() {
							if (play) {
								play = false;
								imgid = document.getElementById("play_stop");
								imgid.src = \'' . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["rarrow"]['other'] . '\';
							}
							else {
								play = true;
								playSlideShow();
								imgid = document.getElementById("play_stop");
								imgid.src = \'' . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["stop"]['other'] . '\';
							}
						}

						function playSlideShow() {
							if (play) {
								ajaxBlock(\'random_picture' . $index . '\', \'print_random_media\', \'' . $side . '\', ' . $index . ', \'' . $ctype . '\', false);
								window.setTimeout(\'playSlideShow()\', 6000);
							}
						}
					//-->
					</script>';
            }
            if ($config['start'] == 'yes') {
                $content .= '
					<script language="JavaScript" type="text/javascript">
					<!--
						play = true;
						imgid = document.getElementById("play_stop");
						imgid.src = \'' . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["stop"]['other'] . '\';
						window.setTimeout("playSlideShow()", 6000);
					//-->
					</script>';
            }
            $content .= "<div class=\"center\" id=\"random_picture_content{$index}\">";
            $imgsize = findImageSize($medialist[$value]["FILE"]);
            $imgwidth = $imgsize[0] + 40;
            $imgheight = $imgsize[1] + 150;
            $content .= "<table id=\"random_picture_box\" width=\"100%\"><tr><td valign=\"top\"";
            if ($block) {
                $content .= " align=\"center\" class=\"details1\"";
            } else {
                $content .= " class=\"details2\"";
            }
            $mediaid = $medialist[$value]["XREF"];
            //LBox --------  change for Lightbox Album --------------------------------------------
            ?>
<script language="JavaScript" type="text/javascript">
<!--
function openPic(filename, width, height) {
		height=height+50;
		screenW = screen.width;
	 	screenH = screen.height;
	 	if (width>screenW-100) width=screenW-100;
	 	if (height>screenH-110) height=screenH-120;
		if ((filename.search(/\.je?pg$/gi)!=-1)||(filename.search(/\.gif$/gi)!=-1)||(filename.search(/\.png$/gi)!=-1)||(filename.search(/\.bmp$/gi)!=-1))
			win02 = window.open('imageview.php?filename='+filename,'win02','top=50,left=150,height='+height+',width='+width+',scrollbars=1,resizable=1');
			// win03.resizeTo(winWidth 2,winHeight 30);
		else window.open(unescape(filename),'win02','top=50,left=150,height='+height+',width='+width+',scrollbars=1,resizable=1');
		win02.focus();
	}
-->
</script><?php 
            if (PGV_USE_LIGHTBOX) {
                // $content .= " ><a href=\"javascript:;\" onclick=\"return openPic('".$medialist[$value]["FILE"]."', $imgwidth, $imgheight);\">";
                // $content .= " ><a href=\"javascript:;\" onclick=\"return openImage('".$medialist[$value]["FILE"]."', $imgwidth, $imgheight);\">";
                // $content .= "><a href=\"" . $medialist[$value]["FILE"] . "\" rel=\"clearbox[general_4]\" title=\"" . $mediaid . "\">" . "\n";
                $content .= " ><a href=\"mediaviewer.php?mid=" . $mediaid . "\">";
            } else {
                // ---------------------------------------------------------------------------------------------
                if ($USE_MEDIA_VIEWER) {
                    $content .= " ><a href=\"mediaviewer.php?mid=" . $mediaid . "\">";
                } else {
                    $content .= " ><a href=\"javascript:;\" onclick=\"return openImage('" . $medialist[$value]["FILE"] . "', {$imgwidth}, {$imgheight});\">";
                }
            }
            $mediaTitle = "";
            if (!empty($medialist[$value]["TITL"])) {
                $mediaTitle = PrintReady($medialist[$value]["TITL"]);
            } else {
                $mediaTitle = basename($medialist[$value]["FILE"]);
            }
            if ($block) {
                $content .= "<img src=\"" . $medialist[$value]["THUMB"] . "\" border=\"0\" class=\"thumbnail\"";
                if ($isExternal) {
                    $content .= " width=\"" . $THUMBNAIL_WIDTH . "\"";
                }
            } else {
                $content .= "<img src=\"" . $medialist[$value]["FILE"] . "\" border=\"0\" class=\"thumbnail\" ";
                $imgsize = findImageSize($medialist[$value]["FILE"]);
                if ($imgsize[0] > 175) {
                    $content .= "width=\"175\" ";
                }
            }
            $content .= " alt=\"{$mediaTitle}\" title=\"{$mediaTitle}\" />";
            $content .= "</a>";
            if ($block) {
                $content .= "<br />";
            } else {
                $content .= "</td><td class=\"details2\">";
            }
            $content .= "<a href=\"mediaviewer.php?mid=" . $mediaid . "\">";
            $content .= "<b>" . $mediaTitle . "</b>";
            $content .= "</a><br />";
            ob_start();
            PrintMediaLinks($medialist[$value]["LINKS"], "normal");
            $content .= ob_get_clean();
            $content .= "<br /><div class=\"indent" . ($TEXT_DIRECTION == "rtl" ? "_rtl" : "") . "\">";
            $content .= print_fact_notes($medialist[$value]["GEDCOM"], "1", false, true);
            $content .= "</div>";
            $content .= "</td></tr></table>";
            $content .= "</div>";
            // random_picture_content
            $content .= "</div>";
            // random_picture_container
            global $THEME_DIR;
            require $THEME_DIR . 'templates/block_main_temp.php';
        }
    }
Пример #12
0
 /**
  * Creates a GrampsXML for a record, if that record exists in the given GEDCOM record
  * @param $fid - The id of the record
  * @return GrampsXML for the recrord
  */
 function create_record($fid)
 {
     $gedrec = find_gedcom_record($fid);
     //0 @I1@ INDI - person
     //0 @F1@ FAM - family
     //0 @S1@ SOUR - source
     //0 @O1@ OBJE - object
     //0 @R1@ REPO - reposotory
     //return $gedrec;
     $ct = preg_match("/0 @.*@ (.*)/", $gedrec, $match);
     if ($ct > 0) {
         $type = trim($match[1]);
         // $type;
         if ($type == 'INDI') {
             return $this->create_person($gedrec, $fid);
         }
         if ($type == 'FAM') {
             return $this->create_family($gedrec, $fid);
         }
         if ($type == 'SOUR') {
             return $this->create_source($gedrec, $fid);
         }
         if ($type == 'OBJE') {
             return $this->create_media($gedrec, $fid);
         }
     }
 }
Пример #13
0
 foreach ($person_facts as $id => $value) {
     foreach ($value as $tag => $value1) {
         foreach ($value1 as $key => $setting) {
             if (isset($v_person_facts_del[$id][$tag][$key]) || $id == $v_new_person_facts_access_ID && $tag == $v_new_person_facts_abbr && $key == $v_new_person_facts_choice) {
                 continue;
             }
             if (isset($v_person_facts[$id][$tag][$key])) {
                 $person_privacy_text .= "\$person_facts['{$id}']['{$tag}']['{$key}'] = " . $v_person_facts[$id][$tag][$key] . ";\n";
             } else {
                 $person_privacy_text .= "\$person_facts['{$id}']['{$tag}']['{$key}'] = " . $PRIVACY_CONSTANTS[$setting] . ";\n";
             }
         }
     }
 }
 if ($v_new_person_facts_access_ID && $v_new_person_facts_abbr && $v_new_global_facts_choice && $v_new_global_facts_access_option) {
     $gedobj = new GedcomRecord(find_gedcom_record($v_new_person_facts_access_ID, PGV_GED_ID));
     $v_new_person_facts_access_ID = $gedobj->getXref();
     if ($v_new_person_facts_access_ID) {
         $person_privacy_text .= "\$person_facts['{$v_new_person_facts_access_ID}']['{$v_new_person_facts_abbr}']['{$v_new_person_facts_choice}'] = " . $v_new_person_facts_access_option . ";\n";
     }
 }
 $configtext = $configtext_beg . $person_privacy_text . $configtext_end;
 $PRIVACY_MODULE = $INDEX_DIRECTORY . $GEDCOM . "_priv.php";
 $fp = @fopen($PRIVACY_MODULE, "wb");
 if (!$fp) {
     global $whichFile;
     $whichFile = $PRIVACY_MODULE;
     print "<span class=\"error\">" . print_text("gedcom_config_write_error", 0, 1) . "<br /></span>\n";
 } else {
     fwrite($fp, $configtext);
     fclose($fp);
Пример #14
0
/**
* Accpet changed gedcom record into database
*
* This function gets an updated record from the gedcom file and replaces it in the database
* @author John Finlay
* @param string $cid The change id of the record to accept
*/
function accept_changes($cid)
{
    global $pgv_changes, $GEDCOM, $TBLPREFIX, $FILE, $GEDCOMS;
    global $INDEX_DIRECTORY, $SYNC_GEDCOM_FILE, $fcontents, $manual_save;
    if (isset($pgv_changes[$cid])) {
        $changes = $pgv_changes[$cid];
        $change = $changes[count($changes) - 1];
        if ($GEDCOM != $change["gedcom"]) {
            $GEDCOM = $change["gedcom"];
        }
        $FILE = $GEDCOM;
        $gid = $change["gid"];
        $gedrec = $change["undo"];
        if (empty($gedrec)) {
            $gedrec = find_gedcom_record($gid);
        }
        update_record($gedrec, $change["type"] == "delete");
        //-- write the changes back to the gedcom file
        if ($SYNC_GEDCOM_FILE) {
            // TODO: We merge CONC lines on import, so need to add them back on export
            if (!isset($manual_save) || $manual_save == false) {
                //-- only allow one thread to accept changes at a time
                //				$mutex = new Mutex("accept_changes");
                //				$mutex->Wait();
            }
            if (empty($fcontents)) {
                read_gedcom_file();
            }
            if ($change["type"] == "delete") {
                $pos1 = find_newline_string($fcontents, "0 @{$gid}@");
                if ($pos1 !== false) {
                    $pos2 = find_newline_string($fcontents, "0", $pos1 + 5);
                    if ($pos2 === false) {
                        $fcontents = substr($fcontents, 0, $pos1) . '0 TRLR' . PGV_EOL;
                        AddToLog("Corruption found in GEDCOM {$GEDCOM} Attempted to correct");
                    } else {
                        $fcontents = substr($fcontents, 0, $pos1) . substr($fcontents, $pos2);
                    }
                } else {
                    AddToLog("Corruption found in GEDCOM {$GEDCOM} Attempted to correct.  Deleted gedcom record {$gid} was not found in the gedcom file.");
                }
            } elseif ($change["type"] == "append") {
                $pos1 = find_newline_string($fcontents, "0 TRLR");
                $fcontents = substr($fcontents, 0, $pos1) . reformat_record_export($gedrec) . '0 TRLR' . PGV_EOL;
            } elseif ($change["type"] == "replace") {
                $pos1 = find_newline_string($fcontents, "0 @{$gid}@");
                if ($pos1 !== false) {
                    $pos2 = find_newline_string($fcontents, "0", $pos1 + 5);
                    if ($pos2 === false) {
                        $fcontents = substr($fcontents, 0, $pos1) . '0 TRLR' . PGV_EOL;
                        AddToLog("Corruption found in GEDCOM {$GEDCOM} Attempted to correct");
                    } else {
                        $fcontents = substr($fcontents, 0, $pos1) . reformat_record_export($gedrec) . substr($fcontents, $pos2);
                    }
                } else {
                    //-- attempted to replace a record that doesn't exist
                    AddToLog("Corruption found in GEDCOM {$GEDCOM} Attempted to correct.  Replaced gedcom record {$gid} was not found in the gedcom file.");
                    $pos1 = find_newline_string($fcontents, "0 TRLR");
                    $fcontents = substr($fcontents, 0, $pos1) . reformat_record_export($gedrec) . '0 TRLR' . PGV_EOL;
                    AddToLog("Gedcom record {$gid} was appended back to the GEDCOM file.");
                }
            }
            if (!isset($manual_save) || $manual_save == false) {
                write_file();
                //				$mutex->Release();
            }
        }
        if ($change["type"] != "delete") {
            //-- synchronize the gedcom record with any user account
            $username = get_user_from_gedcom_xref($GEDCOM, $gid);
            if ($username && get_user_setting($username, 'sync_gedcom') == 'Y') {
                $firstname = get_gedcom_value("GIVN", 2, $gedrec);
                $lastname = get_gedcom_value("SURN", 2, $gedrec);
                if (empty($lastname)) {
                    $fullname = get_gedcom_value("NAME", 1, $gedrec, "", false);
                    $ct = preg_match("~(.*)/(.*)/~", $fullname, $match);
                    if ($ct > 0) {
                        $firstname = $match[1];
                        $lastname = $match[2];
                    } else {
                        $firstname = $fullname;
                    }
                }
                //-- SEE [ 1753047 ] Email/sync with account
                $email = get_gedcom_value("EMAIL", 1, $gedrec);
                if (empty($email)) {
                    $email = get_gedcom_value("_EMAIL", 1, $gedrec);
                }
                if (!empty($email)) {
                    set_user_setting($username, 'email', $email);
                }
                set_user_setting($username, 'firstname', $firstname);
                set_user_setting($username, 'lastname', $lastname);
            }
        }
        unset($pgv_changes[$cid]);
        if (!isset($manual_save) || $manual_save == false) {
            write_changes();
        }
        $logline = AddToLog("Accepted change {$cid} " . $change["type"] . " into database");
        check_in($logline, $GEDCOM, dirname($GEDCOMS[$GEDCOM]['path']));
        if (isset($change["linkpid"])) {
            accept_changes($change["linkpid"] . "_" . $GEDCOM);
        }
        return true;
    }
    return false;
}
Пример #15
0
function print_user_favorites($block = true, $config = "", $side, $index)
{
    global $pgv_lang, $PGV_IMAGE_DIR, $PGV_IMAGES, $GEDCOM, $TEXT_DIRECTION, $INDEX_DIRECTORY, $MEDIA_DIRECTORY, $MULTI_MEDIA, $MEDIA_DIRECTORY_LEVELS, $ctype;
    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_USER_NAME);
    if (!is_array($userfavs)) {
        $userfavs = array();
    }
    $id = "user_favorites";
    $title = print_help_link("mygedview_favorites_help", "qm", "", false, true);
    $title .= $pgv_lang["my_favorites"] . "&nbsp;&nbsp;";
    if ($TEXT_DIRECTION == "rtl") {
        $title .= getRLM();
    }
    $title .= "(" . count($userfavs) . ")";
    if ($TEXT_DIRECTION == "rtl") {
        $title .= getRLM();
    }
    if ($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) {
        $content .= print_text("no_favorites", 0, 1);
    } else {
        $mygedcom = $GEDCOM;
        $current_gedcom = $GEDCOM;
        $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 />";
            $current_gedcom = $GEDCOM;
            $GEDCOM = $favorite["file"];
            $content .= "<tr><td>";
            if ($favorite["type"] == "URL") {
                $content .= "<div id=\"boxurl" . $key . ".0\" class=\"person_box\">";
                if ($ctype == "user" || PGV_USER_IS_ADMIN) {
                    $content .= $removeFavourite;
                }
                $content .= "<a href=\"" . $favorite["url"] . "\">" . PrintReady($favorite["title"]) . "</a>";
                $content .= "<br />" . PrintReady($favorite["note"]);
            } else {
                require $INDEX_DIRECTORY . $GEDCOM . '_conf.php';
                $indirec = find_gedcom_record($favorite["gid"], PGV_GED_ID);
                if ($favorite["type"] == "INDI") {
                    $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 .= "\">";
                    if ($ctype == "user" || PGV_USER_IS_ADMIN) {
                        $content .= $removeFavourite;
                    }
                    ob_start();
                    print_pedigree_person($favorite["gid"], $style, 1, $key);
                    $content .= ob_get_clean();
                    $content .= PrintReady($favorite["note"]);
                } else {
                    $record = GedcomRecord::getInstance($favorite['gid']);
                    $content .= "<div id=\"box" . $favorite["gid"] . ".0\" class=\"person_box\">";
                    if ($ctype == "user" || PGV_USER_IS_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>";
            $GEDCOM = $mygedcom;
            require $INDEX_DIRECTORY . $GEDCOM . '_conf.php';
        }
        $content .= "</table>";
    }
    $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_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>";
    $content .= "<br /><div id=\"add_user_fav\" style=\"display: none;\">";
    $content .= "<form name=\"addufavform\" method=\"post\" action=\"index.php\">";
    $content .= "<input type=\"hidden\" name=\"action\" value=\"addfav\" />";
    $content .= "<input type=\"hidden\" name=\"ctype\" value=\"{$ctype}\" />";
    $content .= "<input type=\"hidden\" name=\"favtype\" value=\"user\" />";
    $content .= "<input type=\"hidden\" name=\"ged\" value=\"{$GEDCOM}\" />";
    $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 .= "<br />" . $pgv_lang["add_fav_or_enter_url"];
    $content .= "<table><tr><td>" . $pgv_lang["url"] . "</td><td><input type=\"text\" name=\"url\" size=\"40\" value=\"\" /></td></tr>";
    $content .= "<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 .= $pgv_lang["add_fav_enter_note"];
    $content .= "<br /><textarea name=\"favnote\" rows=\"6\" cols=\"50\"></textarea>";
    $content .= "</td></tr></table>";
    $content .= "<br /><input type=\"submit\" value=\"" . $pgv_lang["add"] . "\" style=\"font-size: 8pt; \" />";
    $content .= "</form></div>";
    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;
}
Пример #16
0
    echo "<span class=\"error\">", $pgv_lang["access_denied"], "</span>";
    print_footer();
    exit;
}
if ($action != "choose") {
    if ($gid1 == $gid2 && $GEDCOM == $ged2) {
        $action = "choose";
        echo "<span class=\"error\">", $pgv_lang["same_ids"], "</span>\n";
    } else {
        if (!isset($pgv_changes[$gid1 . "_" . PGV_GEDCOM])) {
            $gedrec1 = find_gedcom_record($gid1, PGV_GED_ID);
        } else {
            $gedrec1 = find_updated_record($gid1, get_id_from_gedcom($GEDCOM));
        }
        if (!isset($pgv_changes[$gid2 . "_" . $ged2])) {
            $gedrec2 = find_gedcom_record($gid2, get_id_from_gedcom($ged2));
        } else {
            $gedrec2 = find_updated_record($gid2, get_id_from_gedcom($ged2));
        }
        // Fetch the original XREF - may differ in case from the supplied value
        $tmp = new Person($gedrec1);
        $gid1 = $tmp->getXref();
        $tmp = new Person($gedrec2);
        $gid2 = $tmp->getXref();
        if (empty($gedrec1)) {
            echo '<span class="error">', $pgv_lang['unable_to_find_record'], ':</span> ', $gid1, ', ', $ged;
            $action = "choose";
        } elseif (empty($gedrec2)) {
            echo '<span class="error">', $pgv_lang['unable_to_find_record'], ':</span> ', $gid2, ', ', $ged2;
            $action = "choose";
        } else {
Пример #17
0
 /**
  * Inserts a clipping into the clipping cart
  *
  * @param
  */
 function add_clipping($clipping)
 {
     global $cart, $pgv_lang, $SHOW_SOURCES, $MULTI_MEDIA, $GEDCOM;
     if ($clipping['id'] == false || $clipping['id'] == "") {
         return false;
     }
     if (!id_in_cart($clipping['id'])) {
         $clipping['gedcom'] = $GEDCOM;
         if ($clipping['type'] == "indi") {
             if (displayDetailsById($clipping['id']) || showLivingNameById($clipping['id'])) {
                 $cart[] = $clipping;
                 $this->addCount++;
             } else {
                 $this->privCount++;
                 return false;
             }
         } else {
             if ($clipping['type'] == "fam") {
                 $parents = find_parents($clipping['id']);
                 if ((displayDetailsById($parents['HUSB']) || showLivingNameById($parents['HUSB'])) && (displayDetailsById($parents['WIFE']) || showLivingNameById($parents['WIFE']))) {
                     $cart[] = $clipping;
                     $this->addCount++;
                 } else {
                     $this->privCount++;
                     return false;
                 }
             } else {
                 if (displayDetailsById($clipping['id'], strtoupper($clipping['type']))) {
                     $cart[] = $clipping;
                     $this->addCount++;
                 } else {
                     $this->privCount++;
                     return false;
                 }
             }
         }
         //-- look in the gedcom record for any linked SOUR, NOTE, or OBJE and also add them to the
         //- clippings cart
         $gedrec = find_gedcom_record($clipping['id']);
         if ($SHOW_SOURCES >= PGV_USER_ACCESS_LEVEL) {
             $st = preg_match_all("/\\d SOUR @(.*)@/", $gedrec, $match, PREG_SET_ORDER);
             for ($i = 0; $i < $st; $i++) {
                 // add SOUR
                 $clipping = array();
                 $clipping['type'] = "source";
                 $clipping['id'] = $match[$i][1];
                 $clipping['gedcom'] = $GEDCOM;
                 $this->add_clipping($clipping);
                 // add REPO
                 $sourec = find_gedcom_record($match[$i][1]);
                 $rt = preg_match_all("/\\d REPO @(.*)@/", $sourec, $rmatch, PREG_SET_ORDER);
                 for ($j = 0; $j < $rt; $j++) {
                     $clipping = array();
                     $clipping['type'] = "repository";
                     $clipping['id'] = $rmatch[$j][1];
                     $clipping['gedcom'] = $GEDCOM;
                     $this->add_clipping($clipping);
                 }
             }
         }
         $nt = preg_match_all("/\\d NOTE @(.*)@/", $gedrec, $match, PREG_SET_ORDER);
         for ($i = 0; $i < $nt; $i++) {
             $clipping = array();
             $clipping['type'] = "note";
             $clipping['id'] = $match[$i][1];
             $clipping['gedcom'] = $GEDCOM;
             $this->add_clipping($clipping);
         }
         if ($MULTI_MEDIA) {
             $nt = preg_match_all("/\\d OBJE @(.*)@/", $gedrec, $match, PREG_SET_ORDER);
             for ($i = 0; $i < $nt; $i++) {
                 $clipping = array();
                 $clipping['type'] = "obje";
                 $clipping['id'] = $match[$i][1];
                 $clipping['gedcom'] = $GEDCOM;
                 $this->add_clipping($clipping);
             }
         }
     }
     return true;
 }
Пример #18
0
    print_footer();
    exit;
}
if ($action != "choose") {
    if ($gid1 == $gid2 && $GEDCOM == $ged2) {
        $action = "choose";
        print "<span class=\"error\">" . $pgv_lang["same_ids"] . "</span>\n";
    } else {
        if (!isset($pgv_changes[$gid1 . "_" . $GEDCOM])) {
            $gedrec1 = find_gedcom_record($gid1);
        } else {
            $gedrec1 = find_updated_record($gid1);
        }
        $GEDCOM = $ged2;
        if (!isset($pgv_changes[$gid2 . "_" . $ged2])) {
            $gedrec2 = find_gedcom_record($gid2);
        } else {
            $gedrec2 = find_updated_record($gid2);
        }
        $GEDCOM = $ged;
        // Fetch the original XREF - may differ in case from the supplied value
        $tmp = new Person($gedrec1);
        $gid1 = $tmp->getXref();
        $tmp = new Person($gedrec2);
        $gid2 = $tmp->getXref();
        if (empty($gedrec1)) {
            echo '<span class="error">', $pgv_lang['unable_to_find_record'], ':</span> ', $gid1, ', ', $ged;
            $action = "choose";
        } elseif (empty($gedrec2)) {
            echo '<span class="error">', $pgv_lang['unable_to_find_record'], ':</span> ', $gid2, ', ', $ged2;
            $action = "choose";
Пример #19
0
             unset($GLOBALS["oldThumbFolder"]);
             unset($GLOBALS["newThumbFolder"]);
         }
     }
 }
 if ($finalResult) {
     $_SESSION["upload_folder"] = $folder;
     // store standard media folder in session
     // Insert the 1 FILE xxx record into the arrays used by function handle_updates()
     $glevels = array_merge(array("1"), $glevels);
     $tag = array_merge(array("FILE"), $tag);
     $islink = array_merge(array(0), $islink);
     $text = array_merge(array($folder . $filename), $text);
     if (!empty($pid)) {
         if (!isset($pgv_changes[$pid . "_" . $GEDCOM])) {
             $gedrec = find_gedcom_record($pid);
         } else {
             $gedrec = find_updated_record($pid);
         }
     }
     $newrec = "0 @{$pid}@ OBJE\n";
     $newrec = handle_updates($newrec);
     if (!$update_CHAN) {
         $newrec .= get_sub_record(1, "1 CHAN", $gedrec);
     }
     //print("[".$newrec."]");
     //-- look for the old record media in the file
     //-- if the old media record does not exist that means it was
     //-- generated at import and we need to append it
     if (replace_gedrec($pid, $newrec, $update_CHAN)) {
         AddToChangeLog("Media ID " . $pid . " successfully updated.");
Пример #20
0
/**
* @todo add info
* @param array $attrs an array of key value pairs for the attributes
*/
function PGVRImageSHandler($attrs)
{
    global $gedrec, $pgvreport, $MEDIA_DIRECTORY, $PGVReportRoot;
    // mixed Position the top corner of this box on the page. the default is the current position
    $top = '.';
    if (isset($attrs['top'])) {
        if ($attrs['top'] === '0') {
            $top = 0;
        } else {
            if ($attrs['top'] === '.') {
                $top = '.';
            } else {
                if (!empty($attrs['top'])) {
                    $top = (int) $attrs['top'];
                }
            }
        }
    }
    // mixed Position the left corner of this box on the page. the default is the current position
    $left = '.';
    if (isset($attrs['left'])) {
        if ($attrs['left'] === '0') {
            $left = 0;
        } else {
            if ($attrs['left'] === '.') {
                $left = '.';
            } else {
                if (!empty($attrs['left'])) {
                    $left = (int) $attrs['left'];
                }
            }
        }
    }
    // string Align the image in left, center, right
    $align = '';
    if (!empty($attrs["align"])) {
        $align = $attrs["align"];
    }
    // string Next Line should be T:next to the image, N:next line
    $ln = 'T';
    if (!empty($attrs["ln"])) {
        $ln = $attrs["ln"];
    }
    $width = 0;
    $height = 0;
    if (!empty($attrs["width"])) {
        $width = (int) $attrs["width"];
    }
    if (!empty($attrs["height"])) {
        $height = (int) $attrs["height"];
    }
    $file = "";
    if (!empty($attrs["file"])) {
        $file = $attrs["file"];
    }
    if ($file == "@FILE") {
        $match = array();
        $ct = preg_match("/\\d OBJE @(.+)@/", $gedrec, $match);
        if ($ct > 0) {
            $orec = find_gedcom_record($match[1]);
        } else {
            $orec = $gedrec;
        }
        if (!empty($orec)) {
            $fullpath = extract_fullpath($orec);
            $filename = "";
            $filename = extract_filename($fullpath);
            $filename = $MEDIA_DIRECTORY . $filename;
            $filename = trim($filename);
            if (!empty($filename)) {
                if (preg_match("/(jpg)|(jpeg)|(png)\$/i", $filename) > 0) {
                    if (file_exists($filename)) {
                        $size = findImageSize($filename);
                        if ($width > 0 and $height == 0) {
                            $perc = $width / $size[0];
                            $height = round($size[1] * $perc);
                        } else {
                            if ($height > 0 and $width == 0) {
                                $perc = $height / $size[1];
                                $width = round($size[0] * $perc);
                            } else {
                                $width = $size[0];
                                $height = $size[1];
                            }
                        }
                        $image = $PGVReportRoot->createImage($filename, $left, $top, $width, $height, $align, $ln);
                        $pgvreport->addElement($image);
                    }
                }
            }
        }
    } else {
        $filename = $file;
        if (preg_match("/(jpg)|(jpeg)|(png)|(gif)\$/i", $filename) > 0) {
            if (file_exists($filename)) {
                $size = findImageSize($filename);
                if ($width > 0 && $height == 0) {
                    $perc = $width / $size[0];
                    $height = round($size[1] * $perc);
                } else {
                    if ($height > 0 && $width == 0) {
                        $perc = $height / $size[1];
                        $width = round($size[0] * $perc);
                    } else {
                        $width = $size[0];
                        $height = $size[1];
                    }
                }
                $image = $PGVReportRoot->createImage($filename, $left, $top, $width, $height, $align, $ln);
                $pgvreport->addElement($image);
            }
        }
    }
}