Beispiel #1
0
function event_sort_name($a, $b)
{
    if ($a['jd'] == $b['jd']) {
        return WT_GedcomRecord::compare($a['record'], $b['record']);
    } else {
        return $a['jd'] - $b['jd'];
    }
}
/**
 * print a list of events
 *
 * This performs the same function as print_events_table(), but formats the output differently.
 */
function print_events_list($startjd, $endjd, $events = 'BIRT MARR DEAT', $only_living = false, $sort_by = 'anniv')
{
    // Did we have any output?  Did we skip anything?
    $output = 0;
    $filter = 0;
    $filtered_events = array();
    $html = '';
    foreach (get_events_list($startjd, $endjd, $events) as $fact) {
        $record = $fact->getParent();
        //-- only living people ?
        if ($only_living) {
            if ($record instanceof WT_Individual && $record->isDead()) {
                $filter++;
                continue;
            }
            if ($record instanceof WT_Family) {
                $husb = $record->getHusband();
                if (is_null($husb) || $husb->isDead()) {
                    $filter++;
                    continue;
                }
                $wife = $record->getWife();
                if (is_null($wife) || $wife->isDead()) {
                    $filter++;
                    continue;
                }
            }
        }
        $output++;
        $filtered_events[] = $fact;
    }
    // Now we've filtered the list, we can sort by event, if required
    switch ($sort_by) {
        case 'anniv':
            uasort($filtered_events, function ($x, $y) {
                return WT_Date::compare($y->getDate(), $x->getDate());
                // most recent first
            });
            break;
        case 'alpha':
            uasort($filtered_events, function ($x, $y) {
                return WT_GedcomRecord::compare($x->getParent(), $y->getParent());
            });
            break;
    }
    foreach ($filtered_events as $fact) {
        $record = $fact->getParent();
        $html .= '<a href="' . $record->getHtmlUrl() . '" class="list_item name2">' . $record->getFullName() . '</a>';
        if ($record instanceof WT_Individual) {
            $html .= $record->getSexImage();
        }
        $html .= '<br><div class="indent">';
        $html .= $fact->getLabel() . ' — ' . $fact->getDate()->Display(true);
        if ($fact->anniv) {
            $html .= ' (' . WT_I18N::translate('%s year anniversary', $fact->anniv) . ')';
        }
        if (!$fact->getPlace()->isEmpty()) {
            $html .= ' — <a href="' . $fact->getPlace()->getURL() . '">' . $fact->getPlace()->getFullName() . '</a>';
        }
        $html .= '</div>';
    }
    // Print a final summary message about restricted/filtered facts
    $summary = '';
    if ($endjd == WT_CLIENT_JD) {
        // We're dealing with the Today’s Events block
        if ($output == 0) {
            if ($filter == 0) {
                $summary = WT_I18N::translate('No events exist for today.');
            } else {
                $summary = WT_I18N::translate('No events for living individuals exist for today.');
            }
        }
    } else {
        // We're dealing with the Upcoming Events block
        if ($output == 0) {
            if ($filter == 0) {
                if ($endjd == $startjd) {
                    $summary = WT_I18N::translate('No events exist for tomorrow.');
                } else {
                    // I18N: translation for %s==1 is unused; it is translated separately as “tomorrow”
                    $summary = WT_I18N::plural('No events exist for the next %s day.', 'No events exist for the next %s days.', $endjd - $startjd + 1, WT_I18N::number($endjd - $startjd + 1));
                }
            } else {
                if ($endjd == $startjd) {
                    $summary = WT_I18N::translate('No events for living individuals exist for tomorrow.');
                } else {
                    // I18N: translation for %s==1 is unused; it is translated separately as “tomorrow”
                    $summary = WT_I18N::plural('No events for living people exist for the next %s day.', 'No events for living people exist for the next %s days.', $endjd - $startjd + 1, WT_I18N::number($endjd - $startjd + 1));
                }
            }
        }
    }
    if ($summary) {
        $html .= "<b>" . $summary . "</b>";
    }
    return $html;
}
Beispiel #3
0
 static function compareClippings($a, $b)
 {
     $a = WT_GedcomRecord::getInstance($a);
     $b = WT_GedcomRecord::getInstance($b);
     if ($a && $b) {
         switch ($a::RECORD_TYPE) {
             case 'INDI':
                 $t1 = 1;
                 break;
             case 'FAM':
                 $t1 = 2;
                 break;
             case 'SOUR':
                 $t1 = 3;
                 break;
             case 'REPO':
                 $t1 = 4;
                 break;
             case 'OBJE':
                 $t1 = 5;
                 break;
             case 'NOTE':
                 $t1 = 6;
                 break;
             default:
                 $t1 = 7;
                 break;
         }
         switch ($b::RECORD_TYPE) {
             case 'INDI':
                 $t2 = 1;
                 break;
             case 'FAM':
                 $t2 = 2;
                 break;
             case 'SOUR':
                 $t2 = 3;
                 break;
             case 'REPO':
                 $t2 = 4;
                 break;
             case 'OBJE':
                 $t2 = 5;
                 break;
             case 'NOTE':
                 $t2 = 6;
                 break;
             default:
                 $t2 = 7;
                 break;
         }
         if ($t1 != $t2) {
             return $t1 - $t2;
         } else {
             return WT_GedcomRecord::compare($a, $b);
         }
     } else {
         return 0;
     }
 }