Ejemplo n.º 1
0
 public function __construct()
 {
     global $Dbwidth, $bwidth, $pbwidth, $pbheight, $bheight;
     $bwidth = $Dbwidth;
     $pbwidth = $bwidth + 12;
     $pbheight = $bheight + 14;
     $xref = WT_Filter::get('famid', WT_REGEX_XREF);
     $this->record = WT_Family::getInstance($xref);
     parent::__construct();
 }
Ejemplo n.º 2
0
 public function getTarget()
 {
     $xref = trim($this->getValue(), '@');
     switch ($this->tag) {
         case 'FAMC':
         case 'FAMS':
             return WT_Family::getInstance($xref, $this->getParent()->getGedcomId());
         case 'HUSB':
         case 'WIFE':
         case 'CHIL':
             return WT_Individual::getInstance($xref, $this->getParent()->getGedcomId());
         case 'SOUR':
             return WT_Source::getInstance($xref, $this->getParent()->getGedcomId());
         case 'OBJE':
             return WT_Media::getInstance($xref, $this->getParent()->getGedcomId());
         case 'REPO':
             return WT_Repository::getInstance($xref, $this->getParent()->getGedcomId());
         case 'NOTE':
             return WT_Note::getInstance($xref, $this->getParent()->getGedcomId());
         default:
             return WT_GedcomRecord::getInstance($xref, $this->getParent()->getGedcomId());
     }
 }
Ejemplo n.º 3
0
 function addFamilyDescendancy(WT_Family $family = null, $level = PHP_INT_MAX)
 {
     if (!$family) {
         return;
     }
     foreach ($family->getSpouses() as $spouse) {
         $this->addClipping($spouse);
     }
     foreach ($family->getChildren() as $child) {
         $this->addClipping($child);
         foreach ($child->getSpouseFamilies() as $child_family) {
             $this->addClipping($child_family);
             if ($level > 0) {
                 $this->addFamilyDescendancy($child_family, $level - 1);
                 // recurse on the childs family
             }
         }
     }
 }
Ejemplo n.º 4
0
function print_indi_form($nextaction, WT_Individual $person = null, WT_Family $family = null, WT_Fact $name_fact = null, $famtag = 'CHIL', $gender = 'U')
{
    global $WORD_WRAPPED_NOTES, $NPFX_accept, $SHOW_GEDCOM_RECORD, $bdm, $STANDARD_NAME_FACTS, $ADVANCED_NAME_FACTS;
    global $QUICK_REQUIRED_FACTS, $QUICK_REQUIRED_FAMFACTS, $controller;
    $SURNAME_TRADITION = get_gedcom_setting(WT_GED_ID, 'SURNAME_TRADITION');
    if ($person) {
        $xref = $person->getXref();
    } elseif ($family) {
        $xref = $family->getXref();
    } else {
        $xref = 'new';
    }
    $name_fields = array();
    if ($name_fact) {
        $name_fact_id = $name_fact->getFactId();
        $name_type = $name_fact->getAttribute('TYPE');
        $namerec = $name_fact->getGedcom();
        // Populate the standard NAME field and subfields
        foreach ($STANDARD_NAME_FACTS as $tag) {
            if ($tag == 'NAME') {
                $name_fields[$tag] = $name_fact->getValue();
            } else {
                $name_fields[$tag] = $name_fact->getAttribute($tag);
            }
        }
    } else {
        $name_fact_id = null;
        $name_type = null;
        $namerec = null;
        // Populate the standard NAME field and subfields
        foreach ($STANDARD_NAME_FACTS as $tag) {
            $name_fields[$tag] = '';
        }
    }
    $bdm = '';
    // used to copy '1 SOUR' to '2 SOUR' for BIRT DEAT MARR
    echo '<div id="edit_interface-page">';
    echo '<h4>', $controller->getPageTitle(), '</h4>';
    init_calendar_popup();
    echo '<form method="post" name="addchildform" onsubmit="return checkform();">';
    echo '<input type="hidden" name="ged" value="', WT_Filter::escapeHtml(WT_GEDCOM), '">';
    echo '<input type="hidden" name="action" value="', $nextaction, '">';
    echo '<input type="hidden" name="fact_id" value="', $name_fact_id, '">';
    echo '<input type="hidden" name="xref" value="', $xref, '">';
    echo '<input type="hidden" name="famtag" value="', $famtag, '">';
    echo '<input type="hidden" name="gender" value="', $gender, '">';
    echo '<input type="hidden" name="goto" value="">';
    // set by javascript
    echo WT_Filter::getCsrf();
    echo '<table class="facts_table">';
    switch ($nextaction) {
        case 'add_child_to_family_action':
        case 'add_child_to_individual_action':
            // When adding a new child, specify the pedigree
            add_simple_tag('0 PEDI');
            break;
        case 'update':
            // When adding/editing a name, specify the type
            add_simple_tag('0 TYPE ' . $name_type, '', '', null, $person);
            break;
    }
    $new_marnm = '';
    // Inherit surname from parents, spouse or child
    if (!$namerec) {
        // We’ll need the parent’s name to set the child’s surname
        if ($family) {
            $father = $family->getHusband();
            if ($father && $father->getFirstFact('NAME')) {
                $father_name = $father->getFirstFact('NAME')->getValue();
            } else {
                $father_name = '';
            }
            $mother = $family->getWife();
            if ($mother && $mother->getFirstFact('NAME')) {
                $mother_name = $mother->getFirstFact('NAME')->getValue();
            } else {
                $mother_name = '';
            }
        } else {
            $father_name = '';
            $mother_name = '';
        }
        // We’ll need the spouse/child’s name to set the spouse/parent’s surname
        if ($person && $person->getFirstFact('NAME')) {
            $indi_name = $person->getFirstFact('NAME')->getValue();
        } else {
            $indi_name = '';
        }
        // Different cultures do surnames differently
        switch ($SURNAME_TRADITION) {
            case 'spanish':
                //Mother: Maria /AAAA BBBB/
                //Father: Jose  /CCCC DDDD/
                //Child:  Pablo /CCCC AAAA/
                switch ($nextaction) {
                    case 'add_child_to_family_action':
                        if (preg_match('/\\/(\\S+) \\S+\\//', $mother_name, $matchm) && preg_match('/\\/(\\S+) \\S+\\//', $father_name, $matchf)) {
                            $name_fields['SURN'] = $matchf[1] . ' ' . $matchm[1];
                            $name_fields['NAME'] = '/' . $name_fields['SURN'] . '/';
                        }
                        break;
                    case 'add_parent_to_individual_action':
                        if ($famtag == 'HUSB' && preg_match('/\\/(\\S+) \\S+\\//', $indi_name, $match)) {
                            $name_fields['SURN'] = $match[1];
                            $name_fields['NAME'] = '/' . $name_fields['SURN'] . '/';
                        }
                        if ($famtag == 'WIFE' && preg_match('/\\/\\S+ (\\S+)\\//', $indi_name, $match)) {
                            $name_fields['SURN'] = $match[1];
                            $name_fields['NAME'] = '/' . $name_fields['SURN'] . '/';
                        }
                        break;
                    case 'add_child_to_individual_action':
                    case 'add_spouse_to_individual_action':
                    case 'add_spouse_to_family_action':
                        break;
                }
                break;
            case 'portuguese':
                //Mother: Maria /AAAA BBBB/
                //Father: Jose  /CCCC DDDD/
                //Child:  Pablo /BBBB DDDD/
                switch ($nextaction) {
                    case 'add_child_to_family_action':
                        if (preg_match('/\\/\\S+\\s+(\\S+)\\//', $mother_name, $matchm) && preg_match('/\\/\\S+\\s+(\\S+)\\//', $father_name, $matchf)) {
                            $name_fields['SURN'] = $matchf[1] . ' ' . $matchm[1];
                            $name_fields['NAME'] = '/' . $name_fields['SURN'] . '/';
                        }
                        break;
                    case 'add_parent_to_individual_action':
                        if ($famtag == 'HUSB' && preg_match('/\\/\\S+\\s+(\\S+)\\//', $indi_name, $match)) {
                            $name_fields['SURN'] = $match[1];
                            $name_fields['NAME'] = '/' . $name_fields['SURN'] . '/';
                        }
                        if ($famtag == 'WIFE' && preg_match('/\\/(\\S+)\\s+\\S+\\//', $indi_name, $match)) {
                            $name_fields['SURN'] = $match[1];
                            $name_fields['NAME'] = '/' . $name_fields['SURN'] . '/';
                        }
                        break;
                    case 'add_child_to_individual_action':
                    case 'add_spouse_to_individual_action':
                    case 'add_spouse_to_family_action':
                        break;
                }
                break;
            case 'icelandic':
                // Sons get their father’s given name plus “sson”
                // Daughters get their father’s given name plus “sdottir”
                switch ($nextaction) {
                    case 'add_child_to_family_action':
                        if ($gender == 'M' && preg_match('/(\\S+)\\s+\\/.*\\//', $father_name, $match)) {
                            $name_fields['SURN'] = preg_replace('/s$/', '', $match[1]) . 'sson';
                            $name_fields['NAME'] = '/' . $name_fields['SURN'] . '/';
                        }
                        if ($gender == 'F' && preg_match('/(\\S+)\\s+\\/.*\\//', $father_name, $match)) {
                            $name_fields['SURN'] = preg_replace('/s$/', '', $match[1]) . 'sdottir';
                            $name_fields['NAME'] = '/' . $name_fields['SURN'] . '/';
                        }
                        break;
                    case 'add_parent_to_individual_action':
                        if ($famtag == 'HUSB' && preg_match('/(\\S+)sson\\s+\\/.*\\//i', $indi_name, $match)) {
                            $name_fields['GIVN'] = $match[1];
                            $name_fields['NAME'] = $name_fields['GIVN'] . ' //';
                        }
                        if ($famtag == 'WIFE' && preg_match('/(\\S+)sdottir\\s+\\/.*\\//i', $indi_name, $match)) {
                            $name_fields['GIVN'] = $match[1];
                            $name_fields['NAME'] = $name_fields['GIVN'] . ' //';
                        }
                        break;
                    case 'add_child_to_individual_action':
                    case 'add_spouse_to_individual_action':
                    case 'add_spouse_to_family_action':
                        break;
                }
                break;
            case 'patrilineal':
                // Father gives his surname to his children
                switch ($nextaction) {
                    case 'add_child_to_family_action':
                        if (preg_match('/\\/((?:[a-z]{2,3} )*)(.*)\\//i', $father_name, $match)) {
                            $name_fields['SURN'] = $match[2];
                            $name_fields['SPFX'] = trim($match[1]);
                            $name_fields['NAME'] = "/{$match[1]}{$match[2]}/";
                        }
                        break;
                    case 'add_parent_to_individual_action':
                        if ($famtag == 'HUSB' && preg_match('/\\/((?:[a-z]{2,3} )*)(.*)\\//i', $indi_name, $match)) {
                            $name_fields['SURN'] = $match[2];
                            $name_fields['SPFX'] = trim($match[1]);
                            $name_fields['NAME'] = "/{$match[1]}{$match[2]}/";
                        }
                        break;
                    case 'add_child_to_individual_action':
                    case 'add_spouse_to_individual_action':
                    case 'add_spouse_to_family_action':
                        break;
                }
                break;
            case 'matrilineal':
                // Mother gives her surname to her children
                switch ($nextaction) {
                    case 'add_child_to_family_action':
                        if (preg_match('/\\/((?:[a-z]{2,3} )*)(.*)\\//i', $mother, $match)) {
                            $name_fields['SURN'] = $match[2];
                            $name_fields['SPFX'] = trim($match[1]);
                            $name_fields['NAME'] = "/{$match[1]}{$match[2]}/";
                        }
                        break;
                    case 'add_parent_to_individual_action':
                        if ($famtag == 'WIFE' && preg_match('/\\/((?:[a-z]{2,3} )*)(.*)\\//i', $indi_name, $match)) {
                            $name_fields['SURN'] = $match[2];
                            $name_fields['SPFX'] = trim($match[1]);
                            $name_fields['NAME'] = "/{$match[1]}{$match[2]}/";
                        }
                        break;
                    case 'add_child_to_individual_action':
                    case 'add_spouse_to_individual_action':
                    case 'add_spouse_to_family_action':
                        break;
                }
                break;
            case 'paternal':
            case 'polish':
            case 'lithuanian':
                // Father gives his surname to his wife and children
                switch ($nextaction) {
                    case 'add_spouse_to_individual_action':
                        if ($famtag == 'WIFE' && preg_match('/\\/(.*)\\//', $indi_name, $match)) {
                            if ($SURNAME_TRADITION == 'polish') {
                                $match[1] = preg_replace(array('/ski$/', '/cki$/', '/dzki$/', '/żki$/'), array('ska', 'cka', 'dzka', 'żka'), $match[1]);
                            } elseif ($SURNAME_TRADITION == 'lithuanian') {
                                $match[1] = preg_replace(array('/as$/', '/is$/', '/ys$/', '/us$/'), array('ienė', 'ienė', 'ienė', 'ienė'), $match[1]);
                            }
                            $new_marnm = $match[1];
                        }
                        break;
                    case 'add_child_to_family_action':
                        if (preg_match('/\\/((?:[a-z]{2,3} )*)(.*)\\//i', $father_name, $match)) {
                            $name_fields['SURN'] = $match[2];
                            if ($SURNAME_TRADITION == 'polish' && $gender == 'F') {
                                $match[2] = preg_replace(array('/ski$/', '/cki$/', '/dzki$/', '/żki$/'), array('ska', 'cka', 'dzka', 'żka'), $match[2]);
                            } elseif ($SURNAME_TRADITION == 'lithuanian' && $gender == 'F') {
                                $match[2] = preg_replace(array('/as$/', '/a$/', '/is$/', '/ys$/', '/ius$/', '/us$/'), array('aitė', 'aitė', 'ytė', 'ytė', 'iūtė', 'utė'), $match[2]);
                            }
                            $name_fields['SPFX'] = trim($match[1]);
                            $name_fields['NAME'] = "/{$match[1]}{$match[2]}/";
                        }
                        break;
                    case 'add_child_to_individual_action':
                        if ($person->getSex() == 'M' && preg_match('/\\/((?:[a-z]{2,3} )*)(.*)\\//i', $indi_name, $match)) {
                            $name_fields['SURN'] = $match[2];
                            if ($SURNAME_TRADITION == 'polish' && $gender == 'F') {
                                $match[2] = preg_replace(array('/ski$/', '/cki$/', '/dzki$/', '/żki$/'), array('ska', 'cka', 'dzka', 'żka'), $match[2]);
                            } elseif ($SURNAME_TRADITION == 'lithuanian' && $gender == 'F') {
                                $match[2] = preg_replace(array('/as$/', '/a$/', '/is$/', '/ys$/', '/ius$/', '/us$/'), array('aitė', 'aitė', 'ytė', 'ytė', 'iūtė', 'utė'), $match[2]);
                            }
                            $name_fields['SPFX'] = trim($match[1]);
                            $name_fields['NAME'] = "/{$match[1]}{$match[2]}/";
                        }
                        break;
                    case 'add_parent_to_individual_action':
                        if ($famtag == 'HUSB' && preg_match('/\\/((?:[a-z]{2,3} )*)(.*)\\//i', $indi_name, $match)) {
                            if ($SURNAME_TRADITION == 'polish' && $gender == 'M') {
                                $match[2] = preg_replace(array('/ska$/', '/cka$/', '/dzka$/', '/żka$/'), array('ski', 'cki', 'dzki', 'żki'), $match[2]);
                            } elseif ($SURNAME_TRADITION == 'lithuanian') {
                                // not a complete list as the rules are somewhat complicated but will do 95% correctly
                                $match[2] = preg_replace(array('/aitė$/', '/ytė$/', '/iūtė$/', '/utė$/'), array('as', 'is', 'ius', 'us'), $match[2]);
                            }
                            $name_fields['SPFX'] = trim($match[1]);
                            $name_fields['SURN'] = $match[2];
                            $name_fields['NAME'] = "/{$match[1]}{$match[2]}/";
                        }
                        if ($famtag == 'WIFE' && preg_match('/\\/((?:[a-z]{2,3} )*)(.*)\\//i', $indi_name, $match)) {
                            if ($SURNAME_TRADITION == 'lithuanian') {
                                $match[2] = preg_replace(array('/as$/', '/is$/', '/ys$/', '/us$/'), array('ienė', 'ienė', 'ienė', 'ienė'), $match[2]);
                                $match[2] = preg_replace(array('/aitė$/', '/ytė$/', '/iūtė$/', '/utė$/'), array('ienė', 'ienė', 'ienė', 'ienė'), $match[2]);
                            }
                            $new_marnm = $match[2];
                        }
                        break;
                    case 'add_spouse_to_family_action':
                        break;
                }
                break;
        }
    }
    // Initialise an empty name field
    if (empty($name_fields['NAME'])) {
        $name_fields['NAME'] = '//';
    }
    // Populate any missing 2 XXXX fields from the 1 NAME field
    $npfx_accept = implode('|', $NPFX_accept);
    if (preg_match("/((({$npfx_accept})\\.? +)*)([^\n\\/\"]*)(\"(.*)\")? *\\/(([a-z]{2,3} +)*)(.*)\\/ *(.*)/i", $name_fields['NAME'], $name_bits)) {
        if (empty($name_fields['NPFX'])) {
            $name_fields['NPFX'] = $name_bits[1];
        }
        if (empty($name_fields['SPFX']) && empty($name_fields['SURN'])) {
            $name_fields['SPFX'] = trim($name_bits[7]);
            // For names with two surnames, there will be four slashes.
            // Turn them into a list
            $name_fields['SURN'] = preg_replace('~/[^/]*/~', ',', $name_bits[9]);
        }
        if (empty($name_fields['GIVN'])) {
            $name_fields['GIVN'] = $name_bits[4];
        }
        // Don’t automatically create an empty NICK - it is an “advanced” field.
        if (empty($name_fields['NICK']) && !empty($name_bits[6]) && !preg_match('/^2 NICK/m', $namerec)) {
            $name_fields['NICK'] = $name_bits[6];
        }
    }
    // Edit the standard name fields
    foreach ($name_fields as $tag => $value) {
        add_simple_tag("0 {$tag} {$value}");
    }
    // Get the advanced name fields
    $adv_name_fields = array();
    if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $ADVANCED_NAME_FACTS, $match)) {
        foreach ($match[1] as $tag) {
            $adv_name_fields[$tag] = '';
        }
    }
    // This is a custom tag, but webtrees uses it extensively.
    if ($SURNAME_TRADITION == 'paternal' || $SURNAME_TRADITION == 'polish' || $SURNAME_TRADITION == 'lithuanian' || strpos($namerec, '2 _MARNM') !== false) {
        $adv_name_fields['_MARNM'] = '';
    }
    if (isset($adv_name_fields['TYPE'])) {
        unset($adv_name_fields['TYPE']);
    }
    foreach ($adv_name_fields as $tag => $dummy) {
        // Edit existing tags
        if (preg_match_all("/2 {$tag} (.+)/", $namerec, $match)) {
            foreach ($match[1] as $value) {
                if ($tag == '_MARNM') {
                    $mnsct = preg_match('/\\/(.+)\\//', $value, $match2);
                    $marnm_surn = '';
                    if ($mnsct > 0) {
                        $marnm_surn = $match2[1];
                    }
                    add_simple_tag("2 _MARNM " . $value);
                    add_simple_tag("2 _MARNM_SURN " . $marnm_surn);
                } else {
                    add_simple_tag("2 {$tag} {$value}", '', WT_Gedcom_Tag::getLabel("NAME:{$tag}", $person));
                }
            }
        }
        // Allow a new row to be entered if there was no row provided
        if (count($match[1]) == 0 && empty($name_fields[$tag]) || $tag != '_HEB' && $tag != 'NICK') {
            if ($tag == '_MARNM') {
                if (strstr($ADVANCED_NAME_FACTS, '_MARNM') == false) {
                    add_simple_tag("0 _MARNM");
                    add_simple_tag("0 _MARNM_SURN {$new_marnm}");
                }
            } else {
                add_simple_tag("0 {$tag}", '', WT_Gedcom_Tag::getLabel("NAME:{$tag}", $person));
            }
        }
    }
    // Handle any other NAME subfields that aren’t included above (SOUR, NOTE, _CUSTOM, etc)
    if ($namerec) {
        $gedlines = explode("\n", $namerec);
        // -- find the number of lines in the record
        $fields = explode(' ', $gedlines[0]);
        $glevel = $fields[0];
        $level = $glevel;
        $type = trim($fields[1]);
        $tags = array();
        $i = 0;
        do {
            if ($type != 'TYPE' && !isset($name_fields[$type]) && !isset($adv_name_fields[$type])) {
                $text = '';
                for ($j = 2; $j < count($fields); $j++) {
                    if ($j > 2) {
                        $text .= ' ';
                    }
                    $text .= $fields[$j];
                }
                while ($i + 1 < count($gedlines) && preg_match("/" . ($level + 1) . " (CON[CT]) ?(.*)/", $gedlines[$i + 1], $cmatch) > 0) {
                    if ($cmatch[1] == "CONT") {
                        $text .= "\n";
                    }
                    if ($WORD_WRAPPED_NOTES) {
                        $text .= ' ';
                    }
                    $text .= $cmatch[2];
                    $i++;
                }
                add_simple_tag($level . ' ' . $type . ' ' . $text);
            }
            $tags[] = $type;
            $i++;
            if (isset($gedlines[$i])) {
                $fields = explode(' ', $gedlines[$i]);
                $level = $fields[0];
                if (isset($fields[1])) {
                    $type = $fields[1];
                }
            }
        } while ($level > $glevel && $i < count($gedlines));
    }
    // If we are adding a new individual, add the basic details
    if ($nextaction != 'update') {
        echo '</table><br><table class="facts_table">';
        // 1 SEX
        if ($famtag == "HUSB" || $gender == "M") {
            add_simple_tag("0 SEX M");
        } elseif ($famtag == "WIFE" || $gender == "F") {
            add_simple_tag("0 SEX F");
        } else {
            add_simple_tag("0 SEX");
        }
        $bdm = "BD";
        if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $QUICK_REQUIRED_FACTS, $matches)) {
            foreach ($matches[1] as $match) {
                if (!in_array($match, explode('|', WT_EVENTS_DEAT))) {
                    addSimpleTags($match);
                }
            }
        }
        //-- if adding a spouse add the option to add a marriage fact to the new family
        if ($nextaction == 'add_spouse_to_individual_action' || $nextaction == 'add_spouse_to_family_action') {
            $bdm .= "M";
            if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $QUICK_REQUIRED_FAMFACTS, $matches)) {
                foreach ($matches[1] as $match) {
                    addSimpleTags($match);
                }
            }
        }
        if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $QUICK_REQUIRED_FACTS, $matches)) {
            foreach ($matches[1] as $match) {
                if (in_array($match, explode('|', WT_EVENTS_DEAT))) {
                    addSimpleTags($match);
                }
            }
        }
    }
    echo keep_chan($person);
    echo "</table>";
    if ($nextaction == 'update') {
        // GEDCOM 5.5.1 spec says NAME doesn’t get a OBJE
        print_add_layer('SOUR');
        print_add_layer('NOTE');
        print_add_layer('SHARED_NOTE');
    } else {
        print_add_layer('SOUR', 1);
        print_add_layer('OBJE', 1);
        print_add_layer('NOTE', 1);
        print_add_layer('SHARED_NOTE', 1);
    }
    // If we are editing an existing name, allow raw GEDCOM editing
    if ($name_fact && (Auth::isAdmin() || $SHOW_GEDCOM_RECORD)) {
        echo '<br><br><a href="edit_interface.php?action=editrawfact&amp;xref=', $xref, '&amp;fact_id=', $name_fact->getFactId(), '&amp;ged=', WT_GEDURL, '">', WT_I18N::translate('Edit raw GEDCOM'), '</a>';
    }
    echo '<p id="save-cancel">';
    echo '<input type="submit" class="save" value="', WT_I18N::translate('save'), '">';
    if (preg_match('/^add_(child|spouse|parent|unlinked_indi)/', $nextaction)) {
        echo '<input type="submit" class="save" value="', WT_I18N::translate('go to new individual'), '" onclick="document.addchildform.goto.value=\'new\';">';
    }
    echo '<input type="button" class="cancel" value="', WT_I18N::translate('close'), '" onclick="window.close();">';
    echo '</p>';
    echo '</form>';
    $controller->addInlineJavascript('
	SURNAME_TRADITION="' . $SURNAME_TRADITION . '";
	gender="' . $gender . '";
	famtag="' . $famtag . '";
	function trim(str) {
		str=str.replace(/\\s\\s+/g, " ");
		return str.replace(/(^\\s+)|(\\s+$)/g, "");
	}

	function lang_class(str) {
		if (str.match(/[\\u0370-\\u03FF]/)) return "greek";
		if (str.match(/[\\u0400-\\u04FF]/)) return "cyrillic";
		if (str.match(/[\\u0590-\\u05FF]/)) return "hebrew";
		if (str.match(/[\\u0600-\\u06FF]/)) return "arabic";
		return "latin"; // No matched text implies latin :-)
	}

	// Generate a full name from the name components
	function generate_name() {
		var frm =document.forms[0];
		var npfx=frm.NPFX.value;
		var givn=frm.GIVN.value;
		var spfx=frm.SPFX.value;
		var surn=frm.SURN.value;
		var nsfx=frm.NSFX.value;
		if (SURNAME_TRADITION=="polish" && (gender=="F" || famtag=="WIFE")) {
			surn=surn.replace(/ski$/, "ska");
			surn=surn.replace(/cki$/, "cka");
			surn=surn.replace(/dzki$/, "dzka");
			surn=surn.replace(/żki$/, "żka");
		}
		// Commas are used in the GIVN and SURN field to separate lists of surnames.
		// For example, to differentiate the two Spanish surnames from an English
		// double-barred name.
		// Commas *may* be used in other fields, and will form part of the NAME.
		if (WT_LOCALE=="vi" || WT_LOCALE=="hu") {
			// Default format: /SURN/ GIVN
			return trim(npfx+" /"+trim(spfx+" "+surn).replace(/ *, */g, " ")+"/ "+givn.replace(/ *, */g, " ")+" "+nsfx);
		} else if (WT_LOCALE=="zh") {
			// Default format: /SURN/GIVN
			return trim(npfx+" /"+trim(spfx+" "+surn).replace(/ *, */g, " ")+"/"+givn.replace(/ *, */g, " ")+" "+nsfx);
		} else {
			// Default format: GIVN /SURN/
			return trim(npfx+" "+givn.replace(/ *, */g, " ")+" /"+trim(spfx+" "+surn).replace(/ *, */g, " ")+"/ "+nsfx);
		}
	}

	// Update the NAME and _MARNM fields from the name components
	// and also display the value in read-only "gedcom" format.
	function updatewholename() {
		// don’t update the name if the user manually changed it
		if (manualChange) return;
		// Update NAME field from components and display it
		var frm =document.forms[0];
		var npfx=frm.NPFX.value;
		var givn=frm.GIVN.value;
		var spfx=frm.SPFX.value;
		var surn=frm.SURN.value;
		var nsfx=frm.NSFX.value;
		document.getElementById("NAME").value=generate_name();
		document.getElementById("NAME_display").innerText=frm.NAME.value;
		// Married names inherit some NSFX values, but not these
		nsfx=nsfx.replace(/^(I|II|III|IV|V|VI|Junior|Jr\\.?|Senior|Sr\\.?)$/i, "");
		// Update _MARNM field from _MARNM_SURN field and display it
		// Be careful of mixing latin/hebrew/etc. character sets.
		var ip=document.getElementsByTagName("input");
		var marnm_id="";
		var romn="";
		var heb="";
		for (var i=0; i<ip.length; i++) {
			var val=ip[i].value;
			if (ip[i].id.indexOf("_HEB")==0)
				heb=val;
			if (ip[i].id.indexOf("ROMN")==0)
				romn=val;
			if (ip[i].id.indexOf("_MARNM")==0) {
				if (ip[i].id.indexOf("_MARNM_SURN")==0) {
					var msurn="";
					if (val!="") {
						var lc=lang_class(document.getElementById(ip[i].id).value);
						if (lang_class(frm.NAME.value)==lc)
							msurn=trim(npfx+" "+givn+" /"+val+"/ "+nsfx);
						else if (lc=="hebrew")
							msurn=heb.replace(/\\/.*\\//, "/"+val+"/");
						else if (lang_class(romn)==lc)
							msurn=romn.replace(/\\/.*\\//, "/"+val+"/");
					}
					document.getElementById(marnm_id).value=msurn;
					document.getElementById(marnm_id+"_display").innerHTML=msurn;
				} else {
					marnm_id=ip[i].id;
				}
			}
		}
	}

	// Toggle the name editor fields between
	// <input type="hidden"> <span style="display:inline">
	// <input type="text">   <span style="display:hidden">
	var oldName = "";
	var manualChange = false;
	function convertHidden(eid) {
		var input1 = jQuery("#" + eid);
		var input2 = jQuery("#" + eid + "_display");
		// Note that IE does not allow us to change the type of an input, so we must create a new one.
		if (input1.attr("type")=="hidden") {
			input1.replaceWith(input1.clone().attr("type", "text"));
			input2.hide();
		} else {
			input1.replaceWith(input1.clone().attr("type", "hidden"));
			input2.show();
		}
	}

	/**
	 * if the user manually changed the NAME field, then update the textual
	 * HTML representation of it
	 * If the value changed set manualChange to true so that changing
	 * the other fields doesn’t change the NAME line
	 */
	function updateTextName(eid) {
		var element = document.getElementById(eid);
		if (element) {
			if (element.value!=oldName) manualChange = true;
			var delement = document.getElementById(eid+"_display");
			if (delement) {
				delement.innerHTML = element.value;
			}
		}
	}

	function checkform() {
		var ip=document.getElementsByTagName("input");
		for (var i=0; i<ip.length; i++) {
			// ADD slashes to _HEB and _AKA names
			if (ip[i].id.indexOf("_AKA")==0 || ip[i].id.indexOf("_HEB")==0 || ip[i].id.indexOf("ROMN")==0)
				if (ip[i].value.indexOf("/")<0 && ip[i].value!="")
					ip[i].value=ip[i].value.replace(/([^\\s]+)\\s*$/, "/$1/");
			// Blank out temporary _MARNM_SURN
			if (ip[i].id.indexOf("_MARNM_SURN")==0)
					ip[i].value="";
			// Convert "xxx yyy" and "xxx y yyy" surnames to "xxx,yyy"
			if ((SURNAME_TRADITION=="spanish" || "SURNAME_TRADITION"=="portuguese") && ip[i].id.indexOf("SURN")==0) {
				ip[i].value=document.forms[0].SURN.value.replace(/^\\s*([^\\s,]{2,})\\s+([iIyY] +)?([^\\s,]{2,})\\s*$/, "$1,$3");
			}
		}
		return true;
	}

	// If the name isn’t initially formed from the components in a standard way,
	// then don’t automatically update it.
	if (document.getElementById("NAME").value!=generate_name() && document.getElementById("NAME").value!="//") {
		convertHidden("NAME");
	}
	');
    echo '</div>';
}
Ejemplo n.º 5
0
 public function search($query)
 {
     if (strlen($query) < 2) {
         return '';
     }
     //-- search for INDI names
     $rows = WT_DB::prepare("SELECT i_id AS xref" . " FROM `##individuals`, `##name`" . " WHERE (i_id LIKE ? OR n_sort LIKE ?)" . " AND i_id=n_id AND i_file=n_file AND i_file=?" . " ORDER BY n_sort")->execute(array("%{$query}%", "%{$query}%", WT_GED_ID))->fetchAll();
     $ids = array();
     foreach ($rows as $row) {
         $ids[] = $row->xref;
     }
     $vars = array();
     if (empty($ids)) {
         //-- no match : search for FAM id
         $where = "f_id LIKE ?";
         $vars[] = "%{$query}%";
     } else {
         //-- search for spouses
         $qs = implode(',', array_fill(0, count($ids), '?'));
         $where = "(f_husb IN ({$qs}) OR f_wife IN ({$qs}))";
         $vars = array_merge($vars, $ids, $ids);
     }
     $vars[] = WT_GED_ID;
     $rows = WT_DB::prepare("SELECT f_id AS xref, f_file AS gedcom_id, f_gedcom AS gedcom FROM `##families` WHERE {$where} AND f_file=?")->execute($vars)->fetchAll();
     $out = '<ul>';
     foreach ($rows as $row) {
         $family = WT_Family::getInstance($row->xref, $row->gedcom_id, $row->gedcom);
         if ($family->canShowName()) {
             $out .= '<li><a href="' . $family->getHtmlUrl() . '">' . $family->getFullName() . ' ';
             if ($family->canShow()) {
                 $marriage_year = $family->getMarriageYear();
                 if ($marriage_year) {
                     $out .= ' (' . $marriage_year . ')';
                 }
             }
             $out .= '</a></li>';
         }
     }
     $out .= '</ul>';
     return $out;
 }
Ejemplo n.º 6
0
 /**
  * print a family descendancy
  *
  * @param WT_Individual $person
  * @param WT_Family     $family
  * @param int           $depth the descendancy depth to show
  *
  * @return void
  */
 function print_family_descendancy(WT_Individual $person, WT_Family $family, $depth)
 {
     global $WT_IMAGES, $Dindent, $personcount;
     // print marriage info
     echo '<li>';
     echo '<img src="', $WT_IMAGES['spacer'], '" height="2" width="', $Dindent + 4, '" alt="">';
     echo '<span class="details1" style="white-space:nowrap;">';
     echo "<a href=\"#\" onclick=\"expand_layer('" . $family->getXref() . $personcount . "'); return false;\" class=\"top\"><i id=\"" . $family->getXref() . $personcount . "_img\" class=\"icon-minus\" title=\"" . WT_I18N::translate('View family') . "\"></i></a>";
     if ($family->canShow()) {
         foreach ($family->getFacts(WT_EVENTS_MARR) as $fact) {
             echo ' <a href="', $family->getHtmlUrl(), '" class="details1">', $fact->summary(), '</a>';
         }
     }
     echo '</span>';
     // print spouse
     $spouse = $family->getSpouse($person);
     echo '<ul style="list-style:none; display:block;" id="' . $family->getXref() . $personcount . '">';
     echo '<li>';
     echo '<table border="0" cellpadding="0" cellspacing="0"><tr><td>';
     print_pedigree_person($spouse, 1, 0, $personcount);
     echo '</td>';
     // check if spouse has parents and add an arrow
     echo '<td>&nbsp;</td>';
     echo '<td>';
     if ($spouse) {
         foreach ($spouse->getChildFamilies() as $cfamily) {
             foreach ($cfamily->getSpouses() as $parent) {
                 print_url_arrow($parent->getXref() . $personcount . $person->getXref(), '?rootid=' . $parent->getXref() . '&amp;generations=' . $this->generations . '&amp;chart_style=' . $this->chart_style . '&amp;show_full=' . $this->show_full . '&amp;box_width=' . $this->box_width . '&amp;ged=' . WT_GEDURL, WT_I18N::translate('Start at parents'), 2);
                 $personcount++;
                 // only show the arrow for one of the parents
                 break;
             }
         }
     }
     if ($this->show_full) {
         echo '<br><br>&nbsp;';
     }
     echo '</td></tr>';
     // children
     $children = $family->getChildren();
     echo '<tr><td colspan="3" class="details1" >&nbsp;&nbsp;';
     if ($children) {
         echo WT_Gedcom_Tag::getLabel('NCHI') . ': ' . count($children);
     } else {
         // Distinguish between no children (NCHI 0) and no recorded
         // children (no CHIL records)
         if (strpos($family->getGedcom(), '\\n1 NCHI 0')) {
             echo WT_Gedcom_Tag::getLabel('NCHI') . ': ' . count($children);
         } else {
             echo WT_I18N::translate('No children');
         }
     }
     echo '</td></tr></table>';
     echo '</li>';
     if ($depth > 1) {
         foreach ($children as $child) {
             $personcount++;
             $this->print_child_descendancy($child, $depth - 1);
         }
     }
     echo '</ul>';
     echo '</li>';
 }
Ejemplo n.º 7
0
function print_media_links($factrec, $level)
{
    global $SEARCH_SPIDER, $HIDE_GEDCOM_ERRORS;
    $nlevel = $level + 1;
    if (preg_match_all("/{$level} OBJE @(.*)@/", $factrec, $omatch, PREG_SET_ORDER) == 0) {
        return;
    }
    $objectNum = 0;
    while ($objectNum < count($omatch)) {
        $media_id = $omatch[$objectNum][1];
        $media = WT_Media::getInstance($media_id);
        if ($media) {
            if ($media->canShow()) {
                if ($objectNum > 0) {
                    echo '<br class="media-separator" style="clear:both;">';
                }
                echo '<div class="media-display"><div class="media-display-image">';
                echo $media->displayImage();
                echo '</div>';
                // close div "media-display-image"
                echo '<div class="media-display-title">';
                if ($SEARCH_SPIDER) {
                    echo $media->getFullName();
                } else {
                    echo '<a href="mediaviewer.php?mid=', $media->getXref(), '&amp;ged=', WT_GEDURL, '">', $media->getFullName(), '</a>';
                }
                // NOTE: echo the notes of the media
                echo '<p>';
                echo print_fact_notes($media->getGedcom(), 1);
                $ttype = preg_match("/" . ($nlevel + 1) . " TYPE (.*)/", $media->getGedcom(), $match);
                if ($ttype > 0) {
                    $mediaType = WT_Gedcom_Tag::getFileFormTypeValue($match[1]);
                    echo '<p class="label">', WT_I18N::translate('Type'), ': </span> <span class="field">', $mediaType, '</p>';
                }
                echo '</p>';
                //-- print spouse name for marriage events
                $ct = preg_match("/WT_SPOUSE: (.*)/", $factrec, $match);
                if ($ct > 0) {
                    $spouse = WT_Individual::getInstance($match[1]);
                    if ($spouse) {
                        echo '<a href="', $spouse->getHtmlUrl(), '">';
                        echo $spouse->getFullName();
                        echo '</a>';
                    }
                    if (empty($SEARCH_SPIDER)) {
                        $ct = preg_match("/WT_FAMILY_ID: (.*)/", $factrec, $match);
                        if ($ct > 0) {
                            $famid = trim($match[1]);
                            $family = WT_Family::getInstance($famid);
                            if ($family) {
                                if ($spouse) {
                                    echo " - ";
                                }
                                echo '<a href="', $family->getHtmlUrl(), '">', WT_I18N::translate('View family'), '</a>';
                            }
                        }
                    }
                }
                echo print_fact_notes($media->getGedcom(), $nlevel);
                echo print_fact_sources($media->getGedcom(), $nlevel);
                echo '</div>';
                //close div "media-display-title"
                echo '</div>';
                //close div "media-display"
            }
        } elseif (!$HIDE_GEDCOM_ERRORS) {
            echo '<p class="ui-state-error">', $media_id, '</p>';
        }
        $objectNum++;
    }
}
Ejemplo n.º 8
0
 function getSpouseFamilyLabel(WT_Family $family)
 {
     $spouse = $family->getSpouse($this);
     if ($spouse) {
         return WT_I18N::translate('Family with %s', $spouse->getFullName());
     } else {
         return $family->getFullName();
     }
 }
Ejemplo n.º 9
0
    private function buildIndividualMap(WT_Individual $indi, $indifacts, $famids)
    {
        global $controller;
        $GM_MAX_ZOOM = $this->getSetting('GM_MAX_ZOOM');
        // Create the markers list array
        $gmarks = array();
        sort_facts($indifacts);
        $i = 0;
        foreach ($indifacts as $fact) {
            if (!$fact->getPlace()->isEmpty()) {
                $ctla = preg_match("/\\d LATI (.*)/", $fact->getGedcom(), $match1);
                $ctlo = preg_match("/\\d LONG (.*)/", $fact->getGedcom(), $match2);
                if ($fact->getParent() instanceof WT_Family) {
                    $spouse = $fact->getParent()->getSpouse($indi);
                } else {
                    $spouse = null;
                }
                if ($ctla && $ctlo) {
                    $i++;
                    $gmarks[$i] = array('class' => 'optionbox', 'date' => $fact->getDate()->Display(true), 'fact_label' => $fact->getLabel(), 'image' => $spouse ? $spouse->displayImage() : $fact->Icon(), 'info' => $fact->getValue(), 'lat' => str_replace(array('N', 'S', ','), array('', '-', '.'), $match1[1]), 'lng' => str_replace(array('E', 'W', ','), array('', '-', '.'), $match2[1]), 'name' => $spouse ? '<a href="' . $spouse->getHtmlUrl() . '"' . $spouse->getFullName() . '</a>' : '', 'pl_icon' => '', 'place' => $fact->getPlace()->getFullName(), 'sv_bearing' => '0', 'sv_elevation' => '0', 'sv_lati' => '0', 'sv_long' => '0', 'sv_zoom' => '0', 'tooltip' => $fact->getPlace()->getGedcomName());
                } else {
                    $latlongval = $this->getLatitudeAndLongitudeFromPlaceLocation($fact->getPlace()->getGedcomName());
                    if ($latlongval && $latlongval->pl_lati && $latlongval->pl_long) {
                        $i++;
                        $gmarks[$i] = array('class' => 'optionbox', 'date' => $fact->getDate()->Display(true), 'fact_label' => $fact->getLabel(), 'image' => $spouse ? $spouse->displayImage() : $fact->Icon(), 'info' => $fact->getValue(), 'lat' => str_replace(array('N', 'S', ','), array('', '-', '.'), $latlongval->pl_lati), 'lng' => str_replace(array('E', 'W', ','), array('', '-', '.'), $latlongval->pl_long), 'name' => $spouse ? '<a href="' . $spouse->getHtmlUrl() . '"' . $spouse->getFullName() . '</a>' : '', 'pl_icon' => $latlongval->pl_icon, 'place' => $fact->getPlace()->getFullName(), 'sv_bearing' => $latlongval->sv_bearing, 'sv_elevation' => $latlongval->sv_elevation, 'sv_lati' => $latlongval->sv_lati, 'sv_long' => $latlongval->sv_long, 'sv_zoom' => $latlongval->sv_zoom, 'tooltip' => $fact->getPlace()->getGedcomName());
                        if ($GM_MAX_ZOOM > $latlongval->pl_zoom) {
                            $GM_MAX_ZOOM = $latlongval->pl_zoom;
                        }
                    }
                }
            }
        }
        // Add children to the markers list array
        foreach ($famids as $xref) {
            $family = WT_Family::getInstance($xref);
            foreach ($family->getChildren() as $child) {
                $birth = $child->getFirstFact('BIRT');
                if ($birth) {
                    $birthrec = $birth->getGedcom();
                    if (!$birth->getPlace()->isEmpty()) {
                        $ctla = preg_match('/\\n4 LATI (.+)/', $birthrec, $match1);
                        $ctlo = preg_match('/\\n4 LONG (.+)/', $birthrec, $match2);
                        if ($ctla && $ctlo) {
                            $i++;
                            $gmarks[$i] = array('date' => $birth->getDate()->Display(true), 'image' => $child->displayImage(), 'info' => '', 'lat' => str_replace(array('N', 'S', ','), array('', '-', '.'), $match1[1]), 'lng' => str_replace(array('E', 'W', ','), array('', '-', '.'), $match2[1]), 'name' => '<a href="' . $child->getHtmlUrl() . '"' . $child->getFullName() . '</a>', 'pl_icon' => '', 'place' => $birth->getPlace()->getFullName(), 'sv_bearing' => '0', 'sv_elevation' => '0', 'sv_lati' => '0', 'sv_long' => '0', 'sv_zoom' => '0', 'tooltip' => $birth->getPlace()->getGedcomName());
                            switch ($child->getSex()) {
                                case 'F':
                                    $gmarks[$i]['fact_label'] = WT_I18N::translate('daughter');
                                    $gmarks[$i]['class'] = 'person_boxF';
                                    break;
                                case 'M':
                                    $gmarks[$i]['fact_label'] = WT_I18N::translate('son');
                                    $gmarks[$i]['class'] = 'person_box';
                                    break;
                                default:
                                    $gmarks[$i]['fact_label'] = WT_I18N::translate('child');
                                    $gmarks[$i]['class'] = 'person_boxNN';
                                    break;
                            }
                        } else {
                            $latlongval = $this->getLatitudeAndLongitudeFromPlaceLocation($birth->getPlace()->getGedcomName());
                            if ($latlongval && $latlongval->pl_lati && $latlongval->pl_long) {
                                $i++;
                                $gmarks[$i] = array('date' => $birth->getDate()->Display(true), 'image' => $child->displayImage(), 'info' => '', 'lat' => str_replace(array('N', 'S', ','), array('', '-', '.'), $latlongval->pl_lati), 'lng' => str_replace(array('E', 'W', ','), array('', '-', '.'), $latlongval->pl_long), 'name' => '<a href="' . $child->getHtmlUrl() . '"' . $child->getFullName() . '</a>', 'pl_icon' => $latlongval->pl_icon, 'place' => $birth->getPlace()->getFullName(), 'sv_bearing' => $latlongval->sv_bearing, 'sv_elevation' => $latlongval->sv_elevation, 'sv_lati' => $latlongval->sv_lati, 'sv_long' => $latlongval->sv_long, 'sv_zoom' => $latlongval->sv_zoom, 'tooltip' => $birth->getPlace()->getGedcomName());
                                switch ($child->getSex()) {
                                    case 'M':
                                        $gmarks[$i]['fact_label'] = WT_I18N::translate('son');
                                        $gmarks[$i]['class'] = 'person_box';
                                        break;
                                    case 'F':
                                        $gmarks[$i]['fact_label'] = WT_I18N::translate('daughter');
                                        $gmarks[$i]['class'] = 'person_boxF';
                                        break;
                                    default:
                                        $gmarks[$i]['fact_label'] = WT_I18N::translate('child');
                                        $gmarks[$i]['class'] = 'option_boxNN';
                                        break;
                                }
                                if ($GM_MAX_ZOOM > $latlongval->pl_zoom) {
                                    $GM_MAX_ZOOM = $latlongval->pl_zoom;
                                }
                            }
                        }
                    }
                }
            }
        }
        // Group markers by location
        $location_groups = array();
        foreach ($gmarks as $gmark) {
            $key = $gmark['lat'] . $gmark['lng'];
            if (isset($location_groups[$key])) {
                $location_groups[$key][] = $gmark;
            } else {
                $location_groups[$key] = array($gmark);
            }
        }
        $location_groups = array_values($location_groups);
        // *** ENABLE STREETVIEW ***
        $STREETVIEW = $this->getSetting('GM_USE_STREETVIEW');
        ?>

		<script>
			// this variable will collect the html which will eventually be placed in the side_bar
			var side_bar_html = '';
			var map_center = new google.maps.LatLng(0,0);
			var gmarkers = [];
			var gicons = [];
			var map = null;
			var head = '';
			var dir = '';
			var svzoom = '';

			var infowindow = new google.maps.InfoWindow({});

			gicons["red"] = new google.maps.MarkerImage("https://maps.google.com/mapfiles/marker.png",
				new google.maps.Size(20, 34),
				new google.maps.Point(0,0),
				new google.maps.Point(9, 34)
			);

			var iconImage = new google.maps.MarkerImage("https://maps.google.com/mapfiles/marker.png",
				new google.maps.Size(20, 34),
				new google.maps.Point(0,0),
				new google.maps.Point(9, 34)
			);

			var iconShadow = new google.maps.MarkerImage("https://www.google.com/mapfiles/shadow50.png",
				new google.maps.Size(37, 34),
				new google.maps.Point(0,0),
				new google.maps.Point(9, 34)
			);

			var iconShape = {
				coord: [9,0,6,1,4,2,2,4,0,8,0,12,1,14,2,16,5,19,7,23,8,26,9,30,9,34,11,34,11,30,12,26,13,24,14,21,16,18,18,16,20,12,20,8,18,4,16,2,15,1,13,0],
				type: "poly"
			};

			function getMarkerImage(iconColor) {
				if (typeof(iconColor) === 'undefined' || iconColor === null) {
					iconColor = 'red';
				}
				if (!gicons[iconColor]) {
					gicons[iconColor] = new google.maps.MarkerImage('//maps.google.com/mapfiles/marker'+ iconColor +'.png',
					new google.maps.Size(20, 34),
					new google.maps.Point(0,0),
					new google.maps.Point(9, 34));
				}
				return gicons[iconColor];
			}

			var sv2_bear = null;
			var sv2_elev = null;
			var sv2_zoom = null;
			var placer   = null;

			// A function to create the marker and set up the event window
			function createMarker(latlng, html, tooltip, sv_lati, sv_long, sv_bearing, sv_elevation, sv_zoom, sv_point, marker_icon) {
				var contentString = '<div id="iwcontent">'+html+'</div>';

				// Use flag icon (if defined) instead of regular marker icon
				if (marker_icon) {
					var icon_image = new google.maps.MarkerImage(WT_STATIC_URL+WT_MODULES_DIR+'googlemap/'+marker_icon,
						new google.maps.Size(25, 15),
						new google.maps.Point(0,0),
						new google.maps.Point(0, 44));
					var icon_shadow = new google.maps.MarkerImage(WT_STATIC_URL+WT_MODULES_DIR+'googlemap/images/flag_shadow.png',
						new google.maps.Size(35, 45), // Shadow size
						new google.maps.Point(0,0),   // Shadow origin
						new google.maps.Point(1, 45)  // Shadow anchor is base of flagpole
					);
				} else {
					var icon_image = getMarkerImage('red');
					var icon_shadow = iconShadow;
				}

				// Decide if marker point is Regular (latlng) or StreetView (sv_point) derived
				if (sv_point == '(0, 0)' || sv_point == '(null, null)') {
					placer = latlng;
				} else {
					placer = sv_point;
				}

				// Define the marker
				var marker = new google.maps.Marker({
					position: placer,
					icon:     icon_image,
					shadow:   icon_shadow,
					map:      map,
					title:    tooltip,
					zIndex:   Math.round(latlng.lat()*-100000)<<5
				});

				// Store the tab and event info as marker properties
				marker.sv_lati  = sv_lati;
				marker.sv_long  = sv_long;
				marker.sv_point = sv_point;

				if (sv_bearing == '') {
					marker.sv_bearing = 0;
				} else {
					marker.sv_bearing = sv_bearing;
				}
				if (sv_elevation == '') {
					marker.sv_elevation = 5;
				} else {
					marker.sv_elevation = sv_elevation;
				}
				if (sv_zoom == '' || sv_zoom == 0 || sv_zoom == 1) {
					marker.sv_zoom = 1.2;
				} else {
					marker.sv_zoom = sv_zoom;
				}

				marker.sv_latlng = new google.maps.LatLng(sv_lati, sv_long);
				gmarkers.push(marker);

				// Open infowindow when marker is clicked
				google.maps.event.addListener(marker, 'click', function() {
					infowindow.close();
					infowindow.setContent(contentString);
					infowindow.open(map, marker);
					var panoramaOptions = {
						position:          marker.position,
						mode:              'html5',
						navigationControl: false,
						linksControl:      false,
						addressControl:    false,
						pov: {
							heading: sv_bearing,
							pitch:   sv_elevation,
							zoom:    sv_zoom
						}
					};

					// Use jquery for info window tabs
					google.maps.event.addListener(infowindow, 'domready', function() {
		  	    //jQuery code here
						jQuery('#EV').click(function() {
							document.tabLayerEV = document.getElementById("EV");
							document.tabLayerEV.style.background = '#ffffff';
							document.tabLayerEV.style.paddingBottom = '1px';
							<?php 
        if ($STREETVIEW) {
            ?>
							document.tabLayerSV = document.getElementById("SV");
							document.tabLayerSV.style.background = '#cccccc';
							document.tabLayerSV.style.paddingBottom = '0px';
							<?php 
        }
        ?>
							document.panelLayer1 = document.getElementById("pane1");
							document.panelLayer1.style.display = 'block';
							<?php 
        if ($STREETVIEW) {
            ?>
							document.panelLayer2 = document.getElementById("pane2");
							document.panelLayer2.style.display = 'none';
							<?php 
        }
        ?>
						});

						jQuery('#SV').click(function() {
							document.tabLayerEV = document.getElementById("EV");
							document.tabLayerEV.style.background = '#cccccc';
							document.tabLayerEV.style.paddingBottom = '0px';
							<?php 
        if ($STREETVIEW) {
            ?>
							document.tabLayerSV = document.getElementById("SV");
							document.tabLayerSV.style.background = '#ffffff';
							document.tabLayerSV.style.paddingBottom = '1px';
							<?php 
        }
        ?>
							document.panelLayer1 = document.getElementById("pane1");
							document.panelLayer1.style.display = 'none';
							<?php 
        if ($STREETVIEW) {
            ?>
							document.panelLayer2 = document.getElementById("pane2");
							document.panelLayer2.style.display = 'block';
							<?php 
        }
        ?>
							var panorama = new google.maps.StreetViewPanorama(document.getElementById("pano"), panoramaOptions);
							setTimeout(function() { panorama.setVisible(true); }, 100);
							setTimeout(function() { panorama.setVisible(true); }, 500);
						});
					});
				});
			}

			// Opens Marker infowindow when corresponding Sidebar item is clicked
			function myclick(i) {
				infowindow.close();
				google.maps.event.trigger(gmarkers[i], 'click');
			}

			// Home control
			// returns the user to the original map position ... loadMap() function
			// This constructor takes the control DIV as an argument.
			function HomeControl(controlDiv, map) {
				// Set CSS styles for the DIV containing the control
				// Setting padding to 5 px will offset the control from the edge of the map
				controlDiv.style.paddingTop = '5px';
				controlDiv.style.paddingRight = '0px';

				// Set CSS for the control border
				var controlUI = document.createElement('DIV');
				controlUI.style.backgroundColor = 'white';
				controlUI.style.borderStyle = 'solid';
				controlUI.style.borderWidth = '2px';
				controlUI.style.cursor = 'pointer';
				controlUI.style.textAlign = 'center';
				controlUI.title = '';
				controlDiv.appendChild(controlUI);

				// Set CSS for the control interior
				var controlText = document.createElement('DIV');
				controlText.style.fontFamily = 'Arial,sans-serif';
				controlText.style.fontSize = '12px';
				controlText.style.paddingLeft = '15px';
				controlText.style.paddingRight = '15px';
				controlText.innerHTML = '<b><?php 
        echo WT_I18N::translate('Redraw map');
        ?>
</b>';
				controlUI.appendChild(controlText);

				// Setup the click event listeners: simply set the map to original LatLng
				google.maps.event.addDomListener(controlUI, 'click', function() {
					loadMap();
				});
			}

			function loadMap() {
				<?php 
        global $PEDIGREE_GENERATIONS, $MAX_PEDIGREE_GENERATIONS, $SHOW_HIGHLIGHT_IMAGES;
        ?>

				// Create the map and mapOptions
				var mapOptions = {
					zoom: 7,
					center: map_center,
					mapTypeId: google.maps.MapTypeId.<?php 
        echo $this->getSetting('GM_MAP_TYPE');
        ?>
,
					mapTypeControlOptions: {
						style: google.maps.MapTypeControlStyle.DROPDOWN_MENU  // DEFAULT, DROPDOWN_MENU, HORIZONTAL_BAR
					},
					navigationControl: true,
					navigationControlOptions: {
					position: google.maps.ControlPosition.TOP_RIGHT,  // BOTTOM, BOTTOM_LEFT, LEFT, TOP, etc
					style: google.maps.NavigationControlStyle.SMALL  // ANDROID, DEFAULT, SMALL, ZOOM_PAN
					},
					streetViewControl: false,  // Show Pegman or not
					scrollwheel: false
				};
				map = new google.maps.Map(document.getElementById('map_pane'), mapOptions);

				// Close any infowindow when map is clicked
				google.maps.event.addListener(map, 'click', function() {
					infowindow.close();
				});

				// Create the Home DIV and call the HomeControl() constructor in this DIV.
				var homeControlDiv = document.createElement('DIV');
				var homeControl = new HomeControl(homeControlDiv, map);
				homeControlDiv.index = 1;
				map.controls[google.maps.ControlPosition.TOP_RIGHT].push(homeControlDiv);

				// Add the markers to the map from the $gmarks array
				var locations = [
					<?php 
        foreach ($gmarks as $n => $gmark) {
            ?>
					<?php 
            echo $n ? ',' : '';
            ?>
					{
						"event":        "<?php 
            echo WT_Filter::escapeJs($gmark['fact_label']);
            ?>
",
						"lat":          "<?php 
            echo WT_Filter::escapeJs($gmark['lat']);
            ?>
",
						"lng":          "<?php 
            echo WT_Filter::escapeJs($gmark['lng']);
            ?>
",
						"date":         "<?php 
            echo WT_Filter::escapeJs($gmark['date']);
            ?>
",
						"info":         "<?php 
            echo WT_Filter::escapeJs($gmark['info']);
            ?>
",
						"name":         "<?php 
            echo WT_Filter::escapeJs($gmark['name']);
            ?>
",
						"place":        "<?php 
            echo WT_Filter::escapeJs($gmark['place']);
            ?>
",
						"tooltip":      "<?php 
            echo WT_Filter::escapeJs($gmark['tooltip']);
            ?>
",
						"image":        "<?php 
            echo WT_Filter::escapeJs($gmark['image']);
            ?>
",
						"pl_icon":      "<?php 
            echo WT_Filter::escapeJs($gmark['pl_icon']);
            ?>
",
						"sv_lati":      "<?php 
            echo WT_Filter::escapeJs($gmark['sv_lati']);
            ?>
",
						"sv_long":      "<?php 
            echo WT_Filter::escapeJs($gmark['sv_long']);
            ?>
",
						"sv_bearing":   "<?php 
            echo WT_Filter::escapeJs($gmark['sv_bearing']);
            ?>
",
						"sv_elevation": "<?php 
            echo WT_Filter::escapeJs($gmark['sv_elevation']);
            ?>
",
						"sv_zoom":      "<?php 
            echo WT_Filter::escapeJs($gmark['sv_zoom']);
            ?>
"
					}
					<?php 
        }
        ?>
				];

				// Group the markers by location
				var location_groups = new Array();
				for (var key in locations) {
					if (!location_groups.hasOwnProperty(locations[key].place)) {
						location_groups[locations[key].place] = new Array();
					}
					location_groups[locations[key].place].push(locations[key]);
				}
				// TODO: why doesn't this next line work?
				//var location_groups = <?php 
        echo json_encode($location_groups);
        ?>
;

				// Set the Marker bounds
				var bounds = new google.maps.LatLngBounds ();

				var key;
				// Iterate over each location
				for (key in location_groups) {
					var locations = location_groups[key];
					// Iterate over each marker at this location
					var event_details = '';
					for (var j in locations) {
						var location = locations[j];
						if (location.info && location.name) {
							event_details += '<table><tr><td class="highlt_img">' + location.image + '</td><td><p><span id="sp1">' + location.event + '</span> ' + location.info + '<br><b>' + location.name + '</b><br>' + location.date + '<br></p></td></tr></table>';
						} else if (location.name) {
							event_details += '<table><tr><td class="highlt_img">' + location.image + '</td><td><p><span id="sp1">' + location.event + '</span><br><b>' + location.name + '</b><br>' + location.date + '<br></p></td></tr></table>';
						} else if (location.info) {
							event_details += '<table><tr><td class="highlt_img">' + location.image + '</td><td><p><span id="sp1">' + location.event + '</span> ' + location.info + '<br>' + location.date + '<br></p></td></tr></table>';
						} else {
							event_details += '<table><tr><td class="highlt_img">' + location.image + '</td><td><p><span id="sp1">' + location.event + '</span><br>' + location.date + '<br></p></td></tr></table>';
						}
					}
					// All locations are the same in each group, so create a marker with the first
					var location = location_groups[key][0];
					var html =
					'<div class="infowindow">' +
						'<div id="gmtabs">' +
							'<ul class="tabs" >' +
								'<li><a href="#event" id="EV"><?php 
        echo WT_I18N::translate('Events');
        ?>
</a></li>' +
								<?php 
        if ($STREETVIEW) {
            ?>
								'<li><a href="#sview" id="SV"><?php 
            echo WT_I18N::translate('Google Street View™');
            ?>
</a></li>' +
								<?php 
        }
        ?>
							'</ul>' +
							'<div class="panes">' +
								'<div id="pane1">' +
									'<h4 id="iwhead">' + location.place + '</h4>' +
									event_details +
								'</div>' +
								<?php 
        if ($STREETVIEW) {
            ?>
								'<div id="pane2">' +
									'<h4 id="iwhead">' + location.place + '</h4>' +
									'<div id="pano"></div>' +
								'</div>' +
								<?php 
        }
        ?>
							'</div>' +
						'</div>' +
					'</div>';

					// create the marker
					var point        = new google.maps.LatLng(location.lat,     location.lng);     // Place Latitude, Longitude
					var sv_point     = new google.maps.LatLng(location.sv_lati, location.sv_long); // StreetView Latitude and Longitide

					var zoomLevel = <?php 
        echo $GM_MAX_ZOOM;
        ?>
;
					var marker    = createMarker(point, html, location.tooltip, location.sv_lati, location.sv_long, location.sv_bearing, location.sv_elevation, location.sv_zoom, sv_point, location.pl_icon);

					// if streetview coordinates are available, use them for marker,
					// else use the place coordinates
					if (sv_point && sv_point != "(0, 0)") {
						var myLatLng = sv_point;
					} else {
						var myLatLng = point;
					}

					// Correct zoom level when only one marker is present
					if (location_groups.length == 1) {
						bounds.extend(myLatLng);
						map.setZoom(zoomLevel);
						map.setCenter(myLatLng);
					} else {
						bounds.extend(myLatLng);
						map.fitBounds(bounds);
						// Correct zoom level when multiple markers have the same coordinates
						var listener1 = google.maps.event.addListenerOnce(map, "idle", function() {
							if (map.getZoom() > zoomLevel) {
								map.setZoom(zoomLevel);
							}
							google.maps.event.removeListener(listener1);
						});
					}
				} // end loop through location markers
			} // end loadMap()

		</script>
		<?php 
        // Create the normal googlemap sidebar of events and children
        echo '<div style="overflow: auto; overflow-x: hidden; overflow-y: auto; height:', $this->getSetting('GM_YSIZE'), 'px;"><table class="facts_table">';
        foreach ($location_groups as $key => $location_group) {
            foreach ($location_group as $gmark) {
                echo '<tr>';
                echo '<td class="facts_label">';
                echo '<a href="#" onclick="myclick(\'', WT_Filter::escapeHtml($key), '\')">', $gmark['fact_label'], '</a></td>';
                echo '<td class="', $gmark['class'], '" style="white-space: normal">';
                if ($gmark['info']) {
                    echo '<span class="field">', WT_Filter::escapeHtml($gmark['info']), '</span><br>';
                }
                if ($gmark['name']) {
                    echo $gmark['name'], '<br>';
                }
                echo $gmark['place'], '<br>';
                if ($gmark['date']) {
                    echo $gmark['date'], '<br>';
                }
                echo '</td>';
                echo '</tr>';
            }
        }
        echo '</table></div><br>';
    }
Ejemplo n.º 10
0
 function _topTenGrandFamilyQuery($type = 'list', $params = null)
 {
     global $TEXT_DIRECTION;
     if ($params !== null && isset($params[0])) {
         $total = $params[0];
     } else {
         $total = 10;
     }
     $total = (int) $total;
     $rows = self::_runSQL("SELECT SQL_CACHE COUNT(*) AS tot, f_id AS id" . " FROM `##families`" . " JOIN `##link` AS children ON children.l_file = {$this->_ged_id}" . " JOIN `##link` AS mchildren ON mchildren.l_file = {$this->_ged_id}" . " JOIN `##link` AS gchildren ON gchildren.l_file = {$this->_ged_id}" . " WHERE" . " f_file={$this->_ged_id} AND" . " children.l_from=f_id AND" . " children.l_type='CHIL' AND" . " children.l_to=mchildren.l_from AND" . " mchildren.l_type='FAMS' AND" . " mchildren.l_to=gchildren.l_from AND" . " gchildren.l_type='CHIL'" . " GROUP BY id" . " ORDER BY tot DESC" . " LIMIT " . $total);
     if (!isset($rows[0])) {
         return '';
     }
     $top10 = array();
     foreach ($rows as $row) {
         $family = WT_Family::getInstance($row['id']);
         if ($family->canShow()) {
             if ($type == 'list') {
                 $top10[] = '<li><a href="' . $family->getHtmlUrl() . '">' . $family->getFullName() . '</a> - ' . WT_I18N::plural('%s grandchild', '%s grandchildren', $row['tot'], WT_I18N::number($row['tot']));
             } else {
                 $top10[] = '<a href="' . $family->getHtmlUrl() . '">' . $family->getFullName() . '</a> - ' . WT_I18N::plural('%s grandchild', '%s grandchildren', $row['tot'], WT_I18N::number($row['tot']));
             }
         }
     }
     if ($type == 'list') {
         $top10 = join('', $top10);
     } else {
         $top10 = join(';&nbsp; ', $top10);
     }
     if ($TEXT_DIRECTION == 'rtl') {
         $top10 = str_replace(array('[', ']', '(', ')', '+'), array('&rlm;[', '&rlm;]', '&rlm;(', '&rlm;)', '&rlm;+'), $top10);
     }
     if ($type == 'list') {
         return '<ul>' . $top10 . '</ul>';
     }
     return $top10;
 }
Ejemplo n.º 11
0
 static function getLatestRecord($xref, $type)
 {
     switch ($type) {
         case 'INDI':
             return WT_Individual::getInstance($xref)->getGedcom();
         case 'FAM':
             return WT_Family::getInstance($xref)->getGedcom();
         case 'SOUR':
             return WT_Source::getInstance($xref)->getGedcom();
         case 'REPO':
             return WT_Repository::getInstance($xref)->getGedcom();
         case 'OBJE':
             return WT_Media::getInstance($xref)->getGedcom();
         case 'NOTE':
             return WT_Note::getInstance($xref)->getGedcom();
         default:
             return WT_GedcomRecord::getInstance($xref)->getGedcom();
     }
 }
Ejemplo n.º 12
0
        $record = WT_Individual::getInstance($row->xref, $row->gedcom_id, $row->gedcom);
        foreach ($record->getFacts() as $fact) {
            $old_place = $fact->getAttribute('PLAC');
            if (preg_match('/(^|, )' . preg_quote($search, '/') . '$/i', $old_place)) {
                $new_place = preg_replace('/(^|, )' . preg_quote($search, '/') . '$/i', '$1' . $replace, $old_place);
                $changes[$old_place] = $new_place;
                if ($confirm == 'update') {
                    $gedcom = preg_replace('/(\\n2 PLAC (?:.*, )*)' . preg_quote($search, '/') . '(\\n|$)/i', '$1' . $replace . '$2', $fact->getGedcom());
                    $record->updateFact($fact->getFactId(), $gedcom, false);
                }
            }
        }
    }
    $rows = WT_DB::prepare("SELECT f_id AS xref, f_file AS gedcom_id, f_gedcom AS gedcom" . " FROM `##families`" . " LEFT JOIN `##change` ON (f_id = xref AND f_file=gedcom_id AND status='pending')" . " WHERE COALESCE(new_gedcom, f_gedcom) REGEXP CONCAT('\n2 PLAC ([^\n]*, )*', ?, '(\n|\$)')")->execute(array($search))->fetchAll();
    foreach ($rows as $row) {
        $record = WT_Family::getInstance($row->xref, $row->gedcom_id, $row->gedcom);
        foreach ($record->getFacts() as $fact) {
            $old_place = $fact->getAttribute('PLAC');
            if (preg_match('/(^|, )' . preg_quote($search, '/') . '$/i', $old_place)) {
                $new_place = preg_replace('/(^|, )' . preg_quote($search, '/') . '$/i', '$1' . $replace, $old_place);
                $changes[$old_place] = $new_place;
                if ($confirm == 'update') {
                    $gedcom = preg_replace('/(\\n2 PLAC (?:.*, )*)' . preg_quote($search, '/') . '(\\n|$)/i', '$1' . $replace . '$2', $fact->getGedcom());
                    $record->updateFact($fact->getFactId(), $gedcom, false);
                }
            }
        }
    }
}
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isManager())->setPageTitle(WT_I18N::translate('Administration - place edit'))->pageHeader();
Ejemplo n.º 13
0
    private function drawFamily(WT_Family $family, $title)
    {
        global $controller, $SHOW_PRIVATE_RELATIONSHIPS;
        ?>
		<tr>
			<td class="center" colspan="2">
				<a class="famnav_title" href="<?php 
        echo $family->getHtmlUrl();
        ?>
">
					<?php 
        echo $title;
        ?>
				</a>
			</td>
		</tr>
		<?php 
        $access_level = $SHOW_PRIVATE_RELATIONSHIPS ? WT_PRIV_HIDE : WT_USER_ACCESS_LEVEL;
        $facts = array_merge($family->getFacts('HUSB', false, $access_level), $family->getFacts('WIFE', false, $access_level));
        foreach ($facts as $fact) {
            $spouse = $fact->getTarget();
            if ($this->isPerson($spouse)) {
                $menu = new WT_Menu(get_close_relationship_name($controller->record, $spouse));
                $menu->addClass('', 'submenu flyout');
                $menu->addSubMenu(new WT_Menu($this->getParents($spouse)));
                ?>
				<tr>
					<td class="facts_label">
						<?php 
                echo $menu->getMenu();
                ?>
					</td>
					<td class="center <?php 
                echo $controller->getPersonStyle($spouse);
                ?>
 nam">
						<a class="famnav_link" href="<?php 
                echo $spouse->getHtmlUrl();
                ?>
">
							<?php 
                echo $spouse->getFullName();
                ?>
						</a>
						<div class="font9">
							<?php 
                echo $spouse->getLifeSpan();
                ?>
						</div>
					</td>
				</tr>
				<?php 
            }
        }
        foreach ($family->getFacts('CHIL', false, $access_level) as $fact) {
            $child = $fact->getTarget();
            if ($this->isPerson($child)) {
                $menu = new WT_Menu(get_close_relationship_name($controller->record, $child));
                $menu->addClass('', 'submenu flyout');
                $menu->addSubMenu(new WT_Menu($this->getFamily($child)));
                ?>
				<tr>
					<td class="facts_label">
						<?php 
                echo $menu->getMenu();
                ?>
					</td>
					<td class="center <?php 
                echo $controller->getPersonStyle($child);
                ?>
 nam">
						<a class="famnav_link" href="<?php 
                echo $child->getHtmlUrl();
                ?>
">
							<?php 
                echo $child->getFullName();
                ?>
						</a>
						<div class="font9">
							<?php 
                echo $child->getLifeSpan();
                ?>
						</div>
					</td>
				</tr>
				<?php 
            }
        }
    }
Ejemplo n.º 14
0
 public function loadChildren(WT_Family $family, $generations)
 {
     $out = '';
     if ($family->canShow()) {
         $children = $family->getChildren();
         if ($children) {
             foreach ($children as $child) {
                 $out .= $this->getPersonLi($child, $generations - 1);
             }
         } else {
             $out .= '<li class="sb_desc_none">' . WT_I18N::translate('No children') . '</li>';
         }
     }
     if ($out) {
         return '<ul>' . $out . '</ul>';
     } else {
         return '';
     }
 }
Ejemplo n.º 15
0
 /**
  * Draw a person in the tree
  *
  * @param WT_Individual $person The Person object to draw the box for
  * @param int           $gen    The number of generations up or down to print
  * @param int           $state  Whether we are going up or down the tree, -1 for descendents +1 for ancestors
  * @param WT_Family     $pfamily
  * @param string        $order  first (1), last(2), unique(0), or empty. Required for drawing lines between boxes
  * @param boolean       $isRoot
  *
  * @return string
  *
  * Notes : "spouse" means explicitely married partners. Thus, the word "partner"
  * (for "life partner") here fits much better than "spouse" or "mate"
  * to translate properly the modern french meaning of "conjoint"
  */
 private function drawPerson(WT_Individual $person, $gen, $state, WT_Family $pfamily = null, $order = null, $isRoot = false)
 {
     global $TEXT_DIRECTION;
     if ($gen < 0) {
         return '';
     }
     if (!empty($pfamily)) {
         $partner = $pfamily->getSpouse($person);
     } else {
         $partner = $person->getCurrentSpouse();
     }
     if ($isRoot) {
         $html = '<table id="tvTreeBorder" class="tv_tree"><tbody><tr><td id="tv_tree_topleft"></td><td id="tv_tree_top"></td><td id="tv_tree_topright"></td></tr><tr><td id="tv_tree_left"></td><td>';
     } else {
         $html = '';
     }
     /* height 1% : this hack enable the div auto-dimensioning in td for FF & Chrome */
     $html .= '<table class="tv_tree"' . ($isRoot ? ' id="tv_tree"' : '') . ' style="height: 1%"><tbody><tr>';
     if ($state <= 0) {
         // draw children
         $html .= $this->drawChildren($person->getSpouseFamilies(), $gen);
     } else {
         // draw the parent’s lines
         $html .= $this->drawVerticalLine($order) . $this->drawHorizontalLine();
     }
     /* draw the person. Do NOT add person or family id as an id, since a same person could appear more than once in the tree !!! */
     // Fixing the width for td to the box initial width when the person is the root person fix a rare bug that happen when a person without child and without known parents is the root person : an unwanted white rectangle appear at the right of the person’s boxes, otherwise.
     $html .= '<td' . ($isRoot ? ' style="width:1px"' : '') . '><div class="tv_box' . ($isRoot ? ' rootPerson' : '') . '" dir="' . $TEXT_DIRECTION . '" style="text-align: ' . ($TEXT_DIRECTION == "rtl" ? "right" : "left") . '; direction: ' . $TEXT_DIRECTION . '" abbr="' . $person->getXref() . '" onclick="' . $this->name . 'Handler.expandBox(this, event);">';
     $html .= $this->drawPersonName($person);
     $fop = array();
     // $fop is fathers of partners
     if (!is_null($partner)) {
         $dashed = '';
         foreach ($person->getSpouseFamilies() as $family) {
             $spouse = $family->getSpouse($person);
             if ($spouse) {
                 if ($spouse === $partner || $this->all_partners === 'true') {
                     $spouse_parents = $spouse->getPrimaryChildFamily();
                     if ($spouse_parents && $spouse_parents->getHusband()) {
                         $fop[] = array($spouse_parents->getHusband(), $spouse_parents);
                     }
                     $html .= $this->drawPersonName($spouse, $dashed);
                     if ($this->all_partners !== 'true') {
                         break;
                         // we can stop here the foreach loop
                     }
                     $dashed = 'dashed';
                 }
             }
         }
     }
     $html .= '</div></td>';
     $primaryChildFamily = $person->getPrimaryChildFamily();
     if (!empty($primaryChildFamily)) {
         $parent = $primaryChildFamily->getHusband();
         if (empty($parent)) {
             $parent = $primaryChildFamily->getWife();
         }
     }
     if (!empty($parent) || count($fop) || $state < 0) {
         $html .= $this->drawHorizontalLine();
     }
     /* draw the parents */
     if ($state >= 0 && (!empty($parent) || count($fop))) {
         $unique = empty($parent) || count($fop) == 0;
         $html .= '<td align="left"><table class="tv_tree"><tbody>';
         if (!empty($parent)) {
             $u = $unique ? 'c' : 't';
             $html .= '<tr><td ' . ($gen == 0 ? ' abbr="p' . $primaryChildFamily->getXref() . '@' . $u . '"' : '') . '>';
             $html .= $this->drawPerson($parent, $gen - 1, 1, $primaryChildFamily, $u);
             $html .= '</td></tr>';
         }
         if (count($fop)) {
             $n = 0;
             $nb = count($fop);
             foreach ($fop as $p) {
                 $n++;
                 $u = $unique ? 'c' : ($n == $nb || empty($p[1]) ? 'b' : 'h');
                 $html .= '<tr><td ' . ($gen == 0 ? ' abbr="p' . $p[1]->getXref() . '@' . $u . '"' : '') . '>' . $this->drawPerson($p[0], $gen - 1, 1, $p[1], $u) . '</td></tr>';
             }
         }
         $html .= '</tbody></table></td>';
     }
     if ($state < 0) {
         $html .= $this->drawVerticalLine($order);
     }
     $html .= '</tr></tbody></table>';
     if ($isRoot) {
         $html .= '</td><td id="tv_tree_right"></td></tr><tr><td id="tv_tree_bottomleft"></td><td id="tv_tree_bottom"></td><td id="tv_tree_bottomright"></td></tr></tbody></table>';
     }
     return $html;
 }
Ejemplo n.º 16
0
 private static function child_facts(WT_Individual $person, WT_Family $family, $option, $relation)
 {
     global $controller, $SHOW_RELATIVES_EVENTS;
     $facts = array();
     // Only include events between birth and death
     $birt_date = $controller->record->getEstimatedBirthDate();
     $deat_date = $controller->record->getEstimatedDeathDate();
     // Deal with recursion.
     switch ($option) {
         case '_CHIL':
             // Add grandchildren
             foreach ($family->getChildren() as $child) {
                 foreach ($child->getSpouseFamilies() as $cfamily) {
                     switch ($child->getSex()) {
                         case 'M':
                             foreach (self::child_facts($person, $cfamily, '_GCHI', 'son') as $fact) {
                                 $facts[] = $fact;
                             }
                             break;
                         case 'F':
                             foreach (self::child_facts($person, $cfamily, '_GCHI', 'dau') as $fact) {
                                 $facts[] = $fact;
                             }
                             break;
                         case 'U':
                             foreach (self::child_facts($person, $cfamily, '_GCHI', 'chi') as $fact) {
                                 $facts[] = $fact;
                             }
                             break;
                     }
                 }
             }
             break;
     }
     // For each child in the family
     foreach ($family->getChildren() as $child) {
         if ($child->getXref() == $person->getXref()) {
             // We are not our own sibling!
             continue;
         }
         // add child’s birth
         if (strpos($SHOW_RELATIVES_EVENTS, '_BIRT' . str_replace('_HSIB', '_SIBL', $option)) !== false) {
             foreach ($child->getFacts(WT_EVENTS_BIRT) as $fact) {
                 $sgdate = $fact->getDate();
                 // Always show _BIRT_CHIL, even if the dates are not known
                 if ($option == '_CHIL' || $sgdate->isOK() && WT_Date::Compare($birt_date, $sgdate) <= 0 && WT_Date::Compare($sgdate, $deat_date) <= 0) {
                     if ($option == '_GCHI' && $relation == 'dau') {
                         // Convert the event to a close relatives event.
                         $rela_fact = clone $fact;
                         $rela_fact->setTag('_' . $fact->getTag() . '_GCH1');
                         $facts[] = $rela_fact;
                     } elseif ($option == '_GCHI' && $relation == 'son') {
                         // Convert the event to a close relatives event.
                         $rela_fact = clone $fact;
                         $rela_fact->setTag('_' . $fact->getTag() . '_GCH2');
                         $facts[] = $rela_fact;
                     } else {
                         // Convert the event to a close relatives event.
                         $rela_fact = clone $fact;
                         $rela_fact->setTag('_' . $fact->getTag() . $option);
                         $facts[] = $rela_fact;
                     }
                 }
             }
         }
         // add child’s death
         if (strpos($SHOW_RELATIVES_EVENTS, '_DEAT' . str_replace('_HSIB', '_SIBL', $option)) !== false) {
             foreach ($child->getFacts(WT_EVENTS_DEAT) as $fact) {
                 $sgdate = $fact->getDate();
                 $srec = $fact->getGedcom();
                 if ($sgdate->isOK() && WT_Date::Compare($birt_date, $sgdate) <= 0 && WT_Date::Compare($sgdate, $deat_date) <= 0) {
                     if ($option == '_GCHI' && $relation == 'dau') {
                         // Convert the event to a close relatives event.
                         $rela_fact = clone $fact;
                         $rela_fact->setTag('_' . $fact->getTag() . '_GCH1');
                         $facts[] = $rela_fact;
                     } elseif ($option == '_GCHI' && $relation == 'son') {
                         // Convert the event to a close relatives event.
                         $rela_fact = clone $fact;
                         $rela_fact->setTag('_' . $fact->getTag() . '_GCH2');
                         $facts[] = $rela_fact;
                     } else {
                         // Convert the event to a close relatives event.
                         $rela_fact = clone $fact;
                         $rela_fact->setTag('_' . $fact->getTag() . $option);
                         $facts[] = $rela_fact;
                     }
                 }
             }
         }
         // add child’s marriage
         if (strstr($SHOW_RELATIVES_EVENTS, '_MARR' . str_replace('_HSIB', '_SIBL', $option))) {
             foreach ($child->getSpouseFamilies() as $sfamily) {
                 foreach ($sfamily->getFacts(WT_EVENTS_MARR) as $fact) {
                     $sgdate = $fact->getDate();
                     if ($sgdate->isOK() && WT_Date::Compare($birt_date, $sgdate) <= 0 && WT_Date::Compare($sgdate, $deat_date) <= 0) {
                         if ($option == '_GCHI' && $relation == 'dau') {
                             // Convert the event to a close relatives event.
                             $rela_fact = clone $fact;
                             $rela_fact->setTag('_' . $fact->getTag() . '_GCH1');
                             $facts[] = $rela_fact;
                         } elseif ($option == '_GCHI' && $relation == 'son') {
                             // Convert the event to a close relatives event.
                             $rela_fact = clone $fact;
                             $rela_fact->setTag('_' . $fact->getTag() . '_GCH2');
                             $facts[] = $rela_fact;
                         } else {
                             // Convert the event to a close relatives event.
                             $rela_fact = clone $fact;
                             $rela_fact->setTag('_' . $fact->getTag() . $option);
                             $facts[] = $rela_fact;
                         }
                     }
                 }
             }
         }
     }
     return $facts;
 }
Ejemplo n.º 17
0
 public function __construct()
 {
     global $SCRIPT_NAME, $MEDIA_DIRECTORY, $WT_SESSION;
     // Our cart is an array of items in the session
     if (!is_array($WT_SESSION->cart)) {
         $WT_SESSION->cart = array();
     }
     if (!array_key_exists(WT_GED_ID, $WT_SESSION->cart)) {
         $WT_SESSION->cart[WT_GED_ID] = array();
     }
     $this->action = WT_Filter::get('action');
     $this->id = WT_Filter::get('id');
     $convert = WT_Filter::get('convert', 'yes|no', 'no');
     $this->Zip = WT_Filter::get('Zip');
     $this->IncludeMedia = WT_Filter::get('IncludeMedia');
     $this->conv_path = WT_Filter::get('conv_path');
     $this->privatize_export = WT_Filter::get('privatize_export', 'none|visitor|user|gedadmin', 'visitor');
     $this->level1 = WT_Filter::getInteger('level1');
     $this->level2 = WT_Filter::getInteger('level2');
     $this->level3 = WT_Filter::getInteger('level3');
     $others = WT_Filter::get('others');
     $this->type = WT_Filter::get('type');
     if (($this->privatize_export == 'none' || $this->privatize_export == 'none') && !WT_USER_GEDCOM_ADMIN) {
         $this->privatize_export = 'visitor';
     }
     if ($this->privatize_export == 'user' && !WT_USER_CAN_ACCESS) {
         $this->privatize_export = 'visitor';
     }
     if ($this->action == 'add') {
         if (empty($this->type) && !empty($this->id)) {
             $this->type = "";
             $obj = WT_GedcomRecord::getInstance($this->id);
             if (is_null($obj)) {
                 $this->id = "";
                 $this->action = "";
             } else {
                 $this->type = strtolower($obj::RECORD_TYPE);
             }
         } else {
             if (empty($this->id)) {
                 $this->action = "";
             }
         }
         if (!empty($this->id) && $this->type != 'fam' && $this->type != 'indi' && $this->type != 'sour') {
             $this->action = 'add1';
         }
     }
     if ($this->action == 'add1') {
         $obj = WT_GedcomRecord::getInstance($this->id);
         $this->add_clipping($obj);
         if ($this->type == 'sour') {
             if ($others == 'linked') {
                 foreach ($obj->linkedIndividuals('SOUR') as $indi) {
                     $this->add_clipping($indi);
                 }
                 foreach ($obj->linkedFamilies('SOUR') as $fam) {
                     $this->add_clipping($fam);
                 }
             }
         }
         if ($this->type == 'fam') {
             if ($others == 'parents') {
                 $this->add_clipping($obj->getHusband());
                 $this->add_clipping($obj->getWife());
             } elseif ($others == "members") {
                 $this->add_family_members(WT_Family::getInstance($this->id));
             } elseif ($others == "descendants") {
                 $this->add_family_descendancy(WT_Family::getInstance($this->id));
             }
         } elseif ($this->type == 'indi') {
             if ($others == 'parents') {
                 foreach (WT_Individual::getInstance($this->id)->getChildFamilies() as $family) {
                     $this->add_family_members($family);
                 }
             } elseif ($others == 'ancestors') {
                 $this->add_ancestors_to_cart(WT_Individual::getInstance($this->id), $this->level1);
             } elseif ($others == 'ancestorsfamilies') {
                 $this->add_ancestors_to_cart_families(WT_Individual::getInstance($this->id), $this->level2);
             } elseif ($others == 'members') {
                 foreach (WT_Individual::getInstance($this->id)->getSpouseFamilies() as $family) {
                     $this->add_family_members($family);
                 }
             } elseif ($others == 'descendants') {
                 foreach (WT_Individual::getInstance($this->id)->getSpouseFamilies() as $family) {
                     $this->add_clipping($family);
                     $this->add_family_descendancy($family, $this->level3);
                 }
             }
             uksort($WT_SESSION->cart[WT_GED_ID], array('WT_Controller_Clippings', 'compare_clippings'));
         }
     } elseif ($this->action == 'remove') {
         unset($WT_SESSION->cart[WT_GED_ID][$this->id]);
     } elseif ($this->action == 'empty') {
         $WT_SESSION->cart[WT_GED_ID] = array();
     } elseif ($this->action == 'download') {
         $media = array();
         $mediacount = 0;
         $filetext = gedcom_header(WT_GEDCOM);
         // Include SUBM/SUBN records, if they exist
         $subn = WT_DB::prepare("SELECT o_gedcom FROM `##other` WHERE o_type=? AND o_file=?")->execute(array('SUBN', WT_GED_ID))->fetchOne();
         if ($subn) {
             $filetext .= $subn . "\n";
         }
         $subm = WT_DB::prepare("SELECT o_gedcom FROM `##other` WHERE o_type=? AND o_file=?")->execute(array('SUBM', WT_GED_ID))->fetchOne();
         if ($subm) {
             $filetext .= $subm . "\n";
         }
         if ($convert == "yes") {
             $filetext = str_replace("UTF-8", "ANSI", $filetext);
             $filetext = utf8_decode($filetext);
         }
         switch ($this->privatize_export) {
             case 'gedadmin':
                 $access_level = WT_PRIV_NONE;
                 break;
             case 'user':
                 $access_level = WT_PRIV_USER;
                 break;
             case 'visitor':
                 $access_level = WT_PRIV_PUBLIC;
                 break;
             case 'none':
                 $access_level = WT_PRIV_HIDE;
                 break;
         }
         foreach (array_keys($WT_SESSION->cart[WT_GED_ID]) as $xref) {
             $object = WT_GedcomRecord::getInstance($xref);
             if ($object) {
                 // The object may have been deleted since we added it to the cart....
                 $record = $object->privatizeGedcom($access_level);
                 // Remove links to objects that aren't in the cart
                 preg_match_all('/\\n1 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\\n[2-9].*)*/', $record, $matches, PREG_SET_ORDER);
                 foreach ($matches as $match) {
                     if (!array_key_exists($match[1], $WT_SESSION->cart[WT_GED_ID])) {
                         $record = str_replace($match[0], '', $record);
                     }
                 }
                 preg_match_all('/\\n2 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\\n[3-9].*)*/', $record, $matches, PREG_SET_ORDER);
                 foreach ($matches as $match) {
                     if (!array_key_exists($match[1], $WT_SESSION->cart[WT_GED_ID])) {
                         $record = str_replace($match[0], '', $record);
                     }
                 }
                 preg_match_all('/\\n3 ' . WT_REGEX_TAG . ' @(' . WT_REGEX_XREF . ')@(\\n[4-9].*)*/', $record, $matches, PREG_SET_ORDER);
                 foreach ($matches as $match) {
                     if (!array_key_exists($match[1], $WT_SESSION->cart[WT_GED_ID])) {
                         $record = str_replace($match[0], '', $record);
                     }
                 }
                 $record = convert_media_path($record, $this->conv_path);
                 $savedRecord = $record;
                 // Save this for the "does this file exist" check
                 if ($convert == 'yes') {
                     $record = utf8_decode($record);
                 }
                 switch ($object::RECORD_TYPE) {
                     case 'INDI':
                         $filetext .= $record . "\n";
                         $filetext .= "1 SOUR @WEBTREES@\n";
                         $filetext .= "2 PAGE " . WT_SERVER_NAME . WT_SCRIPT_PATH . $object->getRawUrl() . "\n";
                         break;
                     case 'FAM':
                         $filetext .= $record . "\n";
                         $filetext .= "1 SOUR @WEBTREES@\n";
                         $filetext .= "2 PAGE " . WT_SERVER_NAME . WT_SCRIPT_PATH . $object->getRawUrl() . "\n";
                         break;
                     case 'SOUR':
                         $filetext .= $record . "\n";
                         $filetext .= "1 NOTE " . WT_SERVER_NAME . WT_SCRIPT_PATH . $object->getRawUrl() . "\n";
                         break;
                     default:
                         $ft = preg_match_all("/\n\\d FILE (.+)/", $savedRecord, $match, PREG_SET_ORDER);
                         for ($k = 0; $k < $ft; $k++) {
                             // Skip external files and non-existant files
                             if (file_exists(WT_DATA_DIR . $MEDIA_DIRECTORY . $match[$k][1])) {
                                 $media[$mediacount] = array(PCLZIP_ATT_FILE_NAME => WT_DATA_DIR . $MEDIA_DIRECTORY . $match[$k][1], PCLZIP_ATT_FILE_NEW_FULL_NAME => $match[$k][1]);
                                 $mediacount++;
                             }
                         }
                         $filetext .= trim($record) . "\n";
                         break;
                 }
             }
         }
         if ($this->IncludeMedia == "yes") {
             $this->media_list = $media;
         }
         $filetext .= "0 @WEBTREES@ SOUR\n1 TITL " . WT_SERVER_NAME . WT_SCRIPT_PATH . "\n";
         if ($user_id = get_gedcom_setting(WT_GED_ID, 'CONTACT_EMAIL')) {
             $user = User::find($user_id);
             $filetext .= "1 AUTH " . $user->getRealName() . "\n";
         }
         $filetext .= "0 TRLR\n";
         //-- make sure the preferred line endings are used
         $filetext = preg_replace("/[\r\n]+/", WT_EOL, $filetext);
         $this->download_data = $filetext;
         $this->download_clipping();
     }
 }
Ejemplo n.º 18
0
 /**
  * Static helper function to sort an array of families by marriage date
  *
  * @param WT_Family $x
  * @param WT_Family $y
  *
  * @return int
  */
 public static function compareMarrDate(WT_Family $x, WT_Family $y)
 {
     return WT_Date::Compare($x->getMarriageDate(), $y->getMarriageDate());
 }
Ejemplo n.º 19
0
     if ($linktoid == "") {
         echo '<input class="pedigree_form" type="text" name="linktoid" id="linktopid" size="3" value="', $linktoid, '"> ';
         echo print_findindi_link('linktopid');
     } else {
         $record = WT_Individual::getInstance($linktoid);
         echo $record->format_list('span', false, $record->getFullName());
     }
 }
 if ($linkto == "family") {
     echo WT_I18N::translate('Family'), '</td>';
     echo '<td class="optionbox wrap">';
     if ($linktoid == "") {
         echo '<input class="pedigree_form" type="text" name="linktoid" id="linktofamid" size="3" value="', $linktoid, '"> ';
         echo print_findfamily_link('linktofamid');
     } else {
         $record = WT_Family::getInstance($linktoid);
         echo $record->format_list('span', false, $record->getFullName());
     }
 }
 if ($linkto == "source") {
     echo WT_I18N::translate('Source'), "</td>";
     echo '<td  class="optionbox wrap">';
     if ($linktoid == "") {
         echo '<input class="pedigree_form" type="text" name="linktoid" id="linktosid" size="3" value="', $linktoid, '"> ';
         echo print_findsource_link('linktosid');
     } else {
         $record = WT_Source::getInstance($linktoid);
         echo $record->format_list('span', false, $record->getFullName());
     }
 }
 if ($linkto == "repository") {
Ejemplo n.º 20
0
/**
 * print cousins list
 *
 * @param string $famid family ID
 * @param int    $personcount
 */
function print_cousins($famid, $personcount = 1)
{
    global $show_full, $bheight, $bwidth, $cbheight, $cbwidth, $WT_IMAGES, $TEXT_DIRECTION;
    $family = WT_Family::getInstance($famid);
    $fchildren = $family->getChildren();
    $kids = count($fchildren);
    $save_show_full = $show_full;
    $sbheight = $bheight;
    $sbwidth = $bwidth;
    if ($save_show_full) {
        $bheight = $cbheight;
        $bwidth = $cbwidth;
    }
    $show_full = false;
    echo '<td valign="middle" height="100%">';
    if ($kids) {
        echo '<table cellspacing="0" cellpadding="0" border="0" ><tr valign="middle">';
        if ($kids > 1) {
            echo '<td rowspan="', $kids, '" valign="middle" align="right"><img width="3px" height="', ($bheight + 9) * ($kids - 1), 'px" src="', $WT_IMAGES["vline"], '" alt=""></td>';
        }
        $ctkids = count($fchildren);
        $i = 1;
        foreach ($fchildren as $fchil) {
            if ($i == 1) {
                echo '<td><img width="10px" height="3px" align="top"';
            } else {
                echo '<td><img width="10px" height="3px"';
            }
            if ($TEXT_DIRECTION == 'ltr') {
                echo ' style="padding-right: 2px;"';
            } else {
                echo ' style="padding-left: 2px;"';
            }
            echo ' src="', $WT_IMAGES['hline'], '" alt=""></td><td>';
            print_pedigree_person($fchil, 1, 0, $personcount);
            $personcount++;
            echo '</td></tr>';
            if ($i < $ctkids) {
                echo '<tr>';
                $i++;
            }
        }
        echo '</table>';
    } else {
        // If there is known that there are no children (as opposed to no known children)
        if (preg_match('/\\n1 NCHI (\\d+)/', $family->getGedcom(), $match) && $match[1] == 0) {
            echo ' <i class="icon-childless" title="', WT_I18N::translate('This family remained childless'), '"></i>';
        }
    }
    $show_full = $save_show_full;
    if ($save_show_full) {
        $bheight = $sbheight;
        $bwidth = $sbwidth;
    }
    echo '</td>';
}
Ejemplo n.º 21
0
    function printFamily(WT_Family $family, $type, $label)
    {
        global $controller;
        global $personcount;
        // TODO: use a unique id instead?
        global $SHOW_PRIVATE_RELATIONSHIPS;
        if ($SHOW_PRIVATE_RELATIONSHIPS) {
            $access_level = WT_PRIV_HIDE;
        } else {
            $access_level = WT_USER_ACCESS_LEVEL;
        }
        ?>
		<table>
			<tr>
				<td>
					<i class="icon-cfamily"></i>
				</td>
				<td>
					<span class="subheaders"> <?php 
        echo $label;
        ?>
 </span> -
					<a href="<?php 
        echo $family->getHtmlUrl();
        ?>
"><?php 
        echo WT_I18N::translate('View family');
        ?>
</a>
				</td>
			</tr>
		</table>
		<table class="facts_table">
		<?php 
        ///// HUSB /////
        $found = false;
        foreach ($family->getFacts('HUSB', false, $access_level) as $fact) {
            $found |= !$fact->isOld();
            $person = $fact->getTarget();
            if ($person instanceof WT_Individual) {
                if ($fact->isNew()) {
                    $class = 'facts_label new';
                } elseif ($fact->isOld()) {
                    $class = 'facts_label old';
                } else {
                    $class = 'facts_label';
                }
                ?>
					<tr>
					<td class="<?php 
                echo $class;
                ?>
">
						<?php 
                echo get_close_relationship_name($controller->record, $person);
                ?>
					</td>
					<td class="<?php 
                echo $controller->getPersonStyle($person);
                ?>
">
						<?php 
                print_pedigree_person($person, 2, 0, $personcount++);
                ?>
					</td>
					</tr>
				<?php 
            }
        }
        if (!$found && $family->canEdit()) {
            ?>
			<tr>
				<td class="facts_label">&nbsp;</td>
				<td class="facts_value"><a href="#" onclick="return add_spouse_to_family('<?php 
            echo $family->getXref();
            ?>
', 'HUSB');"><?php 
            echo WT_I18N::translate('Add a husband to this family');
            ?>
</a></td>
			</tr>
			<?php 
        }
        ///// WIFE /////
        $found = false;
        foreach ($family->getFacts('WIFE', false, $access_level) as $fact) {
            $person = $fact->getTarget();
            if ($person instanceof WT_Individual) {
                $found |= !$fact->isOld();
                if ($fact->isNew()) {
                    $class = 'facts_label new';
                } elseif ($fact->isOld()) {
                    $class = 'facts_label old';
                } else {
                    $class = 'facts_label';
                }
                ?>
				<tr>
					<td class="<?php 
                echo $class;
                ?>
">
						<?php 
                echo get_close_relationship_name($controller->record, $person);
                ?>
					</td>
					<td class="<?php 
                echo $controller->getPersonStyle($person);
                ?>
">
						<?php 
                print_pedigree_person($person, 2, 0, $personcount++);
                ?>
					</td>
				</tr>
				<?php 
            }
        }
        if (!$found && $family->canEdit()) {
            ?>
			<tr>
				<td class="facts_label">&nbsp;</td>
				<td class="facts_value"><a href="#" onclick="return add_spouse_to_family('<?php 
            echo $family->getXref();
            ?>
', 'WIFE');"><?php 
            echo WT_I18N::translate('Add a wife to this family');
            ?>
</a></td>
			</tr>
			<?php 
        }
        ///// MARR /////
        $found = false;
        $prev = new WT_Date('');
        foreach ($family->getFacts(WT_EVENTS_MARR) as $fact) {
            $found |= !$fact->isOld();
            if ($fact->isNew()) {
                $class = ' new';
            } elseif ($fact->isOld()) {
                $class = ' old';
            } else {
                $class = '';
            }
            ?>
			<tr>
				<td class="facts_label">
					&nbsp;
				</td>
				<td class="facts_value<?php 
            echo $class;
            ?>
">
					<?php 
            echo WT_Gedcom_Tag::getLabelValue($fact->getTag(), $fact->getDate()->Display(false) . ' — ' . $fact->getPlace()->getFullName());
            ?>
				</td>
			</tr>
			<?php 
            if (!$prev->isOK() && $fact->getDate()->isOK()) {
                $prev = $fact->getDate();
            }
        }
        if (!$found && $family->canShow() && $family->canEdit()) {
            // Add a new marriage
            ?>
			<tr>
				<td class="facts_label">
					&nbsp;
				</td>
				<td class="facts_value">
					<a href="#" onclick="return add_new_record('<?php 
            echo $family->getXref();
            ?>
', 'MARR');">
						<?php 
            echo WT_I18N::translate('Add marriage details');
            ?>
					</a>
				</td>
			</tr>
			<?php 
        }
        ///// CHIL /////
        $child_number = 0;
        foreach ($family->getFacts('CHIL', false, $access_level) as $fact) {
            $person = $fact->getTarget();
            if ($person instanceof WT_Individual) {
                if ($fact->isNew()) {
                    $child_number++;
                    $class = 'facts_label new';
                } elseif ($fact->isOld()) {
                    $class = 'facts_label old';
                } else {
                    $child_number++;
                    $class = 'facts_label';
                }
                $next = new WT_Date('');
                foreach ($person->getFacts(WT_EVENTS_BIRT) as $bfact) {
                    if ($bfact->getDate()->isOK()) {
                        $next = $bfact->getDate();
                        break;
                    }
                }
                ?>
				<tr>
					<td class="<?php 
                echo $class;
                ?>
">
						<?php 
                echo self::ageDifference($prev, $next, $child_number);
                ?>
						<?php 
                echo get_close_relationship_name($controller->record, $person);
                ?>
					</td>
					<td class="<?php 
                echo $controller->getPersonStyle($person);
                ?>
">
						<?php 
                print_pedigree_person($person, 2, 0, $personcount++);
                ?>
					</td>
				</tr>
				<?php 
                $prev = $next;
            }
        }
        // Re-order children / add a new child
        if ($family->canEdit()) {
            if ($type == 'FAMS') {
                $child_u = WT_I18N::translate('Add a new son or daughter');
                $child_m = WT_I18N::translate('son');
                $child_f = WT_I18N::translate('daughter');
            } else {
                $child_u = WT_I18N::translate('Add a new brother or sister');
                $child_m = WT_I18N::translate('brother');
                $child_f = WT_I18N::translate('sister');
            }
            ?>
			<tr>
				<td class="facts_label">
					<?php 
            if (count($family->getChildren()) > 1) {
                ?>
					<a href="#" onclick="reorder_children('<?php 
                echo $family->getXref();
                ?>
');tabswitch(5);"><i class="icon-media-shuffle"></i> <?php 
                echo WT_I18N::translate('Re-order children');
                ?>
</a>
					<?php 
            }
            ?>
				</td>
				<td class="facts_value">
					<a href="#" onclick="return add_child_to_family('<?php 
            echo $family->getXref();
            ?>
');"><?php 
            echo $child_u;
            ?>
</a>
					<span style='white-space:nowrap;'>
						<a href="#" class="icon-sex_m_15x15" onclick="return add_child_to_family('<?php 
            echo $family->getXref();
            ?>
','M');"></a>
						<a href="#" class="icon-sex_f_15x15" onclick="return add_child_to_family('<?php 
            echo $family->getXref();
            ?>
','F');"></a>
					</span>
				</td>
			</tr>
			<?php 
        }
        echo '</table>';
        return;
    }
Ejemplo n.º 22
0
//-- setup the arrays
$newvars = array();
foreach ($vars as $name => $var) {
    $newvars[$name]['id'] = $var;
    if (!empty($type[$name])) {
        switch ($type[$name]) {
            case 'INDI':
                $record = WT_Individual::getInstance($var);
                if ($record && $record->canShowName()) {
                    $newvars[$name]['gedcom'] = $record->privatizeGedcom(WT_USER_ACCESS_LEVEL);
                } else {
                    $action = 'setup';
                }
                break;
            case 'FAM':
                $record = WT_Family::getInstance($var);
                if ($record && $record->canShowName()) {
                    $newvars[$name]['gedcom'] = $record->privatizeGedcom(WT_USER_ACCESS_LEVEL);
                } else {
                    $action = 'setup';
                }
                break;
            case 'SOUR':
                $record = WT_Source::getInstance($var);
                if ($record && $record->canShowName()) {
                    $newvars[$name]['gedcom'] = $record->privatizeGedcom(WT_USER_ACCESS_LEVEL);
                } else {
                    $action = 'setup';
                }
                break;
            default:
Ejemplo n.º 23
0
 public function linkedFamilies($link)
 {
     $rows = WT_DB::prepare("SELECT f_id AS xref, f_file AS gedcom_id, f_gedcom AS gedcom" . " FROM `##families`" . " JOIN `##link` ON (f_file=l_file AND f_id=l_from)" . " LEFT JOIN `##name` ON (f_file=n_file AND f_id=n_id AND n_num=0)" . " WHERE f_file=? AND l_type=? AND l_to=?")->execute(array($this->gedcom_id, $link, $this->xref))->fetchAll();
     $list = array();
     foreach ($rows as $row) {
         $record = WT_Family::getInstance($row->xref, $row->gedcom_id, $row->gedcom);
         if ($record->canShowName()) {
             $list[] = $record;
         }
     }
     return $list;
 }
Ejemplo n.º 24
0
function get_calendar_events($jd1, $jd2, $facts = '', $ged_id = WT_GED_ID)
{
    // If no facts specified, get all except these
    $skipfacts = "CHAN,BAPL,SLGC,SLGS,ENDL,CENS,RESI,NOTE,ADDR,OBJE,SOUR,PAGE,DATA,TEXT";
    if ($facts != '_TODO') {
        $skipfacts .= ',_TODO';
    }
    $found_facts = array();
    // Events that start or end during the period
    $where = "WHERE (d_julianday1>={$jd1} AND d_julianday1<={$jd2} OR d_julianday2>={$jd1} AND d_julianday2<={$jd2})";
    // Restrict to certain types of fact
    if (empty($facts)) {
        $excl_facts = "'" . preg_replace('/\\W+/', "','", $skipfacts) . "'";
        $where .= " AND d_fact NOT IN ({$excl_facts})";
    } else {
        $incl_facts = "'" . preg_replace('/\\W+/', "','", $facts) . "'";
        $where .= " AND d_fact IN ({$incl_facts})";
    }
    // Only get events from the current gedcom
    $where .= " AND d_file=" . $ged_id;
    // Now fetch these events
    $ind_sql = "SELECT d_gid AS xref, i_file AS gedcom_id, i_gedcom AS gedcom, 'INDI' AS type, d_type, d_day, d_month, d_year, d_fact, d_type FROM `##dates`, `##individuals` {$where} AND d_gid=i_id AND d_file=i_file GROUP BY d_julianday1, d_gid ORDER BY d_julianday1";
    $fam_sql = "SELECT d_gid AS xref, f_file AS gedcom_id, f_gedcom AS gedcom, 'FAM'  AS type, d_type, d_day, d_month, d_year, d_fact, d_type FROM `##dates`, `##families`    {$where} AND d_gid=f_id AND d_file=f_file GROUP BY d_julianday1, d_gid ORDER BY d_julianday1";
    foreach (array($ind_sql, $fam_sql) as $sql) {
        $rows = WT_DB::prepare($sql)->fetchAll();
        foreach ($rows as $row) {
            if ($row->type == 'INDI') {
                $record = WT_Individual::getInstance($row->xref, $row->gedcom_id, $row->gedcom);
            } else {
                $record = WT_Family::getInstance($row->xref, $row->gedcom_id, $row->gedcom);
            }
            $anniv_date = new WT_Date($row->d_type . ' ' . $row->d_day . ' ' . $row->d_month . ' ' . $row->d_year);
            foreach ($record->getFacts(str_replace(' ', '|', $facts)) as $fact) {
                if ($fact->getDate() == $anniv_date) {
                    $fact->anniv = 0;
                    $found_facts[] = $fact;
                }
            }
        }
    }
    return $found_facts;
}
Ejemplo n.º 25
0
function export_gedcom($gedcom, $gedout, $exportOptions)
{
    global $GEDCOM;
    // Temporarily switch to the specified GEDCOM
    $oldGEDCOM = $GEDCOM;
    $GEDCOM = $gedcom;
    $ged_id = get_id_from_gedcom($gedcom);
    switch ($exportOptions['privatize']) {
        case 'gedadmin':
            $access_level = WT_PRIV_NONE;
            break;
        case 'user':
            $access_level = WT_PRIV_USER;
            break;
        case 'visitor':
            $access_level = WT_PRIV_PUBLIC;
            break;
        case 'none':
            $access_level = WT_PRIV_HIDE;
            break;
    }
    $head = gedcom_header($gedcom);
    if ($exportOptions['toANSI'] == 'yes') {
        $head = str_replace('UTF-8', 'ANSI', $head);
        $head = utf8_decode($head);
    }
    $head = reformat_record_export($head);
    fwrite($gedout, $head);
    // Buffer the output.  Lots of small fwrite() calls can be very slow when writing large gedcoms.
    $buffer = '';
    // Generate the OBJE/SOUR/REPO/NOTE records first, as their privacy calcualations involve
    // database queries, and we wish to avoid large gaps between queries due to MySQL connection timeouts.
    $tmp_gedcom = '';
    $rows = WT_DB::prepare("SELECT 'OBJE' AS type, m_id AS xref, m_file AS gedcom_id, m_gedcom AS gedcom" . " FROM `##media` WHERE m_file=? ORDER BY m_id")->execute(array($ged_id))->fetchAll();
    foreach ($rows as $row) {
        $rec = WT_Media::getInstance($row->xref, $row->gedcom_id, $row->gedcom)->privatizeGedcom($access_level);
        $rec = convert_media_path($rec, $exportOptions['path']);
        if ($exportOptions['toANSI'] == 'yes') {
            $rec = utf8_decode($rec);
        }
        $tmp_gedcom .= reformat_record_export($rec);
    }
    $rows = WT_DB::prepare("SELECT s_id AS xref, s_file AS gedcom_id, s_gedcom AS gedcom" . " FROM `##sources` WHERE s_file=? ORDER BY s_id")->execute(array($ged_id))->fetchAll();
    foreach ($rows as $row) {
        $rec = WT_Source::getInstance($row->xref, $row->gedcom_id, $row->gedcom)->privatizeGedcom($access_level);
        if ($exportOptions['toANSI'] == 'yes') {
            $rec = utf8_decode($rec);
        }
        $tmp_gedcom .= reformat_record_export($rec);
    }
    $rows = WT_DB::prepare("SELECT o_type AS type, o_id AS xref, o_file AS gedcom_id, o_gedcom AS gedcom" . " FROM `##other` WHERE o_file=? AND o_type!='HEAD' AND o_type!='TRLR' ORDER BY o_id")->execute(array($ged_id))->fetchAll();
    foreach ($rows as $row) {
        switch ($row->type) {
            case 'NOTE':
                $record = WT_Note::getInstance($row->xref, $row->gedcom_id, $row->gedcom);
                break;
            case 'REPO':
                $record = WT_Repository::getInstance($row->xref, $row->gedcom_id, $row->gedcom);
                break;
            default:
                $record = WT_GedcomRecord::getInstance($row->xref, $row->gedcom_id, $row->gedcom);
                break;
        }
        $rec = $record->privatizeGedcom($access_level);
        if ($exportOptions['toANSI'] == 'yes') {
            $rec = utf8_decode($rec);
        }
        $tmp_gedcom .= reformat_record_export($rec);
    }
    $rows = WT_DB::prepare("SELECT i_id AS xref, i_file AS gedcom_id, i_gedcom AS gedcom" . " FROM `##individuals` WHERE i_file=? ORDER BY i_id")->execute(array($ged_id))->fetchAll();
    foreach ($rows as $row) {
        $rec = WT_Individual::getInstance($row->xref, $row->gedcom_id, $row->gedcom)->privatizeGedcom($access_level);
        if ($exportOptions['toANSI'] == 'yes') {
            $rec = utf8_decode($rec);
        }
        $buffer .= reformat_record_export($rec);
        if (strlen($buffer) > 65536) {
            fwrite($gedout, $buffer);
            $buffer = '';
        }
    }
    $rows = WT_DB::prepare("SELECT f_id AS xref, f_file AS gedcom_id, f_gedcom AS gedcom" . " FROM `##families` WHERE f_file=? ORDER BY f_id")->execute(array($ged_id))->fetchAll();
    foreach ($rows as $row) {
        $rec = WT_Family::getInstance($row->xref, $row->gedcom_id, $row->gedcom)->privatizeGedcom($access_level);
        if ($exportOptions['toANSI'] == 'yes') {
            $rec = utf8_decode($rec);
        }
        $buffer .= reformat_record_export($rec);
        if (strlen($buffer) > 65536) {
            fwrite($gedout, $buffer);
            $buffer = '';
        }
    }
    fwrite($gedout, $buffer);
    fwrite($gedout, $tmp_gedcom);
    fwrite($gedout, '0 TRLR' . WT_EOL);
    $GEDCOM = $oldGEDCOM;
}