コード例 #1
0
ファイル: Timeline.php プロジェクト: sadr110/webtrees
 function print_time_fact(WT_Fact $event)
 {
     global $basexoffset, $baseyoffset, $factcount, $TEXT_DIRECTION, $WT_IMAGES, $placements;
     $desc = $event->getValue();
     // check if this is a family fact
     $gdate = $event->getDate();
     $date = $gdate->MinDate();
     $date = $date->convert_to_cal('gregorian');
     $year = $date->y;
     $month = max(1, $date->m);
     $day = max(1, $date->d);
     $xoffset = $basexoffset + 22;
     $yoffset = $baseyoffset + ($year - $this->baseyear) * $this->scale - $this->scale;
     $yoffset = $yoffset + $month / 12 * $this->scale;
     $yoffset = $yoffset + $day / 30 * ($this->scale / 12);
     $yoffset = (int) $yoffset;
     $place = (int) ($yoffset / $this->bheight);
     $i = 1;
     $j = 0;
     $tyoffset = 0;
     while (isset($placements[$place])) {
         if ($i == $j) {
             $tyoffset = $this->bheight * $i;
             $i++;
         } else {
             $tyoffset = -1 * $this->bheight * $j;
             $j++;
         }
         $place = (int) (($yoffset + $tyoffset) / $this->bheight);
     }
     $yoffset += $tyoffset;
     $xoffset += abs($tyoffset);
     $placements[$place] = $yoffset;
     echo "<div id=\"fact{$factcount}\" style=\"position:absolute; " . ($TEXT_DIRECTION == "ltr" ? "left: " . $xoffset : "right: " . $xoffset) . "px; top:" . $yoffset . "px; font-size: 8pt; height: " . $this->bheight . "px;\" onmousedown=\"factMouseDown(this, '" . $factcount . "', " . ($yoffset - $tyoffset) . ");\">";
     echo "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" style=\"cursor: hand;\"><tr><td>";
     echo "<img src=\"" . $WT_IMAGES["hline"] . "\" name=\"boxline{$factcount}\" id=\"boxline{$factcount}\" height=\"3\" align=\"left\" width=\"10\" alt=\"\" style=\"padding-";
     if ($TEXT_DIRECTION == "ltr") {
         echo "left";
     } else {
         echo "right";
     }
     echo ": 3px;\">";
     $col = $event->temp % 6;
     echo "</td><td valign=\"top\" class=\"person" . $col . "\">";
     if (count($this->pids) > 6) {
         echo $event->getParent()->getFullName() . ' — ';
     }
     $record = $event->getParent();
     echo $event->getLabel();
     echo ' — ';
     if ($record instanceof WT_Individual) {
         echo format_fact_date($event, $record, false, false);
     } elseif ($record instanceof WT_Family) {
         echo $gdate->Display(false);
         if ($record->getHusband() && $record->getHusband()->getBirthDate()->isOK()) {
             $ageh = get_age_at_event(WT_Date::GetAgeGedcom($record->getHusband()->getBirthDate(), $gdate), false);
         } else {
             $ageh = null;
         }
         if ($record->getWife() && $record->getWife()->getBirthDate()->isOK()) {
             $agew = get_age_at_event(WT_Date::GetAgeGedcom($record->getWife()->getBirthDate(), $gdate), false);
         } else {
             $agew = null;
         }
         if ($ageh && $agew) {
             echo '<span class="age"> ', WT_I18N::translate('Husband’s age'), ' ', $ageh, ' ', WT_I18N::translate('Wife’s age'), ' ', $agew, '</span>';
         } elseif ($ageh) {
             echo '<span class="age"> ', WT_I18N::translate('Age'), ' ', $ageh, '</span>';
         } elseif ($agew) {
             echo '<span class="age"> ', WT_I18N::translate('Age'), ' ', $ageh, '</span>';
         }
     }
     echo ' ' . WT_Filter::escapeHtml($desc);
     if (!$event->getPlace()->isEmpty()) {
         echo ' — ' . $event->getPlace()->getShortName();
     }
     // print spouse name for marriage events
     if (isset($event->spouse)) {
         $spouse = $event->spouse;
     } else {
         $spouse = null;
     }
     if ($spouse) {
         for ($p = 0; $p < count($this->pids); $p++) {
             if ($this->pids[$p] == $spouse->getXref()) {
                 break;
             }
         }
         if ($p == count($this->pids)) {
             $p = $event->temp;
         }
         if ($spouse->getXref() != $this->pids[$p]) {
             echo ' <a href="', $spouse->getHtmlUrl(), '">', $spouse->getFullName(), '</a>';
         } else {
             echo ' <a href="', $event->getParent()->getHtmlUrl(), '">', $event->getParent()->getFullName(), '</a>';
         }
     }
     echo "</td></tr></table>";
     echo "</div>";
     if ($TEXT_DIRECTION == 'ltr') {
         $img = "dline2";
         $ypos = "0%";
     } else {
         $img = "dline";
         $ypos = "100%";
     }
     $dyoffset = $yoffset - $tyoffset + $this->bheight / 3;
     if ($tyoffset < 0) {
         $dyoffset = $yoffset + $this->bheight / 3;
         if ($TEXT_DIRECTION == 'ltr') {
             $img = "dline";
             $ypos = "100%";
         } else {
             $img = "dline2";
             $ypos = "0%";
         }
     }
     // print the diagnal line
     echo "<div id=\"dbox{$factcount}\" style=\"position:absolute; " . ($TEXT_DIRECTION == "ltr" ? "left: " . ($basexoffset + 25) : "right: " . ($basexoffset + 25)) . "px; top:" . $dyoffset . "px; font-size: 8pt; height: " . abs($tyoffset) . "px; width: " . abs($tyoffset) . "px;";
     echo " background-image: url('" . $WT_IMAGES[$img] . "');";
     echo " background-position: 0% {$ypos};\">";
     echo "</div>";
 }
コード例 #2
0
ファイル: bit_print.php プロジェクト: bitweaver/phpgedview
/**
 * print fact DATE TIME
 *
 * @param string $factrec	gedcom fact record
 * @param boolean $anchor	option to print a link to calendar
 * @param boolean $time		option to print TIME value
 * @param string $fact		optional fact name (to print age)
 * @param string $pid		optional person ID (to print age)
 * @param string $indirec	optional individual record (to print age)
 */
function print_fact_date($factrec, $anchor = false, $time = false, $fact = false, $pid = false, $indirec = false)
{
    global $factarray, $pgv_lang, $SEARCH_SPIDER;
    $ct = preg_match("/2 DATE (.+)/", $factrec, $match);
    if ($ct > 0) {
        print " ";
        // link to calendar
        if ($anchor && empty($SEARCH_SPIDER)) {
            print get_date_url($match[1]);
        } else {
            print get_changed_date(trim($match[1]));
        }
        // time
        if ($time) {
            $timerec = get_sub_record(2, "2 TIME", $factrec);
            if (empty($timerec)) {
                $timerec = get_sub_record(2, "2 DATE", $factrec);
            }
            $tt = preg_match("/[2-3] TIME (.*)/", $timerec, $tmatch);
            if ($tt > 0) {
                print " - <span class=\"date\">" . $tmatch[1] . "</span>";
            }
        }
        if ($fact and $pid) {
            // age of parents at child birth
            if ($fact == "BIRT") {
                print_parents_age($pid, $match[1]);
            } else {
                if ($fact != "CHAN") {
                    if (!$indirec) {
                        $indirec = find_person_record($pid);
                    }
                    // do not print age after death
                    $deatrec = get_sub_record(1, "1 DEAT", $indirec);
                    if (empty($deatrec) || compare_facts($factrec, $deatrec) != 1 || strstr($factrec, "1 DEAT")) {
                        print get_age($indirec, $match[1]);
                    }
                }
            }
        }
        print " ";
    } else {
        // 1 DEAT Y with no DATE => print YES
        // 1 DEAT N is not allowed
        // It is not proper GEDCOM form to use a N(o) value with an event tag to infer that it did not happen.
        $factrec = str_replace("\r\nPGV_OLD\r\n", "", $factrec);
        $factrec = str_replace("\r\nPGV_NEW\r\n", "", $factrec);
        $factdetail = preg_split("/ /", trim($factrec));
        if (isset($factdetail)) {
            if (count($factdetail) == 3) {
                if (strtoupper($factdetail[2]) == "Y") {
                    print $pgv_lang["yes"];
                }
            }
        }
    }
    // gedcom indi age
    $ages = array();
    $agerec = get_gedcom_value("AGE", 2, $factrec);
    $daterec = get_sub_record(2, "2 DATE", $factrec);
    if (empty($agerec)) {
        $agerec = get_gedcom_value("AGE", 3, $daterec);
    }
    $ages[0] = $agerec;
    // gedcom husband age
    $husbrec = get_sub_record(2, "2 HUSB", $factrec);
    if (!empty($husbrec)) {
        $agerec = get_gedcom_value("AGE", 3, $husbrec);
    } else {
        $agerec = "";
    }
    $ages[1] = $agerec;
    // gedcom wife age
    $wiferec = get_sub_record(2, "2 WIFE", $factrec);
    if (!empty($wiferec)) {
        $agerec = get_gedcom_value("AGE", 3, $wiferec);
    } else {
        $agerec = "";
    }
    $ages[2] = $agerec;
    // print gedcom ages
    foreach ($ages as $indexval => $agerec) {
        if (!empty($agerec)) {
            print "<span class=\"label\">";
            if ($indexval == 1) {
                print $pgv_lang["husband"];
            } else {
                if ($indexval == 2) {
                    print $pgv_lang["wife"];
                } else {
                    print $factarray["AGE"];
                }
            }
            print "</span>: ";
            $age = get_age_at_event($agerec);
            print PrintReady($age);
            print " ";
        }
    }
}
コード例 #3
0
 function print_time_fact($event)
 {
     global $basexoffset, $baseyoffset, $factcount, $TEXT_DIRECTION;
     global $factarray, $pgv_lang, $lang_short_cut, $LANGUAGE, $PGV_IMAGE_DIR, $PGV_IMAGES, $SHOW_PEDIGREE_PLACES, $placements;
     global $familyfacts, $GEDCOM;
     /* @var $event Event */
     $factrec = $event->getGedComRecord();
     $fact = $event->getTag();
     $desc = $event->getDetail();
     if ($fact == "EVEN" || $fact == "FACT") {
         $fact = $event->getType();
     }
     //-- check if this is a family fact
     $famid = $event->getFamilyId();
     if ($famid != null) {
         //-- if we already showed this family fact then don't print it
         if (isset($familyfacts[$famid . $fact]) && $familyfacts[$famid . $fact] != $event->temp) {
             return;
         }
         $familyfacts[$famid . $fact] = $event->temp;
     }
     $gdate = $event->getDate();
     $date = $gdate->MinDate();
     $date = $date->convert_to_cal('gregorian');
     $year = $date->y;
     $month = max(1, $date->m);
     $day = max(1, $date->d);
     $xoffset = $basexoffset + 22;
     $yoffset = $baseyoffset + ($year - $this->baseyear) * $this->scale - $this->scale;
     $yoffset = $yoffset + $month / 12 * $this->scale;
     $yoffset = $yoffset + $day / 30 * ($this->scale / 12);
     $yoffset = floor($yoffset);
     $place = round($yoffset / $this->bheight);
     $i = 1;
     $j = 0;
     $tyoffset = 0;
     while (isset($placements[$place])) {
         if ($i == $j) {
             $tyoffset = $this->bheight * $i;
             $i++;
         } else {
             $tyoffset = -1 * $this->bheight * $j;
             $j++;
         }
         $place = round(($yoffset + $tyoffset) / $this->bheight);
     }
     $yoffset += $tyoffset;
     $xoffset += abs($tyoffset);
     $placements[$place] = $yoffset;
     print "\n\t\t<div id=\"fact{$factcount}\" style=\"position:absolute; " . ($TEXT_DIRECTION == "ltr" ? "left: " . $xoffset : "right: " . $xoffset) . "px; top:" . $yoffset . "px; font-size: 8pt; height: " . $this->bheight . "px; \" onmousedown=\"factMD(this, '" . $factcount . "', " . ($yoffset - $tyoffset) . ");\">\n";
     print "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" style=\"cursor: hand;\"><tr><td>\n";
     print "<img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["hline"]["other"] . "\" name=\"boxline{$factcount}\" id=\"boxline{$factcount}\" height=\"3\" align=\"left\" hspace=\"0\" width=\"10\" vspace=\"0\" alt=\"\" style=\"padding-";
     if ($TEXT_DIRECTION == "ltr") {
         print "left";
     } else {
         print "right";
     }
     print ": 3px;\" />\n";
     $col = $event->temp % 6;
     print "</td><td valign=\"top\" class=\"person" . $col . "\">\n";
     if (count($this->pids) > 6) {
         print $event->getParentObject()->getFullName() . " - ";
     }
     $indi = $event->getParentObject();
     if ($fact == "_AKAN" || $fact == "_AKA" || $fact == "ALIA" || $fact == "_INTE") {
         // Allow special processing for different languages
         $func = "fact_AKA_localisation_{$lang_short_cut[$LANGUAGE]}";
         if (function_exists($func) && get_class($indi) == "Person") {
             // Localise the facts
             $func($fact, $indi->getXref());
             print $factarray[$fact];
         } else {
             print $event->getLabel();
         }
     } else {
         print $event->getLabel();
     }
     print " -- ";
     if (get_class($indi) == "Person") {
         print format_fact_date($event);
     }
     if (get_class($indi) == "Family") {
         print $gdate->Display(false);
         $family = $indi;
         $husbid = $family->getHusbId();
         $wifeid = $family->getWifeId();
         //-- Retrieve husband and wife age
         for ($p = 0; $p < count($this->pids); $p++) {
             if ($this->pids[$p] == $husbid) {
                 $husb = $family->getHusband();
                 if (is_null($husb)) {
                     $husb = new Person('');
                 }
                 $hdate = $husb->getBirthDate();
                 if ($hdate->isOK()) {
                     $ageh = get_age_at_event(GedcomDate::GetAgeGedcom($hdate, $gdate), false);
                 }
             } else {
                 if ($this->pids[$p] == $wifeid) {
                     $wife = $family->getWife();
                     if (is_null($wife)) {
                         $wife = new Person('');
                     }
                     $wdate = $wife->getBirthDate();
                     if ($wdate->isOK()) {
                         $agew = get_age_at_event(GedcomDate::GetAgeGedcom($wdate, $gdate), false);
                     }
                 }
             }
         }
         if (!empty($ageh) && $ageh > 0) {
             if (empty($agew)) {
                 print '<span class="age"> ' . PrintReady("({$pgv_lang["age"]} {$ageh})") . '</span>';
             } else {
                 print '<span class="age"> ' . PrintReady("({$pgv_lang["husb_age"]} {$ageh},") . ' ';
             }
         }
         if (!empty($agew) && $agew > 0) {
             if (empty($ageh)) {
                 print '<span class="age"> ' . PrintReady("({$pgv_lang["age"]} {$agew})") . '</span>';
             } else {
                 print PrintReady("{$pgv_lang["wife_age"]} {$agew})") . '</span>';
             }
         }
     }
     print " " . PrintReady($desc);
     if ($SHOW_PEDIGREE_PLACES > 0) {
         $place = $event->getPlace();
         if ($place != null) {
             if ($desc != null) {
                 print " - ";
             }
             $plevels = explode(',', $place);
             for ($plevel = 0; $plevel < $SHOW_PEDIGREE_PLACES; $plevel++) {
                 if (!empty($plevels[$plevel])) {
                     if ($plevel > 0) {
                         print ", ";
                     }
                     print PrintReady($plevels[$plevel]);
                 }
             }
         }
     }
     //-- print spouse name for marriage events
     $spouse = Person::getInstance($event->getSpouseId());
     if ($spouse) {
         for ($p = 0; $p < count($this->pids); $p++) {
             if ($this->pids[$p] == $spouse->getXref()) {
                 break;
             }
         }
         if ($p == count($this->pids)) {
             $p = $event->temp;
         }
         $col = $p % 6;
         if ($spouse->getXref() != $this->pids[$p]) {
             echo ' <a href="', $spouse->getLinkUrl(), '">', $spouse->getFullName(), '</a>';
         } else {
             $ct = preg_match("/2 _PGVFS @(.*)@/", $factrec, $match);
             if ($ct > 0) {
                 print " <a href=\"" . encode_url("family.php?famid={$match[1]}&ged={$GEDCOM}") . "\">";
                 if (displayDetailsById($match[1]) || showLivingNameById($match[1])) {
                     print $event->getParentObject()->getFullName();
                 } else {
                     print $pgv_lang["private"];
                 }
                 print "</a>";
             }
         }
     }
     print "</td></tr></table>\n";
     print "</div>";
     if ($TEXT_DIRECTION == 'ltr') {
         $img = "dline2";
         $ypos = "0%";
     } else {
         $img = "dline";
         $ypos = "100%";
     }
     $dyoffset = $yoffset - $tyoffset + $this->bheight / 3;
     if ($tyoffset < 0) {
         $dyoffset = $yoffset + $this->bheight / 3;
         if ($TEXT_DIRECTION == 'ltr') {
             $img = "dline";
             $ypos = "100%";
         } else {
             $img = "dline2";
             $ypos = "0%";
         }
     }
     //-- print the diagnal line
     print "\n\t\t<div id=\"dbox{$factcount}\" style=\"position:absolute; " . ($TEXT_DIRECTION == "ltr" ? "left: " . ($basexoffset + 25) : "right: " . ($basexoffset + 25)) . "px; top:" . $dyoffset . "px; font-size: 8pt; height: " . abs($tyoffset) . "px; width: " . abs($tyoffset) . "px;";
     print " background-image: url('" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES[$img]["other"] . "');";
     print " background-position: 0% {$ypos}; \" >\n";
     print "</div>\n";
 }
コード例 #4
0
function format_fact_date(WT_Fact $event, WT_GedcomRecord $record, $anchor = false, $time = false)
{
    global $pid, $SEARCH_SPIDER, $SHOW_PARENTS_AGE;
    $factrec = $event->getGedcom();
    $html = '';
    // Recorded age
    if (preg_match('/\\n2 AGE (.+)/', $factrec, $match)) {
        $fact_age = $match[1];
    } else {
        $fact_age = '';
    }
    if (preg_match('/\\n2 HUSB\\n3 AGE (.+)/', $factrec, $match)) {
        $husb_age = $match[1];
    } else {
        $husb_age = '';
    }
    if (preg_match('/\\n2 WIFE\\n3 AGE (.+)/', $factrec, $match)) {
        $wife_age = $match[1];
    } else {
        $wife_age = '';
    }
    // Calculated age
    if (preg_match('/2 DATE (.+)/', $factrec, $match)) {
        $date = new WT_Date($match[1]);
        $html .= ' ' . $date->Display($anchor && !$SEARCH_SPIDER);
        // time
        if ($time) {
            $timerec = get_sub_record(2, '2 TIME', $factrec);
            if ($timerec == '') {
                $timerec = get_sub_record(2, '2 DATE', $factrec);
            }
            if (preg_match('/[2-3] TIME (.*)/', $timerec, $tmatch)) {
                $html .= '<span class="date"> - ' . $tmatch[1] . '</span>';
            }
        }
        $fact = $event->getTag();
        if ($record instanceof WT_Individual) {
            // age of parents at child birth
            if ($fact == 'BIRT' && $SHOW_PARENTS_AGE) {
                $html .= format_parents_age($record, $date);
            } else {
                if ($fact != 'CHAN' && $fact != '_TODO') {
                    $birth_date = $record->getBirthDate();
                    // Can't use getDeathDate(), as this also gives BURI/CREM events, which
                    // wouldn't give the correct "days after death" result for people with
                    // no DEAT.
                    $death_event = $record->getFirstFact('DEAT');
                    if ($death_event) {
                        $death_date = $death_event->getDate();
                    } else {
                        $death_date = new WT_Date('');
                    }
                    $ageText = '';
                    if (WT_Date::Compare($date, $death_date) <= 0 || !$record->isDead() || $fact == 'DEAT') {
                        // Before death, print age
                        $age = WT_Date::GetAgeGedcom($birth_date, $date);
                        // Only show calculated age if it differs from recorded age
                        if ($age != '') {
                            if ($fact_age != '' && $fact_age != $age || $fact_age == '' && $husb_age == '' && $wife_age == '' || $husb_age != '' && $record->getSex() == 'M' && $husb_age != $age || $wife_age != '' && $record->getSex() == 'F' && $wife_age != $age) {
                                if ($age != "0d") {
                                    $ageText = '(' . WT_I18N::translate('Age') . ' ' . get_age_at_event($age, false) . ')';
                                }
                            }
                        }
                    }
                    if ($fact != 'DEAT' && WT_Date::Compare($date, $death_date) >= 0) {
                        // After death, print time since death
                        $age = get_age_at_event(WT_Date::GetAgeGedcom($death_date, $date), true);
                        if ($age != '') {
                            if (WT_Date::GetAgeGedcom($death_date, $date) == "0d") {
                                $ageText = '(' . WT_I18N::translate('on the date of death') . ')';
                            } else {
                                $ageText = '(' . $age . ' ' . WT_I18N::translate('after death') . ')';
                                // Family events which occur after death are probably errors
                                if ($event->getParent() instanceof WT_Family) {
                                    $ageText .= '<i class="icon-warning"></i>';
                                }
                            }
                        }
                    }
                    if ($ageText) {
                        $html .= ' <span class="age">' . $ageText . '</span>';
                    }
                }
            }
        } elseif ($record instanceof WT_Family) {
            $indi = WT_Individual::getInstance($pid);
            if ($indi) {
                $birth_date = $indi->getBirthDate();
                $death_date = $indi->getDeathDate();
                $ageText = '';
                if (WT_Date::Compare($date, $death_date) <= 0) {
                    $age = WT_Date::GetAgeGedcom($birth_date, $date);
                    // Only show calculated age if it differs from recorded age
                    if ($age != '' && $age > 0) {
                        if ($fact_age != '' && $fact_age != $age || $fact_age == '' && $husb_age == '' && $wife_age == '' || $husb_age != '' && $indi->getSex() == 'M' && $husb_age != $age || $wife_age != '' && $indi->getSex() == 'F' && $wife_age != $age) {
                            $ageText = '(' . WT_I18N::translate('Age') . ' ' . get_age_at_event($age, false) . ')';
                        }
                    }
                }
                if ($ageText) {
                    $html .= ' <span class="age">' . $ageText . '</span>';
                }
            }
        }
    } else {
        // 1 DEAT Y with no DATE => print YES
        // 1 BIRT 2 SOUR @S1@ => print YES
        // 1 DEAT N is not allowed
        // It is not proper GEDCOM form to use a N(o) value with an event tag to infer that it did not happen.
        $factdetail = explode(' ', trim($factrec));
        if (isset($factdetail) && (count($factdetail) == 3 && strtoupper($factdetail[2]) == 'Y') || count($factdetail) == 4 && $factdetail[2] == 'SOUR') {
            $html .= WT_I18N::translate('yes');
        }
    }
    // print gedcom ages
    foreach (array(WT_Gedcom_Tag::getLabel('AGE') => $fact_age, WT_Gedcom_Tag::getLabel('HUSB') => $husb_age, WT_Gedcom_Tag::getLabel('WIFE') => $wife_age) as $label => $age) {
        if ($age != '') {
            $html .= ' <span class="label">' . $label . ':</span> <span class="age">' . get_age_at_event($age, false) . '</span>';
        }
    }
    return $html;
}
コード例 #5
0
ファイル: Base.php プロジェクト: brambravo/webtrees
/**
 * XML <AgeAtDeath /> element handler
 *
 * @see Element::addText()
 * @final
 */
function AgeAtDeathSHandler()
{
    // TODO: This duplicates functionality in format_fact_date()
    global $currentElement, $gedrec, $fact, $desc;
    $id = "";
    $match = array();
    if (preg_match("/0 @(.+)@/", $gedrec, $match)) {
        $person = WT_Individual::getInstance($match[1]);
        // Recorded age
        if (preg_match('/\\n2 AGE (.+)/', $factrec, $match)) {
            $fact_age = $match[1];
        } else {
            $fact_age = '';
        }
        if (preg_match('/\\n2 HUSB\\n3 AGE (.+)/', $factrec, $match)) {
            $husb_age = $match[1];
        } else {
            $husb_age = '';
        }
        if (preg_match('/\\n2 WIFE\\n3 AGE (.+)/', $factrec, $match)) {
            $wife_age = $match[1];
        } else {
            $wife_age = '';
        }
        // Calculated age
        $birth_date = $person->getBirthDate();
        // Can't use getDeathDate(), as this also gives BURI/CREM events, which
        // wouldn't give the correct "days after death" result for people with
        // no DEAT.
        $death_event = $person->getFirstFact('DEAT');
        if ($death_event) {
            $death_date = $death_event->getDate();
        } else {
            $death_date = new WT_Date('');
        }
        $value = '';
        if (WT_Date::Compare($birth_date, $death_date) <= 0 || !$person->isDead()) {
            $age = WT_Date::GetAgeGedcom($birth_date, $death_date);
            // Only show calculated age if it differs from recorded age
            if ($age != '' && $age != "0d") {
                if ($fact_age != '' && $fact_age != $age || $fact_age == '' && $husb_age == '' && $wife_age == '' || $husb_age != '' && $person->getSex() == 'M' && $husb_age != $age || $wife_age != '' && $person->getSex() == 'F' && $wife_age != $age) {
                    $value = get_age_at_event($age, false);
                    $abbrev = substr($value, 0, strpos($value, ' ') + 5);
                    if ($value !== $abbrev) {
                        $value = $abbrev . '.';
                    }
                }
            }
        }
        $currentElement->addText($value);
    }
}
コード例 #6
0
ファイル: CENS_ctrl.php プロジェクト: brambravo/webtrees
?>
	<form method="post" action="edit_interface.php" onsubmit="return check_form(this);">
		<input type="hidden" name="action" value="addnoteaction_assisted">
		<input type="hidden" name="noteid" value="newnote">
		<input id="pid_array" type="hidden" name="pid_array" value="none">
		<input id="xref" type="hidden" name="xref" value=<?php 
echo $xref;
?>
>
		<?php 
echo WT_Filter::getCsrf();
global $tabno, $linkToID, $SEARCH_SPIDER;
global $SHOW_AGE_DIFF, $GEDCOM;
global $show_full, $famid;
$summary = $person->format_first_major_fact(WT_EVENTS_BIRT, 2);
if (!$person->isDead()) {
    // If alive display age
    $bdate = $person->getBirthDate();
    $age = WT_Date::GetAgeGedcom($bdate);
    if ($age != "") {
        $summary .= "<span class=\"label\">" . WT_I18N::translate('Age') . ":</span><span class=\"field\"> " . get_age_at_event($age, true) . "</span>";
    }
}
$summary .= $person->format_first_major_fact(WT_EVENTS_DEAT, 2);
require WT_ROOT . WT_MODULES_DIR . 'GEDFact_assistant/_CENS/census_1_ctrl.php';
?>
		</form>
	</div>
	<div style="clear:both;"></div>
</div><!-- id="edit_interface-page" -->
コード例 #7
0
ファイル: Stats.php プロジェクト: sadr110/webtrees
 function _ageBetweenSiblingsQuery($type = 'list', $params = null)
 {
     global $TEXT_DIRECTION;
     if ($params === null) {
         $params = array();
     }
     if (isset($params[0])) {
         $total = $params[0];
     } else {
         $total = 10;
     }
     if (isset($params[1])) {
         $one = $params[1];
     } else {
         $one = false;
     }
     // each family only once if true
     $total = (int) $total;
     $rows = self::_runSQL(" SELECT SQL_CACHE DISTINCT" . " link1.l_from AS family," . " link1.l_to AS ch1," . " link2.l_to AS ch2," . " child1.d_julianday2-child2.d_julianday2 AS age" . " FROM `##link` AS link1" . " LEFT JOIN `##dates` AS child1 ON child1.d_file = {$this->_ged_id}" . " LEFT JOIN `##dates` AS child2 ON child2.d_file = {$this->_ged_id}" . " LEFT JOIN `##link` AS link2 ON link2.l_file = {$this->_ged_id}" . " WHERE" . " link1.l_file = {$this->_ged_id} AND" . " link1.l_from = link2.l_from AND" . " link1.l_type = 'CHIL' AND" . " child1.d_gid = link1.l_to AND" . " child1.d_fact = 'BIRT' AND" . " link2.l_type = 'CHIL' AND" . " child2.d_gid = link2.l_to AND" . " child2.d_fact = 'BIRT' AND" . " child1.d_julianday2 > child2.d_julianday2 AND" . " child2.d_julianday2 <> 0 AND" . " child1.d_gid <> child2.d_gid" . " ORDER BY age DESC" . " LIMIT " . $total);
     if (!isset($rows[0])) {
         return '';
     }
     $top10 = array();
     if ($one) {
         $dist = array();
     }
     foreach ($rows as $fam) {
         $family = WT_Family::getInstance($fam['family']);
         $child1 = WT_Individual::getInstance($fam['ch1']);
         $child2 = WT_Individual::getInstance($fam['ch2']);
         if ($type == 'name') {
             if ($child1->canShow() && $child2->canShow()) {
                 $return = '<a href="' . $child2->getHtmlUrl() . '">' . $child2->getFullName() . '</a> ';
                 $return .= WT_I18N::translate('and') . ' ';
                 $return .= '<a href="' . $child1->getHtmlUrl() . '">' . $child1->getFullName() . '</a>';
                 $return .= ' <a href="' . $family->getHtmlUrl() . '">[' . WT_I18N::translate('View family') . ']</a>';
             } else {
                 $return = WT_I18N::translate('This information is private and cannot be shown.');
             }
             return $return;
         }
         $age = $fam['age'];
         if ((int) ($age / 365.25) > 0) {
             $age = (int) ($age / 365.25) . 'y';
         } else {
             if ((int) ($age / 30.4375) > 0) {
                 $age = (int) ($age / 30.4375) . 'm';
             } else {
                 $age = $age . 'd';
             }
         }
         $age = get_age_at_event($age, true);
         if ($type == 'age') {
             return $age;
         }
         if ($type == 'list') {
             if ($one && !in_array($fam['family'], $dist)) {
                 if ($child1->canShow() && $child2->canShow()) {
                     $return = "<li>";
                     $return .= "<a href=\"" . $child2->getHtmlUrl() . "\">" . $child2->getFullName() . "</a> ";
                     $return .= WT_I18N::translate('and') . " ";
                     $return .= "<a href=\"" . $child1->getHtmlUrl() . "\">" . $child1->getFullName() . "</a>";
                     $return .= " (" . $age . ")";
                     $return .= " <a href=\"" . $family->getHtmlUrl() . "\">[" . WT_I18N::translate('View family') . "]</a>";
                     $return .= '</li>';
                     $top10[] = $return;
                     $dist[] = $fam['family'];
                 }
             } else {
                 if (!$one && $child1->canShow() && $child2->canShow()) {
                     $return = "<li>";
                     $return .= "<a href=\"" . $child2->getHtmlUrl() . "\">" . $child2->getFullName() . "</a> ";
                     $return .= WT_I18N::translate('and') . " ";
                     $return .= "<a href=\"" . $child1->getHtmlUrl() . "\">" . $child1->getFullName() . "</a>";
                     $return .= " (" . $age . ")";
                     $return .= " <a href=\"" . $family->getHtmlUrl() . "\">[" . WT_I18N::translate('View family') . "]</a>";
                     $return .= '</li>';
                     $top10[] = $return;
                 }
             }
         } else {
             if ($child1->canShow() && $child2->canShow()) {
                 $return = $child2->format_list('span', false, $child2->getFullName());
                 $return .= "<br>" . WT_I18N::translate('and') . "<br>";
                 $return .= $child1->format_list('span', false, $child1->getFullName());
                 $return .= "<br><a href=\"" . $family->getHtmlUrl() . "\">[" . WT_I18N::translate('View family') . "]</a>";
                 return $return;
             } else {
                 return WT_I18N::translate('This information is private and cannot be shown.');
             }
         }
     }
     if ($type == 'list') {
         $top10 = join('', $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;
 }
コード例 #8
0
ファイル: individual.php プロジェクト: jacoline/webtrees
if ($controller->record->canShow()) {
    // Highlight image or silhouette
    echo '<div id="indi_mainimage">', $controller->record->displayImage(), '</div>';
    echo '<div id="header_accordion1">';
    // contain accordions for names
    echo '<h3 class="name_one ', $controller->getPersonStyle($controller->record), '"><span>', $controller->record->getFullName(), '</span>';
    // First name accordion header
    $bdate = $controller->record->getBirthDate();
    $ddate = $controller->record->getDeathDate();
    echo '<span class="header_age">';
    if ($bdate->isOK() && !$controller->record->isDead()) {
        // If living display age
        echo WT_Gedcom_Tag::getLabelValue('AGE', get_age_at_event(WT_Date::GetAgeGedcom($bdate), true), '', 'span');
    } elseif ($bdate->isOK() && $ddate->isOK()) {
        // If dead, show age at death
        echo WT_Gedcom_Tag::getLabelValue('AGE', get_age_at_event(WT_Date::GetAgeGedcom($bdate, $ddate), false), '', 'span');
    }
    echo '</span>';
    // Display summary birth/death info.
    echo '<span id="dates">', $controller->record->getLifeSpan(), '</span>';
    // Display gender icon
    foreach ($controller->record->getFacts() as $fact) {
        if ($fact->getTag() == 'SEX') {
            $controller->print_sex_record($fact);
        }
    }
    echo '</h3>';
    // close first name accordion header
    // Display name details
    foreach ($controller->record->getFacts() as $fact) {
        if ($fact->getTag() == 'NAME') {
コード例 #9
0
ファイル: class_person.php プロジェクト: bitweaver/phpgedview
 /**
  * get the birth and death years
  * @return string
  */
 function getBirthDeathYears($age_at_death = true, $classname = "details1")
 {
     global $pgv_lang;
     if (!$this->getBirthYear()) {
         return "";
     }
     $tmp = "<span dir=\"ltr\" title=\"" . strip_tags($this->getBirthDate()->Display()) . "\">" . $this->getBirthYear() . "-</span>";
     $tmp .= "<span title=\"" . strip_tags($this->getDeathDate()->Display()) . "\">" . $this->getDeathYear() . "</span>";
     // display age only for exact dates (empty date qualifier)
     if ($age_at_death && $this->getBirthYear() && empty($this->getBirthDate()->qual1) && $this->getDeathYear() && empty($this->getDeathDate()->qual1)) {
         $age = get_age_at_event(GedcomDate::GetAgeGedcom($this->getBirthDate(), $this->getDeathDate()), false);
         if (!empty($age)) {
             $tmp .= "<span class='age'> ({$pgv_lang['age']} {$age})</span>";
         }
     }
     if ($classname) {
         return "<span class='{$classname}'>{$tmp}</span>";
     }
     return $tmp;
 }