/** * is the person alive in the given year * @param string $indirec the persons raw gedcom record * @param int $year the year to check if they are alive in * @return int return 0 if the person is alive, negative number if they died earlier, positive number if they will be born in the future */ function check_alive($indirec, $year) { global $MAX_ALIVE_AGE; if (is_dead($indirec, $year)) { return -1; } // Died before year? $deathrec = get_sub_record(1, "1 DEAT", $indirec); if (preg_match("/\\d DATE (.*)/", $deathrec, $match)) { $ddate = new GedcomDate($match[1]); $dyear = $ddate->gregorianYear(); if ($year > $dyear) { return -1; } } // Born after year? $birthrec = get_sub_record(1, "1 BIRT", $indirec); if (preg_match("/\\d DATE (.*)/", $birthrec, $match)) { $bdate = new GedcomDate($match[1]); $byear = $bdate->gregorianYear(); if ($year < $byear) { return 1; } } // Born before year and died after year if (isset($byear) && isset($dyear) && $year >= $byear && $year <= $dyear) { return 0; } // If no death record than check all dates; $years = array(); $subrecs = get_all_subrecords($indirec, "CHAN", true, true, false); foreach ($subrecs as $ind => $subrec) { if (preg_match("/\\d DATE (.*)/", $subrec, $match)) { $date = new GedcomDate($match[1]); $datey = $date->gregorianYear(); if ($datey) { $years[] = $datey; } } } // Events both before and after year if (count($years) > 1 && $year >= $years[0] && $year <= $years[count($years) - 1]) { return 0; } foreach ($years as $ind => $year1) { if ($year1 - $year > $MAX_ALIVE_AGE) { return -1; } } return 0; }
static function CompareMarrDate($x, $y) { return GedcomDate::Compare($x->getMarriageDate(), $y->getMarriageDate()); }
/** * Creates the date elements used throughout the GRAMPS XML file. * The function will parse the date record and determine the type of date * (regular, range). * * @param DOMObject $eParent - The parent element the date should be attached to * @param string $dateRec - the entire GEDCOM date record to be parsed * @param int $level - the level the date record was found on in the GEDCOM * @param int $done - whether the method is called from the GrampsExport($done=1) or a sub-class */ function create_date($eParent, $dateRec, $level) { if (empty($dateRec)) { return; } $date = new GedcomDate(get_gedcom_value("DATE", $level, $dateRec, '', false)); //checks to see if there's is a 2nd date value and creates the daterange element if (!empty($date->qual2)) { $eDateRange = $this->dom->createElement("daterange"); $eDateRange = $eParent->appendChild($eDateRange); //sets the start date $eDateRange->setAttribute("start", $this->create_date_value($date->MinDate())); //sets the stop date $eDateRange->setAttribute("stop", $this->create_date_value($date->MaxDate())); } else { //if there's no dateRange, this creates the normal dateval Element $eDateVal = $this->dom->createElement("dateval"); $eDateVal = $eParent->appendChild($eDateVal); //checks for the Type attribute values switch ($date->qual1) { case 'bef': $eDateVal->setAttribute("type", "before"); break; case 'aft': $eDateVal->setAttribute("type", "after"); break; case 'abt': $eDateVal->setAttribute("type", "about"); break; } //sets the date value $eDateVal->setAttribute("val", $this->create_date_value($date->MinDate())); } }
function compare_people($a, $b) { return GedcomDate::Compare($a->getEstimatedBirthDate(), $b->getEstimatedBirthDate()); }
static function CompareChanDate($x, $y) { $chan_x = $x->getChangeEvent(); $chan_y = $y->getChangeEvent(); $tmp = GedcomDate::Compare($chan_x->getDate(), $chan_y->getDate()); if ($tmp) { return $tmp; } else { if (preg_match('/^\\d\\d:\\d\\d:\\d\\d/', get_gedcom_value('DATE:TIME', 2, $chan_x->getGedcomRecord(), '', false) . ':00', $match_x) && preg_match('/^\\d\\d:\\d\\d:\\d\\d/', get_gedcom_value('DATE:TIME', 2, $chan_y->getGedcomRecord(), '', false) . ':00', $match_y)) { return strcmp($match_x[0], $match_y[0]); } else { return 0; } } }
function print_td_person($n) { global $treeid, $PGV_IMAGE_DIR, $PGV_IMAGES, $pgv_lang; global $TEXT_DIRECTION, $MULTI_MEDIA, $SHOW_HIGHLIGHT_IMAGES, $USE_SILHOUETTE, $PGV_IMAGES; global $showids, $showthumbs; $text = ""; $pid = $treeid[$n]; if ($TEXT_DIRECTION == "ltr") { $title = $pgv_lang["indi_info"] . ": " . $pid; } else { $title = $pid . " :" . $pgv_lang["indi_info"]; } if ($pid) { $indi = Person::getInstance($pid); $name = $indi->getFullName(); $addname = $indi->getAddName(); if ($showthumbs && $MULTI_MEDIA && $SHOW_HIGHLIGHT_IMAGES) { if (showFact("OBJE", $pid)) { $object = find_highlighted_object($pid, PGV_GED_ID, $indi->gedrec); if (!empty($object)) { $whichFile = thumb_or_main($object); // Do we send the main image or a thumbnail? $size = findImageSize($whichFile); $class = "pedigree_image_portrait"; if ($size[0] > $size[1]) { $class = "pedigree_image_landscape"; } if ($TEXT_DIRECTION == "rtl") { $class .= "_rtl"; } // NOTE: IMG ID $imgsize = findImageSize($object["file"]); $imgwidth = $imgsize[0] + 50; $imgheight = $imgsize[1] + 150; if (PGV_USE_LIGHTBOX) { $text .= "<a href=\"" . $object["file"] . "\" rel=\"clearbox[general]\" rev=\"" . $object['mid'] . "::" . PGV_GEDCOM . "::" . PrintReady(htmlspecialchars($name, ENT_QUOTES, 'UTF-8')) . "\">" . "\n"; } else { $text .= "<a href=\"javascript:;\" onclick=\"return openImage('" . rawurlencode($object["file"]) . "',{$imgwidth}, {$imgheight});\">"; } $birth_date = $indi->getBirthDate(); $death_date = $indi->getDeathDate(); $text .= "<img id=\"box-{$pid}\" src=\"" . $whichFile . "\"vspace=\"0\" hspace=\"0\" class=\"{$class}\" alt =\"\" title=\"" . PrintReady(htmlspecialchars(strip_tags($name), ENT_QUOTES, 'UTF-8')) . " - " . strip_tags(html_entity_decode($birth_date->Display(false) . " - " . $death_date->Display(false), ENT_QUOTES, 'UTF-8')) . "\""; if ($imgsize) { $text .= " /></a>\n"; } else { $text .= " />\n"; } } else { if ($USE_SILHOUETTE && isset($PGV_IMAGES["default_image_U"]["other"])) { $class = "pedigree_image_portrait"; if ($TEXT_DIRECTION == "rtl") { $class .= "_rtl"; } $sex = $indi->getSex(); $text = "<img src=\""; if ($sex == 'F') { $text .= $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["default_image_F"]["other"]; } else { if ($sex == 'M') { $text .= $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["default_image_M"]["other"]; } else { $text .= $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["default_image_U"]["other"]; } } $text .= "\" class=\"" . $class . "\" border=\"none\" alt=\"\" />"; } } } else { if ($USE_SILHOUETTE && isset($PGV_IMAGES["default_image_U"]["other"])) { $class = "pedigree_image_portrait"; if ($TEXT_DIRECTION == "rtl") { $class .= "_rtl"; } $sex = $indi->getSex(); $text = "<img src=\""; if ($sex == 'F') { $text .= $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["default_image_F"]["other"]; } else { if ($sex == 'M') { $text .= $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["default_image_M"]["other"]; } else { $text .= $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["default_image_U"]["other"]; } } $text .= "\" class=\"" . $class . "\" border=\"none\" alt=\"\" />"; } } } $text .= "<a class=\"name1\" href=\"individual.php?pid={$pid}\" title=\"{$title}\"> "; $text .= PrintReady(htmlspecialchars(strip_tags($name), ENT_QUOTES, 'UTF-8')); if ($addname) { $text .= "<br />" . PrintReady($addname); } $text .= "</a>"; if ($showids) { $text .= " <span class='details1' "; if ($TEXT_DIRECTION == "ltr") { $text .= "dir=\"ltr\">"; } else { $text .= "dir=\"rtl\">"; } $text .= "(" . $pid . ")</span>"; } $text .= "<br />"; if ($indi->canDisplayDetails()) { $text .= "<span class='details1'>"; $text .= $indi->getBirthYear() . '-' . $indi->getDeathYear(); $age = GedcomDate::GetAgeYears($indi->getBirthDate(), $indi->getDeathDate()); if ($age) { $text .= " <span class=\"age\">" . PrintReady("({$age})") . "</span>"; } $text .= "</span>"; } } //Removed by BH causing problems with nicknames not printing //$text = unhtmlentities($text); // -- empty box if (empty($text)) { $text = " <br /> <br />"; } // -- box color $isF = ""; if ($n == 1) { if ($indi->getSex() == 'F') { $isF = "F"; } } elseif ($n % 2) { $isF = "F"; } // -- box size if ($n == 1) { echo "<td"; } else { echo "<td width='15%'"; } // -- print box content echo " class=\"person_box", $isF, "\" style=\"text-align:center; vertical-align:top;\" >"; echo $text; echo "</td>"; }
} if (isset($_FILES['thumbnail'])) { if (!move_uploaded_file($_FILES['thumbnail']['tmp_name'], $MEDIA_DIRECTORY . "thumbs/" . $_FILES['thumbnail']['name'])) { $error .= "\nERROR 19: " . $pgv_lang["upload_error"] . " " . file_upload_error_text($_FILES['thumbnail']['error']); } } if (!empty($error)) { addDebugLog($action . " {$error}"); print $error . "\n"; } else { addDebugLog($action . " SUCCESS"); print "SUCCESS\n"; } exit; case 'getchanges': $lastdate = new GedcomDate(safe_REQUEST($_REQUEST, 'date', '\\d\\d \\w\\w\\w \\d\\d\\d\\d')); if ($lastdate->isOK()) { if ($lastdate->MinJD() < server_jd() - 180) { addDebugLog($action . " ERROR 24: You cannot retrieve updates for more than 180 days."); print "ERROR 24: You cannot retrieve updates for more than 180 days.\n"; } else { print "SUCCESS\n"; foreach (get_recent_changes($lastdate->MinJD()) as $xref) { echo "{$xref}\n"; } } } else { addDebugLog($action . " ERROR 23: Invalid date parameter. Please use a valid date in the GEDCOM format DD MMM YYYY."); print "ERROR 23: Invalid date parameter. Please use a valid date in the GEDCOM format DD MMM YYYY.\n"; } exit;
/** * 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 /> <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 ' <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 ' <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 ' <input type="checkbox" name="SOUR_', $match, '"', $level2_checked, ' value="Y" />'; echo $factarray[$match]; } } } } if (strpos($bdm, 'M') !== false) { echo ' <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 ' <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 " "; 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 " "; 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; }
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 = " " . getRLM() . "({$row['id']})" . getRLM(); } else { $id = " ({$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); }
/** * 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; }
$xref = append_gedrec($gedrec, $update_CHAN); $link = "individual.php?pid={$xref}&show_changes=yes"; if ($xref) { echo "<br /><br />", $pgv_lang["update_successful"]; $gedrec = ""; if (!empty($famid)) { // Insert new child at the right place [ 1686246 ] $newchild = Person::getInstance($xref); $family = Family::getInstance($famid); if ($family->getUpdatedFamily()) { $family = $family->getUpdatedFamily(); } $gedrec = $family->gedrec; $done = false; foreach ($family->getChildren() as $key => $child) { if (GedcomDate::Compare($newchild->getEstimatedBirthDate(), $child->getEstimatedBirthDate()) < 0) { // new child is older : insert before $gedrec = str_replace("1 CHIL @" . $child->getXref() . "@", "1 CHIL @{$xref}@\n1 CHIL @" . $child->getXref() . "@", $gedrec); $done = true; break; } } // new child is the only one if (count($family->getChildren()) < 1) { $gedrec .= "\n1 CHIL @{$xref}@"; } else { if (!$done) { // new child is the youngest or undated : insert after $gedrec = str_replace("1 CHIL @" . $child->getXref() . "@", "1 CHIL @" . $child->getXref() . "@\n1 CHIL @{$xref}@", $gedrec); } }
} $ged_date = new GedcomDate("FROM {$cal} {$match[1]} TO {$cal} {$match[2]}"); $action = 'year'; } else { // advanced-year "decade/century wildcard" if (preg_match('/^(\\d+)(\\?+)$/', $year, $match)) { $y1 = $match[1] . str_replace('?', '0', $match[2]); $y2 = $match[1] . str_replace('?', '9', $match[2]); $ged_date = new GedcomDate("FROM {$cal} {$y1} TO {$cal} {$y2}"); $action = 'year'; } else { if ($year < 0) { $year = -$year . "B.C."; } // need BC to parse date $ged_date = new GedcomDate("{$cal} {$day} {$month} {$year}"); $year = $ged_date->date1->y; // need negative year for year entry field. } } $cal_date =& $ged_date->date1; $cal = urlencode($cal); // Invalid month? Pick a sensible one. if ($cal_date->CALENDAR_ESCAPE() == '@#DHEBREW@' && $cal_date->m == 7 && $cal_date->y != 0 && !$cal_date->IsLeapYear()) { $cal_date->m = 6; } // Fill in any missing bits with todays date $today = $cal_date->Today(); if ($cal_date->d == 0) { $cal_date->d = $today->d; }
/** * returns a marriage anniversary iCalendar event for a family marriage. * If there is no date for the event, or either of the spouses is not alive, * no iCalendar event will be returned * @param Family $family the Family Object used as the source of the marriage anniversary info * @return the marriage anniversary iCalendar event. */ function getFamilyAnniversaryIcalEvent($family) { $anniversaryDate = $family->getMarriageDate(); if ($anniversaryDate == "") { return; } if ($family->isDivorced()) { return; } $wife = $family->getWife(); $husband = $family->getHusband(); if ($wife->isDead() || $husband->isDead()) { return; } $anniversaryDate = new GedcomDate($anniversaryDate); $summary = "Anniversary of " . $husband->getFullName() . " and " . $wife->getFullName(); $place = $family->getMarriagePlace(); $description = "Married on " . $anniversaryDate->Display(false) . ($place == "" ? "" : "in " . $place) . "\n" . encode_url($family->getAbsoluteLinkUrl()); $iCalRecord = getIcalRecord($anniversaryDate, $summary, $description, encode_url($family->getAbsoluteLinkUrl())); return $iCalRecord; }
static function CompareDeathDate($x, $y) { return GedcomDate::Compare($x->getDeathDate(), $y->getDeathDate()); }
function compare_facts_date($arec, $brec) { if (is_array($arec)) { $arec = $arec[1]; } if (is_array($brec)) { $brec = $brec[1]; } // If either fact is undated, the facts sort equally. if (!preg_match("/2 _?DATE (.*)/", $arec, $amatch) || !preg_match("/2 _?DATE (.*)/", $brec, $bmatch)) { if (preg_match('/2 _SORT (\\d+)/', $arec, $match1) && preg_match('/2 _SORT (\\d+)/', $brec, $match2)) { return $match1[1] - $match2[1]; } return 0; } $adate = new GedcomDate($amatch[1]); $bdate = new GedcomDate($bmatch[1]); // If either date can't be parsed, don't sort. if (!$adate->isOK() || !$bdate->isOK()) { if (preg_match('/2 _SORT (\\d+)/', $arec, $match1) && preg_match('/2 _SORT (\\d+)/', $brec, $match2)) { return $match1[1] - $match2[1]; } return 0; } // Remember that dates can be ranges and overlapping ranges sort equally. $amin = $adate->MinJD(); $bmin = $bdate->MinJD(); $amax = $adate->MaxJD(); $bmax = $bdate->MaxJD(); // BEF/AFT XXX sort as the day before/after XXX if ($adate->qual1 == 'BEF') { $amin = $amin - 1; $amax = $amin; } else { if ($adate->qual1 == 'AFT') { $amax = $amax + 1; $amin = $amax; } } if ($bdate->qual1 == 'BEF') { $bmin = $bmin - 1; $bmax = $bmin; } else { if ($bdate->qual1 == 'AFT') { $bmax = $bmax + 1; $bmin = $bmax; } } if ($amax < $bmin) { return -1; } else { if ($amin > $bmax) { return 1; } else { //-- ranged date... take the type of fact sorting into account $factWeight = 0; if (preg_match('/2 _SORT (\\d+)/', $arec, $match1) && preg_match('/2 _SORT (\\d+)/', $brec, $match2)) { $factWeight = $match1[1] - $match2[1]; } //-- fact is prefered to come before, so compare using the minimum ranges if ($factWeight < 0 && $amin != $bmin) { return $amin - $bmin; } else { if ($factWeight > 0 && $bmax != $amax) { //-- fact is prefered to come after, so compare using the max of the ranges return $bmax - $amax; } else { //-- facts are the same or the ranges don't give enough info, so use the average of the range $aavg = ($amin + $amax) / 2; $bavg = ($bmin + $bmax) / 2; if ($aavg < $bavg) { return -1; } else { if ($aavg > $bavg) { return 1; } else { return $factWeight; } } } } return 0; } } }
function print_yahrzeit($block = true, $config = '', $side, $index) { global $pgv_lang, $factarray, $SHOW_ID_NUMBERS, $ctype, $TEXT_DIRECTION; global $PGV_IMAGE_DIR, $PGV_IMAGES, $PGV_BLOCKS; global $DAYS_TO_SHOW_LIMIT, $SHOW_MARRIED_NAMES, $SERVER_URL; $block = true; // Always restrict this block's height if (empty($config)) { $config = $PGV_BLOCKS['print_yahrzeit']['config']; } if (empty($config['infoStyle'])) { $config['infoStyle'] = 'style2'; } if (empty($config['allowDownload'])) { $config['allowDownload'] = 'yes'; } if (empty($config['days'])) { $config['days'] = $DAYS_TO_SHOW_LIMIT; } if ($config['days'] < 1) { $config['days'] = 1; } if ($config['days'] > $DAYS_TO_SHOW_LIMIT) { $config['days'] = $DAYS_TO_SHOW_LIMIT; } $startjd = server_jd(); $endjd = $startjd + max(min($config['days'], 1), $DAYS_TO_SHOW_LIMIT) - 1; if (!PGV_USER_ID) { $allowDownload = "no"; } $id = "yahrzeit"; $title = print_help_link('yahrzeit_help', 'qm', '', false, true); if ($PGV_BLOCKS['print_yahrzeit']['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['yahrzeit_block']; $content = ""; // The standard anniversary rules cover most of the Yahrzeit rules, we just // need to handle a few special cases. // Fetch normal anniversaries... $yahrzeits = array(); $hidden = 0; for ($jd = $startjd - 1; $jd <= $endjd + 30; ++$jd) { foreach (get_anniversary_events($jd, 'DEAT _YART') as $fact) { // Extract hebrew dates only if ($fact['date']->date1->CALENDAR_ESCAPE() == '@#DHEBREW@' && $fact['date']->MinJD() == $fact['date']->MaxJD()) { // Apply privacy if (displayDetailsById($fact['id']) && showFactDetails($fact['fact'], $fact['id']) && !FactViewRestricted($fact['id'], $fact['factrec'])) { $yahrzeits[] = $fact; } else { ++$hidden; } } } } // ...then adjust dates foreach ($yahrzeits as $key => $yahrzeit) { if (strpos('1 DEAT', $yahrzeit['factrec']) !== false) { // Just DEAT, not _YART $today = new JewishDate($yahrzeit['jd']); $hd = $yahrzeit['date']->MinDate(); $hd1 = new JewishDate($hd); $hd1->y += 1; $hd1->SetJDFromYMD(); // Special rules. See http://www.hebcal.com/help/anniv.html // Everything else is taken care of by our standard anniversary rules. if ($hd->d == 30 && $hd->m == 2 && $hd->y != 0 && $hd1->DaysInMonth() < 30) { // 30 CSH // Last day in CSH $yahrzeit[$key]['jd'] = JewishDate::YMDtoJD($today->y, 3, 1) - 1; } if ($hd->d == 30 && $hd->m == 3 && $hd->y != 0 && $hd1->DaysInMonth() < 30) { // 30 KSL // Last day in KSL $yahrzeit[$key]['jd'] = JewishDate::YMDtoJD($today->y, 4, 1) - 1; } if ($hd->d == 30 && $hd->m == 6 && $hd->y != 0 && $today->DaysInMonth() < 30 && !$today->IsLeapYear()) { // 30 ADR // Last day in SHV $yahrzeit[$key]['jd'] = JewishDate::YMDtoJD($today->y, 6, 1) - 1; } } } switch ($config['infoStyle']) { case "style1": // List style foreach ($yahrzeits as $yahrzeit) { if ($yahrzeit['jd'] >= $startjd && $yahrzeit['jd'] < $startjd + $config['days']) { $ind = person::GetInstance($yahrzeit['id']); //@@ $content .= "<a href=\"".encode_url($ind->getLinkUrl())."\" class=\"list_item name2\">".$ind->getFullName()."</a>".$ind->getSexImage(); $content .= "<a href=\"" . encode_url($ind->getLinkUrl()) . "\" class=\"list_item name2\">" . PrintReady($ind->getFullName()) . "</a>" . $ind->getSexImage(); $content .= "<div class=\"indent\">"; $content .= $yahrzeit['date']->Display(true); $content .= ', ' . str_replace("#year_var#", $yahrzeit['anniv'], $pgv_lang["year_anniversary"]); $content .= "</div>"; } } break; case "style2": // Table style 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['NAME']}</th>"; $content .= "<th style=\"display:none\">GIVN</th>"; $content .= "<th class=\"list_label\">{$factarray['DATE']}</th>"; $content .= "<th class=\"list_label\"><img src=\"./images/reminder.gif\" alt=\"{$pgv_lang['anniversary']}\" title=\"{$pgv_lang['anniversary']}\" border=\"0\" /></th>"; $content .= "<th class=\"list_label\">{$factarray['_YART']}</th>"; $content .= "</tr>"; $count = 0; foreach ($yahrzeits as $yahrzeit) { if ($yahrzeit['jd'] >= $startjd && $yahrzeit['jd'] < $startjd + $config['days']) { ++$count; $ind = person::GetInstance($yahrzeit['id']); $content .= "<tr class=\"vevent\">"; // hCalendar:vevent // Record name(s) $name = $ind->getFullName(); $url = $ind->getLinkUrl(); $content .= "<td class=\"list_value_wrap\" align=\"" . get_align($name) . "\">"; $content .= "<a href=\"" . encode_url($ind->getLinkUrl()) . "\" class=\"list_item name2\" dir=\"" . $TEXT_DIRECTION . "\">" . PrintReady($name) . "</a>"; $content .= $ind->getSexImage(); $addname = $ind->getAddName(); if ($addname) { $content .= "<br /><a href=\"" . encode_url($url) . "\" class=\"list_item\">" . PrintReady($addname) . "</a>"; } $content .= "</td>"; // GIVN for sorting $content .= "<td style=\"display:none\">"; $exp = explode(",", str_replace('<', ',', $name) . ","); $content .= $exp[1]; $content .= "</td>"; $today = new JewishDate($yahrzeit['jd']); $td = new GedcomDate($today->Format('@ A O E')); // death/yahrzeit event date $content .= "<td class=\"list_value_wrap\">"; $content .= "<a name='{$yahrzeit['jd']}'>" . $yahrzeit['date']->Display(true, NULL, array()) . "</a>"; $content .= "</td>"; // Anniversary $content .= "<td class=\"list_value_wrap rela\">"; $anniv = $yahrzeit['anniv']; if ($anniv == 0) { $content .= '<a name="0"> </a>'; } else { $content .= "<a name=\"{$anniv}\">{$anniv}</a>"; } if ($config['allowDownload'] == 'yes') { // hCalendar:dtstart and hCalendar:summary //TODO does this work?? $content .= "<abbr class=\"dtstart\" title=\"" . strip_tags($yahrzeit['date']->Display(false, 'Ymd', array())) . "\"></abbr>"; $content .= "<abbr class=\"summary\" title=\"" . $pgv_lang["anniversary"] . " #{$anniv} " . $factarray[$yahrzeit['fact']] . " : " . PrintReady(strip_tags($ind->getFullName())) . "\"></abbr>"; } // upcomming yahrzeit dates $content .= "<td class=\"list_value_wrap\">"; $content .= "<a href=\"" . $url . "\" class=\"list_item url\">" . $td->Display(true, NULL, array('gregorian')) . "</a>"; // hCalendar:url $content .= " </td>"; $content .= "</tr>"; } } // table footer $content .= "<tr class=\"sortbottom\">"; $content .= "<td class=\"list_label\">"; $content .= '<a href="javascript:;" onclick="sortByOtherCol(this,1)"><img src="images/topdown.gif" alt="" border="0" /> ' . $factarray["GIVN"] . '</a><br />'; $content .= $pgv_lang["total_names"] . ": " . $count; if ($hidden) { $content .= "<br /><span class=\"warning\">{$pgv_lang['hidden']} : {$hidden}</span>"; } $content .= "</td>"; $content .= "<td style=\"display:none\">GIVN</td>"; $content .= "<td>"; if ($config['allowDownload'] == 'yes') { $uri = $SERVER_URL . basename($_SERVER['REQUEST_URI']); global $whichFile; $whichFile = 'hCal-events.ics'; $alt = print_text('download_file', 0, 1); if (count($yahrzeits)) { $content .= "<a href=\"http://feeds.technorati.com/events/{$uri}\"><img src=\"images/hcal.png\" border=\"0\" alt=\"{$alt}\" title=\"{$alt}\" /></a>"; } } $content .= '</td><td> </td><td> </td></tr>'; $content .= '</table>'; break; } global $THEME_DIR; if ($block) { require $THEME_DIR . 'templates/block_small_temp.php'; } else { require $THEME_DIR . 'templates/block_main_temp.php'; } }
static function GetAgeGedcom($d1, $d2 = null) { if (is_null($d2)) { return $d1->date1->GetAge(true, client_jd()); } else { // If dates overlap, then can't calculate age. if (GedcomDate::Compare($d1, $d2)) { return $d1->date1->GetAge(true, $d2->MinJD()); } if (GedcomDate::Compare($d1, $d2) == 0 && $d1->date1->minJD == $d2->MinJD()) { return '0d'; } else { return ''; } } }
/** * print parents informations * @param Family family * @param Array people * @param String family type * @return html table rows */ function printParentsRows(&$family, &$people, $type) { global $personcount, $pgv_changes, $pgv_lang, $factarray; global $PGV_IMAGE_DIR, $PGV_IMAGES; global $lang_short_cut, $LANGUAGE; $elderdate = ""; //-- new father/husband $styleadd = ""; if (isset($people["newhusb"])) { $styleadd = "red"; ?> <tr> <td class="facts_labelblue"><?php print $people["newhusb"]->getLabel(); ?> </td> <td class="<?php print $this->getPersonStyle($people["newhusb"]); ?> "> <?php print_pedigree_person($people["newhusb"]->getXref(), 2, !$this->isPrintPreview(), 0, $personcount++); ?> </td> </tr> <?php $elderdate = $people["newhusb"]->getBirthDate(); } //-- father/husband if (isset($people["husb"])) { ?> <tr> <td class="facts_label<?php print $styleadd; ?> "><?php print $people["husb"]->getLabel(); ?> </td> <td class="<?php print $this->getPersonStyle($people["husb"]); ?> "> <?php print_pedigree_person($people["husb"]->getXref(), 2, !$this->isPrintPreview(), 0, $personcount++); ?> </td> </tr> <?php $elderdate = $people["husb"]->getBirthDate(); } //-- missing father if ($type == "parents" && !isset($people["husb"]) && !isset($people["newhusb"])) { if (!$this->isPrintPreview() && PGV_USER_CAN_EDIT && $this->indi->canDisplayDetails()) { ?> <tr> <td class="facts_label"><?php print $pgv_lang["add_father"]; ?> </td> <td class="facts_value"><?php print_help_link("edit_add_parent_help", "qm"); ?> <a href="javascript <?php print $pgv_lang["add_father"]; ?> " onclick="return addnewparentfamily('<?php print $this->pid; ?> ', 'HUSB', '<?php print $family->getXref(); ?> ');"><?php print $pgv_lang["add_father"]; ?> </a></td> </tr> <?php } } //-- missing husband if ($type == "spouse" && $this->indi->equals($people["wife"]) && !isset($people["husb"]) && !isset($people["newhusb"])) { if (!$this->isPrintPreview() && PGV_USER_CAN_EDIT && $this->indi->canDisplayDetails()) { ?> <tr> <td class="facts_label"><?php print $pgv_lang["add_husb"]; ?> </td> <td class="facts_value"><a href="javascript:;" onclick="return addnewspouse('<?php print $family->getXref(); ?> ', 'HUSB');"><?php print $pgv_lang["add_husb_to_family"]; ?> </a></td> </tr> <?php } } //-- new mother/wife $styleadd = ""; if (isset($people["newwife"])) { $styleadd = "red"; ?> <tr> <td class="facts_labelblue"><?php print $people["newwife"]->getLabel($elderdate); ?> </td> <td class="<?php print $this->getPersonStyle($people["newwife"]); ?> "> <?php print_pedigree_person($people["newwife"]->getXref(), 2, !$this->isPrintPreview(), 0, $personcount++); ?> </td> </tr> <?php } //-- mother/wife if (isset($people["wife"])) { ?> <tr> <td class="facts_label<?php print $styleadd; ?> "><?php print $people["wife"]->getLabel($elderdate); ?> </td> <td class="<?php print $this->getPersonStyle($people["wife"]); ?> "> <?php print_pedigree_person($people["wife"]->getXref(), 2, !$this->isPrintPreview(), 0, $personcount++); ?> </td> </tr> <?php } //-- missing mother if ($type == "parents" && !isset($people["wife"]) && !isset($people["newwife"])) { if (!$this->isPrintPreview() && PGV_USER_CAN_EDIT && $this->indi->canDisplayDetails()) { ?> <tr> <td class="facts_label"><?php print $pgv_lang["add_mother"]; ?> </td> <td class="facts_value"><?php print_help_link("edit_add_parent_help", "qm"); ?> <a href="javascript:;" onclick="return addnewparentfamily('<?php print $this->pid; ?> ', 'WIFE', '<?php print $family->getXref(); ?> ');"><?php print $pgv_lang["add_mother"]; ?> </a></td> </tr> <?php } } //-- missing wife if ($type == "spouse" && $this->indi->equals($people["husb"]) && !isset($people["wife"]) && !isset($people["newwife"])) { if (!$this->isPrintPreview() && PGV_USER_CAN_EDIT && $this->indi->canDisplayDetails()) { ?> <tr> <td class="facts_label"><?php print $pgv_lang["add_wife"]; ?> </td> <td class="facts_value"><a href="javascript:;" onclick="return addnewspouse('<?php print $family->getXref(); ?> ', 'WIFE');"><?php print $pgv_lang["add_wife_to_family"]; ?> </a></td> </tr> <?php } } //-- marriage row if ($family->getMarriageRecord() != "" || PGV_USER_CAN_EDIT) { $styleadd = ""; $date = $family->getMarriageDate(); $place = $family->getMarriagePlace(); $famid = $family->getXref(); if (!$date && $this->show_changes && isset($pgv_changes[$famid . "_" . $GEDCOM])) { $famrec = find_updated_record($famid); $marrrec = get_sub_record(1, "1 MARR", $famrec); if ($marrrec != $family->getMarriageRecord()) { $date = new GedcomDate(get_gedcom_value("MARR:DATE", 1, $marrrec, '', false)); $place = get_gedcom_value("MARR:PLAC", 1, $marrrec, '', false); $styleadd = "blue"; } } ?> <tr> <td class="facts_label"><br /> </td> <td class="facts_value<?php print $styleadd; ?> "> <?php //echo "<span class=\"details_label\">".$factarray["NCHI"].": </span>".$family->getNumberOfChildren()."<br />"; ?> <?php if ($date && $date->isOK() || $place) { $marr_type = "MARR_" . strtoupper($family->getMarriageType()); if (isset($factarray[$marr_type])) { echo "<span class=\"details_label\">" . $factarray[$marr_type] . ": </span>"; } else { echo "<span class=\"details_label\">" . $factarray["MARR"] . ": </span>" . $family->getMarriageType(); } if ($date) { echo $date->Display(false); if (!empty($place)) { echo ' -- '; } } if (!empty($place)) { echo $place; } } else { if (get_sub_record(1, "1 _NMR", find_family_record($famid))) { // Allow special processing for different languages $func = "fact_NMR_localisation_{$lang_short_cut[$LANGUAGE]}"; if (function_exists($func)) { // Localise the _NMR facts $func("_NMR", $famid); } echo $factarray["_NMR"]; } else { if (get_sub_record(1, "1 _NMAR", find_family_record($famid))) { // Allow special processing for different languages $func = "fact_NMR_localisation_{$lang_short_cut[$LANGUAGE]}"; if (function_exists($func)) { // Localise the _NMR facts $func("_NMAR", $famid); } echo $factarray["_NMAR"]; } else { if ($family->getMarriageRecord() == "" && PGV_USER_CAN_EDIT) { print "<a href=\"#\" onclick=\"return add_new_record('" . $famid . "', 'MARR');\">" . $pgv_lang['add_marriage'] . "</a>"; } else { $factdetail = explode(' ', trim($family->getMarriageRecord())); if ($family->getMarriageType()) { $marr_type = "MARR_" . strtoupper($family->getMarriageType()); } else { $marr_type = "MARR"; } if (isset($factarray[$marr_type])) { if (isset($factdetail)) { if (count($factdetail) == 3) { if (strtoupper($factdetail[2]) == "Y") { echo "<span class=\"details_label\">" . $factarray[$marr_type] . ": </span>" . $pgv_lang["yes"]; } else { if (strtoupper($factdetail[2]) == "N") { echo "<span class=\"details_label\">" . $factarray[$marr_type] . ": </span>" . $pgv_lang["no"]; } } } } } else { echo "<span class=\"details_label\">" . $factarray["MARR"] . ": </span>" . $family->getMarriageType(); } } } } } ?> </td> </tr> <?php } }
/** * 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; }
function print_time_fact($event) { global $basexoffset, $baseyoffset, $factcount, $TEXT_DIRECTION; global $factarray, $pgv_lang, $lang_short_cut, $LANGUAGE, $PGV_IMAGE_DIR, $PGV_IMAGES, $SHOW_PEDIGREE_PLACES, $placements; global $familyfacts, $GEDCOM; /* @var $event Event */ $factrec = $event->getGedComRecord(); $fact = $event->getTag(); $desc = $event->getDetail(); if ($fact == "EVEN" || $fact == "FACT") { $fact = $event->getType(); } //-- check if this is a family fact $famid = $event->getFamilyId(); if ($famid != null) { //-- if we already showed this family fact then don't print it if (isset($familyfacts[$famid . $fact]) && $familyfacts[$famid . $fact] != $event->temp) { return; } $familyfacts[$famid . $fact] = $event->temp; } $gdate = $event->getDate(); $date = $gdate->MinDate(); $date = $date->convert_to_cal('gregorian'); $year = $date->y; $month = max(1, $date->m); $day = max(1, $date->d); $xoffset = $basexoffset + 22; $yoffset = $baseyoffset + ($year - $this->baseyear) * $this->scale - $this->scale; $yoffset = $yoffset + $month / 12 * $this->scale; $yoffset = $yoffset + $day / 30 * ($this->scale / 12); $yoffset = floor($yoffset); $place = round($yoffset / $this->bheight); $i = 1; $j = 0; $tyoffset = 0; while (isset($placements[$place])) { if ($i == $j) { $tyoffset = $this->bheight * $i; $i++; } else { $tyoffset = -1 * $this->bheight * $j; $j++; } $place = round(($yoffset + $tyoffset) / $this->bheight); } $yoffset += $tyoffset; $xoffset += abs($tyoffset); $placements[$place] = $yoffset; print "\n\t\t<div id=\"fact{$factcount}\" style=\"position:absolute; " . ($TEXT_DIRECTION == "ltr" ? "left: " . $xoffset : "right: " . $xoffset) . "px; top:" . $yoffset . "px; font-size: 8pt; height: " . $this->bheight . "px; \" onmousedown=\"factMD(this, '" . $factcount . "', " . ($yoffset - $tyoffset) . ");\">\n"; print "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" style=\"cursor: hand;\"><tr><td>\n"; print "<img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["hline"]["other"] . "\" name=\"boxline{$factcount}\" id=\"boxline{$factcount}\" height=\"3\" align=\"left\" hspace=\"0\" width=\"10\" vspace=\"0\" alt=\"\" style=\"padding-"; if ($TEXT_DIRECTION == "ltr") { print "left"; } else { print "right"; } print ": 3px;\" />\n"; $col = $event->temp % 6; print "</td><td valign=\"top\" class=\"person" . $col . "\">\n"; if (count($this->pids) > 6) { print $event->getParentObject()->getFullName() . " - "; } $indi = $event->getParentObject(); if ($fact == "_AKAN" || $fact == "_AKA" || $fact == "ALIA" || $fact == "_INTE") { // Allow special processing for different languages $func = "fact_AKA_localisation_{$lang_short_cut[$LANGUAGE]}"; if (function_exists($func) && get_class($indi) == "Person") { // Localise the facts $func($fact, $indi->getXref()); print $factarray[$fact]; } else { print $event->getLabel(); } } else { print $event->getLabel(); } print " -- "; if (get_class($indi) == "Person") { print format_fact_date($event); } if (get_class($indi) == "Family") { print $gdate->Display(false); $family = $indi; $husbid = $family->getHusbId(); $wifeid = $family->getWifeId(); //-- Retrieve husband and wife age for ($p = 0; $p < count($this->pids); $p++) { if ($this->pids[$p] == $husbid) { $husb = $family->getHusband(); if (is_null($husb)) { $husb = new Person(''); } $hdate = $husb->getBirthDate(); if ($hdate->isOK()) { $ageh = get_age_at_event(GedcomDate::GetAgeGedcom($hdate, $gdate), false); } } else { if ($this->pids[$p] == $wifeid) { $wife = $family->getWife(); if (is_null($wife)) { $wife = new Person(''); } $wdate = $wife->getBirthDate(); if ($wdate->isOK()) { $agew = get_age_at_event(GedcomDate::GetAgeGedcom($wdate, $gdate), false); } } } } if (!empty($ageh) && $ageh > 0) { if (empty($agew)) { print '<span class="age"> ' . PrintReady("({$pgv_lang["age"]} {$ageh})") . '</span>'; } else { print '<span class="age"> ' . PrintReady("({$pgv_lang["husb_age"]} {$ageh},") . ' '; } } if (!empty($agew) && $agew > 0) { if (empty($ageh)) { print '<span class="age"> ' . PrintReady("({$pgv_lang["age"]} {$agew})") . '</span>'; } else { print PrintReady("{$pgv_lang["wife_age"]} {$agew})") . '</span>'; } } } print " " . PrintReady($desc); if ($SHOW_PEDIGREE_PLACES > 0) { $place = $event->getPlace(); if ($place != null) { if ($desc != null) { print " - "; } $plevels = explode(',', $place); for ($plevel = 0; $plevel < $SHOW_PEDIGREE_PLACES; $plevel++) { if (!empty($plevels[$plevel])) { if ($plevel > 0) { print ", "; } print PrintReady($plevels[$plevel]); } } } } //-- print spouse name for marriage events $spouse = Person::getInstance($event->getSpouseId()); if ($spouse) { for ($p = 0; $p < count($this->pids); $p++) { if ($this->pids[$p] == $spouse->getXref()) { break; } } if ($p == count($this->pids)) { $p = $event->temp; } $col = $p % 6; if ($spouse->getXref() != $this->pids[$p]) { echo ' <a href="', $spouse->getLinkUrl(), '">', $spouse->getFullName(), '</a>'; } else { $ct = preg_match("/2 _PGVFS @(.*)@/", $factrec, $match); if ($ct > 0) { print " <a href=\"" . encode_url("family.php?famid={$match[1]}&ged={$GEDCOM}") . "\">"; if (displayDetailsById($match[1]) || showLivingNameById($match[1])) { print $event->getParentObject()->getFullName(); } else { print $pgv_lang["private"]; } print "</a>"; } } } print "</td></tr></table>\n"; print "</div>"; if ($TEXT_DIRECTION == 'ltr') { $img = "dline2"; $ypos = "0%"; } else { $img = "dline"; $ypos = "100%"; } $dyoffset = $yoffset - $tyoffset + $this->bheight / 3; if ($tyoffset < 0) { $dyoffset = $yoffset + $this->bheight / 3; if ($TEXT_DIRECTION == 'ltr') { $img = "dline"; $ypos = "100%"; } else { $img = "dline2"; $ypos = "0%"; } } //-- print the diagnal line print "\n\t\t<div id=\"dbox{$factcount}\" style=\"position:absolute; " . ($TEXT_DIRECTION == "ltr" ? "left: " . ($basexoffset + 25) : "right: " . ($basexoffset + 25)) . "px; top:" . $dyoffset . "px; font-size: 8pt; height: " . abs($tyoffset) . "px; width: " . abs($tyoffset) . "px;"; print " background-image: url('" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES[$img]["other"] . "');"; print " background-position: 0% {$ypos}; \" >\n"; print "</div>\n"; }
function advancedSearch($justSql = false, $table = "individuals", $prefix = "i") { global $TBLPREFIX, $gedcom_record_cache; DMsoundex("", "opencache"); $this->myindilist = array(); $fct = count($this->fields); if ($fct == 0) { return; } $namesTable = false; $datesTable = false; $placesTable = false; $famsTable = false; $famcTable = false; $sql = ''; if ($justSql) { $sqlfields = "SELECT DISTINCT {$prefix}_id, {$prefix}_file"; } else { $sqlfields = "SELECT i_id, i_gedcom, i_isdead, i_file, i_sex"; } $sqltables = " FROM " . $TBLPREFIX . $table; $sqlwhere = " WHERE " . $prefix . "_file=" . PGV_GED_ID; $keepfields = $this->fields; for ($i = 0; $i < $fct; $i++) { $field = $this->fields[$i]; if (empty($field)) { continue; } $value = ''; if (isset($this->values[$i])) { $value = $this->values[$i]; } if (empty($value)) { continue; } $parts = preg_split("/:/", $field); //-- handle names seperately if ($parts[0] == "NAME") { // The pgv_name table contains both names and soundex values if (!$namesTable) { $sqltables .= " JOIN {$TBLPREFIX}name ON (i_file=n_file AND i_id=n_id) "; $namesTable = true; } switch (end($parts)) { case 'SDX_STD': $sdx = explode(':', soundex_std($value)); foreach ($sdx as $k => $v) { if ($parts[1] == 'GIVN') { $sdx[$k] = 'n_soundex_givn_std ' . PGV_DB::$LIKE . " '%{$v}%'"; } else { $sdx[$k] = 'n_soundex_surn_std ' . PGV_DB::$LIKE . " '%{$v}%'"; } } $sqlwhere .= ' AND (' . implode(' OR ', $sdx) . ')'; break; case 'SDX': // SDX uses DM by default. // SDX uses DM by default. case 'SDX_DM': $sdx = explode(':', soundex_dm($value)); foreach ($sdx as $k => $v) { if ($parts[1] == 'GIVN') { $sdx[$k] = 'n_soundex_givn_dm ' . PGV_DB::$LIKE . " '%{$v}%'"; } else { $sdx[$k] = 'n_soundex_surn_dm ' . PGV_DB::$LIKE . " '%{$v}%'"; } } $sqlwhere .= ' AND (' . implode(' OR ', $sdx) . ')'; break; case 'EXACT': // Exact match. switch ($parts[1]) { case 'GIVN': // Allow for exact match on multiple given names. $sqlwhere .= ' AND (n_givn ' . PGV_DB::$LIKE . " " . PGV_DB::quote($value) . " OR n_givn " . PGV_DB::$LIKE . " " . PGV_DB::quote("{$value} %") . " OR n_givn " . PGV_DB::$LIKE . " " . PGV_DB::quote("% {$value}") . " OR n_givn " . PGV_DB::$LIKE . " " . PGV_DB::quote("% {$value} %") . ")"; break; case 'SURN': $sqlwhere .= ' AND n_surname ' . PGV_DB::$LIKE . " " . PGV_DB::quote($value); break; default: $sqlwhere .= ' AND n_full ' . PGV_DB::$LIKE . " " . PGV_DB::quote($value); break; } break; case 'BEGINS': // "Begins with" match. switch ($parts[1]) { case 'GIVN': // Allow for match on start of multiple given names $sqlwhere .= ' AND (n_givn ' . PGV_DB::$LIKE . " " . PGV_DB::quote("{$value}%") . " OR n_givn " . PGV_DB::$LIKE . " " . PGV_DB::quote("% {$value}%") . ")"; break; case 'SURN': $sqlwhere .= ' AND n_surname ' . PGV_DB::$LIKE . " " . PGV_DB::quote("{$value}%"); break; default: $sqlwhere .= ' AND n_full ' . PGV_DB::$LIKE . " " . PGV_DB::quote("{$value}%"); break; } break; case 'CONTAINS': default: // Partial match. switch ($parts[1]) { case 'GIVN': $sqlwhere .= ' AND n_givn ' . PGV_DB::$LIKE . " " . PGV_DB::quote("%{$value}%"); break; case 'SURN': $sqlwhere .= ' AND n_surname ' . PGV_DB::$LIKE . " " . PGV_DB::quote("%{$value}%"); break; default: $sqlwhere .= ' AND n_full ' . PGV_DB::$LIKE . " " . PGV_DB::quote("%{$value}%"); break; } break; } } else { if (isset($parts[1]) && $parts[1] == "DATE") { if (!$datesTable) { $sqltables .= ", " . $TBLPREFIX . "dates"; $sqlwhere .= " AND " . $prefix . "_file=d_file AND " . $prefix . "_id=d_gid"; $datesTable = true; } $sqlwhere .= " AND (d_fact='" . $parts[0] . "'"; $date = new GedcomDate($value); if ($date->isOK()) { $jd1 = $date->date1->minJD; if ($date->date2) { $jd2 = $date->date2->maxJD; } else { $jd2 = $date->date1->maxJD; } if (!empty($this->plusminus[$i])) { $adjd = $this->plusminus[$i] * 365; //print $jd1.":".$jd2.":".$adjd; $jd1 = $jd1 - $adjd; $jd2 = $jd2 + $adjd; } $sqlwhere .= " AND d_julianday1>=" . $jd1 . " AND d_julianday2<=" . $jd2; } $sqlwhere .= ") "; } else { if (isset($parts[1]) && $parts[1] == "PLAC") { if (!$placesTable) { $sqltables .= ", " . $TBLPREFIX . "places, " . $TBLPREFIX . "placelinks"; $sqlwhere .= " AND " . $prefix . "_file=p_file AND p_file=pl_file AND " . $prefix . "_id=pl_gid AND pl_p_id=p_id"; $placesTable = true; } //-- soundex search //if (end($parts)=="SDX") { $places = preg_split("/[, ]+/", $value); $parr = array(); for ($j = 0; $j < count($places); $j++) { $parr[$j] = DMsoundex($places[$j]); } $sqlwhere .= " AND ("; $fnc = 0; $field = "p_dm_soundex"; foreach ($parr as $name) { foreach ($name as $name1) { if ($fnc > 0) { $sqlwhere .= " OR "; } $fnc++; $sqlwhere .= $field . " " . PGV_DB::$LIKE . " " . PGV_DB::quote("%{$name1}%"); } } $sqlwhere .= ") "; //} } else { if ($parts[0] == 'FAMS') { if (!$famsTable) { $sqltables .= ", " . $TBLPREFIX . "families as FAMS"; $sqlwhere .= " AND i_file=FAMS.f_file"; $famsTable = true; } //-- alter the fields and recurse to generate a subquery for spouse/parent fields $oldfields = $this->fields; for ($j = 0; $j < $fct; $j++) { //-- if it doesn't start with FAMS or FAMC then remove that field if (preg_match("/^" . $parts[0] . ":/", $this->fields[$j]) == 0) { $this->fields[$j] = ''; } else { $this->fields[$j] = preg_replace("/^" . $parts[0] . ":/", "", $this->fields[$j]); } } $sqlwhere .= " AND (FAMS.f_husb=i_id OR FAMS.f_wife=i_id)"; $subsql = $this->advancedSearch(true, "families", "f"); $sqlwhere .= " AND ROW(FAMS.f_id, FAMS.f_file) IN (" . $subsql . ")"; $this->fields = $oldfields; //-- remove all of the fam fields so they don't show up again for ($j = 0; $j < $fct; $j++) { //-- if it does start with FAMS or FAMC then remove that field if (preg_match("/^" . $parts[0] . ":/", $this->fields[$j]) > 0) { $this->fields[$j] = ''; } } } else { if ($parts[0] == 'FAMC') { if (!$famcTable) { $sqltables .= ", " . $TBLPREFIX . "families as FAMC"; $sqlwhere .= " AND i_file=FAMC.f_file"; $famcTable = true; } //-- alter the fields and recurse to generate a subquery for spouse/parent fields $oldfields = $this->fields; for ($j = 0; $j < $fct; $j++) { //-- if it doesn't start with FAMS or FAMC then remove that field if (preg_match("/^" . $parts[0] . ":/", $this->fields[$j]) == 0) { $this->fields[$j] = ''; } else { $this->fields[$j] = preg_replace("/^" . $parts[0] . ":/", "", $this->fields[$j]); } } $sqlwhere .= " AND (FAMC.f_chil " . PGV_DB::$LIKE . " CONCAT('%',i_id,';%'))"; $subsql = $this->advancedSearch(true, "families", "f"); $sqlwhere .= " AND ROW(FAMC.f_id, FAMC.f_file) IN (" . $subsql . ")"; $this->fields = $oldfields; //-- remove all of the fam fields so they don't show up again for ($j = 0; $j < $fct; $j++) { //-- if it does start with FAMS or FAMC then remove that field if (preg_match("/^" . $parts[0] . ":/", $this->fields[$j]) > 0) { $this->fields[$j] = ''; } } } else { if ($parts[0] == 'HUSB' || $parts[0] == 'WIFE') { if (!$famsTable) { $sqltables .= ", " . $TBLPREFIX . "individuals"; $sqlwhere .= " AND i_file=f_file"; $famsTable = true; } //-- alter the fields and recurse to generate a subquery for spouse/parent fields $oldfields = $this->fields; for ($j = 0; $j < $fct; $j++) { //-- if it doesn't start with FAMS or FAMC then remove that field if (preg_match("/^" . $parts[0] . ":/", $this->fields[$j]) == 0) { $this->fields[$j] = ''; } else { $this->fields[$j] = preg_replace("/^" . $parts[0] . ":/", "", $this->fields[$j]); } } $subsql = $this->advancedSearch(true, "individuals", "i"); if ($parts[0] == 'HUSB') { $sqlwhere .= " AND ROW(f_husb, f_file) IN (" . $subsql . ")"; } if ($parts[0] == 'WIFE') { $sqlwhere .= " AND ROW(f_wife, f_file) IN (" . $subsql . ")"; } $this->fields = $oldfields; //-- remove all of the fam fields so they don't show up again for ($j = 0; $j < $fct; $j++) { //-- if it does start with HUSB or WIFE then remove that field if (preg_match("/^" . $parts[0] . ":/", $this->fields[$j]) > 0) { $this->fields[$j] = ''; } } } else { $sqlwhere .= " AND i_gedcom " . PGV_DB::$LIKE . " "; $ct = count($parts); $liketmp = ''; for ($j = 0; $j < $ct; $j++) { $liketmp .= "%" . ($j + 1) . " " . $parts[$j] . " %"; // if ($j<$ct-1) { // $sqlwhere .= "%"; // } else { $liketmp .= "%{$value}%"; // } } $sqlwhere .= PGV_DB::quote($liketmp); } } } } } } } $sql = $sqlfields . $sqltables . $sqlwhere; // print $sql; if ($justSql) { return $sql; } $rows = PGV_DB::prepare($sql)->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { $row['xref'] = $row['i_id']; $row['ged_id'] = $row['i_file']; $row['type'] = 'INDI'; $row['gedrec'] = $row['i_gedcom']; $object = Person::getInstance($row); $this->myindilist[$row['i_id']] = $object; } $this->fields = $keepfields; }
/** * Static Helper functions to sort events * * @param Event $a * @param Event $b * @return int */ static function CompareDate(&$a, &$b) { $adate = $a->getDate(); $bdate = $b->getDate(); //-- non-dated events should sort according to the preferred sort order if (is_null($adate) && !is_null($a->sortDate)) { $ret = $a->sortOrder - $b->sortOrder; } else { if (is_null($bdate) && !is_null($b->sortDate)) { $ret = $a->sortOrder - $b->sortOrder; } else { $ret = GedcomDate::Compare($adate, $bdate); } } if ($ret == 0) { $ret = $a->sortOrder - $b->sortOrder; //-- if dates are the same they should be ordered by their fact type if ($ret == 0) { $ret = Event::CompareType($a, $b); } } // print "[".$a->getTag().":".$adate->isOK().":".$adate->MinJD()."-".$adate->MaxJD()." ".$b->getTag().":".$bdate->isOK().":".$bdate->MinJD()."-".$bdate->MaxJD()." ".$ret."] "; return $ret; }
/** * add historical events to individual facts array * * @return records added to indifacts array * * Historical facts are imported from optional language file : histo.xx.php * where xx is language code * This file should contain records similar to : * * $histo[]="1 EVEN\n2 TYPE History\n2 DATE 11 NOV 1918\n2 NOTE WW1 Armistice"; * $histo[]="1 EVEN\n2 TYPE History\n2 DATE 8 MAY 1945\n2 NOTE WW2 Armistice"; * etc... * */ function add_historical_facts() { global $LANGUAGE, $lang_short_cut; global $SHOW_RELATIVES_EVENTS; if (!$SHOW_RELATIVES_EVENTS) { return; } // Only include events between birth and death $bDate = $this->getEstimatedBirthDate(); $dDate = $this->getEstimatedDeathDate(); if (!$bDate->isOK()) { return; } if ($SHOW_RELATIVES_EVENTS && file_exists('languages/histo.' . $lang_short_cut[$LANGUAGE] . '.php')) { include 'languages/histo.' . $lang_short_cut[$LANGUAGE] . '.php'; foreach ($histo as $indexval => $hrec) { $sdate = new GedcomDate(get_gedcom_value('DATE', 2, $hrec, '', false)); if ($sdate->isOK() && GedcomDate::Compare($this->getEstimatedBirthDate(), $sdate) <= 0 && GedcomDate::Compare($sdate, $this->getEstimatedDeathDate()) <= 0) { $event = new Event($hrec); $event->setParentObject($this); $this->indifacts[] = $event; } } } }