/** * print fact PLACe TEMPle STATus * * @param WT_Fact $event gedcom fact record * @param bool $anchor to print a link to placelist * @param bool $sub_records to print place subrecords * @param bool $lds to print LDS TEMPle and STATus * * @return string HTML */ function format_fact_place(WT_Fact $event, $anchor = false, $sub_records = false, $lds = false) { global $SEARCH_SPIDER; if ($anchor) { // Show the full place name, for facts/events tab if ($SEARCH_SPIDER) { $html = $event->getPlace()->getFullName(); } else { $html = '<a href="' . $event->getPlace()->getURL() . '">' . $event->getPlace()->getFullName() . '</a>'; } } else { // Abbreviate the place name, for chart boxes return ' - ' . $event->getPlace()->getShortName(); } if ($sub_records) { $placerec = get_sub_record(2, '2 PLAC', $event->getGedcom()); if (!empty($placerec)) { if (preg_match_all('/\\n3 (?:_HEB|ROMN) (.+)/', $placerec, $matches)) { foreach ($matches[1] as $match) { $wt_place = new WT_Place($match, WT_GED_ID); $html .= ' - ' . $wt_place->getFullName(); } } $map_lati = ""; $cts = preg_match('/\\d LATI (.*)/', $placerec, $match); if ($cts > 0) { $map_lati = $match[1]; $html .= '<br><span class="label">' . WT_Gedcom_Tag::getLabel('LATI') . ': </span>' . $map_lati; } $map_long = ''; $cts = preg_match('/\\d LONG (.*)/', $placerec, $match); if ($cts > 0) { $map_long = $match[1]; $html .= ' <span class="label">' . WT_Gedcom_Tag::getLabel('LONG') . ': </span>' . $map_long; } if ($map_lati && $map_long) { $map_lati = trim(strtr($map_lati, "NSEW,�", " - -. ")); // S5,6789 ==> -5.6789 $map_long = trim(strtr($map_long, "NSEW,�", " - -. ")); // E3.456� ==> 3.456 $html .= ' <a rel="nofollow" href="https://maps.google.com/maps?q=' . $map_lati . ',' . $map_long . '" class="icon-googlemaps" title="' . WT_I18N::translate('Google Maps™') . '"></a>'; $html .= ' <a rel="nofollow" href="https://www.bing.com/maps/?lvl=15&cp=' . $map_lati . '~' . $map_long . '" class="icon-bing" title="' . WT_I18N::translate('Bing Maps™') . '"></a>'; $html .= ' <a rel="nofollow" href="https://www.openstreetmap.org/#map=15/' . $map_lati . '/' . $map_long . '" class="icon-osm" title="' . WT_I18N::translate('OpenStreetMap™') . '"></a>'; } if (preg_match('/\\d NOTE (.*)/', $placerec, $match)) { $html .= '<br>' . print_fact_notes($placerec, 3); } } } if ($lds) { if (preg_match('/2 TEMP (.*)/', $event->getGedcom(), $match)) { $html .= '<br>' . WT_I18N::translate('LDS temple') . ': ' . WT_Gedcom_Code_Temp::templeName($match[1]); } if (preg_match('/2 STAT (.*)/', $event->getGedcom(), $match)) { $html .= '<br>' . WT_I18N::translate('Status') . ': ' . WT_Gedcom_Code_Stat::statusName($match[1]); if (preg_match('/3 DATE (.*)/', $event->getGedcom(), $match)) { $date = new WT_Date($match[1]); $html .= ', ' . WT_Gedcom_Tag::getLabel('STAT:DATE') . ': ' . $date->Display(false); } } } return $html; }
/** * 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>'; }
/** * Variable lookup * * Retrieve predefined variables : * @ desc GEDCOM fact description, example: * 1 EVEN This is a description * @ fact GEDCOM fact tag, such as BIRT, DEAT etc. * $ WT_I18N::translate('....') * $ language_settings[] * * * Or retrieve variables preset with <SetVar> element * * If the variable is a date and 'date="1"' attribute is set then the date will be reformated * from Sep to September * * @param array $attrs an array of key value pairs for the attributes * * @see SetVarSHandler() */ function varSHandler($attrs) { // @deprecated global $currentElement, $type, $parser; // Retrievable variables global $desc, $fact, $language_settings, $vars; if (empty($attrs['var'])) { die("<strong>REPORT ERROR var: </strong> The attribute \"var=\" is missing or not set in the XML file on line: " . xml_get_current_line_number($parser)); } $var = $attrs['var']; // SetVar element preset variables if (!empty($vars[$var]['id'])) { $var = $vars[$var]['id']; } else { $tfact = $fact; if (($fact == "EVEN" || $fact == "FACT") && is_string($type) && $type != " ") { // Use : // n TYPE This text if string $tfact = $type; } $var = str_replace(array("@fact", "@desc"), array(WT_Gedcom_Tag::getLabel($tfact), $desc), $var); if (substr($var, 0, 18) == 'WT_I18N::translate' || substr($var, 0, 15) == 'WT_I18N::number') { eval("\$var={$var};"); } } // Check if variable is set as a date and reformat the date if (isset($attrs['date'])) { if ($attrs['date'] === "1") { $g = new WT_Date($var); $var = $g->Display(); } } $currentElement->addText($var); }
/** * 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; }
echo '<form name="dateform" method="get" action="calendar.php">'; echo "<input type=\"hidden\" name=\"cal\" value=\"{$cal}\">"; echo "<input type=\"hidden\" name=\"day\" value=\"{$cal_date->d}\">"; echo "<input type=\"hidden\" name=\"month\" value=\"{$cal_month}\">"; echo "<input type=\"hidden\" name=\"year\" value=\"{$cal_date->y}\">"; echo "<input type=\"hidden\" name=\"action\" value=\"{$action}\">"; echo "<input type=\"hidden\" name=\"filterev\" value=\"{$filterev}\">"; echo "<input type=\"hidden\" name=\"filtersx\" value=\"{$filtersx}\">"; echo "<input type=\"hidden\" name=\"filterof\" value=\"{$filterof}\">"; echo '<table class="facts_table width100">'; echo '<tr><td class="facts_label" colspan="4"><h2>'; // All further uses of $cal are to generate URLs $cal = rawurlencode($cal); switch ($action) { case 'today': echo WT_I18N::translate('On this day…') . '<br>' . $ged_date->Display(false); break; case 'calendar': echo WT_I18N::translate('In this month…') . '<br>' . $ged_date->Display(false, '%F %Y'); break; case 'year': echo WT_I18N::translate('In this year…') . '<br>' . $ged_date->Display(false, '%Y'); break; } echo '</h2></td></tr>'; // Day selector echo '<tr><td class="descriptionbox vmiddle">'; echo WT_I18N::translate('Day'), '</td><td colspan="3" class="optionbox">'; for ($d = 1; $d <= $days_in_month; $d++) { // Format the day number using the calendar $tmp = new WT_Date($cal_date->format("%@ {$d} %O %E"));
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 _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; }