示例#1
0
 /**
  * Each object type may have its own special rules, and re-implement this function.
  *
  * @param int $access_level
  *
  * @return bool
  */
 protected function canShowByType($access_level)
 {
     // Hide notes if they are attached to private records
     $linked_ids = Database::prepare("SELECT l_from FROM `##link` WHERE l_to=? AND l_file=?")->execute(array($this->xref, $this->tree->getTreeId()))->fetchOneColumn();
     foreach ($linked_ids as $linked_id) {
         $linked_record = GedcomRecord::getInstance($linked_id, $this->tree);
         if ($linked_record && !$linked_record->canShow($access_level)) {
             return false;
         }
     }
     // Apply default behaviour
     return parent::canShowByType($access_level);
 }
示例#2
0
 /**
  * Create a GedcomRecord object from raw GEDCOM data.
  *
  * @param string      $xref
  * @param string      $gedcom  an empty string for new/pending records
  * @param string|null $pending null for a record with no pending edits,
  *                             empty string for records with pending deletions
  * @param Tree        $tree
  */
 public function __construct($xref, $gedcom, $pending, $tree)
 {
     parent::__construct($xref, $gedcom, $pending, $tree);
     // Fetch family members
     if (preg_match_all('/^1 (?:HUSB|WIFE|CHIL) @(.+)@/m', $gedcom . $pending, $match)) {
         Individual::load($tree, $match[1]);
     }
     if (preg_match('/^1 HUSB @(.+)@/m', $gedcom . $pending, $match)) {
         $this->husb = Individual::getInstance($match[1], $tree);
     }
     if (preg_match('/^1 WIFE @(.+)@/m', $gedcom . $pending, $match)) {
         $this->wife = Individual::getInstance($match[1], $tree);
     }
     // Make sure husb/wife are the right way round.
     if ($this->husb && $this->husb->getSex() === 'F' || $this->wife && $this->wife->getSex() === 'M') {
         list($this->husb, $this->wife) = array($this->wife, $this->husb);
     }
 }
 /**
  * contstructor to create a new ServiceClient object
  * @param string $gedrec the SERV gedcom record
  */
 function ServiceClient($gedrec)
 {
     //parse url
     //crate soap client class
     //authenticate/get/set sid
     parent::GedcomRecord($gedrec);
     //print "creating new service client ".$this->xref;
     //get the url from the gedcom
     $this->url = get_gedcom_value("URL", 1, $gedrec);
     $this->gedfile = get_gedcom_value("_DBID", 1, $gedrec);
     $this->title = get_gedcom_value("TITL", 1, $gedrec);
     $this->username = get_gedcom_value("_USER", 2, $gedrec);
     $this->password = get_gedcom_value("_PASS", 2, $gedrec);
     $this->type = "remote";
     $this->data_type = "GEDCOM";
     if (empty($this->url) && empty($this->gedfile)) {
         return null;
     }
 }
示例#4
0
 /**
  * get the URL to link to this family
  * @string a url that can be used to link to this family
  */
 public function getLinkUrl()
 {
     return parent::_getLinkUrl('family.php?famid=');
 }
示例#5
0
/**
 * Print Review Changes Block
 *
 * Prints a block allowing the user review all changes pending approval
 */
function review_changes_block($block = true, $config = "", $side, $index)
{
    global $pgv_lang, $ctype, $QUERY_STRING, $factarray, $PGV_IMAGE_DIR, $PGV_IMAGES;
    global $pgv_changes, $TEXT_DIRECTION, $SHOW_SOURCES, $PGV_BLOCKS;
    global $PHPGEDVIEW_EMAIL;
    if (empty($config)) {
        $config = $PGV_BLOCKS["review_changes_block"]["config"];
    }
    if ($pgv_changes) {
        //-- if the time difference from the last email is greater than 24 hours then send out another email
        $LAST_CHANGE_EMAIL = get_site_setting('LAST_CHANGE_EMAIL');
        if (time() - $LAST_CHANGE_EMAIL > 60 * 60 * 24 * $config["days"]) {
            $LAST_CHANGE_EMAIL = time();
            set_site_setting('LAST_CHANGE_EMAIL', $LAST_CHANGE_EMAIL);
            write_changes();
            if ($config["sendmail"] == "yes") {
                // Which users have pending changes?
                $users_with_changes = array();
                foreach (get_all_users() as $user_id => $user_name) {
                    foreach (get_all_gedcoms() as $ged_id => $ged_name) {
                        if (exists_pending_change($user_id, $ged_id)) {
                            $users_with_changes[$user_id] = $user_name;
                            break;
                        }
                    }
                }
                foreach ($users_with_changes as $user_id => $user_name) {
                    //-- send message
                    $message = array();
                    $message["to"] = $user_name;
                    $message["from"] = $PHPGEDVIEW_EMAIL;
                    $message["subject"] = $pgv_lang["review_changes_subject"];
                    $message["body"] = $pgv_lang["review_changes_body"];
                    $message["method"] = get_user_setting($user_id, 'contactmethod');
                    $message["url"] = PGV_SCRIPT_NAME . "?" . html_entity_decode($QUERY_STRING);
                    $message["no_from"] = true;
                    addMessage($message);
                }
            }
        }
        if (PGV_USER_CAN_EDIT) {
            $id = "review_changes_block";
            $title = print_help_link("review_changes_help", "qm", "", false, true);
            if ($PGV_BLOCKS["review_changes_block"]["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["review_changes"];
            $content = "";
            if (PGV_USER_CAN_ACCEPT) {
                $content .= "<a href=\"javascript:;\" onclick=\"window.open('edit_changes.php','_blank','width=600,height=500,resizable=1,scrollbars=1'); return false;\">" . $pgv_lang["accept_changes"] . "</a><br />";
            }
            if ($config["sendmail"] == "yes") {
                $content .= $pgv_lang["last_email_sent"] . format_timestamp($LAST_CHANGE_EMAIL) . "<br />";
                $content .= $pgv_lang["next_email_sent"] . format_timestamp($LAST_CHANGE_EMAIL + 60 * 60 * 24 * $config["days"]) . "<br /><br />";
            }
            foreach ($pgv_changes as $cid => $changes) {
                $change = $changes[count($changes) - 1];
                if ($change["gedcom"] == PGV_GEDCOM) {
                    $record = GedcomRecord::getInstance($change['gid']);
                    if ($record->getType() != 'SOUR' || $SHOW_SOURCES >= PGV_USER_ACCESS_LEVEL) {
                        $content .= '<b>' . PrintReady($record->getFullName()) . '</b> ' . getLRM() . '(' . $record->getXref() . ')' . getLRM();
                        switch ($record->getType()) {
                            case 'INDI':
                            case 'FAM':
                            case 'SOUR':
                            case 'OBJE':
                                $content .= $block ? '<br />' : ' ';
                                $content .= '<a href="' . encode_url($record->getLinkUrl() . '&show_changes=yes') . '">' . $pgv_lang['view_change_diff'] . '</a>';
                                break;
                        }
                        $content .= '<br />';
                    }
                }
            }
            global $THEME_DIR;
            if ($block) {
                require $THEME_DIR . 'templates/block_small_temp.php';
            } else {
                require $THEME_DIR . 'templates/block_main_temp.php';
            }
        }
    }
}
示例#6
0
function calendar_list_text($list, $tag1, $tag2, $show_sex_symbols)
{
    global $PGV_IMAGE_DIR, $PGV_IMAGES, $pgv_lang;
    global $males, $females;
    foreach ($list as $id => $facts) {
        $tmp = GedcomRecord::GetInstance($id);
        print "{$tag1}<a href=\"" . encode_url($tmp->getLinkUrl()) . "\">" . PrintReady($tmp->getFullName()) . "</a>&nbsp;";
        if ($show_sex_symbols && $tmp->getType() == 'INDI') {
            switch ($tmp->getSex()) {
                case 'M':
                    echo Person::sexImage('M', 'small', 'vertical-align: middle', $pgv_lang['all']);
                    ++$males;
                    break;
                case 'F':
                    echo Person::sexImage('F', 'small', 'vertical-align: middle', $pgv_lang['all']);
                    ++$females;
                    break;
                default:
                    echo Person::sexImage('U', 'small', 'vertical-align: middle', $pgv_lang['all']);
                    break;
            }
        }
        print "<div class=\"indent\">" . $facts . "</div>{$tag2}";
    }
}
示例#7
0
            write_file();
        }
        echo '<b>', $pgv_lang['accept_successful'], '</b>';
        break;
}
if (empty($pgv_changes)) {
    echo '<br /><br /><b>', $pgv_lang['no_changes'], '</b>';
} else {
    $output = '<br /><br /><table class="list_table"><tr><td class="list_value ' . $TEXT_DIRECTION . '">';
    $changedgedcoms = array();
    foreach ($pgv_changes as $cid => $changes) {
        foreach ($changes as $i => $change) {
            if ($i == 0) {
                $changedgedcoms[$change['gedcom']] = true;
                $GEDCOM = $change['gedcom'];
                $record = GedcomRecord::getInstance($change['gid']);
                $output .= '<b>' . PrintReady($record->getFullName()) . '</b> ' . getLRM() . '(' . $record->getXref() . ')' . getLRM() . '<br />';
                $output .= '<a href="javascript:;" onclick="return show_diff(\'' . encode_url($record->getLinkUrl() . '&show_changes=yes') . '\');">' . $pgv_lang['view_change_diff'] . '</a> | ';
                $output .= "<a href=\"javascript:show_gedcom_record('" . $change['gid'] . "');\">" . $pgv_lang['view_gedcom'] . "</a> | ";
                $output .= "<a href=\"javascript:;\" onclick=\"return edit_raw('" . $change['gid'] . "');\">" . $pgv_lang['edit_raw'] . "</a><br />";
                $output .= '<div class="indent">';
                $output .= $pgv_lang['changes_occurred'] . '<br />';
                $output .= '<table class="list_table"><tr>';
                $output .= '<td class="list_label">' . $pgv_lang['accept'] . '</td>';
                $output .= '<td class="list_label">' . $pgv_lang['type'] . '</td>';
                $output .= '<td class="list_label">' . $pgv_lang['username'] . '</td>';
                $output .= '<td class="list_label">' . $pgv_lang['date'] . '</td>';
                $output .= '<td class="list_label">GEDCOM</td>';
                $output .= '<td class="list_label">' . $pgv_lang['undo'] . '</td>';
                $output .= '</tr>';
            }
示例#8
0
 function getAllNames()
 {
     // Uniquely, the NOTE objects have data in their level 0 record.
     // Hence the REGEX passed in the second parameter
     return parent::getAllNames('NOTE', "0 @" . PGV_REGEX_XREF . "@");
 }
示例#9
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;
}
示例#10
0
/**
* import record into database
*
* this function will parse the given gedcom record and add it to the database
* @param string $gedrec the raw gedcom record to parse
* @param boolean $update whether or not this is an updated record that has been accepted
*/
function import_record($gedrec, $update)
{
    global $xtype, $TBLPREFIX, $GEDCOM_FILE, $FILE, $pgv_lang, $USE_RIN;
    global $place_id, $WORD_WRAPPED_NOTES, $GEDCOMS, $MAX_IDS, $fpnewged, $GEDCOM, $GENERATE_UIDS;
    global $gBitDb, $gGedcom;
    $FILE = $gGedcom->mGedcomName;
    // Escaped @ signs (only if importing from file)
    if (!$update) {
        $gedrec = str_replace('@@', '@', $gedrec);
    }
    // Standardise gedcom format
    $gedrec = reformat_record_import($gedrec);
    // import different types of records
    if (preg_match('/^0 @(' . PGV_REGEX_XREF . ')@ (' . PGV_REGEX_TAG . ')/', $gedrec, $match) > 0) {
        list(, $gid, $type) = $match;
        // check for a _UID, if the record doesn't have one, add one
        if ($GENERATE_UIDS && !strpos($gedrec, "\n1 _UID ")) {
            $gedrec .= "\n1 _UID " . uuid();
        }
    } elseif (preg_match('/0 (' . PGV_REGEX_TAG . ')/', $gedrec, $match)) {
        $gid = $match[1];
        $type = $match[1];
    } else {
        echo $pgv_lang['invalid_gedformat'], '<br /><pre>', $gedrec, '</pre>';
        return;
    }
    // keep track of the max id for each type as they are imported
    if (!isset($MAX_IDS)) {
        $MAX_IDS = array();
    }
    if (preg_match('/(\\d+)/', $gid, $match)) {
        $idnum = (int) $match[1];
    } else {
        $idnum = 0;
    }
    if (isset($MAX_IDS[$type])) {
        $MAX_IDS[$type] = max($MAX_IDS[$type], $idnum);
    } else {
        $MAX_IDS[$type] = $idnum;
    }
    $newrec = update_media($gid, $gedrec, $update);
    if ($newrec != $gedrec) {
        $gedrec = $newrec;
        // make sure we have the correct media id
        if (preg_match('/0 @(' . PGV_REGEX_XREF . ')@ (' . PGV_REGEX_TAG . ')/', $gedrec, $match)) {
            list(, $gid, $type) = $match;
        } else {
            echo $pgv_lang['invalid_gedformat'], '<br /><pre>', $gedrec, '</pre>';
            return;
        }
    }
    switch ($type) {
        case 'INDI':
            $record = new Person($gedrec);
            break;
        case 'FAM':
            $record = new Family($gedrec);
            break;
        case 'SOUR':
            $record = new Source($gedrec);
            break;
        case 'REPO':
            $record = new Repository($gedrec);
            break;
        case 'OBJE':
            $record = new Media($gedrec);
            break;
        default:
            $record = new GedcomRecord($gedrec);
            $type = $record->getType();
            break;
    }
    // Just in case the admin has blocked themself from seeing names!
    $record->disp = true;
    $record->dispname = true;
    // Update the cross-reference/index tables.
    $ged_id = $gGedcom->mGEDCOMId;
    $xref = $gid;
    update_places($xref, $ged_id, $gedrec);
    update_dates($xref, $ged_id, $gedrec);
    update_links($xref, $ged_id, $gedrec);
    update_rlinks($xref, $ged_id, $gedrec);
    update_names($xref, $ged_id, $record);
    switch ($type) {
        case 'INDI':
            if ($USE_RIN && preg_match('/\\n1 RIN (.+)/', $gedrec, $match)) {
                $rin = $match[1];
            } else {
                $rin = $xref;
            }
            $param = array($xref, $ged_id, $rin, is_dead($gedrec, '', true), $record->getSex(), $gedrec);
            $gBitDb->query("INSERT INTO {$TBLPREFIX}individuals (i_id, i_file, i_rin, i_isdead, i_sex, i_gedcom) VALUES (?,?,?,?,?,?)", $param);
            break;
        case 'FAM':
            if (preg_match('/\\n1 HUSB @(' . PGV_REGEX_XREF . ')@/', $gedrec, $match)) {
                $husb = $match[1];
            } else {
                $husb = '';
            }
            if (preg_match('/\\n1 WIFE @(' . PGV_REGEX_XREF . ')@/', $gedrec, $match)) {
                $wife = $match[1];
            } else {
                $wife = '';
            }
            if ($nchi = preg_match_all('/\\n1 CHIL @(' . PGV_REGEX_XREF . ')@/', $gedrec, $match)) {
                $chil = implode(';', $match[1]) . ';';
            } else {
                $chil = '';
            }
            if (preg_match('/\\n1 NCHI (\\d+)/', $gedrec, $match)) {
                $nchi = max($nchi, $match[1]);
            }
            $param = array($xref, $ged_id, $husb, $wife, $chil, $gedrec, $nchi);
            $gBitDb->query("INSERT INTO {$TBLPREFIX}families (f_id, f_file, f_husb, f_wife, f_chil, f_gedcom, f_numchil) VALUES (?,?,?,?,?,?,?)", $param);
            break;
        case 'SOUR':
            if (preg_match('/\\n1 TITL (.+)/', $gedrec, $match)) {
                $name = $match[1];
            } elseif (preg_match('/\\n1 ABBR (.+)/', $gedrec, $match)) {
                $name = $match[1];
            } else {
                $name = $gid;
            }
            if (strpos($gedrec, "\n1 _DBID")) {
                $_dbid = 'Y';
            } else {
                $_dbid = null;
            }
            $gBitDb->query("INSERT INTO {$TBLPREFIX}sources (s_id, s_file, s_name, s_gedcom, s_dbid) VALUES (?,?,?,?,?)", array($xref, $ged_id, $name, $gedrec, $_dbid));
            break;
        case 'OBJE':
            // OBJE records are imported by update_media function
            break;
        case 'HEAD':
            if (!strpos($gedrec, "\n1 DATE ")) {
                $gedrec .= "\n1 DATE " . date('j M Y');
            }
            // no break
        // no break
        default:
            if (substr($type, 0, 1) != '_') {
                $gBitDb->query("INSERT INTO {$TBLPREFIX}other (o_id, o_file, o_type, o_gedcom) VALUES (?,?,?,?)", array($xref, $ged_id, $type, $gedrec));
            }
            break;
    }
    // if this is not an update then write it to the new gedcom file
    if (!$update && !empty($fpnewged)) {
        fwrite($fpnewged, reformat_record_export($gedrec));
    }
    $xtype = $type;
    // Pass value back to uploadgedcom.php
}
示例#11
0
 /**
  * Returns the changeset as plain text.
  *
  * @param $found_facts
  * @return string
  */
 public function getRecentChangesAsHtml()
 {
     // TODO: Refactor this code taken from RecentChangesModule.
     global $WT_TREE;
     $sort = "date_desc";
     $found_facts = $this->getRecentChanges();
     $n = 0;
     $arr = array();
     foreach ($found_facts as $change_id) {
         $record = GedcomRecord::getInstance($change_id, $WT_TREE);
         if (!$record || !$record->canShow()) {
             continue;
         }
         // setup sorting parameters
         $arr[$n]['record'] = $record;
         $arr[$n]['jd'] = $sort == 'name' ? 1 : $n;
         $arr[$n]['anniv'] = $record->lastChangeTimestamp(true);
         $arr[$n++]['fact'] = $record->getSortName();
         // in case two changes have same timestamp
     }
     uasort($arr, '\\Fisharebest\\Webtrees\\Functions\\Functions::eventSort');
     $arr = array_reverse($arr);
     $mailtext = '';
     foreach ($arr as $value) {
         $mailtext .= '<a href="' . $value['record']->getHtmlUrl() . '" class="list_item name2">' . $value['record']->getFullName() . '</a>';
         $mailtext .= '<div class="indent" style="margin-bottom: 5px;">';
         if ($value['record'] instanceof Individual) {
             if ($value['record']->getAddName()) {
                 $mailtext .= '<a href="' . $value['record']->getHtmlUrl() . '" class="list_item">' . $value['record']->getAddName() . '</a>';
             }
         }
         $mailtext .= I18N::translate('Changed on %1$s by %2$s', $value['record']->lastChangeTimestamp(), Filter::escapeHtml($value['record']->lastChangeUser()));
         $mailtext .= '</div>';
     }
     return $mailtext;
 }
示例#12
0
/**
* returns INDIviduals matching filter
* @return Array of string
*/
function autocomplete_INDI($FILTER, $OPTION)
{
    global $pgv_lang, $MAX_ALIVE_AGE;
    // when adding ASSOciate $OPTION may contain :
    // current INDI/FAM [, current event date]
    if ($OPTION) {
        list($pid, $event_date) = explode("|", $OPTION . "|");
        $record = GedcomRecord::getInstance($pid);
        // INDI or FAM
        $tmp = new GedcomDate($event_date);
        $event_jd = $tmp->JD();
        // INDI
        $indi_birth_jd = 0;
        if ($record && $record->getType() == "INDI") {
            $indi_birth_jd = $record->getEstimatedBirthDate()->minJD();
        }
        // HUSB & WIFE
        $husb_birth_jd = 0;
        $wife_birth_jd = 0;
        if ($record && $record->getType() == "FAM") {
            $husb = $record->getHusband();
            if ($husb) {
                $husb_birth_jd = $husb->getEstimatedBirthDate()->minJD();
            }
            $wife = $record->getWife();
            if ($wife) {
                $wife_birth_jd = $wife->getEstimatedBirthDate()->minJD();
            }
        }
    }
    $rows = get_autocomplete_INDI($FILTER);
    $data = array();
    foreach ($rows as $row) {
        $person = Person::getInstance($row);
        if ($person->canDisplayName()) {
            // filter ASSOciate
            if ($OPTION && $event_jd) {
                // no self-ASSOciate
                if ($pid && $person->getXref() == $pid) {
                    continue;
                }
                // filter by birth date
                $person_birth_jd = $person->getEstimatedBirthDate()->minJD();
                if ($person_birth_jd) {
                    // born after event or not a contemporary
                    if ($event_jd && $person_birth_jd > $event_jd) {
                        continue;
                    } elseif ($indi_birth_jd && abs($indi_birth_jd - $person_birth_jd) > $MAX_ALIVE_AGE * 365) {
                        continue;
                    } elseif ($husb_birth_jd && $wife_birth_jd && abs($husb_birth_jd - $person_birth_jd) > $MAX_ALIVE_AGE * 365 && abs($wife_birth_jd - $person_birth_jd) > $MAX_ALIVE_AGE * 365) {
                        continue;
                    } elseif ($husb_birth_jd && abs($husb_birth_jd - $person_birth_jd) > $MAX_ALIVE_AGE * 365) {
                        continue;
                    } elseif ($wife_birth_jd && abs($wife_birth_jd - $person_birth_jd) > $MAX_ALIVE_AGE * 365) {
                        continue;
                    }
                }
                // filter by death date
                $person_death_jd = $person->getEstimatedDeathDate()->MaxJD();
                if ($person_death_jd) {
                    // dead before event or not a contemporary
                    if ($event_jd && $person_death_jd < $event_jd) {
                        continue;
                    } elseif ($indi_birth_jd && $person_death_jd < $indi_birth_jd) {
                        continue;
                    } elseif ($husb_birth_jd && $wife_birth_jd && $person_death_jd < $husb_birth_jd && $person_death_jd < $wife_birth_jd) {
                        continue;
                    } elseif ($husb_birth_jd && $person_death_jd < $husb_birth_jd) {
                        continue;
                    } elseif ($wife_birth_jd && $person_death_jd < $wife_birth_jd) {
                        continue;
                    }
                }
            }
            // display
            $data[$person->getXref()] = $person->getFullName();
            if ($OPTION && $event_date && $person->getBirthDate()->isOK()) {
                $data[$person->getXref()] .= " <span class=\"age\">(" . $pgv_lang["age"] . " " . $person->getBirthDate()->MinDate()->getAge(false, $event_jd) . ")</span>";
            } else {
                $data[$person->getXref()] .= " <u>" . ltrim($person->getBirthYear(), "0") . "-" . ltrim($person->getDeathYear(), "0") . "</u>";
            }
        }
    }
    return $data;
}
示例#13
0
 function getAllNames()
 {
     return parent::getAllNames('NAME');
 }
示例#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;
    }
示例#15
0
 function _eventQuery($type, $direction, $facts)
 {
     global $TBLPREFIX, $pgv_lang, $SHOW_ID_NUMBERS, $listDir;
     $eventTypes = array('BIRT' => $pgv_lang['htmlplus_block_birth'], 'DEAT' => $pgv_lang['htmlplus_block_death'], 'MARR' => $pgv_lang['htmlplus_block_marrage'], 'ADOP' => $pgv_lang['htmlplus_block_adoption'], 'BURI' => $pgv_lang['htmlplus_block_burial'], 'CENS' => $pgv_lang['htmlplus_block_census']);
     $fact_query = "IN ('" . str_replace('|', "','", $facts) . "')";
     if ($direction != 'ASC') {
         $direction = 'DESC';
     }
     $rows = self::_runSQL('' . ' SELECT' . ' d_gid AS id,' . ' d_year AS year,' . ' d_fact AS fact,' . ' d_type AS type' . ' FROM' . " {$TBLPREFIX}dates" . ' WHERE' . " d_file={$this->_ged_id} AND" . " d_gid!='HEAD' AND" . " d_fact {$fact_query} AND" . ' d_julianday1!=0' . ' ORDER BY' . " d_julianday1 {$direction}, d_type", 1);
     if (!isset($rows[0])) {
         return '';
     }
     $row = $rows[0];
     $record = GedcomRecord::getInstance($row['id']);
     switch ($type) {
         default:
         case 'full':
             if ($record->canDisplayDetails()) {
                 $result = $record->format_list('span', false, $record->getFullName());
             } else {
                 $result = $pgv_lang['privacy_error'];
             }
             break;
         case 'year':
             $date = new GedcomDate($row['type'] . ' ' . $row['year']);
             $result = $date->Display(true);
             break;
         case 'type':
             if (isset($eventTypes[$row['fact']])) {
                 $result = $eventTypes[$row['fact']];
             } else {
                 $result = '';
             }
             break;
         case 'name':
             $id = '';
             if ($SHOW_ID_NUMBERS) {
                 if ($listDir == 'rtl') {
                     $id = "&nbsp;&nbsp;" . getRLM() . "({$row['id']})" . getRLM();
                 } else {
                     $id = "&nbsp;&nbsp;({$row['id']})";
                 }
             }
             $result = "<a href=\"" . $record->getLinkUrl() . "\">" . PrintReady($record->getFullName()) . "{$id}</a>";
             break;
         case 'place':
             $result = format_fact_place($record->getFactByType($row['fact']), true, true, true);
             break;
     }
     return str_replace('<a href="', '<a href="' . $this->_server_url, $result);
 }
示例#16
0
/**
 * print find and print gedcom record ID
 *
 * @param string $checkVar	gedcom key
 * @param string $outputVar	error message style
 */
function search_ID_details($checkVar, $outputVar)
{
    global $pgv_lang;
    $record = GedcomRecord::getInstance($checkVar);
    if ($record) {
        echo $record->format_list('span');
    } else {
        print "<span class=\"error\">";
        if ($outputVar == 1) {
            print $pgv_lang["unable_to_find_privacy_indi"];
            print "<br />[" . $checkVar . "]";
        }
        if ($outputVar == 2) {
            print $pgv_lang["unable_to_find_privacy_indi"];
        }
        print "</span><br /><br />";
    }
}
示例#17
0
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=<?php 
print $CHARACTER_SET;
?>
" />
		<title><?php 
print "{$pid} Record";
?>
</title>
	</head>
	<body><?php 
if (!$SHOW_GEDCOM_RECORD && !PGV_USER_CAN_ACCEPT) {
    print "<span class=\"error\">" . $pgv_lang["ged_noshow"] . "</span>\n";
    print "</body></html>";
    exit;
}
$obj = GedcomRecord::getInstance($pid);
if (is_null($obj) || !$obj->canDisplayDetails()) {
    print_privacy_error($CONTACT_EMAIL);
    print "</body></html>";
    exit;
}
if (!isset($fromfile)) {
    $indirec = $obj->getGedcomRecord();
} else {
    $indirec = find_updated_record($pid);
    $indirec = privatize_gedcom($indirec);
}
$indirec = preg_replace("/@(\\w+)@/", "@<a href=\"gedrecord.php?pid=\$1\">\$1</a>@", $indirec);
print "<pre>{$indirec}</pre>";
print "</body></html>";
示例#18
0
 function getAllNames()
 {
     if (strpos($this->gedrec, "\n1 TITL ")) {
         // Earlier gedcom versions had level 1 titles
         return parent::getAllNames('TITL', 1);
     } else {
         // Later gedcom versions had level 2 titles
         return parent::getAllNames('TITL', 2);
     }
 }
示例#19
0
 /**
  * Handles searches entered in the top search box in the themes and
  * prepares the search to do a general search on indi's, fams, and sources.
  */
 function TopSearch()
 {
     global $SHOW_SOURCES, $GEDCOM;
     // first set some required variables. Search only in current gedcom, only in indi's.
     $this->srindi = "yes";
     // Enable the default gedcom for search
     $str = preg_replace(array("/\\./", "/-/", "/ /"), array("_", "_", "_"), $GEDCOM);
     $_REQUEST["{$str}"] = "yes";
     // Then see if an ID is typed in. If so, we might want to jump there.
     if (isset($this->query)) {
         $record = GedcomRecord::getInstance($this->query);
         if ($record && $record->canDisplayDetails()) {
             header("Location: " . encode_url($record->getLinkUrl(), false));
             exit;
         }
     }
 }
示例#20
0
/**
* returns INDIviduals matching filter
* @return Array of string
*/
function autocomplete_INDI($FILTER, $OPTION)
{
    global $TBLPREFIX, $pgv_lang, $MAX_ALIVE_AGE, $gBitDb;
    // when adding ASSOciate $OPTION may contain :
    // current INDI/FAM [, current event date]
    if ($OPTION) {
        list($pid, $event_date) = explode("|", $OPTION . "|");
        $record = GedcomRecord::getInstance($pid);
        // INDI or FAM
        $tmp = new GedcomDate($event_date);
        $event_jd = $tmp->JD();
        // INDI
        $indi_birth_jd = 0;
        if ($record && $record->getType() == "INDI") {
            $indi_birth_jd = $record->getEstimatedBirthDate()->minJD();
        }
        // HUSB & WIFE
        $husb_birth_jd = 0;
        $wife_birth_jd = 0;
        if ($record && $record->getType() == "FAM") {
            $husb = $record->getHusband();
            if ($husb) {
                $husb_birth_jd = $husb->getEstimatedBirthDate()->minJD();
            }
            $wife = $record->getWife();
            if ($wife) {
                $wife_birth_jd = $wife->getEstimatedBirthDate()->minJD();
            }
        }
    }
    $sql = "SELECT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec, i_isdead, i_sex" . " FROM {$TBLPREFIX}individuals, {$TBLPREFIX}name" . " WHERE (i_id LIKE ? OR n_sort LIKE ?)" . " AND i_id=n_id AND i_file=n_file AND i_file=?" . " ORDER BY n_sort";
    $rows = $gBitDb->query($sql, array("%{$FILTER}%", "%{$FILTER}%", PGV_GED_ID), PGV_AUTOCOMPLETE_LIMIT);
    $data = array();
    while ($row = $rows->fetchRow()) {
        $person = Person::getInstance($row);
        if ($person->canDisplayName()) {
            // filter ASSOciate
            if ($OPTION && $event_jd) {
                // no self-ASSOciate
                if ($pid && $person->getXref() == $pid) {
                    continue;
                }
                // filter by birth date
                $person_birth_jd = $person->getEstimatedBirthDate()->minJD();
                if ($person_birth_jd) {
                    // born after event or not a contemporary
                    if ($event_jd && $person_birth_jd > $event_jd) {
                        continue;
                    } elseif ($indi_birth_jd && abs($indi_birth_jd - $person_birth_jd) > $MAX_ALIVE_AGE * 365) {
                        continue;
                    } elseif ($husb_birth_jd && $wife_birth_jd && abs($husb_birth_jd - $person_birth_jd) > $MAX_ALIVE_AGE * 365 && abs($wife_birth_jd - $person_birth_jd) > $MAX_ALIVE_AGE * 365) {
                        continue;
                    } elseif ($husb_birth_jd && abs($husb_birth_jd - $person_birth_jd) > $MAX_ALIVE_AGE * 365) {
                        continue;
                    } elseif ($wife_birth_jd && abs($wife_birth_jd - $person_birth_jd) > $MAX_ALIVE_AGE * 365) {
                        continue;
                    }
                }
                // filter by death date
                $person_death_jd = $person->getEstimatedDeathDate()->MaxJD();
                if ($person_death_jd) {
                    // dead before event or not a contemporary
                    if ($event_jd && $person_death_jd < $event_jd) {
                        continue;
                    } elseif ($indi_birth_jd && $person_death_jd < $indi_birth_jd) {
                        continue;
                    } elseif ($husb_birth_jd && $wife_birth_jd && $person_death_jd < $husb_birth_jd && $person_death_jd < $wife_birth_jd) {
                        continue;
                    } elseif ($husb_birth_jd && $person_death_jd < $husb_birth_jd) {
                        continue;
                    } elseif ($wife_birth_jd && $person_death_jd < $wife_birth_jd) {
                        continue;
                    }
                }
            }
            // display
            $data[$person->getXref()] = $person->getFullName();
            if ($OPTION && $event_date && $person->getBirthDate()->isOK()) {
                $data[$person->getXref()] .= " <span class=\"age\">(" . $pgv_lang["age"] . " " . $person->getBirthDate()->MinDate()->getAge(false, $event_jd) . ")</span>";
            } else {
                $data[$person->getXref()] .= " <u>" . ltrim($person->getBirthYear(), "0") . "-" . ltrim($person->getDeathYear(), "0") . "</u>";
            }
        }
    }
    return $data;
}
示例#21
0
/**
* add a new tag input field
*
* called for each fact to be edited on a form.
* Fact level=0 means a new empty form : data are POSTed by name
* else data are POSTed using arrays :
* glevels[] : tag level
*  islink[] : tag is a link
*     tag[] : tag name
*    text[] : tag value
*
* @param string $tag fact record to edit (eg 2 DATE xxxxx)
* @param string $upperlevel optional upper level tag (eg BIRT)
* @param string $label An optional label to echo instead of the default from the $factarray
* @param string $readOnly optional, when "READONLY", fact data can't be changed
* @param string $noClose optional, when "NOCLOSE", final "</td></tr>" won't be printed
* (so that additional text can be printed in the box)
* @param boolean $rowDisplay True to have the row displayed by default, false to hide it by default
*/
function add_simple_tag($tag, $upperlevel = "", $label = "", $readOnly = "", $noClose = "", $rowDisplay = true)
{
    global $factarray, $pgv_lang, $PGV_IMAGE_DIR, $PGV_IMAGES, $MEDIA_DIRECTORY, $TEMPLE_CODES;
    global $assorela, $tags, $emptyfacts, $main_fact, $TEXT_DIRECTION, $pgv_changes, $GEDCOM;
    global $NPFX_accept, $SPFX_accept, $NSFX_accept, $FILE_FORM_accept, $upload_count;
    global $tabkey, $STATUS_CODES, $SPLIT_PLACES, $pid, $linkToID;
    global $bdm, $PRIVACY_BY_RESN;
    global $lang_short_cut, $LANGUAGE;
    global $QUICK_REQUIRED_FACTS, $QUICK_REQUIRED_FAMFACTS, $PREFER_LEVEL2_SOURCES;
    if (substr($tag, 0, strpos($tag, "PLAC"))) {
        ?>
<script type="text/javascript">
		<!--
		function valid_lati_long(field, pos, neg) {
			// valid LATI or LONG according to Gedcom standard
			// pos (+) : N or E
			// neg (-) : S or W
			txt=field.value.toUpperCase();
			txt=txt.replace(/(^\s*)|(\s*$)/g,''); // trim
			txt=txt.replace(/ /g,':'); // N12 34 ==> N12.34
			txt=txt.replace(/\+/g,''); // +17.1234 ==> 17.1234
			txt=txt.replace(/-/g,neg); // -0.5698 ==> W0.5698
			txt=txt.replace(/,/g,'.'); // 0,5698 ==> 0.5698
			// 0�34'11 ==> 0:34:11
			txt=txt.replace(/\uB0/g,':'); // �
			txt=txt.replace(/\u27/g,':'); // '
			// 0:34:11.2W ==> W0.5698
			txt=txt.replace(/^([0-9]+):([0-9]+):([0-9.]+)(.*)/g, function($0, $1, $2, $3, $4) { var n=parseFloat($1); n+=($2/60); n+=($3/3600); n=Math.round(n*1E4)/1E4; return $4+n; });
			// 0:34W ==> W0.5667
			txt=txt.replace(/^([0-9]+):([0-9]+)(.*)/g, function($0, $1, $2, $3) { var n=parseFloat($1); n+=($2/60); n=Math.round(n*1E4)/1E4; return $3+n; });
			// 0.5698W ==> W0.5698
			txt=txt.replace(/(.*)([N|S|E|W]+)$/g,'$2$1');
			// 17.1234 ==> N17.1234
			if (txt!='' && txt.charAt(0)!=neg && txt.charAt(0)!=pos) txt=pos+txt;
			field.value = txt;
		}

		function toggle_lati_long() {
			tr = document.getElementsByTagName('tr');
			for (var i=0; i<tr.length; i++) {
				if (tr[i].id.indexOf("LATI")>=0 || tr[i].id.indexOf("LONG")>=0) {
					var disp = tr[i].style.display;
					if (disp=="none") {
						disp="table-row";
						if (document.all && !window.opera) disp = "inline"; // IE
					}
					else disp="none";
					tr[i].style.display=disp;
				}
			}
		}
		//-->
		</script>
		<?php 
    }
    if (!isset($noClose) && isset($readOnly) && $readOnly == "NOCLOSE") {
        $noClose = "NOCLOSE";
        $readOnly = "";
    }
    if (!isset($noClose) || $noClose != "NOCLOSE") {
        $noClose = "";
    }
    if (!isset($readOnly) || $readOnly != "READONLY") {
        $readOnly = "";
    }
    if (!isset($tabkey)) {
        $tabkey = 1;
    }
    if (empty($linkToID)) {
        $linkToID = $pid;
    }
    $subnamefacts = array("NPFX", "GIVN", "SPFX", "SURN", "NSFX", "_MARNM_SURN");
    @(list($level, $fact, $value) = explode(" ", $tag));
    // element name : used to POST data
    if ($level == 0) {
        if ($upperlevel) {
            $element_name = $upperlevel . "_" . $fact;
        } else {
            $element_name = $fact;
        }
        // ex: OCCU
    } else {
        $element_name = "text[]";
    }
    if ($level == 1) {
        $main_fact = $fact;
    }
    // element id : used by javascript functions
    if ($level == 0) {
        $element_id = $fact;
    } else {
        $element_id = $fact . floor(microtime() * 1000000);
    }
    // ex: SOUR56402
    if ($upperlevel) {
        $element_id = $upperlevel . "_" . $fact;
    }
    // ex: BIRT_DATE | DEAT_DATE ...
    // field value
    $islink = (substr($value, 0, 1) == "@" and substr($value, 0, 2) != "@#");
    if ($islink) {
        $value = trim(trim(substr($tag, strlen($fact) + 3)), " @\r");
    } else {
        $value = trim(substr($tag, strlen($fact) + 3));
    }
    if ($fact == 'REPO' || $fact == 'SOUR' || $fact == 'OBJE' || $fact == 'FAMC') {
        $islink = true;
    }
    // rows & cols
    switch ($fact) {
        case 'FORM':
            $rows = 1;
            $cols = 5;
            break;
        case 'LATI':
        case 'LONG':
        case 'NPFX':
        case 'SPFX':
        case 'NSFX':
            $rows = 1;
            $cols = 12;
            break;
        case 'DATE':
        case 'TIME':
        case 'TYPE':
            $rows = 1;
            $cols = 20;
            break;
        case 'GIVN':
        case 'SURN':
        case '_MARNM':
            $rows = 1;
            $cols = 25;
            break;
        case '_UID':
            $rows = 1;
            $cols = 50;
            break;
        case 'TEXT':
        case 'PUBL':
            $rows = 10;
            $cols = 70;
            break;
        case 'SHARED_NOTE_EDIT':
            $islink = 1;
            $fact = "NOTE";
            $rows = 15;
            $cols = 88;
            break;
        case 'SHARED_NOTE':
            $islink = 1;
            $fact = "NOTE";
            $rows = 1;
            $cols = $islink ? 8 : 40;
            break;
        case 'NOTE':
            if ($islink) {
                $rows = 1;
                $cols = $islink ? 8 : 40;
                break;
            } else {
                $rows = 10;
                $cols = 70;
                break;
            }
        case 'ADDR':
            $rows = 4;
            $cols = 40;
            break;
        case 'PAGE':
            $rows = 1;
            $cols = 50;
            break;
        default:
            $rows = 1;
            $cols = $islink ? 8 : 40;
            break;
    }
    // label
    $style = "";
    echo "<tr id=\"" . $element_id . "_tr\" ";
    if ($fact == "MAP" || $fact == "LATI" || $fact == "LONG") {
        echo " style=\"display:none;\"";
    }
    echo " >\n";
    if (in_array($fact, $subnamefacts) || $fact == "LATI" || $fact == "LONG") {
        echo "<td class=\"optionbox {$TEXT_DIRECTION} wrap width25\">";
    } else {
        echo "<td class=\"descriptionbox {$TEXT_DIRECTION} wrap width25\">";
    }
    // help link
    if (!in_array($fact, $emptyfacts)) {
        if ($fact == "DATE") {
            print_help_link("def_gedcom_date_help", "qm", "date");
        } else {
            if ($fact == "RESN") {
                print_help_link($fact . "_help", "qm");
            } else {
                if ($fact == "NOTE" && $islink) {
                    print_help_link("edit_add_SHARED_NOTE_help", "qm");
                } else {
                    print_help_link("edit_" . $fact . "_help", "qm");
                }
            }
        }
    }
    if ($fact == "_AKAN" || $fact == "_AKA" || $fact == "ALIA") {
        // Allow special processing for different languages
        $func = "fact_AKA_localisation_{$lang_short_cut[$LANGUAGE]}";
        if (function_exists($func)) {
            // Localise the AKA fact
            $func($fact, $pid);
        }
    } else {
        if ($fact == "AGNC" && !empty($main_fact)) {
            // Allow special processing for different languages
            $func = "fact_AGNC_localisation_{$lang_short_cut[$LANGUAGE]}";
            if (function_exists($func)) {
                // Localise the AGNC fact
                $func($fact, $main_fact);
            }
        }
    }
    if (PGV_DEBUG) {
        echo $element_name . "<br />\n";
    }
    // tag name
    if (!empty($label)) {
        if ($label == "Note" && $islink) {
            echo $pgv_lang["shared_note"];
        } else {
            echo $label;
        }
    } else {
        if ($fact == "NOTE" && $islink) {
            echo $pgv_lang["shared_note"];
        } else {
            if (isset($pgv_lang[$fact])) {
                echo $pgv_lang[$fact];
            } else {
                if (isset($factarray[$fact])) {
                    echo $factarray[$fact];
                } else {
                    echo $fact;
                }
            }
        }
    }
    echo "\n";
    // tag level
    if ($level > 0) {
        if ($fact == "TEXT" and $level > 1) {
            echo "<input type=\"hidden\" name=\"glevels[]\" value=\"" . ($level - 1) . "\" />";
            echo "<input type=\"hidden\" name=\"islink[]\" value=\"0\" />";
            echo "<input type=\"hidden\" name=\"tag[]\" value=\"DATA\" />";
            //-- leave data text[] value empty because the following TEXT line will
            //--- cause the DATA to be added
            echo "<input type=\"hidden\" name=\"text[]\" value=\"\" />";
        }
        echo "<input type=\"hidden\" name=\"glevels[]\" value=\"" . $level . "\" />\n";
        echo "<input type=\"hidden\" name=\"islink[]\" value=\"" . $islink . "\" />\n";
        echo "<input type=\"hidden\" name=\"tag[]\" value=\"" . $fact . "\" />\n";
        // Shared Notes Debug --------------------
        // echo "<br />Label = ".$label;
        // echo "<br />Level = ".$level;
        // echo "<br />Link = ".$islink;
        // echo "<br />Fact = ".$fact;
        // echo "<br />Value = ".$value;
        // End Debug -------------------
    }
    echo "\n</td>";
    // value
    echo "<td class=\"optionbox wrap\">\n";
    if (PGV_DEBUG) {
        echo $tag . "<br />\n";
    }
    // retrieve linked NOTE
    if ($fact == "NOTE" && $islink) {
        $noteid = $value;
    }
    if (in_array($fact, $emptyfacts) && (empty($value) || $value == "y" || $value == "Y")) {
        $value = strtoupper($value);
        //-- don't default anything to Y when adding events through people
        //-- default to Y when specifically adding one of these events
        if ($level == 1) {
            $value = "Y";
        }
        // default YES
        echo "<input type=\"hidden\" id=\"" . $element_id . "\" name=\"" . $element_name . "\" value=\"" . $value . "\" />";
        if ($level <= 1) {
            echo "<input type=\"checkbox\" ";
            if ($value == "Y") {
                echo " checked=\"checked\"";
            }
            echo " onclick=\"if (this.checked) " . $element_id . ".value='Y'; else " . $element_id . ".value=''; \" />";
            echo $pgv_lang["yes"];
        }
    } else {
        if ($fact == "TEMP") {
            echo "<select tabindex=\"" . $tabkey . "\" name=\"" . $element_name . "\" >\n";
            echo "<option value=''>" . $pgv_lang["no_temple"] . "</option>\n";
            foreach ($TEMPLE_CODES as $code => $temple) {
                echo "<option value=\"{$code}\"";
                if ($code == $value) {
                    echo " selected=\"selected\"";
                }
                echo ">{$temple} ({$code})</option>\n";
            }
            echo "</select>\n";
        } else {
            if ($fact == "ADOP") {
                echo "<select tabindex=\"" . $tabkey . "\" name=\"" . $element_name . "\" >";
                foreach (array("BOTH" => $factarray["HUSB"] . "+" . $factarray["WIFE"], "HUSB" => $factarray["HUSB"], "WIFE" => $factarray["WIFE"]) as $k => $v) {
                    echo "<option value='{$k}'";
                    if ($value == $k) {
                        echo " selected=\"selected\"";
                    }
                    echo ">{$v}</option>";
                }
                echo "</select>\n";
            } else {
                if ($fact == "PEDI") {
                    echo "<select tabindex=\"" . $tabkey . "\" name=\"" . $element_name . "\" >";
                    foreach (array("" => $pgv_lang["unknown"], "birth" => $factarray["BIRT"], "adopted" => $pgv_lang["adopted"], "foster" => $pgv_lang["foster"], "sealing" => $pgv_lang["sealing"]) as $k => $v) {
                        echo "<option value='{$k}'";
                        if (UTF8_strtolower($value) == $k) {
                            echo " selected=\"selected\"";
                        }
                        echo ">{$v}</option>";
                    }
                    echo "</select>\n";
                } else {
                    if ($fact == "STAT") {
                        echo "<select tabindex=\"" . $tabkey . "\" name=\"" . $element_name . "\" >\n";
                        echo "<option value=''>No special status</option>\n";
                        foreach ($STATUS_CODES as $code => $status) {
                            echo "<option value=\"{$code}\"";
                            if ($code == $value) {
                                echo " selected=\"selected\"";
                            }
                            echo ">{$status}</option>\n";
                        }
                        echo "</select>\n";
                    } else {
                        if ($fact == "RELA") {
                            $text = strtolower($value);
                            // add current relationship if not found in default list
                            if (!array_key_exists($text, $assorela)) {
                                $assorela[$text] = $text;
                            }
                            echo "<select tabindex=\"" . $tabkey . "\" id=\"" . $element_id . "\" name=\"" . $element_name . "\" >\n";
                            foreach ($assorela as $key => $value) {
                                echo "<option value=\"" . $key . "\"";
                                if ($key == $text) {
                                    echo " selected=\"selected\"";
                                }
                                echo ">" . $assorela["{$key}"] . "</option>\n";
                            }
                            echo "</select>\n";
                        } else {
                            if ($fact == "_PGVU") {
                                $text = strtolower($value);
                                echo "<select tabindex=\"" . $tabkey . "\" id=\"" . $element_id . "\" name=\"" . $element_name . "\" >\n";
                                echo '<option value=""';
                                if ('' == $text) {
                                    echo ' selected="selected"';
                                }
                                echo ">-</option>\n";
                                foreach (get_all_users('asc', 'username') as $user_id => $user_name) {
                                    echo "<option value=\"" . $user_id . "\"";
                                    if ($user_id == $text) {
                                        echo " selected=\"selected\"";
                                    }
                                    echo ">" . $user_name . "</option>\n";
                                }
                                echo "</select>\n";
                            } else {
                                if ($fact == "RESN") {
                                    ?>
		<script type="text/javascript">
		<!--
		function update_RESN_img(resn_val) {
			document.getElementById("RESN_none").style.display="none";
			document.getElementById("RESN_locked").style.display="none";
			document.getElementById("RESN_privacy").style.display="none";
			document.getElementById("RESN_confidential").style.display="none";
			document.getElementById("RESN_"+resn_val).style.display="inline";
			if (resn_val=='none') resn_val='';
			document.getElementById("<?php 
                                    echo $element_id;
                                    ?>
").value=resn_val;
		}
		//-->
		</script>
		<?php 
                                    if (!$PRIVACY_BY_RESN && $level == 1) {
                                        // warn user that level 1 RESN tags have no effect when PRIVACY_BY_RESN is false
                                        echo "<small>" . $pgv_lang["resn_disabled"] . "</small>";
                                    }
                                    echo "<input type=\"hidden\" id=\"" . $element_id . "\" name=\"" . $element_name . "\" value=\"" . $value . "\" />\n";
                                    echo "<table><tr valign=\"top\">\n";
                                    foreach (array("none", "locked", "privacy", "confidential") as $resn_index => $resn_val) {
                                        if ($resn_val == "none") {
                                            $resnv = "";
                                        } else {
                                            $resnv = $resn_val;
                                        }
                                        echo "<td><input tabindex=\"" . $tabkey . "\" type=\"radio\" name=\"RESN_radio\" onclick=\"update_RESN_img('" . $resn_val . "')\"";
                                        echo " value=\"" . $resnv . "\"";
                                        if ($value == $resnv) {
                                            echo " checked=\"checked\"";
                                        }
                                        echo " /><small>" . $pgv_lang[$resn_val] . "</small>";
                                        echo "<br />&nbsp;<img id=\"RESN_" . $resn_val . "\" src=\"images/RESN_" . $resn_val . ".gif\"  alt=\"" . $pgv_lang[$resn_val] . "\" title=\"" . $pgv_lang[$resn_val] . "\" border=\"0\"";
                                        if ($value == $resnv) {
                                            echo " style=\"display:inline\"";
                                        } else {
                                            echo " style=\"display:none\"";
                                        }
                                        echo " /></td>\n";
                                    }
                                    echo "</tr></table>\n";
                                } else {
                                    if ($fact == "_PRIM" or $fact == "_THUM") {
                                        echo "<select tabindex=\"" . $tabkey . "\" id=\"" . $element_id . "\" name=\"" . $element_name . "\" >\n";
                                        echo "<option value=\"\"></option>\n";
                                        echo "<option value=\"Y\"";
                                        if ($value == "Y") {
                                            echo " selected=\"selected\"";
                                        }
                                        echo ">" . $pgv_lang["yes"] . "</option>\n";
                                        echo "<option value=\"N\"";
                                        if ($value == "N") {
                                            echo " selected=\"selected\"";
                                        }
                                        echo ">" . $pgv_lang["no"] . "</option>\n";
                                        echo "</select>\n";
                                    } else {
                                        if ($fact == "SEX") {
                                            echo "<select tabindex=\"" . $tabkey . "\" id=\"" . $element_id . "\" name=\"" . $element_name . "\">\n<option value=\"M\"";
                                            if ($value == "M") {
                                                echo " selected=\"selected\"";
                                            }
                                            echo ">" . $pgv_lang["male"] . "</option>\n<option value=\"F\"";
                                            if ($value == "F") {
                                                echo " selected=\"selected\"";
                                            }
                                            echo ">" . $pgv_lang["female"] . "</option>\n<option value=\"U\"";
                                            if ($value == "U" || empty($value)) {
                                                echo " selected=\"selected\"";
                                            }
                                            echo ">" . $pgv_lang["unknown"] . "</option>\n</select>\n";
                                        } else {
                                            if ($fact == "TYPE" && $level == '3') {
                                                //-- Build array of currently defined values for this Media Fact
                                                foreach ($pgv_lang as $varname => $typeValue) {
                                                    if (substr($varname, 0, 6) == "TYPE__") {
                                                        if ($varname != "TYPE__other") {
                                                            $type[strtolower(substr($varname, 6))] = $typeValue;
                                                        }
                                                    }
                                                }
                                                //-- Sort the array into a meaningful order
                                                array_flip($type);
                                                asort($type);
                                                array_flip($type);
                                                //-- Add "Other" at the end of the list
                                                $type["other"] = $pgv_lang["TYPE__other"];
                                                //-- Build the selector for the Media "TYPE" Fact
                                                echo "<select tabindex=\"" . $tabkey . "\" name=\"text[]\">";
                                                if ($value == "") {
                                                    echo "<option selected=\"selected\" value=\"\" > " . $pgv_lang["choose"] . " </option>";
                                                }
                                                $selectedValue = strtolower($value);
                                                foreach ($type as $typeName => $typeValue) {
                                                    echo "<option value=\"" . $typeName . "\" ";
                                                    if ($selectedValue == $typeName) {
                                                        echo "selected=\"selected\" ";
                                                    }
                                                    echo "> " . $typeValue . " </option>";
                                                }
                                                echo "</select>";
                                            } else {
                                                if ($fact == "NAME" && $upperlevel != 'REPO' || $fact == "_MARNM") {
                                                    // Populated in javascript from sub-tags
                                                    echo "<input type=\"hidden\" id=\"" . $element_id . "\" name=\"" . $element_name . "\" onchange=\"updateTextName('" . $element_id . "');\" value=\"" . PrintReady(htmlspecialchars($value, ENT_COMPAT, 'UTF-8')) . "\" />";
                                                    echo "<span id=\"" . $element_id . "_display\">" . PrintReady(htmlspecialchars($value, ENT_COMPAT, 'UTF-8')) . "</span>";
                                                    echo " <a href=\"#edit_name\" onclick=\"convertHidden('" . $element_id . "'); return false;\"> ";
                                                    if (isset($PGV_IMAGES["edit_indi"]["small"])) {
                                                        echo "<img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["edit_indi"]["small"] . "\" border=\"0\" width=\"20\" alt=\"" . $pgv_lang["edit_name"] . "\" align=\"top\" />";
                                                    } else {
                                                        echo "<span class=\"age\">[" . $pgv_lang["edit_name"] . "]</span>";
                                                    }
                                                    echo "</a>";
                                                } else {
                                                    // textarea
                                                    if ($rows > 1) {
                                                        echo "<textarea tabindex=\"" . $tabkey . "\" id=\"" . $element_id . "\" name=\"" . $element_name . "\" rows=\"" . $rows . "\" cols=\"" . $cols . "\">" . PrintReady(htmlspecialchars($value, ENT_COMPAT, 'UTF-8')) . "</textarea><br />\n";
                                                    } else {
                                                        // text
                                                        echo "<input tabindex=\"" . $tabkey . "\" type=\"text\" id=\"" . $element_id . "\" name=\"" . $element_name . "\" value=\"" . PrintReady(htmlspecialchars($value, ENT_COMPAT, 'UTF-8')) . "\" size=\"" . $cols . "\" dir=\"ltr\"";
                                                        echo " class=\"{$fact}\"";
                                                        echo " autocomplete=\"off\"";
                                                        if (in_array($fact, $subnamefacts)) {
                                                            echo " onblur=\"updatewholename();\" onkeyup=\"updatewholename();\"";
                                                        }
                                                        if ($fact == "DATE") {
                                                            echo " onblur=\"valid_date(this);\" onmouseout=\"valid_date(this);\"";
                                                        }
                                                        if ($fact == "LATI") {
                                                            echo " onblur=\"valid_lati_long(this, 'N', 'S');\" onmouseout=\"valid_lati_long(this, 'N', 'S');\"";
                                                        }
                                                        if ($fact == "LONG") {
                                                            echo " onblur=\"valid_lati_long(this, 'E', 'W');\" onmouseout=\"valid_lati_long(this, 'E', 'W');\"";
                                                        }
                                                        //if ($fact=="FILE") echo " onchange=\"if (updateFormat) updateFormat(this.value);\"";
                                                        echo " " . $readOnly . " />\n";
                                                    }
                                                    // split PLAC
                                                    if ($fact == "PLAC" && $readOnly == "") {
                                                        echo "<div id=\"" . $element_id . "_pop\" style=\"display: inline;\">\n";
                                                        print_specialchar_link($element_id, false);
                                                        print_findplace_link($element_id);
                                                        echo "</div>\n";
                                                        echo "<a href=\"javascript:;\" onclick=\"toggle_lati_long();\"><img src=\"images/buttons/target.gif\" border=\"0\" align=\"middle\" alt=\"" . $factarray["LATI"] . " / " . $factarray["LONG"] . "\" title=\"" . $factarray["LATI"] . " / " . $factarray["LONG"] . "\" /></a>";
                                                        if ($SPLIT_PLACES) {
                                                            if (!function_exists("print_place_subfields")) {
                                                                require "includes/functions/functions_places.php";
                                                            }
                                                            setup_place_subfields($element_id);
                                                            print_place_subfields($element_id);
                                                        }
                                                    } else {
                                                        if (($cols > 20 || $fact == "NPFX") && $readOnly == "") {
                                                            print_specialchar_link($element_id, false);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    // MARRiage TYPE : hide text field and show a selection list
    if ($fact == "TYPE" and $tags[0] == "MARR") {
        echo "<script type='text/javascript'>";
        echo "document.getElementById('" . $element_id . "').style.display='none'";
        echo "</script>";
        echo "<select tabindex=\"" . $tabkey . "\" id=\"" . $element_id . "_sel\" onchange=\"document.getElementById('" . $element_id . "').value=this.value;\" >\n";
        foreach (array("Unknown", "Civil", "Religious", "Partners") as $indexval => $key) {
            if ($key == "Unknown") {
                echo "<option value=\"\"";
            } else {
                echo "<option value=\"" . $key . "\"";
            }
            $a = strtolower($key);
            $b = strtolower($value);
            if (@strpos($a, $b) !== false or @strpos($b, $a) !== false) {
                echo " selected=\"selected\"";
            }
            echo ">" . $factarray["MARR_" . strtoupper($key)] . "</option>\n";
        }
        echo "</select>";
    }
    // popup links
    if ($readOnly == "") {
        if ($fact == "DATE") {
            print_calendar_popup($element_id);
        }
        if ($fact == "FAMC") {
            print_findfamily_link($element_id, "");
        }
        if ($fact == "FAMS") {
            print_findfamily_link($element_id, "");
        }
        if ($fact == "ASSO") {
            print_findindi_link($element_id, "");
        }
        if ($fact == "FILE") {
            print_findmedia_link($element_id, "0file");
        }
        if ($fact == "SOUR") {
            print_findsource_link($element_id);
            print_addnewsource_link($element_id);
            //print_autopaste_link($element_id, array("S1", "S2"), false, false, true);
            //-- checkboxes to apply '1 SOUR' to BIRT/MARR/DEAT as '2 SOUR'
            if ($level == 1) {
                echo '<br />';
                if ($PREFER_LEVEL2_SOURCES === '0') {
                    $level1_checked = '';
                    $level2_checked = '';
                } else {
                    if ($PREFER_LEVEL2_SOURCES === '1' || $PREFER_LEVEL2_SOURCES === true) {
                        $level1_checked = '';
                        $level2_checked = ' checked="checked"';
                    } else {
                        $level1_checked = ' checked="checked"';
                        $level2_checked = '';
                    }
                }
                if (strpos($bdm, 'B') !== false) {
                    echo '&nbsp;<input type="checkbox" name="SOUR_INDI" ', $level1_checked, ' value="Y" />';
                    echo $pgv_lang['individual'];
                    if (preg_match_all('/(' . PGV_REGEX_TAG . ')/', $QUICK_REQUIRED_FACTS, $matches)) {
                        foreach ($matches[1] as $match) {
                            if (!in_array($match, explode('|', PGV_EVENTS_DEAT))) {
                                echo '&nbsp;<input type="checkbox" name="SOUR_', $match, '"', $level2_checked, ' value="Y" />';
                                echo $factarray[$match];
                            }
                        }
                    }
                }
                if (strpos($bdm, 'D') !== false) {
                    if (preg_match_all('/(' . PGV_REGEX_TAG . ')/', $QUICK_REQUIRED_FACTS, $matches)) {
                        foreach ($matches[1] as $match) {
                            if (in_array($match, explode('|', PGV_EVENTS_DEAT))) {
                                echo '&nbsp;<input type="checkbox" name="SOUR_', $match, '"', $level2_checked, ' value="Y" />';
                                echo $factarray[$match];
                            }
                        }
                    }
                }
                if (strpos($bdm, 'M') !== false) {
                    echo '&nbsp;<input type="checkbox" name="SOUR_FAM" ', $level1_checked, ' value="Y" />';
                    echo $pgv_lang["family"];
                    if (preg_match_all('/(' . PGV_REGEX_TAG . ')/', $QUICK_REQUIRED_FAMFACTS, $matches)) {
                        foreach ($matches[1] as $match) {
                            echo '&nbsp;<input type="checkbox" name="SOUR_', $match, '"', $level2_checked, ' value="Y" />';
                            echo $factarray[$match];
                        }
                    }
                }
            }
        }
        if ($fact == "REPO") {
            print_findrepository_link($element_id);
            print_addnewrepository_link($element_id);
        }
        // Shared Notes Icons ========================================
        // $record=GedcomRecord::getInstance($value);
        if ($fact == "NOTE" && $islink) {
            print_findnote_link($element_id);
            print_addnewnote_link($element_id);
            if ($value != "") {
                echo "&nbsp;&nbsp;&nbsp;";
                print_editnote_link($value);
            }
            // If GEDFAct_assistant/_CENS/ module exists && we are on the INDI page
            // Then show the add Shared note assisted icon, if not  ... do not show
            if ($pid) {
                $type_pid = GedcomRecord::getInstance($pid);
                if (file_exists('modules/GEDFact_assistant/_CENS/census_1_ctrl.php') && $type_pid->getType() == "INDI") {
                    echo "&nbsp;&nbsp;&nbsp;";
                    print_addnewnote_assisted_link($element_id);
                }
            }
            echo "<br />";
        }
        // ===========================================================
        if ($fact == "OBJE") {
            print_findmedia_link($element_id, "1media");
        }
        if ($fact == "OBJE" && !$value) {
            print_addnewmedia_link($element_id);
            $value = "new";
        }
    }
    // current value
    if ($TEXT_DIRECTION == "ltr") {
        if ($fact == "DATE") {
            $date = new GedcomDate($value);
            echo $date->Display(false);
        }
        if (($fact == "ASSO" || $fact == "SOUR" || $fact == "OBJE" || $fact == "NOTE" && $islink) && $value) {
            $record = GedcomRecord::getInstance($value);
            if ($record) {
                echo ' ', PrintReady($record->getFullName()), ' (', $value, ')';
            } else {
                if ($value != "new") {
                    echo ' ', $value;
                }
            }
        }
    } else {
        if ($fact == "DATE") {
            $date = new GedcomDate($value);
            echo getRLM(), $date->Display(false), getRLM();
        }
        if (($fact == "ASSO" || $fact == "SOUR" || $fact == "OBJE" || $fact == "NOTE" && $islink) && $value) {
            $record = GedcomRecord::getInstance($value);
            if ($record) {
                echo getRLM(), PrintReady($record->getFullName()), ' ', getLRM(), '(', $value, ') ', getLRM(), getRLM();
            } else {
                if ($value != "new") {
                    echo getRLM(), $value, ' ', getRLM();
                }
            }
        }
    }
    /*
    	if ($fact=="NOTE" && $islink && $value!="") {
    		include('includes/functions/functions_print_lists.php'); 
    		echo "<tr><td class=\"descriptionbox ".$TEXT_DIRECTION." wrap width25\">";
    				print_help_link("edit_add_SHARED_NOTE_help", "qm");
    			//	echo $pgv_lang["admin_override"];
    			echo "Shared Note Links<br /><br />";
    		echo "</td><td class=\"optionbox wrap\">\n";
    			print_indi_list(fetch_linked_indi($value, "NOTE", "1"));
    		echo "</td></tr>\n";
    	}
    */
    // pastable values
    if ($readOnly == "") {
        if ($fact == "SPFX") {
            print_autopaste_link($element_id, $SPFX_accept);
        }
        if ($fact == "NSFX") {
            print_autopaste_link($element_id, $NSFX_accept);
        }
        if ($fact == "FORM") {
            print_autopaste_link($element_id, $FILE_FORM_accept, false, false);
        }
    }
    if ($noClose != "NOCLOSE") {
        echo "</td></tr>\n";
    }
    $tabkey++;
    return $element_id;
}
示例#22
0
 static function &getFavoritesMenu()
 {
     global $REQUIRE_AUTHENTICATION, $pgv_lang, $GEDCOM, $QUERY_STRING, $SCRIPT_NAME, $PGV_IMAGE_DIR, $PGV_IMAGES, $TEXT_DIRECTION;
     global $SEARCH_SPIDER;
     global $controller;
     // Pages with a controller can be added to the favorites
     if (!empty($SEARCH_SPIDER)) {
         return false;
         // show no favorites, because they taint every page that is indexed.
     }
     if ($TEXT_DIRECTION == "rtl") {
         $ff = "_rtl";
     } else {
         $ff = "";
     }
     if (PGV_USER_ID || !$REQUIRE_AUTHENTICATION) {
         $menu = new Menu($pgv_lang['favorites'], '#', 'down');
         if (!empty($PGV_IMAGES['gedcom']['large'])) {
             $menu->addIcon($PGV_IMAGE_DIR . '/' . $PGV_IMAGES['gedcom']['large']);
         }
         $menu->addClass("menuitem{$ff}", "menuitem_hover{$ff}", "submenu{$ff}", "icon_large_gedcom");
         //			$menu->print_menu = NULL;
         $userfavs = getUserFavorites(PGV_USER_ID);
         $gedfavs = getUserFavorites($GEDCOM);
         // User favorites
         if ($userfavs || PGV_USER_ID) {
             $submenu = new Menu('<strong>' . $pgv_lang['my_favorites'] . '</strong>');
             $submenu->addClass('favsubmenuitem', 'favsubmenuitem_hover');
             $menu->addSubMenu($submenu);
             while (PGV_USER_ID && isset($controller)) {
                 // Get the right $gid from each supported controller type
                 switch (get_class($controller)) {
                     case 'IndividualController':
                         $gid = $controller->pid;
                         break;
                     case 'FamilyController':
                         $gid = $controller->famid;
                         break;
                     case 'MediaController':
                         $gid = $controller->mid;
                         break;
                     case 'SourceController':
                         $gid = $controller->sid;
                         break;
                     case 'RepositoryController':
                         $gid = $controller->rid;
                         break;
                     default:
                         break 2;
                 }
                 $submenu = new Menu('<em>' . $pgv_lang['add_to_my_favorites'] . '</em>', $SCRIPT_NAME . normalize_query_string($QUERY_STRING . '&amp;action=addfav&amp;gid=' . $gid));
                 $submenu->addClass('favsubmenuitem', 'favsubmenuitem_hover');
                 $menu->addSubMenu($submenu);
                 break;
             }
             foreach ($userfavs as $fav) {
                 $OLD_GEDCOM = $GEDCOM;
                 $GEDCOM = $fav['file'];
                 switch ($fav['type']) {
                     case 'URL':
                         $submenu = new Menu(PrintReady($fav['title']), $fav['url']);
                         $submenu->addClass('favsubmenuitem', 'favsubmenuitem_hover');
                         $menu->addSubMenu($submenu);
                         break;
                     case 'INDI':
                     case 'FAM':
                     case 'SOUR':
                     case 'OBJE':
                         if (displayDetailsById($fav['gid'], $fav['type'])) {
                             $obj = GedcomRecord::getInstance($fav['gid']);
                             if ($obj) {
                                 $submenu = new Menu(PrintReady($obj->getFullName()), encode_url($obj->getLinkUrl()));
                                 $submenu->addClass('favsubmenuitem', 'favsubmenuitem_hover');
                                 $menu->addSubMenu($submenu);
                             }
                         }
                         break;
                 }
                 $GEDCOM = $OLD_GEDCOM;
             }
             if ($gedfavs) {
                 $menu->addSeparator();
             }
         }
         // Gedcom favorites
         if ($gedfavs) {
             $submenu = new Menu('<strong>' . $pgv_lang['gedcom_favorites'] . '</strong>');
             $submenu->addClass('favsubmenuitem', 'favsubmenuitem_hover');
             $menu->addSubMenu($submenu);
             foreach ($gedfavs as $fav) {
                 $OLD_GEDCOM = $GEDCOM;
                 $GEDCOM = $fav['file'];
                 switch ($fav['type']) {
                     case 'URL':
                         $submenu = new Menu(PrintReady($fav['title']), $fav['url']);
                         $submenu->addClass('favsubmenuitem', 'favsubmenuitem_hover');
                         $menu->addSubMenu($submenu);
                         break;
                     case 'INDI':
                     case 'FAM':
                     case 'SOUR':
                     case 'OBJE':
                         if (displayDetailsById($fav['gid'], $fav['type'])) {
                             $obj = GedcomRecord::getInstance($fav['gid']);
                             if ($obj) {
                                 $submenu = new Menu(PrintReady($obj->getFullName()), encode_url($obj->getLinkUrl()));
                                 $submenu->addClass('favsubmenuitem', 'favsubmenuitem_hover');
                                 $menu->addSubMenu($submenu);
                             }
                         }
                         break;
                 }
                 $GEDCOM = $OLD_GEDCOM;
             }
         }
     }
     return $menu;
 }
示例#23
0
function top10_pageviews($block = true, $config = "", $side, $index)
{
    global $TBLPREFIX, $pgv_lang, $INDEX_DIRECTORY, $PGV_BLOCKS, $ctype, $PGV_IMAGES, $PGV_IMAGE_DIR, $SHOW_COUNTER, $SHOW_SOURCES, $TEXT_DIRECTION;
    if (empty($config)) {
        $config = $PGV_BLOCKS["top10_pageviews"]["config"];
    }
    if (isset($config["count_placement"])) {
        $CountSide = $config["count_placement"];
    } else {
        $CountSide = "left";
    }
    $id = "top10hits";
    $title = print_help_link("index_top10_pageviews_help", "qm", "", false, true);
    if ($PGV_BLOCKS["top10_pageviews"]["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["top10_pageviews"];
    $content = "";
    // if the counter file does not exist then don't do anything
    if (!$SHOW_COUNTER) {
        if (PGV_USER_IS_ADMIN) {
            $content .= "<span class=\"error\">" . $pgv_lang["top10_pageviews_msg"] . "</span>";
        }
    } else {
        // load the lines from the file
        $top10 = PGV_DB::prepareLimit("SELECT page_parameter, page_count" . " FROM {$TBLPREFIX}hit_counter" . " WHERE gedcom_id=? AND page_name IN ('individual.php','family.php','source.php','repo.php','note.php','mediaviewer.php')" . " ORDER BY page_count DESC", $config['num'])->execute(array(PGV_GED_ID))->FetchAssoc();
        if ($top10) {
            if ($block) {
                $content .= "<table width=\"90%\">";
            } else {
                $content .= "<table>";
            }
            foreach ($top10 as $id => $count) {
                $record = GedcomRecord::getInstance($id);
                if ($record && $record->canDisplayDetails()) {
                    $content .= '<tr valign="top">';
                    if ($CountSide == 'left') {
                        $content .= '<td dir="ltr" align="right">[' . $count . ']</td>';
                    }
                    $content .= '<td class="name2" ><a href="' . encode_url($record->getLinkUrl()) . '">' . PrintReady($record->getFullName()) . '</a></td>';
                    if ($CountSide == 'right') {
                        $content .= '<td dir="ltr" align="right">[' . $count . ']</td>';
                    }
                    $content .= '</tr>';
                }
            }
            $content .= "</table>";
        } else {
            $content .= "<b>" . $pgv_lang["top10_pageviews_nohits"] . "</b>";
        }
    }
    global $THEME_DIR;
    if ($block) {
        require $THEME_DIR . 'templates/block_small_temp.php';
    } else {
        require $THEME_DIR . 'templates/block_main_temp.php';
    }
}
示例#24
0
 }
 echo "<a href=\"javascript:;\" onclick=\"return openImage('", rawurlencode($media["FILE"]), "', {$imgwidth}, {$imgheight});\">", $pgv_lang["view"], "</a><br />";
 if (!$media["EXISTS"] && !isFileExternal($media["FILE"])) {
     echo $media["FILE"], "<br /><span class=\"error\">", $pgv_lang["file_not_exists"], "</span><br />";
 } else {
     if (!isFileExternal($media["FILE"]) && !empty($imgsize[0])) {
         echo "<br /><sub>&nbsp;&nbsp;", $pgv_lang["image_size"], " -- ", $imgsize[0], "x", $imgsize[1], "</sub><br />";
     }
 }
 if ($media["LINKED"]) {
     echo $pgv_lang["media_linked"], "<br />";
     foreach ($media["LINKS"] as $indi => $type_record) {
         if ($type_record != 'INDI' && $type_record != 'FAM' && $type_record != 'SOUR' && $type_record != 'OBJE') {
             continue;
         }
         $record = GedcomRecord::getInstance($indi);
         echo '<br /><a href="', encode_url($record->getLinkUrl()), '">';
         switch ($type_record) {
             case 'INDI':
                 echo $pgv_lang['view_person'], ' - ';
                 break;
             case 'FAM':
                 echo $pgv_lang['view_family'], ' - ';
                 break;
             case 'SOUR':
                 echo $pgv_lang['view_source'], ' - ';
                 break;
             case 'OBJE':
                 echo $pgv_lang['view_object'], ' - ';
                 break;
         }
示例#25
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();
                         }
                     }
                 }
             }
         }
     }
 }
示例#26
0
function print_todo($block = true, $config = '', $side, $index)
{
    global $pgv_lang, $factarray, $ctype, $PGV_IMAGE_DIR, $PGV_IMAGES, $PGV_BLOCKS;
    $block = true;
    // Always restrict this block's height
    if (empty($config)) {
        $config = $PGV_BLOCKS['print_todo']['config'];
    }
    $id = 'todo';
    $title = print_help_link('todo_help', 'qm', '', false, true);
    if ($PGV_BLOCKS['print_todo']['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['todo_block'];
    $content = "";
    require_once PGV_ROOT . 'js/sorttable.js.htm';
    require_once PGV_ROOT . 'includes/classes/class_gedcomrecord.php';
    $table_id = 'ID' . floor(microtime() * 1000000);
    // sorttable requires a unique ID
    $content .= '<table id="' . $table_id . '" class="sortable list_table center">';
    $content .= '<tr>';
    $content .= '<th class="list_label">' . $factarray['DATE'] . '</th>';
    $content .= '<th class="list_label">' . $pgv_lang['record'] . '</th>';
    if ($config['show_unassigned'] == 'yes' || $config['show_other'] == 'yes') {
        $content .= '<th class="list_label">' . $pgv_lang['username'] . '</th>';
    }
    $content .= '<th class="list_label">' . $factarray['TEXT'] . '</th>';
    $content .= '</tr>';
    $found = false;
    $end_jd = $config['show_future'] == 'yes' ? 99999999 : client_jd();
    foreach (get_calendar_events(0, $end_jd, '_TODO', PGV_GED_ID) as $todo) {
        $record = GedcomRecord::getInstance($todo['id']);
        if ($record && $record->canDisplayDetails()) {
            $pgvu = get_gedcom_value('_PGVU', 2, $todo['factrec']);
            if ($pgvu == PGV_USER_NAME || !$pgvu && $config['show_unassigned'] == 'yes' || $pgvu && $config['show_other'] == 'yes') {
                $content .= '<tr valign="top">';
                $content .= '<td class="list_value_wrap">' . str_replace('<a', '<a name="' . $todo['date']->MinJD() . '"', $todo['date']->Display(false)) . '</td>';
                $name = $record->getListName();
                $content .= '<td class="list_value_wrap" align="' . get_align(PGV_GEDCOM) . '"><a href="' . encode_url($record->getLinkUrl()) . '">' . PrintReady($name) . '</a></td>';
                if ($config['show_unassigned'] == 'yes' || $config['show_other'] == 'yes') {
                    $content .= '<td class="list_value_wrap">' . $pgvu . '</td>';
                }
                $text = get_gedcom_value('_TODO', 1, $todo['factrec']);
                $content .= '<td class="list_value_wrap" align="' . get_align($text) . '">' . PrintReady($text) . '</td>';
                $content .= '</tr>';
                $found = true;
            }
        }
    }
    $content .= '</table>';
    if (!$found) {
        $content .= '<p>' . $pgv_lang['todo_nothing'] . '</p>';
    }
    global $THEME_DIR;
    if ($block) {
        require $THEME_DIR . 'templates/block_small_temp.php';
    } else {
        require $THEME_DIR . 'templates/block_main_temp.php';
    }
}
示例#27
0
                echo $tag;
                ?>
" title="<?php 
                echo $tag;
                ?>
" /><?php 
            }
            ?>
			</td>
			<td class="list_value ltr"><?php 
            echo $clipping['id'];
            ?>
</td>
			<td class="list_value">
			<?php 
            $record = GedcomRecord::getInstance($clipping['id']);
            if ($record) {
                echo '<a href="', encode_url($record->getLinkUrl()), '">', PrintReady($record->getListName()), '</a>';
            }
            ?>
			</td>
			<td class="list_value center vmiddle"><a href="clippings.php?action=remove&amp;item=<?php 
            echo $i;
            ?>
"><img src="<?php 
            echo $PGV_IMAGE_DIR, "/", $PGV_IMAGES["remove"]["other"];
            ?>
" border="0" alt="<?php 
            echo $pgv_lang["remove"];
            ?>
" title="<?php 
示例#28
0
                                    print $pgv_lang["adding"] . " " . $facts1[$i]["fact"] . " " . $pgv_lang["from"] . " {$gid1}<br />\n";
                                }
                            }
                            if (isset($facts2[$i])) {
                                if (in_array($i, $keep2)) {
                                    $newgedrec .= $facts2[$i]["subrec"] . "\n";
                                    print $pgv_lang["adding"] . " " . $facts2[$i]["fact"] . " " . $pgv_lang["from"] . " {$gid2}<br />\n";
                                }
                            }
                        }
                        replace_gedrec($gid1, $newgedrec);
                        if ($SYNC_GEDCOM_FILE) {
                            write_file();
                        }
                        write_changes();
                        $rec = GedcomRecord::getInstance($gid1);
                        $pid = $rec->getXrefLink();
                        // $pid is embedded in $pgv_lang['record_updated']
                        echo '<br />', print_text('record_updated', 0, 1), '<br />';
                        print "<br /><a href=\"edit_merge.php?action=choose\">" . $pgv_lang["merge_more"] . "</a><br />\n";
                        print "<br /><br /><br />\n";
                    }
                }
            }
        }
    }
}
if ($action == "choose") {
    ?>
	<script language="JavaScript" type="text/javascript">
	<!--
示例#29
0
 /**
  * Extract names from the GEDCOM record.
  */
 public function extractNames()
 {
     parent::extractNamesFromFacts(1, 'NAME', $this->getFacts('NAME'));
 }
示例#30
0
/**
* @todo add info
* @see PGVRRelativesSHandler()
*/
function PGVRRelativesEHandler()
{
    global $list, $repeats, $repeatsStack, $repeatBytes, $parser, $parserStack, $report, $pgvreport, $gedrec, $processRepeats, $list_total, $list_private, $generation;
    $processRepeats--;
    if ($processRepeats > 0) {
        return;
    }
    $line = xml_get_current_line_number($parser) - 1;
    $lineoffset = 0;
    for ($i = 0; $i < count($repeatsStack); $i++) {
        $p = $repeatsStack[$i];
        $l = $p[1];
        $lineoffset += $l;
    }
    //-- read the xml from the file
    $lines = file($report);
    $reportxml = "<tempdoc>\n";
    while (strstr($lines[$lineoffset + $repeatBytes], "<PGVRRelatives") === false && $lineoffset + $repeatBytes > 0) {
        $lineoffset--;
    }
    $lineoffset++;
    $line1 = $repeatBytes;
    $ct = 1;
    while ($ct > 0 && $line1 < $line + 2) {
        if (strstr($lines[$lineoffset + $line1], "<PGVRRelatives") !== false) {
            $ct++;
        }
        if (strstr($lines[$lineoffset + $line1], "</PGVRRelatives") !== false) {
            $ct--;
        }
        $line1++;
    }
    $line = $line1 - 1;
    for ($i = $repeatBytes + $lineoffset; $i < $line + $lineoffset; $i++) {
        $reportxml .= $lines[$i];
    }
    $reportxml .= "</tempdoc>\n";
    //	print htmlentities($reportxml,ENT_COMPAT,'UTF-8')."\n";
    array_push($parserStack, $parser);
    $oldgedrec = $gedrec;
    $list_total = count($list);
    $list_private = 0;
    foreach ($list as $key => $value) {
        if (isset($value->generation)) {
            $generation = $value->generation;
        }
        //KN		if (displayDetailsById($key)) {
        if (strpos($key, "empty") === 0) {
            continue;
        }
        // key can be something like "empty7"
        $tmp = GedcomRecord::getInstance($key);
        $gedrec = $tmp->getGedcomRecord();
        //-- start the sax parser
        $repeat_parser = xml_parser_create();
        $parser = $repeat_parser;
        //-- make sure everything is case sensitive
        xml_parser_set_option($repeat_parser, XML_OPTION_CASE_FOLDING, false);
        //-- set the main element handler functions
        xml_set_element_handler($repeat_parser, "startElement", "endElement");
        //-- set the character data handler
        xml_set_character_data_handler($repeat_parser, "characterData");
        if (!xml_parse($repeat_parser, $reportxml, true)) {
            printf($reportxml . "\nPGVRRelativesEHandler XML error: %s at line %d", xml_error_string(xml_get_error_code($repeat_parser)), xml_get_current_line_number($repeat_parser));
            print_r($repeatsStack);
            debug_print_backtrace();
            exit;
        }
        xml_parser_free($repeat_parser);
        //KN		}
        //KN		else $list_private++;
    }
    $parser = array_pop($parserStack);
    $gedrec = $oldgedrec;
    $temp = array_pop($repeatsStack);
    $repeats = $temp[0];
    $repeatBytes = $temp[1];
}