Esempio n. 1
0
    /**
     * print parents informations
     * @param Family family
     * @param Array people
     * @param String family type
     * @return html table rows
     */
    function printParentsRows(&$family, &$people, $type)
    {
        global $personcount, $pgv_changes, $pgv_lang, $factarray;
        global $PGV_IMAGE_DIR, $PGV_IMAGES;
        global $lang_short_cut, $LANGUAGE;
        $elderdate = "";
        //-- new father/husband
        $styleadd = "";
        if (isset($people["newhusb"])) {
            $styleadd = "red";
            ?>
			<tr>
				<td class="facts_labelblue"><?php 
            print $people["newhusb"]->getLabel();
            ?>
</td>
				<td class="<?php 
            print $this->getPersonStyle($people["newhusb"]);
            ?>
">
					<?php 
            print_pedigree_person($people["newhusb"]->getXref(), 2, !$this->isPrintPreview(), 0, $personcount++);
            ?>
				</td>
			</tr>
			<?php 
            $elderdate = $people["newhusb"]->getBirthDate();
        }
        //-- father/husband
        if (isset($people["husb"])) {
            ?>
			<tr>
				<td class="facts_label<?php 
            print $styleadd;
            ?>
"><?php 
            print $people["husb"]->getLabel();
            ?>
</td>
				<td class="<?php 
            print $this->getPersonStyle($people["husb"]);
            ?>
">
					<?php 
            print_pedigree_person($people["husb"]->getXref(), 2, !$this->isPrintPreview(), 0, $personcount++);
            ?>
				</td>
			</tr>
			<?php 
            $elderdate = $people["husb"]->getBirthDate();
        }
        //-- missing father
        if ($type == "parents" && !isset($people["husb"]) && !isset($people["newhusb"])) {
            if (!$this->isPrintPreview() && PGV_USER_CAN_EDIT && $this->indi->canDisplayDetails()) {
                ?>
				<tr>
					<td class="facts_label"><?php 
                print $pgv_lang["add_father"];
                ?>
</td>
					<td class="facts_value"><?php 
                print_help_link("edit_add_parent_help", "qm");
                ?>
 <a href="javascript <?php 
                print $pgv_lang["add_father"];
                ?>
" onclick="return addnewparentfamily('<?php 
                print $this->pid;
                ?>
', 'HUSB', '<?php 
                print $family->getXref();
                ?>
');"><?php 
                print $pgv_lang["add_father"];
                ?>
</a></td>
				</tr>
				<?php 
            }
        }
        //-- missing husband
        if ($type == "spouse" && $this->indi->equals($people["wife"]) && !isset($people["husb"]) && !isset($people["newhusb"])) {
            if (!$this->isPrintPreview() && PGV_USER_CAN_EDIT && $this->indi->canDisplayDetails()) {
                ?>
				<tr>
					<td class="facts_label"><?php 
                print $pgv_lang["add_husb"];
                ?>
</td>
					<td class="facts_value"><a href="javascript:;" onclick="return addnewspouse('<?php 
                print $family->getXref();
                ?>
', 'HUSB');"><?php 
                print $pgv_lang["add_husb_to_family"];
                ?>
</a></td>
				</tr>
				<?php 
            }
        }
        //-- new mother/wife
        $styleadd = "";
        if (isset($people["newwife"])) {
            $styleadd = "red";
            ?>
			<tr>
				<td class="facts_labelblue"><?php 
            print $people["newwife"]->getLabel($elderdate);
            ?>
</td>
				<td class="<?php 
            print $this->getPersonStyle($people["newwife"]);
            ?>
">
					<?php 
            print_pedigree_person($people["newwife"]->getXref(), 2, !$this->isPrintPreview(), 0, $personcount++);
            ?>
				</td>
			</tr>
			<?php 
        }
        //-- mother/wife
        if (isset($people["wife"])) {
            ?>
			<tr>
				<td class="facts_label<?php 
            print $styleadd;
            ?>
"><?php 
            print $people["wife"]->getLabel($elderdate);
            ?>
</td>
				<td class="<?php 
            print $this->getPersonStyle($people["wife"]);
            ?>
">
					<?php 
            print_pedigree_person($people["wife"]->getXref(), 2, !$this->isPrintPreview(), 0, $personcount++);
            ?>
				</td>
			</tr>
			<?php 
        }
        //-- missing mother
        if ($type == "parents" && !isset($people["wife"]) && !isset($people["newwife"])) {
            if (!$this->isPrintPreview() && PGV_USER_CAN_EDIT && $this->indi->canDisplayDetails()) {
                ?>
				<tr>
					<td class="facts_label"><?php 
                print $pgv_lang["add_mother"];
                ?>
</td>
					<td class="facts_value"><?php 
                print_help_link("edit_add_parent_help", "qm");
                ?>
 <a href="javascript:;" onclick="return addnewparentfamily('<?php 
                print $this->pid;
                ?>
', 'WIFE', '<?php 
                print $family->getXref();
                ?>
');"><?php 
                print $pgv_lang["add_mother"];
                ?>
</a></td>
				</tr>
				<?php 
            }
        }
        //-- missing wife
        if ($type == "spouse" && $this->indi->equals($people["husb"]) && !isset($people["wife"]) && !isset($people["newwife"])) {
            if (!$this->isPrintPreview() && PGV_USER_CAN_EDIT && $this->indi->canDisplayDetails()) {
                ?>
				<tr>
					<td class="facts_label"><?php 
                print $pgv_lang["add_wife"];
                ?>
</td>
					<td class="facts_value"><a href="javascript:;" onclick="return addnewspouse('<?php 
                print $family->getXref();
                ?>
', 'WIFE');"><?php 
                print $pgv_lang["add_wife_to_family"];
                ?>
</a></td>
				</tr>
				<?php 
            }
        }
        //-- marriage row
        if ($family->getMarriageRecord() != "" || PGV_USER_CAN_EDIT) {
            $styleadd = "";
            $date = $family->getMarriageDate();
            $place = $family->getMarriagePlace();
            $famid = $family->getXref();
            if (!$date && $this->show_changes && isset($pgv_changes[$famid . "_" . $GEDCOM])) {
                $famrec = find_updated_record($famid);
                $marrrec = get_sub_record(1, "1 MARR", $famrec);
                if ($marrrec != $family->getMarriageRecord()) {
                    $date = new GedcomDate(get_gedcom_value("MARR:DATE", 1, $marrrec, '', false));
                    $place = get_gedcom_value("MARR:PLAC", 1, $marrrec, '', false);
                    $styleadd = "blue";
                }
            }
            ?>
			<tr>
				<td class="facts_label"><br />
				</td>
				<td class="facts_value<?php 
            print $styleadd;
            ?>
">
					<?php 
            //echo "<span class=\"details_label\">".$factarray["NCHI"].": </span>".$family->getNumberOfChildren()."<br />";
            ?>
					<?php 
            if ($date && $date->isOK() || $place) {
                $marr_type = "MARR_" . strtoupper($family->getMarriageType());
                if (isset($factarray[$marr_type])) {
                    echo "<span class=\"details_label\">" . $factarray[$marr_type] . ": </span>";
                } else {
                    echo "<span class=\"details_label\">" . $factarray["MARR"] . ": </span>" . $family->getMarriageType();
                }
                if ($date) {
                    echo $date->Display(false);
                    if (!empty($place)) {
                        echo ' -- ';
                    }
                }
                if (!empty($place)) {
                    echo $place;
                }
            } else {
                if (get_sub_record(1, "1 _NMR", find_family_record($famid))) {
                    // Allow special processing for different languages
                    $func = "fact_NMR_localisation_{$lang_short_cut[$LANGUAGE]}";
                    if (function_exists($func)) {
                        // Localise the _NMR facts
                        $func("_NMR", $famid);
                    }
                    echo $factarray["_NMR"];
                } else {
                    if (get_sub_record(1, "1 _NMAR", find_family_record($famid))) {
                        // Allow special processing for different languages
                        $func = "fact_NMR_localisation_{$lang_short_cut[$LANGUAGE]}";
                        if (function_exists($func)) {
                            // Localise the _NMR facts
                            $func("_NMAR", $famid);
                        }
                        echo $factarray["_NMAR"];
                    } else {
                        if ($family->getMarriageRecord() == "" && PGV_USER_CAN_EDIT) {
                            print "<a href=\"#\" onclick=\"return add_new_record('" . $famid . "', 'MARR');\">" . $pgv_lang['add_marriage'] . "</a>";
                        } else {
                            $factdetail = explode(' ', trim($family->getMarriageRecord()));
                            if ($family->getMarriageType()) {
                                $marr_type = "MARR_" . strtoupper($family->getMarriageType());
                            } else {
                                $marr_type = "MARR";
                            }
                            if (isset($factarray[$marr_type])) {
                                if (isset($factdetail)) {
                                    if (count($factdetail) == 3) {
                                        if (strtoupper($factdetail[2]) == "Y") {
                                            echo "<span class=\"details_label\">" . $factarray[$marr_type] . ": </span>" . $pgv_lang["yes"];
                                        } else {
                                            if (strtoupper($factdetail[2]) == "N") {
                                                echo "<span class=\"details_label\">" . $factarray[$marr_type] . ": </span>" . $pgv_lang["no"];
                                            }
                                        }
                                    }
                                }
                            } else {
                                echo "<span class=\"details_label\">" . $factarray["MARR"] . ": </span>" . $family->getMarriageType();
                            }
                        }
                    }
                }
            }
            ?>
				</td>
			</tr>
			<?php 
        }
    }
Esempio n. 2
0
function print_yahrzeit($block = true, $config = '', $side, $index)
{
    global $pgv_lang, $factarray, $SHOW_ID_NUMBERS, $ctype, $TEXT_DIRECTION;
    global $PGV_IMAGE_DIR, $PGV_IMAGES, $PGV_BLOCKS;
    global $DAYS_TO_SHOW_LIMIT, $SHOW_MARRIED_NAMES, $SERVER_URL;
    $block = true;
    // Always restrict this block's height
    if (empty($config)) {
        $config = $PGV_BLOCKS['print_yahrzeit']['config'];
    }
    if (empty($config['infoStyle'])) {
        $config['infoStyle'] = 'style2';
    }
    if (empty($config['allowDownload'])) {
        $config['allowDownload'] = 'yes';
    }
    if (empty($config['days'])) {
        $config['days'] = $DAYS_TO_SHOW_LIMIT;
    }
    if ($config['days'] < 1) {
        $config['days'] = 1;
    }
    if ($config['days'] > $DAYS_TO_SHOW_LIMIT) {
        $config['days'] = $DAYS_TO_SHOW_LIMIT;
    }
    $startjd = server_jd();
    $endjd = $startjd + max(min($config['days'], 1), $DAYS_TO_SHOW_LIMIT) - 1;
    if (!PGV_USER_ID) {
        $allowDownload = "no";
    }
    $id = "yahrzeit";
    $title = print_help_link('yahrzeit_help', 'qm', '', false, true);
    if ($PGV_BLOCKS['print_yahrzeit']['canconfig']) {
        if ($ctype == "gedcom" && PGV_USER_GEDCOM_ADMIN || $ctype == "user" && PGV_USER_ID) {
            if ($ctype == "gedcom") {
                $name = PGV_GEDCOM;
            } else {
                $name = PGV_USER_NAME;
            }
            $title .= "<a href=\"javascript: configure block\" onclick=\"window.open('" . encode_url("index_edit.php?name={$name}&ctype={$ctype}&action=configure&side={$side}&index={$index}") . "', '_blank', 'top=50,left=50,width=600,height=350,scrollbars=1,resizable=1'); return false;\">";
            $title .= "<img class=\"adminicon\" src=\"{$PGV_IMAGE_DIR}/{$PGV_IMAGES['admin']['small']}\" width=\"15\" height=\"15\" border=\"0\" alt=\"{$pgv_lang['config_block']}\" /></a>";
        }
    }
    $title .= $pgv_lang['yahrzeit_block'];
    $content = "";
    // The standard anniversary rules cover most of the Yahrzeit rules, we just
    // need to handle a few special cases.
    // Fetch normal anniversaries...
    $yahrzeits = array();
    $hidden = 0;
    for ($jd = $startjd - 1; $jd <= $endjd + 30; ++$jd) {
        foreach (get_anniversary_events($jd, 'DEAT _YART') as $fact) {
            // Extract hebrew dates only
            if ($fact['date']->date1->CALENDAR_ESCAPE() == '@#DHEBREW@' && $fact['date']->MinJD() == $fact['date']->MaxJD()) {
                // Apply privacy
                if (displayDetailsById($fact['id']) && showFactDetails($fact['fact'], $fact['id']) && !FactViewRestricted($fact['id'], $fact['factrec'])) {
                    $yahrzeits[] = $fact;
                } else {
                    ++$hidden;
                }
            }
        }
    }
    // ...then adjust dates
    foreach ($yahrzeits as $key => $yahrzeit) {
        if (strpos('1 DEAT', $yahrzeit['factrec']) !== false) {
            // Just DEAT, not _YART
            $today = new JewishDate($yahrzeit['jd']);
            $hd = $yahrzeit['date']->MinDate();
            $hd1 = new JewishDate($hd);
            $hd1->y += 1;
            $hd1->SetJDFromYMD();
            // Special rules.  See http://www.hebcal.com/help/anniv.html
            // Everything else is taken care of by our standard anniversary rules.
            if ($hd->d == 30 && $hd->m == 2 && $hd->y != 0 && $hd1->DaysInMonth() < 30) {
                // 30 CSH
                // Last day in CSH
                $yahrzeit[$key]['jd'] = JewishDate::YMDtoJD($today->y, 3, 1) - 1;
            }
            if ($hd->d == 30 && $hd->m == 3 && $hd->y != 0 && $hd1->DaysInMonth() < 30) {
                // 30 KSL
                // Last day in KSL
                $yahrzeit[$key]['jd'] = JewishDate::YMDtoJD($today->y, 4, 1) - 1;
            }
            if ($hd->d == 30 && $hd->m == 6 && $hd->y != 0 && $today->DaysInMonth() < 30 && !$today->IsLeapYear()) {
                // 30 ADR
                // Last day in SHV
                $yahrzeit[$key]['jd'] = JewishDate::YMDtoJD($today->y, 6, 1) - 1;
            }
        }
    }
    switch ($config['infoStyle']) {
        case "style1":
            // List style
            foreach ($yahrzeits as $yahrzeit) {
                if ($yahrzeit['jd'] >= $startjd && $yahrzeit['jd'] < $startjd + $config['days']) {
                    $ind = person::GetInstance($yahrzeit['id']);
                    //@@			$content .= "<a href=\"".encode_url($ind->getLinkUrl())."\" class=\"list_item name2\">".$ind->getFullName()."</a>".$ind->getSexImage();
                    $content .= "<a href=\"" . encode_url($ind->getLinkUrl()) . "\" class=\"list_item name2\">" . PrintReady($ind->getFullName()) . "</a>" . $ind->getSexImage();
                    $content .= "<div class=\"indent\">";
                    $content .= $yahrzeit['date']->Display(true);
                    $content .= ', ' . str_replace("#year_var#", $yahrzeit['anniv'], $pgv_lang["year_anniversary"]);
                    $content .= "</div>";
                }
            }
            break;
        case "style2":
            // Table style
            require_once PGV_ROOT . 'js/sorttable.js.htm';
            require_once PGV_ROOT . 'includes/classes/class_gedcomrecord.php';
            $table_id = "ID" . floor(microtime() * 1000000);
            // sorttable requires a unique ID
            $content .= "<table id=\"{$table_id}\" class=\"sortable list_table center\">";
            $content .= "<tr>";
            $content .= "<th class=\"list_label\">{$factarray['NAME']}</th>";
            $content .= "<th style=\"display:none\">GIVN</th>";
            $content .= "<th class=\"list_label\">{$factarray['DATE']}</th>";
            $content .= "<th class=\"list_label\"><img src=\"./images/reminder.gif\" alt=\"{$pgv_lang['anniversary']}\" title=\"{$pgv_lang['anniversary']}\" border=\"0\" /></th>";
            $content .= "<th class=\"list_label\">{$factarray['_YART']}</th>";
            $content .= "</tr>";
            $count = 0;
            foreach ($yahrzeits as $yahrzeit) {
                if ($yahrzeit['jd'] >= $startjd && $yahrzeit['jd'] < $startjd + $config['days']) {
                    ++$count;
                    $ind = person::GetInstance($yahrzeit['id']);
                    $content .= "<tr class=\"vevent\">";
                    // hCalendar:vevent
                    // Record name(s)
                    $name = $ind->getFullName();
                    $url = $ind->getLinkUrl();
                    $content .= "<td class=\"list_value_wrap\" align=\"" . get_align($name) . "\">";
                    $content .= "<a href=\"" . encode_url($ind->getLinkUrl()) . "\" class=\"list_item name2\" dir=\"" . $TEXT_DIRECTION . "\">" . PrintReady($name) . "</a>";
                    $content .= $ind->getSexImage();
                    $addname = $ind->getAddName();
                    if ($addname) {
                        $content .= "<br /><a href=\"" . encode_url($url) . "\" class=\"list_item\">" . PrintReady($addname) . "</a>";
                    }
                    $content .= "</td>";
                    // GIVN for sorting
                    $content .= "<td style=\"display:none\">";
                    $exp = explode(",", str_replace('<', ',', $name) . ",");
                    $content .= $exp[1];
                    $content .= "</td>";
                    $today = new JewishDate($yahrzeit['jd']);
                    $td = new GedcomDate($today->Format('@ A O E'));
                    // death/yahrzeit event date
                    $content .= "<td class=\"list_value_wrap\">";
                    $content .= "<a name='{$yahrzeit['jd']}'>" . $yahrzeit['date']->Display(true, NULL, array()) . "</a>";
                    $content .= "</td>";
                    // Anniversary
                    $content .= "<td class=\"list_value_wrap rela\">";
                    $anniv = $yahrzeit['anniv'];
                    if ($anniv == 0) {
                        $content .= '<a name="0">&nbsp;</a>';
                    } else {
                        $content .= "<a name=\"{$anniv}\">{$anniv}</a>";
                    }
                    if ($config['allowDownload'] == 'yes') {
                        // hCalendar:dtstart and hCalendar:summary
                        //TODO does this work??
                        $content .= "<abbr class=\"dtstart\" title=\"" . strip_tags($yahrzeit['date']->Display(false, 'Ymd', array())) . "\"></abbr>";
                        $content .= "<abbr class=\"summary\" title=\"" . $pgv_lang["anniversary"] . " #{$anniv} " . $factarray[$yahrzeit['fact']] . " : " . PrintReady(strip_tags($ind->getFullName())) . "\"></abbr>";
                    }
                    // upcomming yahrzeit dates
                    $content .= "<td class=\"list_value_wrap\">";
                    $content .= "<a href=\"" . $url . "\" class=\"list_item url\">" . $td->Display(true, NULL, array('gregorian')) . "</a>";
                    // hCalendar:url
                    $content .= "&nbsp;</td>";
                    $content .= "</tr>";
                }
            }
            // table footer
            $content .= "<tr class=\"sortbottom\">";
            $content .= "<td class=\"list_label\">";
            $content .= '<a href="javascript:;" onclick="sortByOtherCol(this,1)"><img src="images/topdown.gif" alt="" border="0" /> ' . $factarray["GIVN"] . '</a><br />';
            $content .= $pgv_lang["total_names"] . ": " . $count;
            if ($hidden) {
                $content .= "<br /><span class=\"warning\">{$pgv_lang['hidden']} : {$hidden}</span>";
            }
            $content .= "</td>";
            $content .= "<td style=\"display:none\">GIVN</td>";
            $content .= "<td>";
            if ($config['allowDownload'] == 'yes') {
                $uri = $SERVER_URL . basename($_SERVER['REQUEST_URI']);
                global $whichFile;
                $whichFile = 'hCal-events.ics';
                $alt = print_text('download_file', 0, 1);
                if (count($yahrzeits)) {
                    $content .= "<a href=\"http://feeds.technorati.com/events/{$uri}\"><img src=\"images/hcal.png\" border=\"0\" alt=\"{$alt}\" title=\"{$alt}\" /></a>";
                }
            }
            $content .= '</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
            $content .= '</table>';
            break;
    }
    global $THEME_DIR;
    if ($block) {
        require $THEME_DIR . 'templates/block_small_temp.php';
    } else {
        require $THEME_DIR . 'templates/block_main_temp.php';
    }
}
Esempio n. 3
0
/**
* add a new tag input field
*
* called for each fact to be edited on a form.
* Fact level=0 means a new empty form : data are POSTed by name
* else data are POSTed using arrays :
* glevels[] : tag level
*  islink[] : tag is a link
*     tag[] : tag name
*    text[] : tag value
*
* @param string $tag fact record to edit (eg 2 DATE xxxxx)
* @param string $upperlevel optional upper level tag (eg BIRT)
* @param string $label An optional label to echo instead of the default from the $factarray
* @param string $readOnly optional, when "READONLY", fact data can't be changed
* @param string $noClose optional, when "NOCLOSE", final "</td></tr>" won't be printed
* (so that additional text can be printed in the box)
* @param boolean $rowDisplay True to have the row displayed by default, false to hide it by default
*/
function add_simple_tag($tag, $upperlevel = "", $label = "", $readOnly = "", $noClose = "", $rowDisplay = true)
{
    global $factarray, $pgv_lang, $PGV_IMAGE_DIR, $PGV_IMAGES, $MEDIA_DIRECTORY, $TEMPLE_CODES;
    global $assorela, $tags, $emptyfacts, $main_fact, $TEXT_DIRECTION, $pgv_changes, $GEDCOM;
    global $NPFX_accept, $SPFX_accept, $NSFX_accept, $FILE_FORM_accept, $upload_count;
    global $tabkey, $STATUS_CODES, $SPLIT_PLACES, $pid, $linkToID;
    global $bdm, $PRIVACY_BY_RESN;
    global $lang_short_cut, $LANGUAGE;
    global $QUICK_REQUIRED_FACTS, $QUICK_REQUIRED_FAMFACTS, $PREFER_LEVEL2_SOURCES;
    if (substr($tag, 0, strpos($tag, "PLAC"))) {
        ?>
<script type="text/javascript">
		<!--
		function valid_lati_long(field, pos, neg) {
			// valid LATI or LONG according to Gedcom standard
			// pos (+) : N or E
			// neg (-) : S or W
			txt=field.value.toUpperCase();
			txt=txt.replace(/(^\s*)|(\s*$)/g,''); // trim
			txt=txt.replace(/ /g,':'); // N12 34 ==> N12.34
			txt=txt.replace(/\+/g,''); // +17.1234 ==> 17.1234
			txt=txt.replace(/-/g,neg); // -0.5698 ==> W0.5698
			txt=txt.replace(/,/g,'.'); // 0,5698 ==> 0.5698
			// 0�34'11 ==> 0:34:11
			txt=txt.replace(/\uB0/g,':'); // �
			txt=txt.replace(/\u27/g,':'); // '
			// 0:34:11.2W ==> W0.5698
			txt=txt.replace(/^([0-9]+):([0-9]+):([0-9.]+)(.*)/g, function($0, $1, $2, $3, $4) { var n=parseFloat($1); n+=($2/60); n+=($3/3600); n=Math.round(n*1E4)/1E4; return $4+n; });
			// 0:34W ==> W0.5667
			txt=txt.replace(/^([0-9]+):([0-9]+)(.*)/g, function($0, $1, $2, $3) { var n=parseFloat($1); n+=($2/60); n=Math.round(n*1E4)/1E4; return $3+n; });
			// 0.5698W ==> W0.5698
			txt=txt.replace(/(.*)([N|S|E|W]+)$/g,'$2$1');
			// 17.1234 ==> N17.1234
			if (txt!='' && txt.charAt(0)!=neg && txt.charAt(0)!=pos) txt=pos+txt;
			field.value = txt;
		}

		function toggle_lati_long() {
			tr = document.getElementsByTagName('tr');
			for (var i=0; i<tr.length; i++) {
				if (tr[i].id.indexOf("LATI")>=0 || tr[i].id.indexOf("LONG")>=0) {
					var disp = tr[i].style.display;
					if (disp=="none") {
						disp="table-row";
						if (document.all && !window.opera) disp = "inline"; // IE
					}
					else disp="none";
					tr[i].style.display=disp;
				}
			}
		}
		//-->
		</script>
		<?php 
    }
    if (!isset($noClose) && isset($readOnly) && $readOnly == "NOCLOSE") {
        $noClose = "NOCLOSE";
        $readOnly = "";
    }
    if (!isset($noClose) || $noClose != "NOCLOSE") {
        $noClose = "";
    }
    if (!isset($readOnly) || $readOnly != "READONLY") {
        $readOnly = "";
    }
    if (!isset($tabkey)) {
        $tabkey = 1;
    }
    if (empty($linkToID)) {
        $linkToID = $pid;
    }
    $subnamefacts = array("NPFX", "GIVN", "SPFX", "SURN", "NSFX", "_MARNM_SURN");
    @(list($level, $fact, $value) = explode(" ", $tag));
    // element name : used to POST data
    if ($level == 0) {
        if ($upperlevel) {
            $element_name = $upperlevel . "_" . $fact;
        } else {
            $element_name = $fact;
        }
        // ex: OCCU
    } else {
        $element_name = "text[]";
    }
    if ($level == 1) {
        $main_fact = $fact;
    }
    // element id : used by javascript functions
    if ($level == 0) {
        $element_id = $fact;
    } else {
        $element_id = $fact . floor(microtime() * 1000000);
    }
    // ex: SOUR56402
    if ($upperlevel) {
        $element_id = $upperlevel . "_" . $fact;
    }
    // ex: BIRT_DATE | DEAT_DATE ...
    // field value
    $islink = (substr($value, 0, 1) == "@" and substr($value, 0, 2) != "@#");
    if ($islink) {
        $value = trim(trim(substr($tag, strlen($fact) + 3)), " @\r");
    } else {
        $value = trim(substr($tag, strlen($fact) + 3));
    }
    if ($fact == 'REPO' || $fact == 'SOUR' || $fact == 'OBJE' || $fact == 'FAMC') {
        $islink = true;
    }
    // rows & cols
    switch ($fact) {
        case 'FORM':
            $rows = 1;
            $cols = 5;
            break;
        case 'LATI':
        case 'LONG':
        case 'NPFX':
        case 'SPFX':
        case 'NSFX':
            $rows = 1;
            $cols = 12;
            break;
        case 'DATE':
        case 'TIME':
        case 'TYPE':
            $rows = 1;
            $cols = 20;
            break;
        case 'GIVN':
        case 'SURN':
        case '_MARNM':
            $rows = 1;
            $cols = 25;
            break;
        case '_UID':
            $rows = 1;
            $cols = 50;
            break;
        case 'TEXT':
        case 'PUBL':
            $rows = 10;
            $cols = 70;
            break;
        case 'SHARED_NOTE_EDIT':
            $islink = 1;
            $fact = "NOTE";
            $rows = 15;
            $cols = 88;
            break;
        case 'SHARED_NOTE':
            $islink = 1;
            $fact = "NOTE";
            $rows = 1;
            $cols = $islink ? 8 : 40;
            break;
        case 'NOTE':
            if ($islink) {
                $rows = 1;
                $cols = $islink ? 8 : 40;
                break;
            } else {
                $rows = 10;
                $cols = 70;
                break;
            }
        case 'ADDR':
            $rows = 4;
            $cols = 40;
            break;
        case 'PAGE':
            $rows = 1;
            $cols = 50;
            break;
        default:
            $rows = 1;
            $cols = $islink ? 8 : 40;
            break;
    }
    // label
    $style = "";
    echo "<tr id=\"" . $element_id . "_tr\" ";
    if ($fact == "MAP" || $fact == "LATI" || $fact == "LONG") {
        echo " style=\"display:none;\"";
    }
    echo " >\n";
    if (in_array($fact, $subnamefacts) || $fact == "LATI" || $fact == "LONG") {
        echo "<td class=\"optionbox {$TEXT_DIRECTION} wrap width25\">";
    } else {
        echo "<td class=\"descriptionbox {$TEXT_DIRECTION} wrap width25\">";
    }
    // help link
    if (!in_array($fact, $emptyfacts)) {
        if ($fact == "DATE") {
            print_help_link("def_gedcom_date_help", "qm", "date");
        } else {
            if ($fact == "RESN") {
                print_help_link($fact . "_help", "qm");
            } else {
                if ($fact == "NOTE" && $islink) {
                    print_help_link("edit_add_SHARED_NOTE_help", "qm");
                } else {
                    print_help_link("edit_" . $fact . "_help", "qm");
                }
            }
        }
    }
    if ($fact == "_AKAN" || $fact == "_AKA" || $fact == "ALIA") {
        // Allow special processing for different languages
        $func = "fact_AKA_localisation_{$lang_short_cut[$LANGUAGE]}";
        if (function_exists($func)) {
            // Localise the AKA fact
            $func($fact, $pid);
        }
    } else {
        if ($fact == "AGNC" && !empty($main_fact)) {
            // Allow special processing for different languages
            $func = "fact_AGNC_localisation_{$lang_short_cut[$LANGUAGE]}";
            if (function_exists($func)) {
                // Localise the AGNC fact
                $func($fact, $main_fact);
            }
        }
    }
    if (PGV_DEBUG) {
        echo $element_name . "<br />\n";
    }
    // tag name
    if (!empty($label)) {
        if ($label == "Note" && $islink) {
            echo $pgv_lang["shared_note"];
        } else {
            echo $label;
        }
    } else {
        if ($fact == "NOTE" && $islink) {
            echo $pgv_lang["shared_note"];
        } else {
            if (isset($pgv_lang[$fact])) {
                echo $pgv_lang[$fact];
            } else {
                if (isset($factarray[$fact])) {
                    echo $factarray[$fact];
                } else {
                    echo $fact;
                }
            }
        }
    }
    echo "\n";
    // tag level
    if ($level > 0) {
        if ($fact == "TEXT" and $level > 1) {
            echo "<input type=\"hidden\" name=\"glevels[]\" value=\"" . ($level - 1) . "\" />";
            echo "<input type=\"hidden\" name=\"islink[]\" value=\"0\" />";
            echo "<input type=\"hidden\" name=\"tag[]\" value=\"DATA\" />";
            //-- leave data text[] value empty because the following TEXT line will
            //--- cause the DATA to be added
            echo "<input type=\"hidden\" name=\"text[]\" value=\"\" />";
        }
        echo "<input type=\"hidden\" name=\"glevels[]\" value=\"" . $level . "\" />\n";
        echo "<input type=\"hidden\" name=\"islink[]\" value=\"" . $islink . "\" />\n";
        echo "<input type=\"hidden\" name=\"tag[]\" value=\"" . $fact . "\" />\n";
        // Shared Notes Debug --------------------
        // echo "<br />Label = ".$label;
        // echo "<br />Level = ".$level;
        // echo "<br />Link = ".$islink;
        // echo "<br />Fact = ".$fact;
        // echo "<br />Value = ".$value;
        // End Debug -------------------
    }
    echo "\n</td>";
    // value
    echo "<td class=\"optionbox wrap\">\n";
    if (PGV_DEBUG) {
        echo $tag . "<br />\n";
    }
    // retrieve linked NOTE
    if ($fact == "NOTE" && $islink) {
        $noteid = $value;
    }
    if (in_array($fact, $emptyfacts) && (empty($value) || $value == "y" || $value == "Y")) {
        $value = strtoupper($value);
        //-- don't default anything to Y when adding events through people
        //-- default to Y when specifically adding one of these events
        if ($level == 1) {
            $value = "Y";
        }
        // default YES
        echo "<input type=\"hidden\" id=\"" . $element_id . "\" name=\"" . $element_name . "\" value=\"" . $value . "\" />";
        if ($level <= 1) {
            echo "<input type=\"checkbox\" ";
            if ($value == "Y") {
                echo " checked=\"checked\"";
            }
            echo " onclick=\"if (this.checked) " . $element_id . ".value='Y'; else " . $element_id . ".value=''; \" />";
            echo $pgv_lang["yes"];
        }
    } else {
        if ($fact == "TEMP") {
            echo "<select tabindex=\"" . $tabkey . "\" name=\"" . $element_name . "\" >\n";
            echo "<option value=''>" . $pgv_lang["no_temple"] . "</option>\n";
            foreach ($TEMPLE_CODES as $code => $temple) {
                echo "<option value=\"{$code}\"";
                if ($code == $value) {
                    echo " selected=\"selected\"";
                }
                echo ">{$temple} ({$code})</option>\n";
            }
            echo "</select>\n";
        } else {
            if ($fact == "ADOP") {
                echo "<select tabindex=\"" . $tabkey . "\" name=\"" . $element_name . "\" >";
                foreach (array("BOTH" => $factarray["HUSB"] . "+" . $factarray["WIFE"], "HUSB" => $factarray["HUSB"], "WIFE" => $factarray["WIFE"]) as $k => $v) {
                    echo "<option value='{$k}'";
                    if ($value == $k) {
                        echo " selected=\"selected\"";
                    }
                    echo ">{$v}</option>";
                }
                echo "</select>\n";
            } else {
                if ($fact == "PEDI") {
                    echo "<select tabindex=\"" . $tabkey . "\" name=\"" . $element_name . "\" >";
                    foreach (array("" => $pgv_lang["unknown"], "birth" => $factarray["BIRT"], "adopted" => $pgv_lang["adopted"], "foster" => $pgv_lang["foster"], "sealing" => $pgv_lang["sealing"]) as $k => $v) {
                        echo "<option value='{$k}'";
                        if (UTF8_strtolower($value) == $k) {
                            echo " selected=\"selected\"";
                        }
                        echo ">{$v}</option>";
                    }
                    echo "</select>\n";
                } else {
                    if ($fact == "STAT") {
                        echo "<select tabindex=\"" . $tabkey . "\" name=\"" . $element_name . "\" >\n";
                        echo "<option value=''>No special status</option>\n";
                        foreach ($STATUS_CODES as $code => $status) {
                            echo "<option value=\"{$code}\"";
                            if ($code == $value) {
                                echo " selected=\"selected\"";
                            }
                            echo ">{$status}</option>\n";
                        }
                        echo "</select>\n";
                    } else {
                        if ($fact == "RELA") {
                            $text = strtolower($value);
                            // add current relationship if not found in default list
                            if (!array_key_exists($text, $assorela)) {
                                $assorela[$text] = $text;
                            }
                            echo "<select tabindex=\"" . $tabkey . "\" id=\"" . $element_id . "\" name=\"" . $element_name . "\" >\n";
                            foreach ($assorela as $key => $value) {
                                echo "<option value=\"" . $key . "\"";
                                if ($key == $text) {
                                    echo " selected=\"selected\"";
                                }
                                echo ">" . $assorela["{$key}"] . "</option>\n";
                            }
                            echo "</select>\n";
                        } else {
                            if ($fact == "_PGVU") {
                                $text = strtolower($value);
                                echo "<select tabindex=\"" . $tabkey . "\" id=\"" . $element_id . "\" name=\"" . $element_name . "\" >\n";
                                echo '<option value=""';
                                if ('' == $text) {
                                    echo ' selected="selected"';
                                }
                                echo ">-</option>\n";
                                foreach (get_all_users('asc', 'username') as $user_id => $user_name) {
                                    echo "<option value=\"" . $user_id . "\"";
                                    if ($user_id == $text) {
                                        echo " selected=\"selected\"";
                                    }
                                    echo ">" . $user_name . "</option>\n";
                                }
                                echo "</select>\n";
                            } else {
                                if ($fact == "RESN") {
                                    ?>
		<script type="text/javascript">
		<!--
		function update_RESN_img(resn_val) {
			document.getElementById("RESN_none").style.display="none";
			document.getElementById("RESN_locked").style.display="none";
			document.getElementById("RESN_privacy").style.display="none";
			document.getElementById("RESN_confidential").style.display="none";
			document.getElementById("RESN_"+resn_val).style.display="inline";
			if (resn_val=='none') resn_val='';
			document.getElementById("<?php 
                                    echo $element_id;
                                    ?>
").value=resn_val;
		}
		//-->
		</script>
		<?php 
                                    if (!$PRIVACY_BY_RESN && $level == 1) {
                                        // warn user that level 1 RESN tags have no effect when PRIVACY_BY_RESN is false
                                        echo "<small>" . $pgv_lang["resn_disabled"] . "</small>";
                                    }
                                    echo "<input type=\"hidden\" id=\"" . $element_id . "\" name=\"" . $element_name . "\" value=\"" . $value . "\" />\n";
                                    echo "<table><tr valign=\"top\">\n";
                                    foreach (array("none", "locked", "privacy", "confidential") as $resn_index => $resn_val) {
                                        if ($resn_val == "none") {
                                            $resnv = "";
                                        } else {
                                            $resnv = $resn_val;
                                        }
                                        echo "<td><input tabindex=\"" . $tabkey . "\" type=\"radio\" name=\"RESN_radio\" onclick=\"update_RESN_img('" . $resn_val . "')\"";
                                        echo " value=\"" . $resnv . "\"";
                                        if ($value == $resnv) {
                                            echo " checked=\"checked\"";
                                        }
                                        echo " /><small>" . $pgv_lang[$resn_val] . "</small>";
                                        echo "<br />&nbsp;<img id=\"RESN_" . $resn_val . "\" src=\"images/RESN_" . $resn_val . ".gif\"  alt=\"" . $pgv_lang[$resn_val] . "\" title=\"" . $pgv_lang[$resn_val] . "\" border=\"0\"";
                                        if ($value == $resnv) {
                                            echo " style=\"display:inline\"";
                                        } else {
                                            echo " style=\"display:none\"";
                                        }
                                        echo " /></td>\n";
                                    }
                                    echo "</tr></table>\n";
                                } else {
                                    if ($fact == "_PRIM" or $fact == "_THUM") {
                                        echo "<select tabindex=\"" . $tabkey . "\" id=\"" . $element_id . "\" name=\"" . $element_name . "\" >\n";
                                        echo "<option value=\"\"></option>\n";
                                        echo "<option value=\"Y\"";
                                        if ($value == "Y") {
                                            echo " selected=\"selected\"";
                                        }
                                        echo ">" . $pgv_lang["yes"] . "</option>\n";
                                        echo "<option value=\"N\"";
                                        if ($value == "N") {
                                            echo " selected=\"selected\"";
                                        }
                                        echo ">" . $pgv_lang["no"] . "</option>\n";
                                        echo "</select>\n";
                                    } else {
                                        if ($fact == "SEX") {
                                            echo "<select tabindex=\"" . $tabkey . "\" id=\"" . $element_id . "\" name=\"" . $element_name . "\">\n<option value=\"M\"";
                                            if ($value == "M") {
                                                echo " selected=\"selected\"";
                                            }
                                            echo ">" . $pgv_lang["male"] . "</option>\n<option value=\"F\"";
                                            if ($value == "F") {
                                                echo " selected=\"selected\"";
                                            }
                                            echo ">" . $pgv_lang["female"] . "</option>\n<option value=\"U\"";
                                            if ($value == "U" || empty($value)) {
                                                echo " selected=\"selected\"";
                                            }
                                            echo ">" . $pgv_lang["unknown"] . "</option>\n</select>\n";
                                        } else {
                                            if ($fact == "TYPE" && $level == '3') {
                                                //-- Build array of currently defined values for this Media Fact
                                                foreach ($pgv_lang as $varname => $typeValue) {
                                                    if (substr($varname, 0, 6) == "TYPE__") {
                                                        if ($varname != "TYPE__other") {
                                                            $type[strtolower(substr($varname, 6))] = $typeValue;
                                                        }
                                                    }
                                                }
                                                //-- Sort the array into a meaningful order
                                                array_flip($type);
                                                asort($type);
                                                array_flip($type);
                                                //-- Add "Other" at the end of the list
                                                $type["other"] = $pgv_lang["TYPE__other"];
                                                //-- Build the selector for the Media "TYPE" Fact
                                                echo "<select tabindex=\"" . $tabkey . "\" name=\"text[]\">";
                                                if ($value == "") {
                                                    echo "<option selected=\"selected\" value=\"\" > " . $pgv_lang["choose"] . " </option>";
                                                }
                                                $selectedValue = strtolower($value);
                                                foreach ($type as $typeName => $typeValue) {
                                                    echo "<option value=\"" . $typeName . "\" ";
                                                    if ($selectedValue == $typeName) {
                                                        echo "selected=\"selected\" ";
                                                    }
                                                    echo "> " . $typeValue . " </option>";
                                                }
                                                echo "</select>";
                                            } else {
                                                if ($fact == "NAME" && $upperlevel != 'REPO' || $fact == "_MARNM") {
                                                    // Populated in javascript from sub-tags
                                                    echo "<input type=\"hidden\" id=\"" . $element_id . "\" name=\"" . $element_name . "\" onchange=\"updateTextName('" . $element_id . "');\" value=\"" . PrintReady(htmlspecialchars($value, ENT_COMPAT, 'UTF-8')) . "\" />";
                                                    echo "<span id=\"" . $element_id . "_display\">" . PrintReady(htmlspecialchars($value, ENT_COMPAT, 'UTF-8')) . "</span>";
                                                    echo " <a href=\"#edit_name\" onclick=\"convertHidden('" . $element_id . "'); return false;\"> ";
                                                    if (isset($PGV_IMAGES["edit_indi"]["small"])) {
                                                        echo "<img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["edit_indi"]["small"] . "\" border=\"0\" width=\"20\" alt=\"" . $pgv_lang["edit_name"] . "\" align=\"top\" />";
                                                    } else {
                                                        echo "<span class=\"age\">[" . $pgv_lang["edit_name"] . "]</span>";
                                                    }
                                                    echo "</a>";
                                                } else {
                                                    // textarea
                                                    if ($rows > 1) {
                                                        echo "<textarea tabindex=\"" . $tabkey . "\" id=\"" . $element_id . "\" name=\"" . $element_name . "\" rows=\"" . $rows . "\" cols=\"" . $cols . "\">" . PrintReady(htmlspecialchars($value, ENT_COMPAT, 'UTF-8')) . "</textarea><br />\n";
                                                    } else {
                                                        // text
                                                        echo "<input tabindex=\"" . $tabkey . "\" type=\"text\" id=\"" . $element_id . "\" name=\"" . $element_name . "\" value=\"" . PrintReady(htmlspecialchars($value, ENT_COMPAT, 'UTF-8')) . "\" size=\"" . $cols . "\" dir=\"ltr\"";
                                                        echo " class=\"{$fact}\"";
                                                        echo " autocomplete=\"off\"";
                                                        if (in_array($fact, $subnamefacts)) {
                                                            echo " onblur=\"updatewholename();\" onkeyup=\"updatewholename();\"";
                                                        }
                                                        if ($fact == "DATE") {
                                                            echo " onblur=\"valid_date(this);\" onmouseout=\"valid_date(this);\"";
                                                        }
                                                        if ($fact == "LATI") {
                                                            echo " onblur=\"valid_lati_long(this, 'N', 'S');\" onmouseout=\"valid_lati_long(this, 'N', 'S');\"";
                                                        }
                                                        if ($fact == "LONG") {
                                                            echo " onblur=\"valid_lati_long(this, 'E', 'W');\" onmouseout=\"valid_lati_long(this, 'E', 'W');\"";
                                                        }
                                                        //if ($fact=="FILE") echo " onchange=\"if (updateFormat) updateFormat(this.value);\"";
                                                        echo " " . $readOnly . " />\n";
                                                    }
                                                    // split PLAC
                                                    if ($fact == "PLAC" && $readOnly == "") {
                                                        echo "<div id=\"" . $element_id . "_pop\" style=\"display: inline;\">\n";
                                                        print_specialchar_link($element_id, false);
                                                        print_findplace_link($element_id);
                                                        echo "</div>\n";
                                                        echo "<a href=\"javascript:;\" onclick=\"toggle_lati_long();\"><img src=\"images/buttons/target.gif\" border=\"0\" align=\"middle\" alt=\"" . $factarray["LATI"] . " / " . $factarray["LONG"] . "\" title=\"" . $factarray["LATI"] . " / " . $factarray["LONG"] . "\" /></a>";
                                                        if ($SPLIT_PLACES) {
                                                            if (!function_exists("print_place_subfields")) {
                                                                require "includes/functions/functions_places.php";
                                                            }
                                                            setup_place_subfields($element_id);
                                                            print_place_subfields($element_id);
                                                        }
                                                    } else {
                                                        if (($cols > 20 || $fact == "NPFX") && $readOnly == "") {
                                                            print_specialchar_link($element_id, false);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    // MARRiage TYPE : hide text field and show a selection list
    if ($fact == "TYPE" and $tags[0] == "MARR") {
        echo "<script type='text/javascript'>";
        echo "document.getElementById('" . $element_id . "').style.display='none'";
        echo "</script>";
        echo "<select tabindex=\"" . $tabkey . "\" id=\"" . $element_id . "_sel\" onchange=\"document.getElementById('" . $element_id . "').value=this.value;\" >\n";
        foreach (array("Unknown", "Civil", "Religious", "Partners") as $indexval => $key) {
            if ($key == "Unknown") {
                echo "<option value=\"\"";
            } else {
                echo "<option value=\"" . $key . "\"";
            }
            $a = strtolower($key);
            $b = strtolower($value);
            if (@strpos($a, $b) !== false or @strpos($b, $a) !== false) {
                echo " selected=\"selected\"";
            }
            echo ">" . $factarray["MARR_" . strtoupper($key)] . "</option>\n";
        }
        echo "</select>";
    }
    // popup links
    if ($readOnly == "") {
        if ($fact == "DATE") {
            print_calendar_popup($element_id);
        }
        if ($fact == "FAMC") {
            print_findfamily_link($element_id, "");
        }
        if ($fact == "FAMS") {
            print_findfamily_link($element_id, "");
        }
        if ($fact == "ASSO") {
            print_findindi_link($element_id, "");
        }
        if ($fact == "FILE") {
            print_findmedia_link($element_id, "0file");
        }
        if ($fact == "SOUR") {
            print_findsource_link($element_id);
            print_addnewsource_link($element_id);
            //print_autopaste_link($element_id, array("S1", "S2"), false, false, true);
            //-- checkboxes to apply '1 SOUR' to BIRT/MARR/DEAT as '2 SOUR'
            if ($level == 1) {
                echo '<br />';
                if ($PREFER_LEVEL2_SOURCES === '0') {
                    $level1_checked = '';
                    $level2_checked = '';
                } else {
                    if ($PREFER_LEVEL2_SOURCES === '1' || $PREFER_LEVEL2_SOURCES === true) {
                        $level1_checked = '';
                        $level2_checked = ' checked="checked"';
                    } else {
                        $level1_checked = ' checked="checked"';
                        $level2_checked = '';
                    }
                }
                if (strpos($bdm, 'B') !== false) {
                    echo '&nbsp;<input type="checkbox" name="SOUR_INDI" ', $level1_checked, ' value="Y" />';
                    echo $pgv_lang['individual'];
                    if (preg_match_all('/(' . PGV_REGEX_TAG . ')/', $QUICK_REQUIRED_FACTS, $matches)) {
                        foreach ($matches[1] as $match) {
                            if (!in_array($match, explode('|', PGV_EVENTS_DEAT))) {
                                echo '&nbsp;<input type="checkbox" name="SOUR_', $match, '"', $level2_checked, ' value="Y" />';
                                echo $factarray[$match];
                            }
                        }
                    }
                }
                if (strpos($bdm, 'D') !== false) {
                    if (preg_match_all('/(' . PGV_REGEX_TAG . ')/', $QUICK_REQUIRED_FACTS, $matches)) {
                        foreach ($matches[1] as $match) {
                            if (in_array($match, explode('|', PGV_EVENTS_DEAT))) {
                                echo '&nbsp;<input type="checkbox" name="SOUR_', $match, '"', $level2_checked, ' value="Y" />';
                                echo $factarray[$match];
                            }
                        }
                    }
                }
                if (strpos($bdm, 'M') !== false) {
                    echo '&nbsp;<input type="checkbox" name="SOUR_FAM" ', $level1_checked, ' value="Y" />';
                    echo $pgv_lang["family"];
                    if (preg_match_all('/(' . PGV_REGEX_TAG . ')/', $QUICK_REQUIRED_FAMFACTS, $matches)) {
                        foreach ($matches[1] as $match) {
                            echo '&nbsp;<input type="checkbox" name="SOUR_', $match, '"', $level2_checked, ' value="Y" />';
                            echo $factarray[$match];
                        }
                    }
                }
            }
        }
        if ($fact == "REPO") {
            print_findrepository_link($element_id);
            print_addnewrepository_link($element_id);
        }
        // Shared Notes Icons ========================================
        // $record=GedcomRecord::getInstance($value);
        if ($fact == "NOTE" && $islink) {
            print_findnote_link($element_id);
            print_addnewnote_link($element_id);
            if ($value != "") {
                echo "&nbsp;&nbsp;&nbsp;";
                print_editnote_link($value);
            }
            // If GEDFAct_assistant/_CENS/ module exists && we are on the INDI page
            // Then show the add Shared note assisted icon, if not  ... do not show
            if ($pid) {
                $type_pid = GedcomRecord::getInstance($pid);
                if (file_exists('modules/GEDFact_assistant/_CENS/census_1_ctrl.php') && $type_pid->getType() == "INDI") {
                    echo "&nbsp;&nbsp;&nbsp;";
                    print_addnewnote_assisted_link($element_id);
                }
            }
            echo "<br />";
        }
        // ===========================================================
        if ($fact == "OBJE") {
            print_findmedia_link($element_id, "1media");
        }
        if ($fact == "OBJE" && !$value) {
            print_addnewmedia_link($element_id);
            $value = "new";
        }
    }
    // current value
    if ($TEXT_DIRECTION == "ltr") {
        if ($fact == "DATE") {
            $date = new GedcomDate($value);
            echo $date->Display(false);
        }
        if (($fact == "ASSO" || $fact == "SOUR" || $fact == "OBJE" || $fact == "NOTE" && $islink) && $value) {
            $record = GedcomRecord::getInstance($value);
            if ($record) {
                echo ' ', PrintReady($record->getFullName()), ' (', $value, ')';
            } else {
                if ($value != "new") {
                    echo ' ', $value;
                }
            }
        }
    } else {
        if ($fact == "DATE") {
            $date = new GedcomDate($value);
            echo getRLM(), $date->Display(false), getRLM();
        }
        if (($fact == "ASSO" || $fact == "SOUR" || $fact == "OBJE" || $fact == "NOTE" && $islink) && $value) {
            $record = GedcomRecord::getInstance($value);
            if ($record) {
                echo getRLM(), PrintReady($record->getFullName()), ' ', getLRM(), '(', $value, ') ', getLRM(), getRLM();
            } else {
                if ($value != "new") {
                    echo getRLM(), $value, ' ', getRLM();
                }
            }
        }
    }
    /*
    	if ($fact=="NOTE" && $islink && $value!="") {
    		include('includes/functions/functions_print_lists.php'); 
    		echo "<tr><td class=\"descriptionbox ".$TEXT_DIRECTION." wrap width25\">";
    				print_help_link("edit_add_SHARED_NOTE_help", "qm");
    			//	echo $pgv_lang["admin_override"];
    			echo "Shared Note Links<br /><br />";
    		echo "</td><td class=\"optionbox wrap\">\n";
    			print_indi_list(fetch_linked_indi($value, "NOTE", "1"));
    		echo "</td></tr>\n";
    	}
    */
    // pastable values
    if ($readOnly == "") {
        if ($fact == "SPFX") {
            print_autopaste_link($element_id, $SPFX_accept);
        }
        if ($fact == "NSFX") {
            print_autopaste_link($element_id, $NSFX_accept);
        }
        if ($fact == "FORM") {
            print_autopaste_link($element_id, $FILE_FORM_accept, false, false);
        }
    }
    if ($noClose != "NOCLOSE") {
        echo "</td></tr>\n";
    }
    $tabkey++;
    return $element_id;
}
Esempio n. 4
0
/**
 * get gedcom tag value
 *
 * returns the value of a gedcom tag from the given gedcom record
 * @param string $tag	The tag to find, use : to delineate subtags
 * @param int $level	The gedcom line level of the first tag to find, setting level to 0 will cause it to use 1+ the level of the incoming record
 * @param string $gedrec	The gedcom record to get the value from
 * @param int $truncate	Should the value be truncated to a certain number of characters
 * @param boolean $convert	Should data like dates be converted using the configuration settings
 * @return string
 */
function get_gedcom_value($tag, $level, $gedrec, $truncate = '', $convert = true)
{
    global $SHOW_PEDIGREE_PLACES, $pgv_lang;
    if (empty($gedrec)) {
        return "";
    }
    $tags = explode(':', $tag);
    $origlevel = $level;
    if ($level == 0) {
        $level = $gedrec[0] + 1;
    }
    $subrec = $gedrec;
    foreach ($tags as $indexval => $t) {
        $lastsubrec = $subrec;
        $subrec = get_sub_record($level, "{$level} {$t}", $subrec);
        if (empty($subrec) && $origlevel == 0) {
            $level--;
            $subrec = get_sub_record($level, "{$level} {$t}", $lastsubrec);
        }
        if (empty($subrec)) {
            if ($t == "TITL") {
                $subrec = get_sub_record($level, "{$level} ABBR", $lastsubrec);
                if (!empty($subrec)) {
                    $t = "ABBR";
                }
            }
            if (empty($subrec)) {
                if ($level > 0) {
                    $level--;
                }
                $subrec = get_sub_record($level, "@ {$t}", $gedrec);
                if (empty($subrec)) {
                    return;
                }
            }
        }
        $level++;
    }
    $level--;
    $ct = preg_match("/{$level} {$t}(.*)/", $subrec, $match);
    if ($ct == 0) {
        $ct = preg_match("/{$level} @.+@ (.+)/", $subrec, $match);
    }
    if ($ct == 0) {
        $ct = preg_match("/@ {$t} (.+)/", $subrec, $match);
    }
    if ($ct > 0) {
        $value = trim($match[1]);
        $ct = preg_match("/@(.*)@/", $value, $match);
        if ($ct > 0 && $t != "DATE") {
            $oldsub = $subrec;
            switch ($t) {
                case 'HUSB':
                case 'WIFE':
                case 'CHIL':
                    $subrec = find_person_record($match[1]);
                    break;
                case 'FAMC':
                case 'FAMS':
                    $subrec = find_family_record($match[1]);
                    break;
                case 'SOUR':
                    $subrec = find_source_record($match[1]);
                    break;
                case 'REPO':
                    $subrec = find_other_record($match[1]);
                    break;
                default:
                    $subrec = find_gedcom_record($match[1]);
                    break;
            }
            if ($subrec) {
                $value = $match[1];
                $ct = preg_match("/0 @{$match['1']}@ {$t} (.+)/", $subrec, $match);
                if ($ct > 0) {
                    $value = $match[1];
                    $level = 0;
                } else {
                    $subrec = $oldsub;
                }
            } else {
                //-- set the value to the id without the @
                $value = $match[1];
            }
        }
        if ($level != 0 || $t != "NOTE") {
            $value .= get_cont($level + 1, $subrec);
        }
        $value = preg_replace("'\n'", "", $value);
        $value = preg_replace("'<br />'", "\n", $value);
        $value = trim($value);
        //-- if it is a date value then convert the date
        if ($convert && $t == "DATE") {
            $g = new GedcomDate($value);
            $value = $g->Display();
            if (!empty($truncate)) {
                if (UTF8_strlen($value) > $truncate) {
                    $value = preg_replace("/\\(.+\\)/", "", $value);
                    //if (UTF8_strlen($value)>$truncate) {
                    //	$value = preg_replace_callback("/([a-zśź]+)/ui", create_function('$matches', 'return UTF8_substr($matches[1], 0, 3);'), $value);
                    //}
                }
            }
        } else {
            //-- if it is a place value then apply the pedigree place limit
            if ($convert && $t == "PLAC") {
                if ($SHOW_PEDIGREE_PLACES > 0) {
                    $plevels = explode(',', $value);
                    $value = "";
                    for ($plevel = 0; $plevel < $SHOW_PEDIGREE_PLACES; $plevel++) {
                        if (!empty($plevels[$plevel])) {
                            if ($plevel > 0) {
                                $value .= ", ";
                            }
                            $value .= trim($plevels[$plevel]);
                        }
                    }
                }
                if (!empty($truncate)) {
                    if (strlen($value) > $truncate) {
                        $plevels = explode(',', $value);
                        $value = "";
                        for ($plevel = 0; $plevel < count($plevels); $plevel++) {
                            if (!empty($plevels[$plevel])) {
                                if (strlen($plevels[$plevel]) + strlen($value) + 3 < $truncate) {
                                    if ($plevel > 0) {
                                        $value .= ", ";
                                    }
                                    $value .= trim($plevels[$plevel]);
                                } else {
                                    break;
                                }
                            }
                        }
                    }
                }
            } else {
                if ($convert && $t == "SEX") {
                    if ($value == "M") {
                        $value = get_first_letter($pgv_lang["male"]);
                    } elseif ($value == "F") {
                        $value = get_first_letter($pgv_lang["female"]);
                    } else {
                        $value = get_first_letter($pgv_lang["unknown"]);
                    }
                } else {
                    if (!empty($truncate)) {
                        if (strlen($value) > $truncate) {
                            $plevels = explode(' ', $value);
                            $value = "";
                            for ($plevel = 0; $plevel < count($plevels); $plevel++) {
                                if (!empty($plevels[$plevel])) {
                                    if (strlen($plevels[$plevel]) + strlen($value) + 3 < $truncate) {
                                        if ($plevel > 0) {
                                            $value .= " ";
                                        }
                                        $value .= trim($plevels[$plevel]);
                                    } else {
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        return $value;
    }
    return "";
}
Esempio n. 5
0
 function _eventQuery($type, $direction, $facts)
 {
     global $TBLPREFIX, $pgv_lang, $SHOW_ID_NUMBERS, $listDir;
     $eventTypes = array('BIRT' => $pgv_lang['htmlplus_block_birth'], 'DEAT' => $pgv_lang['htmlplus_block_death'], 'MARR' => $pgv_lang['htmlplus_block_marrage'], 'ADOP' => $pgv_lang['htmlplus_block_adoption'], 'BURI' => $pgv_lang['htmlplus_block_burial'], 'CENS' => $pgv_lang['htmlplus_block_census']);
     $fact_query = "IN ('" . str_replace('|', "','", $facts) . "')";
     if ($direction != 'ASC') {
         $direction = 'DESC';
     }
     $rows = self::_runSQL('' . ' SELECT' . ' d_gid AS id,' . ' d_year AS year,' . ' d_fact AS fact,' . ' d_type AS type' . ' FROM' . " {$TBLPREFIX}dates" . ' WHERE' . " d_file={$this->_ged_id} AND" . " d_gid!='HEAD' AND" . " d_fact {$fact_query} AND" . ' d_julianday1!=0' . ' ORDER BY' . " d_julianday1 {$direction}, d_type", 1);
     if (!isset($rows[0])) {
         return '';
     }
     $row = $rows[0];
     $record = GedcomRecord::getInstance($row['id']);
     switch ($type) {
         default:
         case 'full':
             if ($record->canDisplayDetails()) {
                 $result = $record->format_list('span', false, $record->getFullName());
             } else {
                 $result = $pgv_lang['privacy_error'];
             }
             break;
         case 'year':
             $date = new GedcomDate($row['type'] . ' ' . $row['year']);
             $result = $date->Display(true);
             break;
         case 'type':
             if (isset($eventTypes[$row['fact']])) {
                 $result = $eventTypes[$row['fact']];
             } else {
                 $result = '';
             }
             break;
         case 'name':
             $id = '';
             if ($SHOW_ID_NUMBERS) {
                 if ($listDir == 'rtl') {
                     $id = "&nbsp;&nbsp;" . getRLM() . "({$row['id']})" . getRLM();
                 } else {
                     $id = "&nbsp;&nbsp;({$row['id']})";
                 }
             }
             $result = "<a href=\"" . $record->getLinkUrl() . "\">" . PrintReady($record->getFullName()) . "{$id}</a>";
             break;
         case 'place':
             $result = format_fact_place($record->getFactByType($row['fact']), true, true, true);
             break;
     }
     return str_replace('<a href="', '<a href="' . $this->_server_url, $result);
 }
Esempio n. 6
0
    // Calendar form
    print '<form name="dateform" method="get" action="calendar.php">';
    print "<input type=\"hidden\" name=\"cal\"      value=\"{$cal}\"         />";
    print "<input type=\"hidden\" name=\"day\"      value=\"{$cal_date->d}\" />";
    print "<input type=\"hidden\" name=\"month\"    value=\"{$cal_month}\"   />";
    print "<input type=\"hidden\" name=\"year\"     value=\"{$cal_date->y}\" />";
    print "<input type=\"hidden\" name=\"action\"   value=\"{$action}\"      />";
    print "<input type=\"hidden\" name=\"filterev\" value=\"{$filterev}\"    />";
    print "<input type=\"hidden\" name=\"filtersx\" value=\"{$filtersx}\"    />";
    print "<input type=\"hidden\" name=\"filterof\" value=\"{$filterof}\"    />";
}
print '<table class="facts_table ' . $TEXT_DIRECTION . ' width100">';
print '<tr><td class="facts_label" colspan="8"><h2>';
switch ($action) {
    case 'today':
        print $pgv_lang['on_this_day'] . '<br/>' . $ged_date->Display(false);
        break;
    case 'calendar':
        print $pgv_lang['in_this_month'] . '<br/>' . $ged_date->Display(false, 'F Y');
        break;
    case 'year':
        print $pgv_lang['in_this_year'] . '<br/>' . $ged_date->Display(false, 'Y');
        break;
}
print '</h2></td></tr>';
if ($view != 'preview') {
    // Day selector
    print '<tr><td class="descriptionbox vmiddle">';
    print_help_link('annivers_date_select_help', 'qm', 'day');
    print $pgv_lang['day'] . '</td><td colspan="7" class="optionbox">';
    for ($d = 1; $d <= $days_in_month; $d++) {
Esempio n. 7
0
/**
 * returns a marriage anniversary iCalendar event for a family marriage.
 * If there is no date for the event, or either of the spouses is not alive,
 * no iCalendar event will be returned
 * @param Family $family the Family Object used as the source of the marriage anniversary info
 * @return the marriage anniversary iCalendar event.
 */
function getFamilyAnniversaryIcalEvent($family)
{
    $anniversaryDate = $family->getMarriageDate();
    if ($anniversaryDate == "") {
        return;
    }
    if ($family->isDivorced()) {
        return;
    }
    $wife = $family->getWife();
    $husband = $family->getHusband();
    if ($wife->isDead() || $husband->isDead()) {
        return;
    }
    $anniversaryDate = new GedcomDate($anniversaryDate);
    $summary = "Anniversary of " . $husband->getFullName() . " and " . $wife->getFullName();
    $place = $family->getMarriagePlace();
    $description = "Married on " . $anniversaryDate->Display(false) . ($place == "" ? "" : "in " . $place) . "\n" . encode_url($family->getAbsoluteLinkUrl());
    $iCalRecord = getIcalRecord($anniversaryDate, $summary, $description, encode_url($family->getAbsoluteLinkUrl()));
    return $iCalRecord;
}
Esempio n. 8
0
/**
* Variable lookap
*
* @param array $attrs an array of key value pairs for the attributes
* @see PGVRSetVarSHandler()
* @todo check the date attribute, what is this?
*/
function PGVRvarSHandler($attrs)
{
    global $currentElement, $vars, $gedrec, $gedrecStack, $pgv_lang, $language_settings, $factarray, $fact, $desc, $type;
    $var = $attrs["var"];
    if (!empty($var)) {
        if (!empty($vars[$var]['id'])) {
            $var = $vars[$var]['id'];
        } else {
            $tfact = $fact;
            if ($fact == "EVEN" || $fact == "FACT") {
                $tfact = $type;
            }
            $var = preg_replace(array("/\\[/", "/\\]/", "/@fact/", "/@desc/"), array("['", "']", $tfact, $desc), $var);
            eval("if (!empty(\${$var})) \$var = \${$var};");
            $match = array();
            $ct = preg_match("/factarray\\['(.*)'\\]/", $var, $match);
            if ($ct > 0) {
                $var = $match[1];
            }
        }
        if (!empty($attrs["date"])) {
            $g = new GedcomDate($var);
            $var = $g->Display();
        }
        $currentElement->addText($var);
    }
}