Exemplo n.º 1
0
function format_asso_rela_record(WT_Fact $event)
{
    global $SEARCH_SPIDER;
    $parent = $event->getParent();
    // To whom is this record an assocate?
    if ($parent instanceof WT_Individual) {
        // On an individual page, we just show links to the person
        $associates = array($parent);
    } elseif ($parent instanceof WT_Family) {
        // On a family page, we show links to both spouses
        $associates = $parent->getSpouses();
    } else {
        // On other pages, it does not make sense to show associates
        return '';
    }
    preg_match_all('/^1 ASSO @(' . WT_REGEX_XREF . ')@((\\n[2-9].*)*)/', $event->getGedcom(), $amatches1, PREG_SET_ORDER);
    preg_match_all('/\\n2 _?ASSO @(' . WT_REGEX_XREF . ')@((\\n[3-9].*)*)/', $event->getGedcom(), $amatches2, PREG_SET_ORDER);
    $html = '';
    // For each ASSO record
    foreach (array_merge($amatches1, $amatches2) as $amatch) {
        $person = WT_Individual::getInstance($amatch[1]);
        if ($person) {
            // Is there a "RELA" tag
            if (preg_match('/\\n[23] RELA (.+)/', $amatch[2], $rmatch)) {
                // Use the supplied relationship as a label
                $label = WT_Gedcom_Code_Rela::getValue($rmatch[1], $person);
            } else {
                // Use a default label
                $label = WT_Gedcom_Tag::getLabel('ASSO', $person);
            }
            $values = array('<a href="' . $person->getHtmlUrl() . '">' . $person->getFullName() . '</a>');
            if (!$SEARCH_SPIDER) {
                foreach ($associates as $associate) {
                    $relationship_name = get_associate_relationship_name($associate, $person);
                    if (!$relationship_name) {
                        $relationship_name = WT_Gedcom_Tag::getLabel('RELA');
                    }
                    if ($parent instanceof WT_Family) {
                        // For family ASSO records (e.g. MARR), identify the spouse with a sex icon
                        $relationship_name .= $associate->getSexImage();
                    }
                    $values[] = '<a href="relationship.php?pid1=' . $associate->getXref() . '&amp;pid2=' . $person->getXref() . '&amp;ged=' . WT_GEDURL . '">' . $relationship_name . '</a>';
                }
            }
            $value = implode(' — ', $values);
            // Use same markup as WT_Gedcom_Tag::getLabelValue()
            $asso = WT_I18N::translate('<span class="label">%1$s:</span> <span class="field" dir="auto">%2$s</span>', $label, $value);
        } else {
            $asso = WT_Gedcom_Tag::getLabelValue('ASSO', '<span class="error">' . $amatch[1] . '</span>');
        }
        $html .= '<div class="fact_ASSO">' . $asso . '</div>';
    }
    return $html;
}
Exemplo n.º 2
0
function edit_field_rela($name, $selected = '', $extra = '')
{
    $rela_codes = WT_Gedcom_Code_Rela::getValues();
    // The user is allowed to specify values that aren't in the list.
    if (!array_key_exists($selected, $rela_codes)) {
        $rela_codes[$selected] = $selected;
    }
    return select_edit_control($name, $rela_codes, '', $selected, $extra);
}