/** * add a new tag input field * * called for each fact to be edited on a form. * Fact level=0 means a new empty form : data are POSTed by name * else data are POSTed using arrays : * glevels[] : tag level * islink[] : tag is a link * tag[] : tag name * text[] : tag value * * @param string $tag fact record to edit (eg 2 DATE xxxxx) * @param string $upperlevel optional upper level tag (eg BIRT) * @param string $label An optional label to echo instead of the default from the $factarray * @param string $readOnly optional, when "READONLY", fact data can't be changed * @param string $noClose optional, when "NOCLOSE", final "</td></tr>" won't be printed * (so that additional text can be printed in the box) * @param boolean $rowDisplay True to have the row displayed by default, false to hide it by default */ function add_simple_tag($tag, $upperlevel = "", $label = "", $readOnly = "", $noClose = "", $rowDisplay = true) { global $factarray, $pgv_lang, $PGV_IMAGE_DIR, $PGV_IMAGES, $MEDIA_DIRECTORY, $TEMPLE_CODES; global $assorela, $tags, $emptyfacts, $main_fact, $TEXT_DIRECTION, $pgv_changes, $GEDCOM; global $NPFX_accept, $SPFX_accept, $NSFX_accept, $FILE_FORM_accept, $upload_count; global $tabkey, $STATUS_CODES, $SPLIT_PLACES, $pid, $linkToID; global $bdm, $PRIVACY_BY_RESN; global $lang_short_cut, $LANGUAGE; global $QUICK_REQUIRED_FACTS, $QUICK_REQUIRED_FAMFACTS, $PREFER_LEVEL2_SOURCES; if (substr($tag, 0, strpos($tag, "PLAC"))) { ?> <script type="text/javascript"> <!-- function valid_lati_long(field, pos, neg) { // valid LATI or LONG according to Gedcom standard // pos (+) : N or E // neg (-) : S or W txt=field.value.toUpperCase(); txt=txt.replace(/(^\s*)|(\s*$)/g,''); // trim txt=txt.replace(/ /g,':'); // N12 34 ==> N12.34 txt=txt.replace(/\+/g,''); // +17.1234 ==> 17.1234 txt=txt.replace(/-/g,neg); // -0.5698 ==> W0.5698 txt=txt.replace(/,/g,'.'); // 0,5698 ==> 0.5698 // 0�34'11 ==> 0:34:11 txt=txt.replace(/\uB0/g,':'); // � txt=txt.replace(/\u27/g,':'); // ' // 0:34:11.2W ==> W0.5698 txt=txt.replace(/^([0-9]+):([0-9]+):([0-9.]+)(.*)/g, function($0, $1, $2, $3, $4) { var n=parseFloat($1); n+=($2/60); n+=($3/3600); n=Math.round(n*1E4)/1E4; return $4+n; }); // 0:34W ==> W0.5667 txt=txt.replace(/^([0-9]+):([0-9]+)(.*)/g, function($0, $1, $2, $3) { var n=parseFloat($1); n+=($2/60); n=Math.round(n*1E4)/1E4; return $3+n; }); // 0.5698W ==> W0.5698 txt=txt.replace(/(.*)([N|S|E|W]+)$/g,'$2$1'); // 17.1234 ==> N17.1234 if (txt!='' && txt.charAt(0)!=neg && txt.charAt(0)!=pos) txt=pos+txt; field.value = txt; } function toggle_lati_long() { tr = document.getElementsByTagName('tr'); for (var i=0; i<tr.length; i++) { if (tr[i].id.indexOf("LATI")>=0 || tr[i].id.indexOf("LONG")>=0) { var disp = tr[i].style.display; if (disp=="none") { disp="table-row"; if (document.all && !window.opera) disp = "inline"; // IE } else disp="none"; tr[i].style.display=disp; } } } //--> </script> <?php } if (!isset($noClose) && isset($readOnly) && $readOnly == "NOCLOSE") { $noClose = "NOCLOSE"; $readOnly = ""; } if (!isset($noClose) || $noClose != "NOCLOSE") { $noClose = ""; } if (!isset($readOnly) || $readOnly != "READONLY") { $readOnly = ""; } if (!isset($tabkey)) { $tabkey = 1; } if (empty($linkToID)) { $linkToID = $pid; } $subnamefacts = array("NPFX", "GIVN", "SPFX", "SURN", "NSFX", "_MARNM_SURN"); @(list($level, $fact, $value) = explode(" ", $tag)); // element name : used to POST data if ($level == 0) { if ($upperlevel) { $element_name = $upperlevel . "_" . $fact; } else { $element_name = $fact; } // ex: OCCU } else { $element_name = "text[]"; } if ($level == 1) { $main_fact = $fact; } // element id : used by javascript functions if ($level == 0) { $element_id = $fact; } else { $element_id = $fact . floor(microtime() * 1000000); } // ex: SOUR56402 if ($upperlevel) { $element_id = $upperlevel . "_" . $fact; } // ex: BIRT_DATE | DEAT_DATE ... // field value $islink = (substr($value, 0, 1) == "@" and substr($value, 0, 2) != "@#"); if ($islink) { $value = trim(trim(substr($tag, strlen($fact) + 3)), " @\r"); } else { $value = trim(substr($tag, strlen($fact) + 3)); } if ($fact == 'REPO' || $fact == 'SOUR' || $fact == 'OBJE' || $fact == 'FAMC') { $islink = true; } // rows & cols switch ($fact) { case 'FORM': $rows = 1; $cols = 5; break; case 'LATI': case 'LONG': case 'NPFX': case 'SPFX': case 'NSFX': $rows = 1; $cols = 12; break; case 'DATE': case 'TIME': case 'TYPE': $rows = 1; $cols = 20; break; case 'GIVN': case 'SURN': case '_MARNM': $rows = 1; $cols = 25; break; case '_UID': $rows = 1; $cols = 50; break; case 'TEXT': case 'PUBL': $rows = 10; $cols = 70; break; case 'SHARED_NOTE_EDIT': $islink = 1; $fact = "NOTE"; $rows = 15; $cols = 88; break; case 'SHARED_NOTE': $islink = 1; $fact = "NOTE"; $rows = 1; $cols = $islink ? 8 : 40; break; case 'NOTE': if ($islink) { $rows = 1; $cols = $islink ? 8 : 40; break; } else { $rows = 10; $cols = 70; break; } case 'ADDR': $rows = 4; $cols = 40; break; case 'PAGE': $rows = 1; $cols = 50; break; default: $rows = 1; $cols = $islink ? 8 : 40; break; } // label $style = ""; echo "<tr id=\"" . $element_id . "_tr\" "; if ($fact == "MAP" || $fact == "LATI" || $fact == "LONG") { echo " style=\"display:none;\""; } echo " >\n"; if (in_array($fact, $subnamefacts) || $fact == "LATI" || $fact == "LONG") { echo "<td class=\"optionbox {$TEXT_DIRECTION} wrap width25\">"; } else { echo "<td class=\"descriptionbox {$TEXT_DIRECTION} wrap width25\">"; } // help link if (!in_array($fact, $emptyfacts)) { if ($fact == "DATE") { print_help_link("def_gedcom_date_help", "qm", "date"); } else { if ($fact == "RESN") { print_help_link($fact . "_help", "qm"); } else { if ($fact == "NOTE" && $islink) { print_help_link("edit_add_SHARED_NOTE_help", "qm"); } else { print_help_link("edit_" . $fact . "_help", "qm"); } } } } if ($fact == "_AKAN" || $fact == "_AKA" || $fact == "ALIA") { // Allow special processing for different languages $func = "fact_AKA_localisation_{$lang_short_cut[$LANGUAGE]}"; if (function_exists($func)) { // Localise the AKA fact $func($fact, $pid); } } else { if ($fact == "AGNC" && !empty($main_fact)) { // Allow special processing for different languages $func = "fact_AGNC_localisation_{$lang_short_cut[$LANGUAGE]}"; if (function_exists($func)) { // Localise the AGNC fact $func($fact, $main_fact); } } } if (PGV_DEBUG) { echo $element_name . "<br />\n"; } // tag name if (!empty($label)) { if ($label == "Note" && $islink) { echo $pgv_lang["shared_note"]; } else { echo $label; } } else { if ($fact == "NOTE" && $islink) { echo $pgv_lang["shared_note"]; } else { if (isset($pgv_lang[$fact])) { echo $pgv_lang[$fact]; } else { if (isset($factarray[$fact])) { echo $factarray[$fact]; } else { echo $fact; } } } } echo "\n"; // tag level if ($level > 0) { if ($fact == "TEXT" and $level > 1) { echo "<input type=\"hidden\" name=\"glevels[]\" value=\"" . ($level - 1) . "\" />"; echo "<input type=\"hidden\" name=\"islink[]\" value=\"0\" />"; echo "<input type=\"hidden\" name=\"tag[]\" value=\"DATA\" />"; //-- leave data text[] value empty because the following TEXT line will //--- cause the DATA to be added echo "<input type=\"hidden\" name=\"text[]\" value=\"\" />"; } echo "<input type=\"hidden\" name=\"glevels[]\" value=\"" . $level . "\" />\n"; echo "<input type=\"hidden\" name=\"islink[]\" value=\"" . $islink . "\" />\n"; echo "<input type=\"hidden\" name=\"tag[]\" value=\"" . $fact . "\" />\n"; // Shared Notes Debug -------------------- // echo "<br />Label = ".$label; // echo "<br />Level = ".$level; // echo "<br />Link = ".$islink; // echo "<br />Fact = ".$fact; // echo "<br />Value = ".$value; // End Debug ------------------- } echo "\n</td>"; // value echo "<td class=\"optionbox wrap\">\n"; if (PGV_DEBUG) { echo $tag . "<br />\n"; } // retrieve linked NOTE if ($fact == "NOTE" && $islink) { $noteid = $value; } if (in_array($fact, $emptyfacts) && (empty($value) || $value == "y" || $value == "Y")) { $value = strtoupper($value); //-- don't default anything to Y when adding events through people //-- default to Y when specifically adding one of these events if ($level == 1) { $value = "Y"; } // default YES echo "<input type=\"hidden\" id=\"" . $element_id . "\" name=\"" . $element_name . "\" value=\"" . $value . "\" />"; if ($level <= 1) { echo "<input type=\"checkbox\" "; if ($value == "Y") { echo " checked=\"checked\""; } echo " onclick=\"if (this.checked) " . $element_id . ".value='Y'; else " . $element_id . ".value=''; \" />"; echo $pgv_lang["yes"]; } } else { if ($fact == "TEMP") { echo "<select tabindex=\"" . $tabkey . "\" name=\"" . $element_name . "\" >\n"; echo "<option value=''>" . $pgv_lang["no_temple"] . "</option>\n"; foreach ($TEMPLE_CODES as $code => $temple) { echo "<option value=\"{$code}\""; if ($code == $value) { echo " selected=\"selected\""; } echo ">{$temple} ({$code})</option>\n"; } echo "</select>\n"; } else { if ($fact == "ADOP") { echo "<select tabindex=\"" . $tabkey . "\" name=\"" . $element_name . "\" >"; foreach (array("BOTH" => $factarray["HUSB"] . "+" . $factarray["WIFE"], "HUSB" => $factarray["HUSB"], "WIFE" => $factarray["WIFE"]) as $k => $v) { echo "<option value='{$k}'"; if ($value == $k) { echo " selected=\"selected\""; } echo ">{$v}</option>"; } echo "</select>\n"; } else { if ($fact == "PEDI") { echo "<select tabindex=\"" . $tabkey . "\" name=\"" . $element_name . "\" >"; foreach (array("" => $pgv_lang["unknown"], "birth" => $factarray["BIRT"], "adopted" => $pgv_lang["adopted"], "foster" => $pgv_lang["foster"], "sealing" => $pgv_lang["sealing"]) as $k => $v) { echo "<option value='{$k}'"; if (UTF8_strtolower($value) == $k) { echo " selected=\"selected\""; } echo ">{$v}</option>"; } echo "</select>\n"; } else { if ($fact == "STAT") { echo "<select tabindex=\"" . $tabkey . "\" name=\"" . $element_name . "\" >\n"; echo "<option value=''>No special status</option>\n"; foreach ($STATUS_CODES as $code => $status) { echo "<option value=\"{$code}\""; if ($code == $value) { echo " selected=\"selected\""; } echo ">{$status}</option>\n"; } echo "</select>\n"; } else { if ($fact == "RELA") { $text = strtolower($value); // add current relationship if not found in default list if (!array_key_exists($text, $assorela)) { $assorela[$text] = $text; } echo "<select tabindex=\"" . $tabkey . "\" id=\"" . $element_id . "\" name=\"" . $element_name . "\" >\n"; foreach ($assorela as $key => $value) { echo "<option value=\"" . $key . "\""; if ($key == $text) { echo " selected=\"selected\""; } echo ">" . $assorela["{$key}"] . "</option>\n"; } echo "</select>\n"; } else { if ($fact == "_PGVU") { $text = strtolower($value); echo "<select tabindex=\"" . $tabkey . "\" id=\"" . $element_id . "\" name=\"" . $element_name . "\" >\n"; echo '<option value=""'; if ('' == $text) { echo ' selected="selected"'; } echo ">-</option>\n"; foreach (get_all_users('asc', 'username') as $user_id => $user_name) { echo "<option value=\"" . $user_id . "\""; if ($user_id == $text) { echo " selected=\"selected\""; } echo ">" . $user_name . "</option>\n"; } echo "</select>\n"; } else { if ($fact == "RESN") { ?> <script type="text/javascript"> <!-- function update_RESN_img(resn_val) { document.getElementById("RESN_none").style.display="none"; document.getElementById("RESN_locked").style.display="none"; document.getElementById("RESN_privacy").style.display="none"; document.getElementById("RESN_confidential").style.display="none"; document.getElementById("RESN_"+resn_val).style.display="inline"; if (resn_val=='none') resn_val=''; document.getElementById("<?php echo $element_id; ?> ").value=resn_val; } //--> </script> <?php if (!$PRIVACY_BY_RESN && $level == 1) { // warn user that level 1 RESN tags have no effect when PRIVACY_BY_RESN is false echo "<small>" . $pgv_lang["resn_disabled"] . "</small>"; } echo "<input type=\"hidden\" id=\"" . $element_id . "\" name=\"" . $element_name . "\" value=\"" . $value . "\" />\n"; echo "<table><tr valign=\"top\">\n"; foreach (array("none", "locked", "privacy", "confidential") as $resn_index => $resn_val) { if ($resn_val == "none") { $resnv = ""; } else { $resnv = $resn_val; } echo "<td><input tabindex=\"" . $tabkey . "\" type=\"radio\" name=\"RESN_radio\" onclick=\"update_RESN_img('" . $resn_val . "')\""; echo " value=\"" . $resnv . "\""; if ($value == $resnv) { echo " checked=\"checked\""; } echo " /><small>" . $pgv_lang[$resn_val] . "</small>"; echo "<br /> <img id=\"RESN_" . $resn_val . "\" src=\"images/RESN_" . $resn_val . ".gif\" alt=\"" . $pgv_lang[$resn_val] . "\" title=\"" . $pgv_lang[$resn_val] . "\" border=\"0\""; if ($value == $resnv) { echo " style=\"display:inline\""; } else { echo " style=\"display:none\""; } echo " /></td>\n"; } echo "</tr></table>\n"; } else { if ($fact == "_PRIM" or $fact == "_THUM") { echo "<select tabindex=\"" . $tabkey . "\" id=\"" . $element_id . "\" name=\"" . $element_name . "\" >\n"; echo "<option value=\"\"></option>\n"; echo "<option value=\"Y\""; if ($value == "Y") { echo " selected=\"selected\""; } echo ">" . $pgv_lang["yes"] . "</option>\n"; echo "<option value=\"N\""; if ($value == "N") { echo " selected=\"selected\""; } echo ">" . $pgv_lang["no"] . "</option>\n"; echo "</select>\n"; } else { if ($fact == "SEX") { echo "<select tabindex=\"" . $tabkey . "\" id=\"" . $element_id . "\" name=\"" . $element_name . "\">\n<option value=\"M\""; if ($value == "M") { echo " selected=\"selected\""; } echo ">" . $pgv_lang["male"] . "</option>\n<option value=\"F\""; if ($value == "F") { echo " selected=\"selected\""; } echo ">" . $pgv_lang["female"] . "</option>\n<option value=\"U\""; if ($value == "U" || empty($value)) { echo " selected=\"selected\""; } echo ">" . $pgv_lang["unknown"] . "</option>\n</select>\n"; } else { if ($fact == "TYPE" && $level == '3') { //-- Build array of currently defined values for this Media Fact foreach ($pgv_lang as $varname => $typeValue) { if (substr($varname, 0, 6) == "TYPE__") { if ($varname != "TYPE__other") { $type[strtolower(substr($varname, 6))] = $typeValue; } } } //-- Sort the array into a meaningful order array_flip($type); asort($type); array_flip($type); //-- Add "Other" at the end of the list $type["other"] = $pgv_lang["TYPE__other"]; //-- Build the selector for the Media "TYPE" Fact echo "<select tabindex=\"" . $tabkey . "\" name=\"text[]\">"; if ($value == "") { echo "<option selected=\"selected\" value=\"\" > " . $pgv_lang["choose"] . " </option>"; } $selectedValue = strtolower($value); foreach ($type as $typeName => $typeValue) { echo "<option value=\"" . $typeName . "\" "; if ($selectedValue == $typeName) { echo "selected=\"selected\" "; } echo "> " . $typeValue . " </option>"; } echo "</select>"; } else { if ($fact == "NAME" && $upperlevel != 'REPO' || $fact == "_MARNM") { // Populated in javascript from sub-tags echo "<input type=\"hidden\" id=\"" . $element_id . "\" name=\"" . $element_name . "\" onchange=\"updateTextName('" . $element_id . "');\" value=\"" . PrintReady(htmlspecialchars($value, ENT_COMPAT, 'UTF-8')) . "\" />"; echo "<span id=\"" . $element_id . "_display\">" . PrintReady(htmlspecialchars($value, ENT_COMPAT, 'UTF-8')) . "</span>"; echo " <a href=\"#edit_name\" onclick=\"convertHidden('" . $element_id . "'); return false;\"> "; if (isset($PGV_IMAGES["edit_indi"]["small"])) { echo "<img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["edit_indi"]["small"] . "\" border=\"0\" width=\"20\" alt=\"" . $pgv_lang["edit_name"] . "\" align=\"top\" />"; } else { echo "<span class=\"age\">[" . $pgv_lang["edit_name"] . "]</span>"; } echo "</a>"; } else { // textarea if ($rows > 1) { echo "<textarea tabindex=\"" . $tabkey . "\" id=\"" . $element_id . "\" name=\"" . $element_name . "\" rows=\"" . $rows . "\" cols=\"" . $cols . "\">" . PrintReady(htmlspecialchars($value, ENT_COMPAT, 'UTF-8')) . "</textarea><br />\n"; } else { // text echo "<input tabindex=\"" . $tabkey . "\" type=\"text\" id=\"" . $element_id . "\" name=\"" . $element_name . "\" value=\"" . PrintReady(htmlspecialchars($value, ENT_COMPAT, 'UTF-8')) . "\" size=\"" . $cols . "\" dir=\"ltr\""; echo " class=\"{$fact}\""; echo " autocomplete=\"off\""; if (in_array($fact, $subnamefacts)) { echo " onblur=\"updatewholename();\" onkeyup=\"updatewholename();\""; } if ($fact == "DATE") { echo " onblur=\"valid_date(this);\" onmouseout=\"valid_date(this);\""; } if ($fact == "LATI") { echo " onblur=\"valid_lati_long(this, 'N', 'S');\" onmouseout=\"valid_lati_long(this, 'N', 'S');\""; } if ($fact == "LONG") { echo " onblur=\"valid_lati_long(this, 'E', 'W');\" onmouseout=\"valid_lati_long(this, 'E', 'W');\""; } //if ($fact=="FILE") echo " onchange=\"if (updateFormat) updateFormat(this.value);\""; echo " " . $readOnly . " />\n"; } // split PLAC if ($fact == "PLAC" && $readOnly == "") { echo "<div id=\"" . $element_id . "_pop\" style=\"display: inline;\">\n"; print_specialchar_link($element_id, false); print_findplace_link($element_id); echo "</div>\n"; echo "<a href=\"javascript:;\" onclick=\"toggle_lati_long();\"><img src=\"images/buttons/target.gif\" border=\"0\" align=\"middle\" alt=\"" . $factarray["LATI"] . " / " . $factarray["LONG"] . "\" title=\"" . $factarray["LATI"] . " / " . $factarray["LONG"] . "\" /></a>"; if ($SPLIT_PLACES) { if (!function_exists("print_place_subfields")) { require "includes/functions/functions_places.php"; } setup_place_subfields($element_id); print_place_subfields($element_id); } } else { if (($cols > 20 || $fact == "NPFX") && $readOnly == "") { print_specialchar_link($element_id, false); } } } } } } } } } } } } } } // MARRiage TYPE : hide text field and show a selection list if ($fact == "TYPE" and $tags[0] == "MARR") { echo "<script type='text/javascript'>"; echo "document.getElementById('" . $element_id . "').style.display='none'"; echo "</script>"; echo "<select tabindex=\"" . $tabkey . "\" id=\"" . $element_id . "_sel\" onchange=\"document.getElementById('" . $element_id . "').value=this.value;\" >\n"; foreach (array("Unknown", "Civil", "Religious", "Partners") as $indexval => $key) { if ($key == "Unknown") { echo "<option value=\"\""; } else { echo "<option value=\"" . $key . "\""; } $a = strtolower($key); $b = strtolower($value); if (@strpos($a, $b) !== false or @strpos($b, $a) !== false) { echo " selected=\"selected\""; } echo ">" . $factarray["MARR_" . strtoupper($key)] . "</option>\n"; } echo "</select>"; } // popup links if ($readOnly == "") { if ($fact == "DATE") { print_calendar_popup($element_id); } if ($fact == "FAMC") { print_findfamily_link($element_id, ""); } if ($fact == "FAMS") { print_findfamily_link($element_id, ""); } if ($fact == "ASSO") { print_findindi_link($element_id, ""); } if ($fact == "FILE") { print_findmedia_link($element_id, "0file"); } if ($fact == "SOUR") { print_findsource_link($element_id); print_addnewsource_link($element_id); //print_autopaste_link($element_id, array("S1", "S2"), false, false, true); //-- checkboxes to apply '1 SOUR' to BIRT/MARR/DEAT as '2 SOUR' if ($level == 1) { echo '<br />'; if ($PREFER_LEVEL2_SOURCES === '0') { $level1_checked = ''; $level2_checked = ''; } else { if ($PREFER_LEVEL2_SOURCES === '1' || $PREFER_LEVEL2_SOURCES === true) { $level1_checked = ''; $level2_checked = ' checked="checked"'; } else { $level1_checked = ' checked="checked"'; $level2_checked = ''; } } if (strpos($bdm, 'B') !== false) { echo ' <input type="checkbox" name="SOUR_INDI" ', $level1_checked, ' value="Y" />'; echo $pgv_lang['individual']; if (preg_match_all('/(' . PGV_REGEX_TAG . ')/', $QUICK_REQUIRED_FACTS, $matches)) { foreach ($matches[1] as $match) { if (!in_array($match, explode('|', PGV_EVENTS_DEAT))) { echo ' <input type="checkbox" name="SOUR_', $match, '"', $level2_checked, ' value="Y" />'; echo $factarray[$match]; } } } } if (strpos($bdm, 'D') !== false) { if (preg_match_all('/(' . PGV_REGEX_TAG . ')/', $QUICK_REQUIRED_FACTS, $matches)) { foreach ($matches[1] as $match) { if (in_array($match, explode('|', PGV_EVENTS_DEAT))) { echo ' <input type="checkbox" name="SOUR_', $match, '"', $level2_checked, ' value="Y" />'; echo $factarray[$match]; } } } } if (strpos($bdm, 'M') !== false) { echo ' <input type="checkbox" name="SOUR_FAM" ', $level1_checked, ' value="Y" />'; echo $pgv_lang["family"]; if (preg_match_all('/(' . PGV_REGEX_TAG . ')/', $QUICK_REQUIRED_FAMFACTS, $matches)) { foreach ($matches[1] as $match) { echo ' <input type="checkbox" name="SOUR_', $match, '"', $level2_checked, ' value="Y" />'; echo $factarray[$match]; } } } } } if ($fact == "REPO") { print_findrepository_link($element_id); print_addnewrepository_link($element_id); } // Shared Notes Icons ======================================== // $record=GedcomRecord::getInstance($value); if ($fact == "NOTE" && $islink) { print_findnote_link($element_id); print_addnewnote_link($element_id); if ($value != "") { echo " "; print_editnote_link($value); } // If GEDFAct_assistant/_CENS/ module exists && we are on the INDI page // Then show the add Shared note assisted icon, if not ... do not show if ($pid) { $type_pid = GedcomRecord::getInstance($pid); if (file_exists('modules/GEDFact_assistant/_CENS/census_1_ctrl.php') && $type_pid->getType() == "INDI") { echo " "; print_addnewnote_assisted_link($element_id); } } echo "<br />"; } // =========================================================== if ($fact == "OBJE") { print_findmedia_link($element_id, "1media"); } if ($fact == "OBJE" && !$value) { print_addnewmedia_link($element_id); $value = "new"; } } // current value if ($TEXT_DIRECTION == "ltr") { if ($fact == "DATE") { $date = new GedcomDate($value); echo $date->Display(false); } if (($fact == "ASSO" || $fact == "SOUR" || $fact == "OBJE" || $fact == "NOTE" && $islink) && $value) { $record = GedcomRecord::getInstance($value); if ($record) { echo ' ', PrintReady($record->getFullName()), ' (', $value, ')'; } else { if ($value != "new") { echo ' ', $value; } } } } else { if ($fact == "DATE") { $date = new GedcomDate($value); echo getRLM(), $date->Display(false), getRLM(); } if (($fact == "ASSO" || $fact == "SOUR" || $fact == "OBJE" || $fact == "NOTE" && $islink) && $value) { $record = GedcomRecord::getInstance($value); if ($record) { echo getRLM(), PrintReady($record->getFullName()), ' ', getLRM(), '(', $value, ') ', getLRM(), getRLM(); } else { if ($value != "new") { echo getRLM(), $value, ' ', getRLM(); } } } } /* if ($fact=="NOTE" && $islink && $value!="") { include('includes/functions/functions_print_lists.php'); echo "<tr><td class=\"descriptionbox ".$TEXT_DIRECTION." wrap width25\">"; print_help_link("edit_add_SHARED_NOTE_help", "qm"); // echo $pgv_lang["admin_override"]; echo "Shared Note Links<br /><br />"; echo "</td><td class=\"optionbox wrap\">\n"; print_indi_list(fetch_linked_indi($value, "NOTE", "1")); echo "</td></tr>\n"; } */ // pastable values if ($readOnly == "") { if ($fact == "SPFX") { print_autopaste_link($element_id, $SPFX_accept); } if ($fact == "NSFX") { print_autopaste_link($element_id, $NSFX_accept); } if ($fact == "FORM") { print_autopaste_link($element_id, $FILE_FORM_accept, false, false); } } if ($noClose != "NOCLOSE") { echo "</td></tr>\n"; } $tabkey++; return $element_id; }
/** * 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; }