function calc_legend($grenzen_zas) { global $legend, $zmax, $zgrenzen; // calculate the legend values $hulpar = explode(',', $grenzen_zas); $i = 1; // I18N: %d is a year $date = new WT_Date('BEF ' . $hulpar[0]); $legend[0] = strip_tags($date->display()); $zgrenzen[0] = $hulpar[0] - 1; while (isset($hulpar[$i])) { $i1 = $i - 1; $date = new WT_Date('BET ' . $hulpar[$i1] . ' AND ' . ($hulpar[$i] - 1)); $legend[$i] = strip_tags($date->display()); $zgrenzen[$i] = $hulpar[$i] - 1; $i++; } $zmax = $i; $zmax1 = $zmax - 1; // I18N: %d is a year $date = new WT_Date('AFT ' . $hulpar[$zmax1]); $legend[$zmax] = strip_tags($date->display()); $zgrenzen[$zmax] = 10000; $zmax = $zmax + 1; if ($zmax > 8) { $zmax = 8; } }
private static function historical_facts(WT_Individual $person) { global $SHOW_RELATIVES_EVENTS; $facts = array(); if ($SHOW_RELATIVES_EVENTS) { // Only include events between birth and death $birt_date = $person->getEstimatedBirthDate(); $deat_date = $person->getEstimatedDeathDate(); if (file_exists(WT_Site::preference('INDEX_DIRECTORY') . 'histo.' . WT_LOCALE . '.php')) { require WT_Site::preference('INDEX_DIRECTORY') . 'histo.' . WT_LOCALE . '.php'; foreach ($histo as $hist) { // Earlier versions of the WIKI encouraged people to use HTML entities, // rather than UTF8 encoding. $hist = html_entity_decode($hist, ENT_QUOTES, 'UTF-8'); $fact = new WT_Fact($hist, $person, 'histo'); $sdate = $fact->getDate(); if ($sdate->isOK() && WT_Date::Compare($birt_date, $sdate) <= 0 && WT_Date::Compare($sdate, $deat_date) <= 0) { $facts[] = $fact; } } } } return $facts; }
function __construct() { global $WT_SESSION; parent::__construct(); $this->setPageTitle(WT_I18N::translate('Lifespans')); $this->colorindex = 0; $this->Fcolorindex = 0; $this->Mcolorindex = 0; $this->zoomfactor = 10; $this->color = "#0000FF"; $this->currentYear = date("Y"); $this->deathMod = 0; $this->endDate = $this->currentYear; // Request parameters $newpid = WT_Filter::get('newpid', WT_REGEX_XREF); $remove = WT_Filter::get('remove', WT_REGEX_XREF); $pids = WT_Filter::getArray('pids', WT_REGEX_XREF); $clear = WT_Filter::getBool('clear'); $addfam = WT_Filter::getBool('addFamily'); $place = WT_Filter::get('place'); $beginYear = WT_Filter::getInteger('beginYear', 0, date('Y') + 100, 0); $endYear = WT_Filter::getInteger('endYear', 0, date('Y') + 100, 0); if ($clear) { // Empty list $this->pids = array(); } elseif ($pids) { // List of specified records $this->pids = $pids; } elseif ($place) { // All records found in a place $wt_place = new WT_Place($place, WT_GED_ID); $this->pids = WT_DB::prepare("SELECT DISTINCT pl_gid FROM `##placelinks` WHERE pl_p_id=? AND pl_file=?")->execute(array($wt_place->getPlaceId(), WT_GED_ID))->fetchOneColumn(); $this->place = $place; } else { // Modify an existing list of records if (is_array($WT_SESSION->timeline_pids)) { $this->pids = $WT_SESSION->timeline_pids; } else { $this->pids = array(); } if ($remove) { foreach ($this->pids as $key => $value) { if ($value == $remove) { unset($this->pids[$key]); } } } elseif ($newpid) { $person = WT_Individual::getInstance($newpid); $this->addFamily($person, $addfam); } elseif (!$this->pids) { $this->addFamily($this->getSignificantIndividual(), false); } } $WT_SESSION->timeline_pids = $this->pids; $this->beginYear = $beginYear; $this->endYear = $endYear; if ($beginYear == 0 || $endYear == 0) { //-- cleanup user input $this->pids = array_unique($this->pids); //removes duplicates foreach ($this->pids as $key => $value) { if ($value != $remove) { $this->pids[$key] = $value; $person = WT_Individual::getInstance($value); // list of linked records includes families as well as individuals. if ($person) { $bdate = $person->getEstimatedBirthDate(); if ($bdate->isOK() && $person->canShow()) { $this->people[] = $person; } } } } } else { //--Finds if the begin year and end year textboxes are not empty //-- reset the people array when doing a year range search $this->people = array(); //Takes the begining year and end year passed by the postback and modifies them and uses them to populate //the time line //Variables to restrict the person boxes to the year searched. //--Searches for individuals who had an even between the year begin and end years $indis = self::search_indis_year_range($beginYear, $endYear); //--Populates an array of people that had an event within those years foreach ($indis as $person) { if (empty($searchplace) || in_array($person->getXref(), $this->pids)) { $bdate = $person->getEstimatedBirthDate(); if ($bdate->isOK() && $person->canShow()) { $this->people[] = $person; } } } $WT_SESSION->timeline_pids = null; } // Sort the array in order of birth year uasort($this->people, function (WT_Individual $a, WT_Individual $b) { return WT_Date::Compare($a->getEstimatedBirthDate(), $b->getEstimatedBirthDate()); }); //If there is people in the array posted back this if occurs if (isset($this->people[0])) { //Find the maximum Death year and mimimum Birth year for each individual returned in the array. $bdate = $this->people[0]->getEstimatedBirthDate(); $ddate = $this->people[0]->getEstimatedDeathDate(); $this->timelineMinYear = $bdate->gregorianYear(); $this->timelineMaxYear = $ddate->gregorianYear() ? $ddate->gregorianYear() : date('Y'); foreach ($this->people as $value) { $bdate = $value->getEstimatedBirthDate(); $ddate = $value->getEstimatedDeathDate(); $this->timelineMinYear = min($this->timelineMinYear, $bdate->gregorianYear()); $this->timelineMaxYear = max($this->timelineMaxYear, $ddate->gregorianYear() ? $ddate->gregorianYear() : date('Y')); } if ($this->timelineMaxYear > $this->currentYear) { $this->timelineMaxYear = $this->currentYear; } } else { // Sets the default timeline length $this->timelineMinYear = date("Y") - 101; $this->timelineMaxYear = date("Y"); } }
/** * Print SOUR structure * * This function prints the input array of SOUR sub-records built by the * getSourceStructure() function. */ function printSourceStructure($textSOUR) { global $WT_TREE; $html = ''; if ($textSOUR['PAGE']) { $html .= WT_Gedcom_Tag::getLabelValue('PAGE', WT_Filter::expandUrls($textSOUR['PAGE'])); } if ($textSOUR['EVEN']) { $html .= WT_Gedcom_Tag::getLabelValue('EVEN', WT_Filter::escapeHtml($textSOUR['EVEN'])); if ($textSOUR['ROLE']) { $html .= WT_Gedcom_Tag::getLabelValue('ROLE', WT_Filter::escapeHtml($textSOUR['ROLE'])); } } if ($textSOUR['DATE'] || count($textSOUR['TEXT'])) { if ($textSOUR['DATE']) { $date = new WT_Date($textSOUR['DATE']); $html .= WT_Gedcom_Tag::getLabelValue('DATA:DATE', $date->Display(false)); } foreach ($textSOUR['TEXT'] as $text) { $html .= WT_Gedcom_Tag::getLabelValue('TEXT', WT_Filter::formatText($text, $WT_TREE)); } } if ($textSOUR['QUAY'] != '') { $html .= WT_Gedcom_Tag::getLabelValue('QUAY', WT_Gedcom_Code_Quay::getValue($textSOUR['QUAY'])); } return '<div class="indent">' . $html . '</div>'; }
Zend_Session::writeClose(); $term = WT_Filter::get('term'); // we can search on '"><& etc. $type = WT_Filter::get('field'); switch ($type) { case 'ASSO': // Associates of an individuals, whose name contains the search terms $data = array(); // Fetch all data, regardless of privacy $rows = WT_DB::prepare("SELECT 'INDI' AS type, i_id AS xref, i_file AS gedcom_id, i_gedcom AS gedcom, n_full" . " FROM `##individuals`" . " JOIN `##name` ON (i_id=n_id AND i_file=n_file)" . " WHERE (n_full LIKE CONCAT('%', REPLACE(?, ' ', '%'), '%') OR n_surn LIKE CONCAT('%', REPLACE(?, ' ', '%'), '%')) AND i_file=? ORDER BY n_full COLLATE '" . WT_I18N::$collation . "'")->execute(array($term, $term, WT_GED_ID))->fetchAll(); // Filter for privacy - and whether they could be alive at the right time $pid = WT_Filter::get('pid', WT_REGEX_XREF); $event_date = WT_Filter::get('event_date'); $record = WT_GedcomRecord::getInstance($pid); // INDI or FAM $tmp = new WT_Date($event_date); $event_jd = $tmp->JD(); // INDI $indi_birth_jd = 0; if ($record instanceof WT_Individual) { $indi_birth_jd = $record->getEstimatedBirthDate()->minJD(); } // HUSB & WIFE $husb_birth_jd = 0; $wife_birth_jd = 0; if ($record instanceof WT_Family) { $husb = $record->getHusband(); if ($husb) { $husb_birth_jd = $husb->getEstimatedBirthDate()->minJD(); } $wife = $record->getWife();
function print_time_fact(WT_Fact $event) { global $basexoffset, $baseyoffset, $factcount, $TEXT_DIRECTION, $WT_IMAGES, $placements; $desc = $event->getValue(); // check if this is a family fact $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 = (int) $yoffset; $place = (int) ($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 = (int) (($yoffset + $tyoffset) / $this->bheight); } $yoffset += $tyoffset; $xoffset += abs($tyoffset); $placements[$place] = $yoffset; echo "<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=\"factMouseDown(this, '" . $factcount . "', " . ($yoffset - $tyoffset) . ");\">"; echo "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" style=\"cursor: hand;\"><tr><td>"; echo "<img src=\"" . $WT_IMAGES["hline"] . "\" name=\"boxline{$factcount}\" id=\"boxline{$factcount}\" height=\"3\" align=\"left\" width=\"10\" alt=\"\" style=\"padding-"; if ($TEXT_DIRECTION == "ltr") { echo "left"; } else { echo "right"; } echo ": 3px;\">"; $col = $event->temp % 6; echo "</td><td valign=\"top\" class=\"person" . $col . "\">"; if (count($this->pids) > 6) { echo $event->getParent()->getFullName() . ' — '; } $record = $event->getParent(); echo $event->getLabel(); echo ' — '; if ($record instanceof WT_Individual) { echo format_fact_date($event, $record, false, false); } elseif ($record instanceof WT_Family) { echo $gdate->Display(false); if ($record->getHusband() && $record->getHusband()->getBirthDate()->isOK()) { $ageh = get_age_at_event(WT_Date::GetAgeGedcom($record->getHusband()->getBirthDate(), $gdate), false); } else { $ageh = null; } if ($record->getWife() && $record->getWife()->getBirthDate()->isOK()) { $agew = get_age_at_event(WT_Date::GetAgeGedcom($record->getWife()->getBirthDate(), $gdate), false); } else { $agew = null; } if ($ageh && $agew) { echo '<span class="age"> ', WT_I18N::translate('Husband’s age'), ' ', $ageh, ' ', WT_I18N::translate('Wife’s age'), ' ', $agew, '</span>'; } elseif ($ageh) { echo '<span class="age"> ', WT_I18N::translate('Age'), ' ', $ageh, '</span>'; } elseif ($agew) { echo '<span class="age"> ', WT_I18N::translate('Age'), ' ', $ageh, '</span>'; } } echo ' ' . WT_Filter::escapeHtml($desc); if (!$event->getPlace()->isEmpty()) { echo ' — ' . $event->getPlace()->getShortName(); } // print spouse name for marriage events if (isset($event->spouse)) { $spouse = $event->spouse; } else { $spouse = null; } 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; } if ($spouse->getXref() != $this->pids[$p]) { echo ' <a href="', $spouse->getHtmlUrl(), '">', $spouse->getFullName(), '</a>'; } else { echo ' <a href="', $event->getParent()->getHtmlUrl(), '">', $event->getParent()->getFullName(), '</a>'; } } echo "</td></tr></table>"; echo "</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 echo "<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;"; echo " background-image: url('" . $WT_IMAGES[$img] . "');"; echo " background-position: 0% {$ypos};\">"; echo "</div>"; }
function advancedSearch($justSql = false, $table = "individuals", $prefix = "i") { $this->myindilist = array(); $fct = count($this->fields); if ($fct == 0) { return; } // Dynamic SQL query, plus bind variables $sql = "SELECT DISTINCT ind.i_id AS xref, ind.i_file AS gedcom_id, ind.i_gedcom AS gedcom FROM `##individuals` ind"; $bind = array(); // Join the following tables $father_name = false; $mother_name = false; $spouse_family = false; $indi_name = false; $indi_date = false; $fam_date = false; $indi_plac = false; $fam_plac = false; foreach ($this->fields as $n => $field) { if ($this->values[$n]) { if (substr($field, 0, 14) == 'FAMC:HUSB:NAME') { $father_name = true; } elseif (substr($field, 0, 14) == 'FAMC:WIFE:NAME') { $mother_name = true; } elseif (substr($field, 0, 4) == 'NAME') { $indi_name = true; } elseif (strpos($field, ':DATE') !== false) { if (substr($field, 0, 4) == 'FAMS') { $fam_date = true; $spouse_family = true; } else { $indi_date = true; } } elseif (strpos($field, ':PLAC') !== false) { if (substr($field, 0, 4) == 'FAMS') { $fam_plac = true; $spouse_family = true; } else { $indi_plac = true; } } } } if ($father_name || $mother_name) { $sql .= " JOIN `##link` l_1 ON (l_1.l_file=ind.i_file AND l_1.l_from=ind.i_id AND l_1.l_type='FAMC')"; } if ($father_name) { $sql .= " JOIN `##link` l_2 ON (l_2.l_file=ind.i_file AND l_2.l_from=l_1.l_to AND l_2.l_type='HUSB')"; $sql .= " JOIN `##name` f_n ON (f_n.n_file=ind.i_file AND f_n.n_id =l_2.l_to)"; } if ($mother_name) { $sql .= " JOIN `##link` l_3 ON (l_3.l_file=ind.i_file AND l_3.l_from=l_1.l_to AND l_3.l_type='WIFE')"; $sql .= " JOIN `##name` m_n ON (m_n.n_file=ind.i_file AND m_n.n_id =l_3.l_to)"; } if ($spouse_family) { $sql .= " JOIN `##link` l_4 ON (l_4.l_file=ind.i_file AND l_4.l_from=ind.i_id AND l_4.l_type='FAMS')"; $sql .= " JOIN `##families` fam ON (fam.f_file=ind.i_file AND fam.f_id =l_4.l_to)"; } if ($indi_name) { $sql .= " JOIN `##name` i_n ON (i_n.n_file=ind.i_file AND i_n.n_id=ind.i_id)"; } if ($indi_date) { $sql .= " JOIN `##dates` i_d ON (i_d.d_file=ind.i_file AND i_d.d_gid=ind.i_id)"; } if ($fam_date) { $sql .= " JOIN `##dates` f_d ON (f_d.d_file=ind.i_file AND f_d.d_gid=fam.f_id)"; } if ($indi_plac) { $sql .= " JOIN `##placelinks` i_pl ON (i_pl.pl_file=ind.i_file AND i_pl.pl_gid =ind.i_id)"; $sql .= " JOIN (" . "SELECT CONCAT_WS(', ', p1.p_place, p2.p_place, p3.p_place, p4.p_place, p5.p_place, p6.p_place, p7.p_place, p8.p_place, p9.p_place) AS place, p1.p_id AS id, p1.p_file AS file" . " FROM `##places` AS p1" . " LEFT JOIN `##places` AS p2 ON (p1.p_parent_id=p2.p_id)" . " LEFT JOIN `##places` AS p3 ON (p2.p_parent_id=p3.p_id)" . " LEFT JOIN `##places` AS p4 ON (p3.p_parent_id=p4.p_id)" . " LEFT JOIN `##places` AS p5 ON (p4.p_parent_id=p5.p_id)" . " LEFT JOIN `##places` AS p6 ON (p5.p_parent_id=p6.p_id)" . " LEFT JOIN `##places` AS p7 ON (p6.p_parent_id=p7.p_id)" . " LEFT JOIN `##places` AS p8 ON (p7.p_parent_id=p8.p_id)" . " LEFT JOIN `##places` AS p9 ON (p8.p_parent_id=p9.p_id)" . ") AS i_p ON (i_p.file =ind.i_file AND i_pl.pl_p_id= i_p.id)"; } if ($fam_plac) { $sql .= " JOIN `##placelinks` f_pl ON (f_pl.pl_file=ind.i_file AND f_pl.pl_gid =fam.f_id)"; $sql .= " JOIN (" . "SELECT CONCAT_WS(', ', p1.p_place, p2.p_place, p3.p_place, p4.p_place, p5.p_place, p6.p_place, p7.p_place, p8.p_place, p9.p_place) AS place, p1.p_id AS id, p1.p_file AS file" . " FROM `##places` AS p1" . " LEFT JOIN `##places` AS p2 ON (p1.p_parent_id=p2.p_id)" . " LEFT JOIN `##places` AS p3 ON (p2.p_parent_id=p3.p_id)" . " LEFT JOIN `##places` AS p4 ON (p3.p_parent_id=p4.p_id)" . " LEFT JOIN `##places` AS p5 ON (p4.p_parent_id=p5.p_id)" . " LEFT JOIN `##places` AS p6 ON (p5.p_parent_id=p6.p_id)" . " LEFT JOIN `##places` AS p7 ON (p6.p_parent_id=p7.p_id)" . " LEFT JOIN `##places` AS p8 ON (p7.p_parent_id=p8.p_id)" . " LEFT JOIN `##places` AS p9 ON (p8.p_parent_id=p9.p_id)" . ") AS f_p ON (f_p.file =ind.i_file AND f_pl.pl_p_id= f_p.id)"; } // Add the where clause $sql .= " WHERE ind.i_file=?"; $bind[] = WT_GED_ID; for ($i = 0; $i < $fct; $i++) { $field = $this->fields[$i]; $value = $this->values[$i]; if ($value === '') { continue; } $parts = preg_split("/:/", $field . '::::'); if ($parts[0] == 'NAME') { // NAME:* switch ($parts[1]) { case 'GIVN': switch ($parts[2]) { case 'EXACT': $sql .= " AND i_n.n_givn=?"; $bind[] = $value; break; case 'BEGINS': $sql .= " AND i_n.n_givn LIKE CONCAT(?, '%')"; $bind[] = $value; break; case 'CONTAINS': $sql .= " AND i_n.n_givn LIKE CONCAT('%', ?, '%')"; $bind[] = $value; break; case 'SDX_STD': $sdx = WT_Soundex::soundex_std($value); if ($sdx) { $sdx = explode(':', $sdx); foreach ($sdx as $k => $v) { $sdx[$k] = "i_n.n_soundex_givn_std LIKE CONCAT('%', ?, '%')"; $bind[] = $v; } $sql .= ' AND (' . implode(' OR ', $sdx) . ')'; } else { // No phonetic content? Use a substring match $sql .= " AND i_n.n_givn LIKE CONCAT('%', ?, '%')"; $bind[] = $value; } break; case 'SDX': // SDX uses DM by default. // SDX uses DM by default. case 'SDX_DM': $sdx = WT_Soundex::soundex_dm($value); if ($sdx) { $sdx = explode(':', $sdx); foreach ($sdx as $k => $v) { $sdx[$k] = "i_n.n_soundex_givn_dm LIKE CONCAT('%', ?, '%')"; $bind[] = $v; } $sql .= ' AND (' . implode(' OR ', $sdx) . ')'; } else { // No phonetic content? Use a substring match $sql .= " AND i_n.n_givn LIKE CONCAT('%', ?, '%')"; $bind[] = $value; } break; } break; case 'SURN': switch ($parts[2]) { case 'EXACT': $sql .= " AND i_n.n_surname=?"; $bind[] = $value; break; case 'BEGINS': $sql .= " AND i_n.n_surname LIKE CONCAT(?, '%')"; $bind[] = $value; break; case 'CONTAINS': $sql .= " AND i_n.n_surname LIKE CONCAT('%', ?, '%')"; $bind[] = $value; break; case 'SDX_STD': $sdx = WT_Soundex::soundex_std($value); if ($sdx) { $sdx = explode(':', $sdx); foreach ($sdx as $k => $v) { $sdx[$k] = "i_n.n_soundex_surn_std LIKE CONCAT('%', ?, '%')"; $bind[] = $v; } $sql .= " AND (" . implode(' OR ', $sdx) . ")"; } else { // No phonetic content? Use a substring match $sql .= " AND i_n.n_surn LIKE CONCAT('%', ?, '%')"; $bind[] = $value; } break; case 'SDX': // SDX uses DM by default. // SDX uses DM by default. case 'SDX_DM': $sdx = WT_Soundex::soundex_dm($value); if ($sdx) { $sdx = explode(':', $sdx); foreach ($sdx as $k => $v) { $sdx[$k] = "i_n.n_soundex_surn_dm LIKE CONCAT('%', ?, '%')"; $bind[] = $v; } $sql .= " AND (" . implode(' OR ', $sdx) . ")"; break; } else { // No phonetic content? Use a substring match $sql .= " AND i_n.n_surn LIKE CONCAT('%', ?, '%')"; $bind[] = $value; } } break; case 'NICK': case '_MARNM': case '_HEB': case '_AKA': $sql .= " AND i_n.n_type=? AND i_n.n_full LIKE CONCAT('%', ?, '%')"; $bind[] = $parts[1]; $bind[] = $value; break; } } elseif ($parts[1] == 'DATE') { // *:DATE $date = new WT_Date($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; //echo $jd1.":".$jd2.":".$adjd; $jd1 = $jd1 - $adjd; $jd2 = $jd2 + $adjd; } $sql .= " AND i_d.d_fact=? AND i_d.d_julianday1>=? AND i_d.d_julianday2<=?"; $bind[] = $parts[0]; $bind[] = $jd1; $bind[] = $jd2; } } elseif ($parts[0] == 'FAMS' && $parts[2] == 'DATE') { // FAMS:*:DATE $date = new WT_Date($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; //echo $jd1.":".$jd2.":".$adjd; $jd1 = $jd1 - $adjd; $jd2 = $jd2 + $adjd; } $sql .= " AND f_d.d_fact=? AND f_d.d_julianday1>=? AND f_d.d_julianday2<=?"; $bind[] = $parts[1]; $bind[] = $jd1; $bind[] = $jd2; } } elseif ($parts[1] == 'PLAC') { // *:PLAC // SQL can only link a place to a person/family, not to an event. $sql .= " AND i_p.place LIKE CONCAT('%', ?, '%')"; //$sql.=" AND i_p.p_place=?"; $bind[] = $value; } elseif ($parts[0] == 'FAMS' && $parts[2] == 'PLAC') { // FAMS:*:PLAC // SQL can only link a place to a person/family, not to an event. $sql .= " AND f_p.place LIKE CONCAT('%', ?, '%')"; $bind[] = $value; } elseif ($parts[0] == 'FAMC' && $parts[2] == 'NAME') { $table = $parts[1] == 'HUSB' ? 'f_n' : 'm_n'; // NAME:* switch ($parts[3]) { case 'GIVN': switch ($parts[4]) { case 'EXACT': $sql .= " AND {$table}.n_givn=?"; $bind[] = $value; break; case 'BEGINS': $sql .= " AND {$table}.n_givn LIKE CONCAT(?, '%')"; $bind[] = $value; break; case 'CONTAINS': $sql .= " AND {$table}.n_givn LIKE CONCAT('%', ?, '%')"; $bind[] = $value; break; case 'SDX_STD': $sdx = WT_Soundex::soundex_std($value); if ($sdx) { $sdx = explode(':', $sdx); foreach ($sdx as $k => $v) { $sdx[$k] = "{$table}.n_soundex_givn_std LIKE CONCAT('%', ?, '%')"; $bind[] = $v; } $sql .= ' AND (' . implode(' OR ', $sdx) . ')'; } else { // No phonetic content? Use a substring match $sql .= " AND {$table}.n_givn = LIKE CONCAT('%', ?, '%')"; $bind[] = $value; } break; case 'SDX': // SDX uses DM by default. // SDX uses DM by default. case 'SDX_DM': $sdx = WT_Soundex::soundex_dm($value); if ($sdx) { $sdx = explode(':', $sdx); foreach ($sdx as $k => $v) { $sdx[$k] = "{$table}.n_soundex_givn_dm LIKE CONCAT('%', ?, '%')"; $bind[] = $v; } $sql .= ' AND (' . implode(' OR ', $sdx) . ')'; break; } else { // No phonetic content? Use a substring match $sql .= " AND {$table}.n_givn = LIKE CONCAT('%', ?, '%')"; $bind[] = $value; } } break; case 'SURN': switch ($parts[4]) { case 'EXACT': $sql .= " AND {$table}.n_surname=?"; $bind[] = $value; break; case 'BEGINS': $sql .= " AND {$table}.n_surname LIKE CONCAT(?, '%')"; $bind[] = $value; break; case 'CONTAINS': $sql .= " AND {$table}.n_surname LIKE CONCAT('%', ?, '%')"; $bind[] = $value; break; case 'SDX_STD': $sdx = WT_Soundex::soundex_std($value); if ($sdx) { $sdx = explode(':', $sdx); foreach ($sdx as $k => $v) { $sdx[$k] = "{$table}.n_soundex_surn_std LIKE CONCAT('%', ?, '%')"; $bind[] = $v; } $sql .= ' AND (' . implode(' OR ', $sdx) . ')'; } else { // No phonetic content? Use a substring match $sql .= " AND {$table}.n_surn = LIKE CONCAT('%', ?, '%')"; $bind[] = $value; } break; case 'SDX': // SDX uses DM by default. // SDX uses DM by default. case 'SDX_DM': $sdx = WT_Soundex::soundex_dm($value); if ($sdx) { $sdx = explode(':', $sdx); foreach ($sdx as $k => $v) { $sdx[$k] = "{$table}.n_soundex_surn_dm LIKE CONCAT('%', ?, '%')"; $bind[] = $v; } $sql .= ' AND (' . implode(' OR ', $sdx) . ')'; } else { // No phonetic content? Use a substring match $sql .= " AND {$table}.n_surn = LIKE CONCAT('%', ?, '%')"; $bind[] = $value; } break; } break; } } elseif ($parts[0] == 'FAMS') { $sql .= " AND fam.f_gedcom LIKE CONCAT('%', ?, '%')"; $bind[] = $value; } else { $sql .= " AND ind.i_gedcom LIKE CONCAT('%', ?, '%')"; $bind[] = $value; } } $rows = WT_DB::prepare($sql)->execute($bind)->fetchAll(); foreach ($rows as $row) { $person = WT_Individual::getInstance($row->xref, $row->gedcom_id, $row->gedcom); // Check for XXXX:PLAC fields, which were only partially matched by SQL foreach ($this->fields as $n => $field) { if ($this->values[$n] && preg_match('/^(' . WT_REGEX_TAG . '):PLAC$/', $field, $match)) { if (!preg_match('/\\n1 ' . $match[1] . '(\\n[2-9].*)*\\n2 PLAC .*' . preg_quote($this->values[$n], '/') . '/i', $person->getGedcom())) { continue 2; } } } $this->myindilist[] = $person; } }
$gedrec .= addNewFact($match); } } $gedrec .= "\n" . WT_Gedcom_Code_Pedi::createNewFamcPedi($PEDI, $xref); if (WT_Filter::postBool('SOUR_INDI')) { $gedrec = handle_updates($gedrec); } else { $gedrec = updateRest($gedrec); } // Create the new child $new_child = WT_GedcomRecord::createRecord($gedrec, WT_GED_ID); // Insert new child at the right place $done = false; foreach ($family->getFacts('CHIL') as $fact) { $old_child = $fact->getTarget(); if ($old_child && WT_Date::Compare($new_child->getEstimatedBirthDate(), $old_child->getEstimatedBirthDate()) < 0) { // Insert before this child $family->updateFact($fact->getFactId(), '1 CHIL @' . $new_child->getXref() . "@\n" . $fact->getGedcom(), !$keep_chan); $done = true; break; } } if (!$done) { // Append child at end $family->createFact('1 CHIL @' . $new_child->getXref() . '@', !$keep_chan); } if (WT_Filter::post('goto') == 'new') { $controller->addInlineJavascript('closePopupAndReloadParent("' . $new_child->getRawUrl() . '");'); } else { $controller->addInlineJavascript('closePopupAndReloadParent();'); }
public function getBlock($block_id, $template = true, $cfg = null) { global $ctype, $controller; $days = get_block_setting($block_id, 'days', 7); $infoStyle = get_block_setting($block_id, 'infoStyle', 'table'); $calendar = get_block_setting($block_id, 'calendar', 'jewish'); $block = get_block_setting($block_id, 'block', true); if ($cfg) { foreach (array('days', 'infoStyle', 'block') as $name) { if (array_key_exists($name, $cfg)) { ${$name} = $cfg[$name]; } } } $startjd = WT_CLIENT_JD; $endjd = WT_CLIENT_JD + $days - 1; $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; if ($ctype == 'gedcom' && WT_USER_GEDCOM_ADMIN || $ctype == 'user' && WT_USER_ID) { $title = '<i class="icon-admin" title="' . WT_I18N::translate('Configure') . '" onclick="modalDialog(\'block_edit.php?block_id=' . $block_id . '\', \'' . $this->getTitle() . '\');"></i>'; } else { $title = ''; } $title .= $this->getTitle(); $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(); for ($jd = $startjd - 1; $jd <= $endjd + $days; ++$jd) { foreach (get_anniversary_events($jd, 'DEAT _YART') as $fact) { // Exact hebrew dates only $date = $fact->getDate(); if ($date->MinDate() instanceof WT_Date_Jewish && $date->MinJD() == $date->MaxJD()) { $fact->jd = $jd; $yahrzeits[] = $fact; } } } // ...then adjust dates $jewish_calendar = new JewishCalendar(); foreach ($yahrzeits as $yahrzeit) { if ($yahrzeit->getTag() == 'DEAT') { // Just DEAT, not _YART $today = new WT_Date_Jewish($yahrzeit->jd); $hd = $yahrzeit->getDate()->MinDate(); $hd1 = new WT_Date_Jewish($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->jd = $jewish_calendar->ymdToJd($today->y, 3, 1) - 1; } elseif ($hd->d == 30 && $hd->m == 3 && $hd->y != 0 && $hd1->daysInMonth() < 30) { // 30 KSL // Last day in KSL $yahrzeit->jd = $jewish_calendar->ymdToJd($today->y, 4, 1) - 1; } elseif ($hd->d == 30 && $hd->m == 6 && $hd->y != 0 && $today->daysInMonth() < 30 && !$today->isLeapYear()) { // 30 ADR // Last day in SHV $yahrzeit->jd = $jewish_calendar->ymdToJd($today->y, 6, 1) - 1; } } } switch ($infoStyle) { case 'list': foreach ($yahrzeits as $yahrzeit) { if ($yahrzeit->jd >= $startjd && $yahrzeit->jd < $startjd + $days) { $ind = $yahrzeit->getParent(); $content .= "<a href=\"" . $ind->getHtmlUrl() . "\" class=\"list_item name2\">" . $ind->getFullName() . "</a>" . $ind->getSexImage(); $content .= "<div class=\"indent\">"; $content .= $yahrzeit->getDate()->Display(true); $content .= ', ' . WT_I18N::translate('%s year anniversary', $yahrzeit->anniv); $content .= "</div>"; } } break; case 'table': default: $table_id = Uuid::uuid4(); // table requires a unique ID $controller->addExternalJavascript(WT_JQUERY_DATATABLES_URL)->addInlineJavascript(' jQuery("#' . $table_id . '").dataTable({ dom: \'t\', ' . WT_I18N::datatablesI18N() . ', autoWidth: false, paginate: false, lengthChange: false, filter: false, info: true, jQueryUI: true, sorting: [[5,"asc"]], columns: [ /* 0-name */ { dataSort: 1 }, /* 1-NAME */ { visible: false }, /* 2-date */ { dataSort: 3 }, /* 3-DATE */ { visible: false }, /* 4-Aniv */ { class: "center"}, /* 5-yart */ { dataSort: 6 }, /* 6-YART */ { visible: false } ] }); jQuery("#' . $table_id . '").css("visibility", "visible"); jQuery(".loading-image").css("display", "none"); '); $content = ''; $content .= '<div class="loading-image"> </div>'; $content .= '<table id="' . $table_id . '" class="width100" style="visibility:hidden;">'; $content .= '<thead><tr>'; $content .= '<th>' . WT_Gedcom_Tag::getLabel('NAME') . '</th>'; $content .= '<th>' . WT_Gedcom_Tag::getLabel('NAME') . '</th>'; $content .= '<th>' . WT_Gedcom_Tag::getLabel('DEAT') . '</th>'; $content .= '<th>DEAT</th>'; $content .= '<th><i class="icon-reminder" title="' . WT_I18N::translate('Anniversary') . '"></i></th>'; $content .= '<th>' . WT_Gedcom_Tag::getLabel('_YART') . '</th>'; $content .= '<th>_YART</th>'; $content .= '</tr></thead><tbody>'; foreach ($yahrzeits as $yahrzeit) { if ($yahrzeit->jd >= $startjd && $yahrzeit->jd < $startjd + $days) { $content .= '<tr>'; $ind = $yahrzeit->getParent(); // Individual name(s) $name = $ind->getFullName(); $url = $ind->getHtmlUrl(); $content .= '<td>'; $content .= '<a href="' . $url . '">' . $name . '</a>'; $content .= $ind->getSexImage(); $addname = $ind->getAddName(); if ($addname) { $content .= '<br><a href="' . $url . '">' . $addname . '</a>'; } $content .= '</td>'; $content .= '<td>' . $ind->getSortName() . '</td>'; // death/yahrzeit event date $content .= '<td>' . $yahrzeit->getDate()->Display() . '</td>'; $content .= '<td>' . $yahrzeit->getDate()->minJD() . '</td>'; // sortable date // Anniversary $content .= '<td>' . $yahrzeit->anniv . '</td>'; // upcomming yahrzeit dates switch ($calendar) { case 'gregorian': $today = new WT_Date_Gregorian($yahrzeit->jd); break; case 'jewish': default: $today = new WT_Date_Jewish($yahrzeit->jd); break; } $td = new WT_Date($today->format('%@ %A %O %E')); $content .= '<td>' . $td->Display() . '</td>'; $content .= '<td>' . $td->minJD() . '</td>'; // sortable date $content .= '</tr>'; } } $content .= '</tbody></table>'; break; } if ($template) { if ($block) { require WT_THEME_DIR . 'templates/block_small_temp.php'; } else { require WT_THEME_DIR . 'templates/block_main_temp.php'; } } else { return $content; } }
function printFamily(WT_Family $family, $type, $label) { global $controller; global $personcount; // TODO: use a unique id instead? global $SHOW_PRIVATE_RELATIONSHIPS; if ($SHOW_PRIVATE_RELATIONSHIPS) { $access_level = WT_PRIV_HIDE; } else { $access_level = WT_USER_ACCESS_LEVEL; } ?> <table> <tr> <td> <i class="icon-cfamily"></i> </td> <td> <span class="subheaders"> <?php echo $label; ?> </span> - <a href="<?php echo $family->getHtmlUrl(); ?> "><?php echo WT_I18N::translate('View family'); ?> </a> </td> </tr> </table> <table class="facts_table"> <?php ///// HUSB ///// $found = false; foreach ($family->getFacts('HUSB', false, $access_level) as $fact) { $found |= !$fact->isOld(); $person = $fact->getTarget(); if ($person instanceof WT_Individual) { if ($fact->isNew()) { $class = 'facts_label new'; } elseif ($fact->isOld()) { $class = 'facts_label old'; } else { $class = 'facts_label'; } ?> <tr> <td class="<?php echo $class; ?> "> <?php echo get_close_relationship_name($controller->record, $person); ?> </td> <td class="<?php echo $controller->getPersonStyle($person); ?> "> <?php print_pedigree_person($person, 2, 0, $personcount++); ?> </td> </tr> <?php } } if (!$found && $family->canEdit()) { ?> <tr> <td class="facts_label"> </td> <td class="facts_value"><a href="#" onclick="return add_spouse_to_family('<?php echo $family->getXref(); ?> ', 'HUSB');"><?php echo WT_I18N::translate('Add a husband to this family'); ?> </a></td> </tr> <?php } ///// WIFE ///// $found = false; foreach ($family->getFacts('WIFE', false, $access_level) as $fact) { $person = $fact->getTarget(); if ($person instanceof WT_Individual) { $found |= !$fact->isOld(); if ($fact->isNew()) { $class = 'facts_label new'; } elseif ($fact->isOld()) { $class = 'facts_label old'; } else { $class = 'facts_label'; } ?> <tr> <td class="<?php echo $class; ?> "> <?php echo get_close_relationship_name($controller->record, $person); ?> </td> <td class="<?php echo $controller->getPersonStyle($person); ?> "> <?php print_pedigree_person($person, 2, 0, $personcount++); ?> </td> </tr> <?php } } if (!$found && $family->canEdit()) { ?> <tr> <td class="facts_label"> </td> <td class="facts_value"><a href="#" onclick="return add_spouse_to_family('<?php echo $family->getXref(); ?> ', 'WIFE');"><?php echo WT_I18N::translate('Add a wife to this family'); ?> </a></td> </tr> <?php } ///// MARR ///// $found = false; $prev = new WT_Date(''); foreach ($family->getFacts(WT_EVENTS_MARR) as $fact) { $found |= !$fact->isOld(); if ($fact->isNew()) { $class = ' new'; } elseif ($fact->isOld()) { $class = ' old'; } else { $class = ''; } ?> <tr> <td class="facts_label"> </td> <td class="facts_value<?php echo $class; ?> "> <?php echo WT_Gedcom_Tag::getLabelValue($fact->getTag(), $fact->getDate()->Display(false) . ' — ' . $fact->getPlace()->getFullName()); ?> </td> </tr> <?php if (!$prev->isOK() && $fact->getDate()->isOK()) { $prev = $fact->getDate(); } } if (!$found && $family->canShow() && $family->canEdit()) { // Add a new marriage ?> <tr> <td class="facts_label"> </td> <td class="facts_value"> <a href="#" onclick="return add_new_record('<?php echo $family->getXref(); ?> ', 'MARR');"> <?php echo WT_I18N::translate('Add marriage details'); ?> </a> </td> </tr> <?php } ///// CHIL ///// $child_number = 0; foreach ($family->getFacts('CHIL', false, $access_level) as $fact) { $person = $fact->getTarget(); if ($person instanceof WT_Individual) { if ($fact->isNew()) { $child_number++; $class = 'facts_label new'; } elseif ($fact->isOld()) { $class = 'facts_label old'; } else { $child_number++; $class = 'facts_label'; } $next = new WT_Date(''); foreach ($person->getFacts(WT_EVENTS_BIRT) as $bfact) { if ($bfact->getDate()->isOK()) { $next = $bfact->getDate(); break; } } ?> <tr> <td class="<?php echo $class; ?> "> <?php echo self::ageDifference($prev, $next, $child_number); ?> <?php echo get_close_relationship_name($controller->record, $person); ?> </td> <td class="<?php echo $controller->getPersonStyle($person); ?> "> <?php print_pedigree_person($person, 2, 0, $personcount++); ?> </td> </tr> <?php $prev = $next; } } // Re-order children / add a new child if ($family->canEdit()) { if ($type == 'FAMS') { $child_u = WT_I18N::translate('Add a new son or daughter'); $child_m = WT_I18N::translate('son'); $child_f = WT_I18N::translate('daughter'); } else { $child_u = WT_I18N::translate('Add a new brother or sister'); $child_m = WT_I18N::translate('brother'); $child_f = WT_I18N::translate('sister'); } ?> <tr> <td class="facts_label"> <?php if (count($family->getChildren()) > 1) { ?> <a href="#" onclick="reorder_children('<?php echo $family->getXref(); ?> ');tabswitch(5);"><i class="icon-media-shuffle"></i> <?php echo WT_I18N::translate('Re-order children'); ?> </a> <?php } ?> </td> <td class="facts_value"> <a href="#" onclick="return add_child_to_family('<?php echo $family->getXref(); ?> ');"><?php echo $child_u; ?> </a> <span style='white-space:nowrap;'> <a href="#" class="icon-sex_m_15x15" onclick="return add_child_to_family('<?php echo $family->getXref(); ?> ','M');"></a> <a href="#" class="icon-sex_f_15x15" onclick="return add_child_to_family('<?php echo $family->getXref(); ?> ','F');"></a> </span> </td> </tr> <?php } echo '</table>'; return; }
function compare_people($a, $b) { return WT_Date::Compare($a->getEstimatedBirthDate(), $b->getEstimatedBirthDate()); }
/** * Static Helper functions to sort events * * @param WT_Fact $a Fact one * @param WT_Fact $b Fact two * * @return integer */ public static function CompareDate(WT_Fact $a, WT_Fact $b) { if ($a->getDate()->isOK() && $b->getDate()->isOK()) { // If both events have dates, compare by date $ret = WT_Date::Compare($a->getDate(), $b->getDate()); if ($ret == 0) { // If dates are the same, compare by fact type $ret = self::CompareType($a, $b); // If the fact type is also the same, retain the initial order if ($ret == 0) { $ret = $a->sortOrder - $b->sortOrder; } } return $ret; } else { // One or both events have no date - retain the initial order return $a->sortOrder - $b->sortOrder; } }
function _eventQuery($type, $direction, $facts) { $eventTypes = array('BIRT' => WT_I18N::translate('birth'), 'DEAT' => WT_I18N::translate('death'), 'MARR' => WT_I18N::translate('marriage'), 'ADOP' => WT_I18N::translate('adoption'), 'BURI' => WT_I18N::translate('burial'), 'CENS' => WT_I18N::translate('census added')); $fact_query = "IN ('" . str_replace('|', "','", $facts) . "')"; if ($direction != 'ASC') { $direction = 'DESC'; } $rows = self::_runSQL('' . ' SELECT SQL_CACHE' . ' d_gid AS id,' . ' d_year AS year,' . ' d_fact AS fact,' . ' d_type AS type' . ' FROM' . " `##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 LIMIT 1"); if (!isset($rows[0])) { return ''; } $row = $rows[0]; $record = WT_GedcomRecord::getInstance($row['id']); switch ($type) { default: case 'full': if ($record->canShow()) { $result = $record->format_list('span', false, $record->getFullName()); } else { $result = WT_I18N::translate('This information is private and cannot be shown.'); } break; case 'year': $date = new WT_Date($row['type'] . ' ' . $row['year']); $result = $date->Display(true); break; case 'type': if (isset($eventTypes[$row['fact']])) { $result = $eventTypes[$row['fact']]; } else { $result = WT_Gedcom_Tag::getLabel($row['fact']); } break; case 'name': $result = "<a href=\"" . $record->getHtmlUrl() . "\">" . $record->getFullName() . "</a>"; break; case 'place': $fact = $record->getFirstFact($row['fact']); if ($fact) { $result = format_fact_place($fact, true, true, true); } else { $result = WT_I18N::translate('Private'); } break; } return $result; }
if ($controller->record->canShow()) { // Highlight image or silhouette echo '<div id="indi_mainimage">', $controller->record->displayImage(), '</div>'; echo '<div id="header_accordion1">'; // contain accordions for names echo '<h3 class="name_one ', $controller->getPersonStyle($controller->record), '"><span>', $controller->record->getFullName(), '</span>'; // First name accordion header $bdate = $controller->record->getBirthDate(); $ddate = $controller->record->getDeathDate(); echo '<span class="header_age">'; if ($bdate->isOK() && !$controller->record->isDead()) { // If living display age echo WT_Gedcom_Tag::getLabelValue('AGE', get_age_at_event(WT_Date::GetAgeGedcom($bdate), true), '', 'span'); } elseif ($bdate->isOK() && $ddate->isOK()) { // If dead, show age at death echo WT_Gedcom_Tag::getLabelValue('AGE', get_age_at_event(WT_Date::GetAgeGedcom($bdate, $ddate), false), '', 'span'); } echo '</span>'; // Display summary birth/death info. echo '<span id="dates">', $controller->record->getLifeSpan(), '</span>'; // Display gender icon foreach ($controller->record->getFacts() as $fact) { if ($fact->getTag() == 'SEX') { $controller->print_sex_record($fact); } } echo '</h3>'; // close first name accordion header // Display name details foreach ($controller->record->getFacts() as $fact) { if ($fact->getTag() == 'NAME') {
/** * Static helper function to sort an array of families by marriage date * * @param WT_Family $x * @param WT_Family $y * * @return int */ public static function compareMarrDate(WT_Family $x, WT_Family $y) { return WT_Date::Compare($x->getMarriageDate(), $y->getMarriageDate()); }
} $ged_date = new WT_Date("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 WT_Date("FROM {$cal} {$y1} TO {$cal} {$y2}"); $action = 'year'; } else { if ($year < 0) { $year = -$year . " B.C."; } // need BC to parse date $ged_date = new WT_Date("{$cal} {$day} {$month} {$year}"); $year = $ged_date->date1->y; // need negative year for year entry field. } } $cal_date =& $ged_date->date1; // Invalid month? Pick a sensible one. if ($cal_date instanceof WT_Date_Jewish && $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; } if ($cal_date->m == 0) {
/** * Print a new fact box on details pages * * @param string $id the id of the person, family, source etc the fact will be added to * @param array $usedfacts an array of facts already used in this record * @param string $type the type of record INDI, FAM, SOUR etc */ function print_add_new_fact($id, $usedfacts, $type) { global $WT_SESSION; // -- Add from clipboard if ($WT_SESSION->clipboard) { $newRow = true; foreach (array_reverse($WT_SESSION->clipboard, true) as $fact_id => $fact) { if ($fact["type"] == $type || $fact["type"] == 'all') { if ($newRow) { $newRow = false; echo '<tr><td class="descriptionbox">'; echo WT_I18N::translate('Add from clipboard'), '</td>'; echo '<td class="optionbox wrap"><form method="get" name="newFromClipboard" action="?" onsubmit="return false;">'; echo '<select id="newClipboardFact">'; } echo '<option value="', WT_Filter::escapeHtml($fact_id), '">', WT_Gedcom_Tag::getLabel($fact['fact']); // TODO use the event class to store/parse the clipboard events if (preg_match('/^2 DATE (.+)/m', $fact['factrec'], $match)) { $tmp = new WT_Date($match[1]); echo '; ', $tmp->minDate()->format('%Y'); } if (preg_match('/^2 PLAC ([^,\\n]+)/m', $fact['factrec'], $match)) { echo '; ', $match[1]; } echo '</option>'; } } if (!$newRow) { echo '</select>'; echo ' <input type="button" value="', WT_I18N::translate('Add'), "\" onclick=\"return paste_fact('{$id}', '#newClipboardFact');\"> "; echo '</form></td></tr>', "\n"; } } // -- Add from pick list switch ($type) { case "INDI": $addfacts = preg_split("/[, ;:]+/", get_gedcom_setting(WT_GED_ID, 'INDI_FACTS_ADD'), -1, PREG_SPLIT_NO_EMPTY); $uniquefacts = preg_split("/[, ;:]+/", get_gedcom_setting(WT_GED_ID, 'INDI_FACTS_UNIQUE'), -1, PREG_SPLIT_NO_EMPTY); $quickfacts = preg_split("/[, ;:]+/", get_gedcom_setting(WT_GED_ID, 'INDI_FACTS_QUICK'), -1, PREG_SPLIT_NO_EMPTY); break; case "FAM": $addfacts = preg_split("/[, ;:]+/", get_gedcom_setting(WT_GED_ID, 'FAM_FACTS_ADD'), -1, PREG_SPLIT_NO_EMPTY); $uniquefacts = preg_split("/[, ;:]+/", get_gedcom_setting(WT_GED_ID, 'FAM_FACTS_UNIQUE'), -1, PREG_SPLIT_NO_EMPTY); $quickfacts = preg_split("/[, ;:]+/", get_gedcom_setting(WT_GED_ID, 'FAM_FACTS_QUICK'), -1, PREG_SPLIT_NO_EMPTY); break; case "SOUR": $addfacts = preg_split("/[, ;:]+/", get_gedcom_setting(WT_GED_ID, 'SOUR_FACTS_ADD'), -1, PREG_SPLIT_NO_EMPTY); $uniquefacts = preg_split("/[, ;:]+/", get_gedcom_setting(WT_GED_ID, 'SOUR_FACTS_UNIQUE'), -1, PREG_SPLIT_NO_EMPTY); $quickfacts = preg_split("/[, ;:]+/", get_gedcom_setting(WT_GED_ID, 'SOUR_FACTS_QUICK'), -1, PREG_SPLIT_NO_EMPTY); break; case "NOTE": $addfacts = preg_split("/[, ;:]+/", get_gedcom_setting(WT_GED_ID, 'NOTE_FACTS_ADD'), -1, PREG_SPLIT_NO_EMPTY); $uniquefacts = preg_split("/[, ;:]+/", get_gedcom_setting(WT_GED_ID, 'NOTE_FACTS_UNIQUE'), -1, PREG_SPLIT_NO_EMPTY); $quickfacts = preg_split("/[, ;:]+/", get_gedcom_setting(WT_GED_ID, 'NOTE_FACTS_QUICK'), -1, PREG_SPLIT_NO_EMPTY); break; case "REPO": $addfacts = preg_split("/[, ;:]+/", get_gedcom_setting(WT_GED_ID, 'REPO_FACTS_ADD'), -1, PREG_SPLIT_NO_EMPTY); $uniquefacts = preg_split("/[, ;:]+/", get_gedcom_setting(WT_GED_ID, 'REPO_FACTS_UNIQUE'), -1, PREG_SPLIT_NO_EMPTY); $quickfacts = preg_split("/[, ;:]+/", get_gedcom_setting(WT_GED_ID, 'REPO_FACTS_QUICK'), -1, PREG_SPLIT_NO_EMPTY); break; default: return; } $addfacts = array_merge(CheckFactUnique($uniquefacts, $usedfacts, $type), $addfacts); $quickfacts = array_intersect($quickfacts, $addfacts); $translated_addfacts = array(); foreach ($addfacts as $addfact) { $translated_addfacts[$addfact] = WT_Gedcom_Tag::getLabel($addfact); } uasort($translated_addfacts, function ($x, $y) { return WT_I18N::strcasecmp(WT_I18N::translate($x), WT_I18N::translate($y)); }); echo '<tr><td class="descriptionbox">'; echo WT_I18N::translate('Fact or event'); echo help_link('add_facts'), '</td>'; echo '<td class="optionbox wrap">'; echo '<form method="get" name="newfactform" action="?" onsubmit="return false;">'; echo '<select id="newfact" name="newfact">'; echo '<option value="" disabled selected>' . WT_I18N::translate('<select>') . '</option>'; foreach ($translated_addfacts as $fact => $fact_name) { echo '<option value="', $fact, '">', $fact_name, '</option>'; } if ($type == 'INDI' || $type == 'FAM') { echo '<option value="FACT">', WT_I18N::translate('Custom fact'), '</option>'; echo '<option value="EVEN">', WT_I18N::translate('Custom event'), '</option>'; } echo '</select>'; echo '<input type="button" value="', WT_I18N::translate('Add'), '" onclick="add_record(\'' . $id . '\', \'newfact\');">'; echo '<span class="quickfacts">'; foreach ($quickfacts as $fact) { echo '<a href="#" onclick="add_new_record(\'' . $id . '\', \'' . $fact . '\');return false;">', WT_Gedcom_Tag::getLabel($fact), '</a>'; } echo '</span></form>'; echo '</td></tr>'; }
?> <form method="post" action="edit_interface.php" onsubmit="return check_form(this);"> <input type="hidden" name="action" value="addnoteaction_assisted"> <input type="hidden" name="noteid" value="newnote"> <input id="pid_array" type="hidden" name="pid_array" value="none"> <input id="xref" type="hidden" name="xref" value=<?php echo $xref; ?> > <?php echo WT_Filter::getCsrf(); global $tabno, $linkToID, $SEARCH_SPIDER; global $SHOW_AGE_DIFF, $GEDCOM; global $show_full, $famid; $summary = $person->format_first_major_fact(WT_EVENTS_BIRT, 2); if (!$person->isDead()) { // If alive display age $bdate = $person->getBirthDate(); $age = WT_Date::GetAgeGedcom($bdate); if ($age != "") { $summary .= "<span class=\"label\">" . WT_I18N::translate('Age') . ":</span><span class=\"field\"> " . get_age_at_event($age, true) . "</span>"; } } $summary .= $person->format_first_major_fact(WT_EVENTS_DEAT, 2); require WT_ROOT . WT_MODULES_DIR . 'GEDFact_assistant/_CENS/census_1_ctrl.php'; ?> </form> </div> <div style="clear:both;"></div> </div><!-- id="edit_interface-page" -->
public function isDead() { global $MAX_ALIVE_AGE; // "1 DEAT Y" or "1 DEAT/2 DATE" or "1 DEAT/2 PLAC" if (preg_match('/\\n1 (?:' . WT_EVENTS_DEAT . ')(?: Y|(?:\\n[2-9].+)*\\n2 (DATE|PLAC) )/', $this->gedcom)) { return true; } // If any event occured more than $MAX_ALIVE_AGE years ago, then assume the individual is dead if (preg_match_all('/\\n2 DATE (.+)/', $this->gedcom, $date_matches)) { foreach ($date_matches[1] as $date_match) { $date = new WT_Date($date_match); if ($date->isOK() && $date->MaxJD() <= WT_CLIENT_JD - 365 * $MAX_ALIVE_AGE) { return true; } } // The individual has one or more dated events. All are less than $MAX_ALIVE_AGE years ago. // If one of these is a birth, the individual must be alive. if (preg_match('/\\n1 BIRT(?:\\n[2-9].+)*\\n2 DATE /', $this->gedcom)) { return false; } } // If we found no conclusive dates then check the dates of close relatives. // Check parents (birth and adopted) foreach ($this->getChildFamilies(WT_PRIV_HIDE) as $family) { foreach ($family->getSpouses(WT_PRIV_HIDE) as $parent) { // Assume parents are no more than 45 years older than their children preg_match_all('/\\n2 DATE (.+)/', $parent->gedcom, $date_matches); foreach ($date_matches[1] as $date_match) { $date = new WT_Date($date_match); if ($date->isOK() && $date->MaxJD() <= WT_CLIENT_JD - 365 * ($MAX_ALIVE_AGE + 45)) { return true; } } } } // Check spouses foreach ($this->getSpouseFamilies(WT_PRIV_HIDE) as $family) { preg_match_all('/\\n2 DATE (.+)/', $family->gedcom, $date_matches); foreach ($date_matches[1] as $date_match) { $date = new WT_Date($date_match); // Assume marriage occurs after age of 10 if ($date->isOK() && $date->MaxJD() <= WT_CLIENT_JD - 365 * ($MAX_ALIVE_AGE - 10)) { return true; } } // Check spouse dates $spouse = $family->getSpouse($this); if ($spouse) { preg_match_all('/\\n2 DATE (.+)/', $spouse->gedcom, $date_matches); foreach ($date_matches[1] as $date_match) { $date = new WT_Date($date_match); // Assume max age difference between spouses of 40 years if ($date->isOK() && $date->MaxJD() <= WT_CLIENT_JD - 365 * ($MAX_ALIVE_AGE + 40)) { return true; } } } // Check child dates foreach ($family->getChildren(WT_PRIV_HIDE) as $child) { preg_match_all('/\\n2 DATE (.+)/', $child->gedcom, $date_matches); // Assume children born after age of 15 foreach ($date_matches[1] as $date_match) { $date = new WT_Date($date_match); if ($date->isOK() && $date->MaxJD() <= WT_CLIENT_JD - 365 * ($MAX_ALIVE_AGE - 15)) { return true; } } // Check grandchildren foreach ($child->getSpouseFamilies(WT_PRIV_HIDE) as $child_family) { foreach ($child_family->getChildren(WT_PRIV_HIDE) as $grandchild) { preg_match_all('/\\n2 DATE (.+)/', $grandchild->gedcom, $date_matches); // Assume grandchildren born after age of 30 foreach ($date_matches[1] as $date_match) { $date = new WT_Date($date_match); if ($date->isOK() && $date->MaxJD() <= WT_CLIENT_JD - 365 * ($MAX_ALIVE_AGE - 30)) { return true; } } } } } } return false; }
/** * 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 * @param string $extra optional text to display after the input field * @param WT_Individual $person For male/female translations * * @return string */ function add_simple_tag($tag, $upperlevel = '', $label = '', $extra = null, WT_Individual $person = null) { global $tags, $emptyfacts, $main_fact, $FILE_FORM_accept, $xref, $bdm, $action; global $QUICK_REQUIRED_FACTS, $QUICK_REQUIRED_FAMFACTS, $PREFER_LEVEL2_SOURCES; $subnamefacts = array("NPFX", "GIVN", "SPFX", "SURN", "NSFX", "_MARNM_SURN"); preg_match('/^(?:(\\d+) (' . WT_REGEX_TAG . ') ?(.*))/', $tag, $match); list(, $level, $fact, $value) = $match; // 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 . Uuid::uuid4(); } if ($upperlevel) { $element_id = $upperlevel . '_' . $fact . Uuid::uuid4(); } // field value $islink = substr($value, 0, 1) === '@' && 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; } if ($fact == 'SHARED_NOTE_EDIT' || $fact == 'SHARED_NOTE') { $islink = 1; $fact = "NOTE"; } // label echo "<tr id=\"", $element_id, "_tr\" "; if ($fact == "MAP" || ($fact == "LATI" || $fact == "LONG") && $value == '') { echo " style=\"display:none;\""; } echo " >"; if (in_array($fact, $subnamefacts) || $fact == "LATI" || $fact == "LONG") { echo "<td class=\"optionbox wrap width25\">"; } else { echo "<td class=\"descriptionbox wrap width25\">"; } if (WT_DEBUG) { echo $element_name, "<br>"; } // tag name if ($label) { echo $label; } elseif ($upperlevel) { echo WT_Gedcom_Tag::getLabel($upperlevel . ':' . $fact); } else { echo WT_Gedcom_Tag::getLabel($fact); } // help link // If using GEDFact-assistant window if ($action == "addnewnote_assisted") { // Do not print on GEDFact Assistant window } else { // Not all facts have help text. switch ($fact) { case 'FORM': if ($upperlevel != 'OBJE') { echo help_link($fact); } break; case 'NOTE': if ($islink) { echo help_link('edit_add_SHARED_NOTE'); } else { echo help_link($fact); } break; case 'NAME': if ($upperlevel != 'REPO') { echo help_link($fact); } break; case 'ASSO': case '_ASSO': // Some apps (including webtrees) use "2 _ASSO", since "2 ASSO" is not strictly valid GEDCOM if ($level == 1) { echo help_link('ASSO_1'); } else { echo help_link('ASSO_2'); } break; case 'ADDR': case 'AGNC': case 'CAUS': case 'DATE': case 'EMAI': case 'EMAIL': case 'EMAL': case '_EMAIL': case 'FAX': case 'OBJE': case 'PAGE': case 'PEDI': case 'PHON': case 'PLAC': case 'RELA': case 'RESN': case 'ROMN': case 'SEX': case 'SOUR': case 'STAT': case 'SURN': case 'TEMP': case 'TEXT': case 'TIME': case 'URL': case '_HEB': case '_PRIM': echo help_link($fact); break; } } // tag level if ($level > 0) { if ($fact == 'TEXT' && $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, "\">"; echo "<input type=\"hidden\" name=\"islink[]\" value=\"", $islink, "\">"; echo "<input type=\"hidden\" name=\"tag[]\" value=\"", $fact, "\">"; } echo "</td>"; // value echo "<td class=\"optionbox wrap\">"; if (WT_DEBUG) { echo $tag, "<br>"; } // retrieve linked NOTE if ($fact == "NOTE" && $islink) { $note1 = WT_Note::getInstance($value); if ($note1) { $noterec = $note1->getGedcom(); preg_match("/{$value}/i", $noterec, $notematch); $value = $notematch[0]; } } if (in_array($fact, $emptyfacts) && ($value == '' || $value == 'Y' || $value == 'y')) { echo "<input type=\"hidden\" id=\"", $element_id, "\" name=\"", $element_name, "\" value=\"", $value, "\">"; if ($level <= 1) { echo '<input type="checkbox" '; if ($value) { echo ' checked="checked"'; } echo " onclick=\"if (this.checked) ", $element_id, ".value='Y'; else ", $element_id, ".value='';\">"; echo WT_I18N::translate('yes'); } } else { if ($fact == "TEMP") { echo select_edit_control($element_name, WT_Gedcom_Code_Temp::templeNames(), WT_I18N::translate('No temple - living ordinance'), $value); } else { if ($fact == "ADOP") { echo edit_field_adop($element_name, $value, '', $person); } else { if ($fact == "PEDI") { echo edit_field_pedi($element_name, $value, '', $person); } else { if ($fact == 'STAT') { echo select_edit_control($element_name, WT_Gedcom_Code_Stat::statusNames($upperlevel), '', $value); } else { if ($fact == 'RELA') { echo edit_field_rela($element_name, strtolower($value)); } else { if ($fact == 'QUAY') { echo select_edit_control($element_name, WT_Gedcom_Code_Quay::getValues(), '', $value); } else { if ($fact == '_WT_USER') { echo edit_field_username($element_name, $value); } else { if ($fact == 'RESN') { echo edit_field_resn($element_name, $value); } else { if ($fact == '_PRIM') { echo '<select id="', $element_id, '" name="', $element_name, '" >'; echo '<option value=""></option>'; echo '<option value="Y"'; if ($value == 'Y') { echo ' selected="selected"'; } echo '>', WT_I18N::translate('yes'), '</option>'; echo '<option value="N"'; if ($value == 'N') { echo ' selected="selected"'; } echo '>', WT_I18N::translate('no'), '</option>'; echo '</select>'; } else { if ($fact == 'SEX') { echo '<select id="', $element_id, '" name="', $element_name, '"><option value="M"'; if ($value == 'M') { echo ' selected="selected"'; } echo '>', WT_I18N::translate('Male'), '</option><option value="F"'; if ($value == 'F') { echo ' selected="selected"'; } echo '>', WT_I18N::translate('Female'), '</option><option value="U"'; if ($value == 'U' || empty($value)) { echo ' selected="selected"'; } echo '>', WT_I18N::translate_c('unknown gender', 'Unknown'), '</option></select>'; } else { if ($fact == 'TYPE' && $level == '3') { //-- Build the selector for the Media 'TYPE' Fact echo '<select name="text[]"><option selected="selected" value="" ></option>'; $selectedValue = strtolower($value); if (!array_key_exists($selectedValue, WT_Gedcom_Tag::getFileFormTypes())) { echo '<option selected="selected" value="', WT_Filter::escapeHtml($value), '" >', WT_Filter::escapeHtml($value), '</option>'; } foreach (WT_Gedcom_Tag::getFileFormTypes() 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=\"", WT_Filter::escapeHtml($value), "\" class=\"", $fact, "\">"; echo '<span id="', $element_id, '_display" dir="auto">', WT_Filter::escapeHtml($value), '</span>'; echo ' <a href="#edit_name" onclick="convertHidden(\'', $element_id, '\'); return false;" class="icon-edit_indi" title="' . WT_I18N::translate('Edit name') . '"></a>'; } else { // textarea if ($fact == 'TEXT' || $fact == 'ADDR' || $fact == 'NOTE' && !$islink) { echo "<textarea id=\"", $element_id, "\" name=\"", $element_name, "\" dir=\"auto\">", WT_Filter::escapeHtml($value), "</textarea><br>"; } else { // text // If using GEDFact-assistant window if ($action == "addnewnote_assisted") { echo "<input type=\"text\" id=\"", $element_id, "\" name=\"", $element_name, "\" value=\"", WT_Filter::escapeHtml($value), "\" style=\"width:4.1em;\" dir=\"ltr\""; } else { echo "<input type=\"text\" id=\"", $element_id, "\" name=\"", $element_name, "\" value=\"", WT_Filter::escapeHtml($value), "\" dir=\"ltr\""; } echo " class=\"{$fact}\""; if (in_array($fact, $subnamefacts)) { echo " onblur=\"updatewholename();\" onkeyup=\"updatewholename();\""; } // Extra markup for specific fact types switch ($fact) { case 'DATE': echo " onblur=\"valid_date(this);\" onmouseout=\"valid_date(this);\""; break; case 'GIVN': echo ' autofocus data-autocomplete-type="GIVN"'; break; case 'LATI': echo " onblur=\"valid_lati_long(this, 'N', 'S');\" onmouseout=\"valid_lati_long(this, 'N', 'S');\""; break; case 'LONG': echo " onblur=\"valid_lati_long(this, 'E', 'W');\" onmouseout=\"valid_lati_long(this, 'E', 'W');\""; break; case 'NOTE': // Shared notes. Inline notes are handled elsewhere. echo ' data-autocomplete-type="NOTE"'; break; case 'OBJE': echo ' data-autocomplete-type="OBJE"'; break; case 'PLAC': echo ' data-autocomplete-type="PLAC"'; break; case 'REPO': echo ' data-autocomplete-type="REPO"'; break; case 'SOUR': echo ' data-autocomplete-type="SOUR"'; break; case 'SURN': case '_MARNM_SURN': echo ' data-autocomplete-type="SURN"'; break; } echo '>'; } $tmp_array = array('TYPE', 'TIME', 'NOTE', 'SOUR', 'REPO', 'OBJE', 'ASSO', '_ASSO', 'AGE'); // split PLAC if ($fact == 'PLAC') { echo "<div id=\"", $element_id, "_pop\" style=\"display: inline;\">"; echo print_specialchar_link($element_id), ' ', print_findplace_link($element_id); echo '<span onclick="jQuery(\'tr[id^=', $upperlevel, '_LATI],tr[id^=', $upperlevel, '_LONG],tr[id^=LATI],tr[id^=LONG]\').toggle(\'fast\'); return false;" class="icon-target" title="', WT_Gedcom_Tag::getLabel('LATI'), ' / ', WT_Gedcom_Tag::getLabel('LONG'), '"></span>'; echo '</div>'; if (array_key_exists('places_assistant', WT_Module::getActiveModules())) { places_assistant_WT_Module::setup_place_subfields($element_id); places_assistant_WT_Module::print_place_subfields($element_id); } } elseif (!in_array($fact, $tmp_array)) { echo print_specialchar_link($element_id); } } } } } } } } } } } } } } // MARRiage TYPE : hide text field and show a selection list if ($fact == 'TYPE' && $level == 2 && $tags[0] == 'MARR') { echo '<script>'; echo "document.getElementById('", $element_id, "').style.display='none'"; echo '</script>'; echo "<select id=\"", $element_id, "_sel\" onchange=\"document.getElementById('", $element_id, "').value=this.value;\" >"; foreach (array("Unknown", "Civil", "Religious", "Partners") as $key) { if ($key == "Unknown") { echo "<option value=\"\""; } else { echo "<option value=\"", $key, "\""; } $a = strtolower($key); $b = strtolower($value); if (@strpos($a, $b) !== false || @strpos($b, $a) !== false) { echo ' selected="selected"'; } $tmp = "MARR_" . strtoupper($key); echo ">", WT_Gedcom_Tag::getLabel($tmp), "</option>"; } echo "</select>"; } else { if ($fact == 'TYPE' && $level == 0) { $onchange = 'onchange="document.getElementById(\'' . $element_id . '\').value=this.value;"'; echo edit_field_name_type($element_name, $value, $onchange, $person); echo '<script>'; echo "document.getElementById('", $element_id, "').style.display='none';"; echo '</script>'; } } // popup links switch ($fact) { case 'DATE': echo print_calendar_popup($element_id); // Allow the GEDFact_assistant module to show a census-date selector if (array_key_exists('GEDFact_assistant', WT_Module::getActiveModules())) { echo GEDFact_assistant_WT_Module::censusDateSelector($action, $upperlevel, $element_id); } break; case 'FAMC': case 'FAMS': echo print_findfamily_link($element_id); break; case 'ASSO': case '_ASSO': echo print_findindi_link($element_id, $element_id . '_description'); break; case 'FILE': print_findmedia_link($element_id, "0file"); break; case 'SOUR': echo print_findsource_link($element_id, $element_id . '_description'), ' ', print_addnewsource_link($element_id); //-- 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="1">'; echo WT_I18N::translate('Individual'); if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $QUICK_REQUIRED_FACTS, $matches)) { foreach ($matches[1] as $match) { if (!in_array($match, explode('|', WT_EVENTS_DEAT))) { echo ' <input type="checkbox" name="SOUR_', $match, '"', $level2_checked, ' value="1">'; echo WT_Gedcom_Tag::getLabel($match); } } } } if (strpos($bdm, 'D') !== false) { if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $QUICK_REQUIRED_FACTS, $matches)) { foreach ($matches[1] as $match) { if (in_array($match, explode('|', WT_EVENTS_DEAT))) { echo ' <input type="checkbox" name="SOUR_', $match, '"', $level2_checked, ' value="1">'; echo WT_Gedcom_Tag::getLabel($match); } } } } if (strpos($bdm, 'M') !== false) { echo ' <input type="checkbox" name="SOUR_FAM" ', $level1_checked, ' value="1">'; echo WT_I18N::translate('Family'); if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $QUICK_REQUIRED_FAMFACTS, $matches)) { foreach ($matches[1] as $match) { echo ' <input type="checkbox" name="SOUR_', $match, '"', $level2_checked, ' value="1">'; echo WT_Gedcom_Tag::getLabel($match); } } } } break; case 'REPO': echo print_findrepository_link($element_id), ' ', print_addnewrepository_link($element_id); break; case 'NOTE': // Shared Notes Icons ======================================== if ($islink) { // Print regular Shared Note icons --------------------------- echo ' ', print_findnote_link($element_id, $element_id . '_description'), ' ', print_addnewnote_link($element_id); if ($value) { echo ' ', print_editnote_link($value); } // Allow the GEDFact_assistant module to create a formatted shared note. if (array_key_exists('GEDFact_assistant', WT_Module::getActiveModules())) { echo GEDFact_assistant_WT_Module::print_addnewnote_assisted_link($element_id, $xref, $action); } } break; case 'OBJE': echo print_findmedia_link($element_id, '1media'); if (!$value) { echo ' ', print_addnewmedia_link($element_id); $value = 'new'; } break; } echo '<div id="' . $element_id . '_description">'; // current value if ($fact == 'DATE') { $date = new WT_Date($value); echo $date->Display(false); } if ($value && $value != 'new' && $islink) { switch ($fact) { case 'ASSO': case '_ASSO': $tmp = WT_Individual::getInstance($value); if ($tmp) { echo ' ', $tmp->getFullname(); } break; case 'SOUR': $tmp = WT_Source::getInstance($value); if ($tmp) { echo ' ', $tmp->getFullname(); } break; case 'NOTE': $tmp = WT_Note::getInstance($value); if ($tmp) { echo ' ', $tmp->getFullname(); } break; case 'OBJE': $tmp = WT_Media::getInstance($value); if ($tmp) { echo ' ', $tmp->getFullname(); } break; case 'REPO': $tmp = WT_Repository::getInstance($value); if ($tmp) { echo ' ', $tmp->getFullname(); } break; } } // pastable values if ($fact == 'FORM' && $upperlevel == 'OBJE') { print_autopaste_link($element_id, $FILE_FORM_accept); } echo '</div>', $extra, '</td></tr>'; return $element_id; }
/** * print a list of events * * This performs the same function as print_events_table(), but formats the output differently. */ function print_events_list($startjd, $endjd, $events = 'BIRT MARR DEAT', $only_living = false, $sort_by = 'anniv') { // Did we have any output? Did we skip anything? $output = 0; $filter = 0; $filtered_events = array(); $html = ''; foreach (get_events_list($startjd, $endjd, $events) as $fact) { $record = $fact->getParent(); //-- only living people ? if ($only_living) { if ($record instanceof WT_Individual && $record->isDead()) { $filter++; continue; } if ($record instanceof WT_Family) { $husb = $record->getHusband(); if (is_null($husb) || $husb->isDead()) { $filter++; continue; } $wife = $record->getWife(); if (is_null($wife) || $wife->isDead()) { $filter++; continue; } } } $output++; $filtered_events[] = $fact; } // Now we've filtered the list, we can sort by event, if required switch ($sort_by) { case 'anniv': uasort($filtered_events, function ($x, $y) { return WT_Date::compare($y->getDate(), $x->getDate()); // most recent first }); break; case 'alpha': uasort($filtered_events, function ($x, $y) { return WT_GedcomRecord::compare($x->getParent(), $y->getParent()); }); break; } foreach ($filtered_events as $fact) { $record = $fact->getParent(); $html .= '<a href="' . $record->getHtmlUrl() . '" class="list_item name2">' . $record->getFullName() . '</a>'; if ($record instanceof WT_Individual) { $html .= $record->getSexImage(); } $html .= '<br><div class="indent">'; $html .= $fact->getLabel() . ' — ' . $fact->getDate()->Display(true); if ($fact->anniv) { $html .= ' (' . WT_I18N::translate('%s year anniversary', $fact->anniv) . ')'; } if (!$fact->getPlace()->isEmpty()) { $html .= ' — <a href="' . $fact->getPlace()->getURL() . '">' . $fact->getPlace()->getFullName() . '</a>'; } $html .= '</div>'; } // Print a final summary message about restricted/filtered facts $summary = ''; if ($endjd == WT_CLIENT_JD) { // We're dealing with the Today’s Events block if ($output == 0) { if ($filter == 0) { $summary = WT_I18N::translate('No events exist for today.'); } else { $summary = WT_I18N::translate('No events for living individuals exist for today.'); } } } else { // We're dealing with the Upcoming Events block if ($output == 0) { if ($filter == 0) { if ($endjd == $startjd) { $summary = WT_I18N::translate('No events exist for tomorrow.'); } else { // I18N: translation for %s==1 is unused; it is translated separately as “tomorrow” $summary = WT_I18N::plural('No events exist for the next %s day.', 'No events exist for the next %s days.', $endjd - $startjd + 1, WT_I18N::number($endjd - $startjd + 1)); } } else { if ($endjd == $startjd) { $summary = WT_I18N::translate('No events for living individuals exist for tomorrow.'); } else { // I18N: translation for %s==1 is unused; it is translated separately as “tomorrow” $summary = WT_I18N::plural('No events for living people exist for the next %s day.', 'No events for living people exist for the next %s days.', $endjd - $startjd + 1, WT_I18N::number($endjd - $startjd + 1)); } } } } if ($summary) { $html .= "<b>" . $summary . "</b>"; } return $html; }
/** * XML <List> start element handler * * @see ListEHandler() * * @param array $attrs an array of key value pairs for the attributes */ function ListSHandler($attrs) { global $gedrec, $repeats, $repeatBytes, $list, $repeatsStack, $processRepeats, $parser, $vars, $sortby; global $GEDCOM; $processRepeats++; if ($processRepeats > 1) { return; } $match = array(); if (isset($attrs['sortby'])) { $sortby = $attrs['sortby']; if (preg_match("/\\\$(\\w+)/", $sortby, $match)) { $sortby = $vars[$match[1]]['id']; $sortby = trim($sortby); } } else { $sortby = "NAME"; } if (isset($attrs['list'])) { $listname = $attrs['list']; } else { $listname = "individual"; } // Some filters/sorts can be applied using SQL, while others require PHP switch ($listname) { case "pending": $rows = WT_DB::prepare("SELECT xref, gedcom_id, CASE new_gedcom WHEN '' THEN old_gedcom ELSE new_gedcom END AS gedcom" . " FROM `##change`" . " WHERE (xref, change_id) IN (" . " SELECT xref, MAX(change_id)" . " FROM `##change`" . " WHERE status='pending' AND gedcom_id=?" . " GROUP BY xref" . " )")->execute(array(WT_GED_ID))->fetchAll(); $list = array(); foreach ($rows as $row) { $list[] = WT_GedcomRecord::getInstance($row->xref, $row->gedcom_id, $row->gedcom); } break; case "individual": case "family": $sql_col_prefix = substr($listname, 0, 1) . "_"; // i_ for individual, f_ for family, etc. $sql_join = array(); $sql_where = array($sql_col_prefix . "file=" . WT_GED_ID); $sql_order_by = array(); foreach ($attrs as $attr => $value) { if (strpos($attr, "filter") === 0 && $value) { // Substitute global vars $value = preg_replace_callback('/\\$(\\w+)/', function ($matches) use($vars) { return $vars[$matches[1]]['id']; }, $value); // Convert the various filters into SQL if (preg_match('/^(\\w+):DATE (LTE|GTE) (.+)$/', $value, $match)) { $sql_join[] = "JOIN `##dates` AS {$attr} ON ({$attr}.d_file={$sql_col_prefix}file AND {$attr}.d_gid={$sql_col_prefix}id)"; $sql_where[] = "{$attr}.d_fact='{$match[1]}'"; $date = new WT_Date($match[3]); if ($match[2] == "LTE") { $sql_where[] = "{$attr}.d_julianday2<=" . $date->minJD(); } else { $sql_where[] = "{$attr}.d_julianday1>=" . $date->minJD(); } if ($sortby == $match[1]) { $sortby = ""; $sql_order_by[] = "{$attr}.d_julianday1"; } unset($attrs[$attr]); // This filter has been fully processed } elseif ($listname == "individual" && preg_match('/^NAME CONTAINS (.*)$/', $value, $match)) { // Do nothing, unless you have to if ($match[1] != "" or $sortby == "NAME") { $sql_join[] = "JOIN `##name` AS {$attr} ON (n_file={$sql_col_prefix}file AND n_id={$sql_col_prefix}id)"; // Search the DB only if there is any name supplied if ($match[1] != "") { $names = explode(" ", $match[1]); foreach ($names as $name) { $sql_where[] = "{$attr}.n_full LIKE " . WT_DB::quote("%{$name}%"); } } // Let the DB do the name sorting even when no name was entered if ($sortby == "NAME") { $sortby = ""; $sql_order_by[] = "{$attr}.n_sort"; } } unset($attrs[$attr]); // This filter has been fully processed } elseif ($listname == "individual" && preg_match('/^REGEXP \\/(.+)\\//', $value, $match)) { $sql_where[] = "i_gedcom REGEXP '" . $match[1] . "'"; unset($attrs[$attr]); // This filter has been fully processed } elseif ($listname == "family" && preg_match('/^REGEXP \\/(.+)\\//', $value, $match)) { $sql_where[] = "f_gedcom REGEXP '" . $match[1] . "'"; unset($attrs[$attr]); // This filter has been fully processed } elseif ($listname == "family" && preg_match('/^NAME CONTAINS (.+)$/', $value, $match)) { // Eventually, family "names" will be stored in wt_name. Until then, an extra is needed.... $sql_join[] = "JOIN `##link` AS {$attr}a ON ({$attr}a.l_file={$sql_col_prefix}file AND {$attr}a.l_from={$sql_col_prefix}id)"; $sql_join[] = "JOIN `##name` AS {$attr}b ON ({$attr}b.n_file={$sql_col_prefix}file AND n_id={$sql_col_prefix}id)"; $sql_where[] = "{$attr}a.l_type=IN ('HUSB, 'WIFE')"; $sql_where[] = "{$attr}.n_full LIKE " . WT_DB::quote("%{$match[1]}%"); if ($sortby == "NAME") { $sortby = ""; $sql_order_by[] = "{$attr}.n_sort"; } unset($attrs[$attr]); // This filter has been fully processed } elseif (preg_match('/^(?:\\w+):PLAC CONTAINS (.+)$/', $value, $match)) { $sql_join[] = "JOIN `##places` AS {$attr}a ON ({$attr}a.p_file={$sql_col_prefix}file)"; $sql_join[] = "JOIN `##placelinks` AS {$attr}b ON ({$attr}a.p_file={$attr}b.pl_file AND {$attr}b.pl_p_id={$attr}a.p_id AND {$attr}b.pl_gid={$sql_col_prefix}id)"; $sql_where[] = "{$attr}a.p_place LIKE " . WT_DB::quote("%{$match[1]}%"); // Don't unset this filter. This is just the first primary PLAC filter to reduce the returned list from the DB } elseif ($listname == "individual" && preg_match('/^(\\w*):*(\\w*) CONTAINS (.+)$/', $value, $match)) { $query = ""; // Level 1 tag if ($match[1] != "") { $query .= "%1 {$match[1]}%"; } // Level 2 tag if ($match[2] != "") { $query .= "%2 {$match[2]}%"; } // Contains what? if ($match[3] != "") { $query .= "%{$match[3]}%"; } $sql_where[] = "i_gedcom LIKE " . WT_DB::quote($query); } elseif ($listname == "family" && preg_match('/^(\\w*):*(\\w*) CONTAINS (.+)$/', $value, $match)) { $query = ""; // Level 1 tag if ($match[1] != "") { $query .= "%1 {$match[1]}%"; } // Level 2 tag if ($match[2] != "") { $query .= "%2 {$match[2]}%"; } // Contains what? if ($match[3] != "") { $query .= "%{$match[3]}%"; } $sql_where[] = "f_gedcom LIKE " . WT_DB::quote($query); } else { // TODO: what other filters can we apply in SQL? } } } if ($listname == "family") { $list = search_fams_custom($sql_join, $sql_where, $sql_order_by); } else { $list = search_indis_custom($sql_join, $sql_where, $sql_order_by); } // Clean up the SQL queries - they will not be used again unset($sql_join, $sql_where, $sql_order_by); break; default: die("Invalid list name: {$listname}"); } $filters = array(); $filters2 = array(); if (isset($attrs['filter1']) and count($list) > 0) { foreach ($attrs as $key => $value) { if (preg_match("/filter(\\d)/", $key)) { $condition = $value; if (preg_match("/@(\\w+)/", $condition, $match)) { $id = $match[1]; $value = "''"; if ($id == "ID") { if (preg_match("/0 @(.+)@/", $gedrec, $match)) { $value = "'" . $match[1] . "'"; } } elseif ($id == "fact") { $value = "'{$fact}'"; } elseif ($id == "desc") { $value = "'{$desc}'"; } else { if (preg_match("/\\d {$id} (.+)/", $gedrec, $match)) { $value = "'" . str_replace("@", "", trim($match[1])) . "'"; } } $condition = preg_replace("/@{$id}/", $value, $condition); } //-- handle regular expressions if (preg_match("/([A-Z:]+)\\s*([^\\s]+)\\s*(.+)/", $condition, $match)) { $tag = trim($match[1]); $expr = trim($match[2]); $val = trim($match[3]); if (preg_match("/\\\$(\\w+)/", $val, $match)) { $val = $vars[$match[1]]['id']; $val = trim($val); } if ($val) { $searchstr = ""; $tags = explode(":", $tag); //-- only limit to a level number if we are specifically looking at a level if (count($tags) > 1) { $level = 1; foreach ($tags as $t) { if (!empty($searchstr)) { $searchstr .= "[^\n]*(\n[2-9][^\n]*)*\n"; } //-- search for both EMAIL and _EMAIL... silly double gedcom standard if ($t == "EMAIL" || $t == "_EMAIL") { $t = "_?EMAIL"; } $searchstr .= $level . " " . $t; $level++; } } else { if ($tag == "EMAIL" || $tag == "_EMAIL") { $tag = "_?EMAIL"; } $t = $tag; $searchstr = "1 " . $tag; } switch ($expr) { case "CONTAINS": if ($t == "PLAC") { $searchstr .= "[^\n]*[, ]*" . $val; } else { $searchstr .= "[^\n]*" . $val; } $filters[] = $searchstr; break; default: $filters2[] = array("tag" => $tag, "expr" => $expr, "val" => $val); break; } } } } } } //-- apply other filters to the list that could not be added to the search string if ($filters) { foreach ($list as $key => $record) { foreach ($filters as $filter) { if (!preg_match("/" . $filter . "/i", $record->privatizeGedcom(WT_USER_ACCESS_LEVEL))) { unset($list[$key]); break; } } } } if ($filters2) { $mylist = array(); foreach ($list as $indi) { $key = $indi->getXref(); $grec = $indi->privatizeGedcom(WT_USER_ACCESS_LEVEL); $keep = true; foreach ($filters2 as $filter) { if ($keep) { $tag = $filter['tag']; $expr = $filter['expr']; $val = $filter['val']; if ($val == "''") { $val = ""; } $tags = explode(":", $tag); $t = end($tags); $v = get_gedcom_value($tag, 1, $grec); //-- check for EMAIL and _EMAIL (silly double gedcom standard :P) if ($t == "EMAIL" && empty($v)) { $tag = str_replace("EMAIL", "_EMAIL", $tag); $tags = explode(":", $tag); $t = end($tags); $v = get_sub_record(1, $tag, $grec); } $level = count($tags); switch ($expr) { case "GTE": if ($t == "DATE") { $date1 = new WT_Date($v); $date2 = new WT_Date($val); $keep = WT_Date::Compare($date1, $date2) >= 0; } elseif ($val >= $v) { $keep = true; } break; case "LTE": if ($t == "DATE") { $date1 = new WT_Date($v); $date2 = new WT_Date($val); $keep = WT_Date::Compare($date1, $date2) <= 0; } elseif ($val >= $v) { $keep = true; } break; default: if ($v == $val) { $keep = true; } else { $keep = false; } break; } } } if ($keep) { $mylist[$key] = $indi; } } $list = $mylist; } switch ($sortby) { case "NAME": uasort($list, array("WT_GedcomRecord", "compare")); break; case "CHAN": uasort($list, function (WT_GedcomRecord $x, WT_GedcomRecord $y) { $f1 = $x->getFirstFact('CHAN'); $f2 = $y->getFirstFact('CHAN'); if ($f1 && $f2) { $d1 = $f1->getDate(); $d2 = $f2->getDate(); $cmp = WT_Date::compare($d1, $d2); if ($cmp) { return $cmp; } else { // Same date. Compare times preg_match('/\\n3 TIME (.+)/', $f1->getGedcom(), $m1); preg_match('/\\n3 TIME (.+)/', $f2->getGedcom(), $m2); return strcmp($m1[1], $m2[1]); } } else { return 0; } }); break; case "BIRT:DATE": uasort($list, array("WT_Individual", "CompareBirtDate")); break; case "DEAT:DATE": uasort($list, array("WT_Individual", "CompareDeatDate")); break; case "MARR:DATE": uasort($list, array("WT_Family", "compareMarrDate")); break; default: // unsorted or already sorted by SQL break; } array_push($repeatsStack, array($repeats, $repeatBytes)); $repeatBytes = xml_get_current_line_number($parser) + 1; }
<?php echo $gparent->getFullName(); // Full Name (Link) ?> </a> </td> <tr> <?php } // Spouse Children foreach ($family->getChildren() as $child) { // Get Spouse child’s marriage status $married = ""; $marrdate = ""; foreach ($child->getSpouseFamilies() as $childfamily) { $marrdate = $childfamily->getMarriageDate(); $married = WT_Date::Compare($censdate, $marrdate); } // Get Child’s Children $chBLDarray = array(); foreach ($child->getSpouseFamilies() as $childfamily) { $chchildren = $childfamily->getChildren(); foreach ($chchildren as $chchild) { $chnam = $chchild->getAllNames(); $chfulln = rtrim($chnam[0]['givn'], '*') . " " . $chnam[0]['surname']; $chfulln = str_replace("@N.N.", "(" . WT_I18N::translate('unknown') . ")", $chfulln); $chfulln = str_replace("@P.N.", "(" . WT_I18N::translate('unknown') . ")", $chfulln); $chfulln = WT_Filter::escapeHtml($chfulln); // Child’s Full Name// Child’s Full Name $chdob = ($chchild->getBirthDate()->minJD() + $chchild->getBirthDate()->maxJD()) / 2; // Child’s Date of Birth (Julian) $chdod = ($chchild->getDeathDate()->minJD() + $chchild->getDeathDate()->maxJD()) / 2;
static function getAge(WT_Date $d1, WT_Date $d2 = null, $format) { if ($d2) { if ($d2->MaxJD() >= $d1->MinJD() && $d2->MinJD() <= $d1->MinJD()) { // Overlapping dates $jd = $d1->MinJD(); } else { // Non-overlapping dates $jd = $d2->MinJD(); } } else { // If second date not specified, use today’s date $jd = WT_CLIENT_JD; } switch ($format) { case 0: // Years - integer only (for statistics, rather than for display) if ($jd && $d1->MinJD() && $d1->MinJD() <= $jd) { return $d1->MinDate()->GetAge(false, $jd, false); } else { return -1; } case 1: // Days - integer only (for sorting, rather than for display) if ($jd && $d1->MinJD()) { return $jd - $d1->MinJD(); } else { return -1; } case 2: // Just years, in local digits, with warning for negative/ if ($jd && $d1->MinJD()) { if ($d1->MinJD() > $jd) { return '<i class="icon-warning"></i>'; } else { return WT_I18N::number($d1->MinDate()->GetAge(false, $jd)); } } else { return ' '; } // TODO: combine GetAgeGedcom() into this function } }