Пример #1
0
function get_anniversary_events($jd, $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();
    foreach (array(new WT_Date_Gregorian($jd), new WT_Date_Julian($jd), new WT_Date_French($jd), new WT_Date_Jewish($jd), new WT_Date_Hijri($jd), new WT_Date_Jalali($jd)) as $anniv) {
        // Build a SQL where clause to match anniversaries in the appropriate calendar.
        $where = "WHERE d_type='" . $anniv->Format('%@') . "'";
        // SIMPLE CASES:
        // a) Non-hebrew anniversaries
        // b) Hebrew months TVT, SHV, IYR, SVN, TMZ, AAV, ELL
        if (!$anniv instanceof WT_Date_Jewish || in_array($anniv->m, array(1, 5, 9, 10, 11, 12, 13))) {
            // Dates without days go on the first day of the month
            // Dates with invalid days go on the last day of the month
            if ($anniv->d == 1) {
                $where .= " AND d_day<=1";
            } else {
                if ($anniv->d == $anniv->daysInMonth()) {
                    $where .= " AND d_day>={$anniv->d}";
                } else {
                    $where .= " AND d_day={$anniv->d}";
                }
            }
            $where .= " AND d_mon={$anniv->m}";
        } else {
            // SPECIAL CASES:
            switch ($anniv->m) {
                case 2:
                    // 29 CSH does not include 30 CSH (but would include an invalid 31 CSH if there were no 30 CSH)
                    if ($anniv->d == 1) {
                        $where .= " AND d_day<=1 AND d_mon=2";
                    } elseif ($anniv->d == 30) {
                        $where .= " AND d_day>=30 AND d_mon=2";
                    } elseif ($anniv->d == 29 && $anniv->daysInMonth() == 29) {
                        $where .= " AND (d_day=29 OR d_day>30) AND d_mon=2";
                    } else {
                        $where .= " AND d_day={$anniv->d} AND d_mon=2";
                    }
                    break;
                case 3:
                    // 1 KSL includes 30 CSH (if this year didn’t have 30 CSH)
                    // 29 KSL does not include 30 KSL (but would include an invalid 31 KSL if there were no 30 KSL)
                    if ($anniv->d == 1) {
                        $tmp = new WT_Date_Jewish(array($anniv->y, 'CSH', 1));
                        if ($tmp->daysInMonth() == 29) {
                            $where .= " AND (d_day<=1 AND d_mon=3 OR d_day=30 AND d_mon=2)";
                        } else {
                            $where .= " AND d_day<=1 AND d_mon=3";
                        }
                    } else {
                        if ($anniv->d == 30) {
                            $where .= " AND d_day>=30 AND d_mon=3";
                        } elseif ($anniv->d == 29 && $anniv->daysInMonth() == 29) {
                            $where .= " AND (d_day=29 OR d_day>30) AND d_mon=3";
                        } else {
                            $where .= " AND d_day={$anniv->d} AND d_mon=3";
                        }
                    }
                    break;
                case 4:
                    // 1 TVT includes 30 KSL (if this year didn’t have 30 KSL)
                    if ($anniv->d == 1) {
                        $tmp = new WT_Date_Jewish(array($anniv->y, 'KSL', 1));
                        if ($tmp->daysInMonth() == 29) {
                            $where .= " AND (d_day<=1 AND d_mon=4 OR d_day=30 AND d_mon=3)";
                        } else {
                            $where .= " AND d_day<=1 AND d_mon=4";
                        }
                    } else {
                        if ($anniv->d == $anniv->daysInMonth()) {
                            $where .= " AND d_day>={$anniv->d} AND d_mon=4";
                        } else {
                            $where .= " AND d_day={$anniv->d} AND d_mon=4";
                        }
                    }
                    break;
                case 6:
                    // ADR (non-leap) includes ADS (leap)
                    if ($anniv->d == 1) {
                        $where .= " AND d_day<=1";
                    } elseif ($anniv->d == $anniv->daysInMonth()) {
                        $where .= " AND d_day>={$anniv->d}";
                    } else {
                        $where .= " AND d_day={$anniv->d}";
                    }
                    if ($anniv->isLeapYear()) {
                        $where .= " AND (d_mon=6 AND MOD(7*d_year+1, 19)<7)";
                    } else {
                        $where .= " AND (d_mon=6 OR d_mon=7)";
                    }
                    break;
                case 7:
                    // ADS includes ADR (non-leap)
                    if ($anniv->d == 1) {
                        $where .= " AND d_day<=1";
                    } elseif ($anniv->d == $anniv->daysInMonth()) {
                        $where .= " AND d_day>={$anniv->d}";
                    } else {
                        $where .= " AND d_day={$anniv->d}";
                    }
                    $where .= " AND (d_mon=6 AND MOD(7*d_year+1, 19)>=7 OR d_mon=7)";
                    break;
                case 8:
                    // 1 NSN includes 30 ADR, if this year is non-leap
                    if ($anniv->d == 1) {
                        if ($anniv->isLeapYear()) {
                            $where .= " AND d_day<=1 AND d_mon=8";
                        } else {
                            $where .= " AND (d_day<=1 AND d_mon=8 OR d_day=30 AND d_mon=6)";
                        }
                    } elseif ($anniv->d == $anniv->daysInMonth()) {
                        $where .= " AND d_day>={$anniv->d} AND d_mon=8";
                    } else {
                        $where .= " AND d_day={$anniv->d} AND d_mon=8";
                    }
                    break;
            }
        }
        // Only events in the past (includes dates without a year)
        $where .= " AND d_year<={$anniv->y}";
        // 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 anniversaries
        $ind_sql = "SELECT DISTINCT 'INDI' AS type, i_id AS xref, i_file AS gedcom_id, i_gedcom AS gedcom, d_type, d_day, d_month, d_year, d_fact FROM `##dates`, `##individuals` {$where} AND d_gid=i_id AND d_file=i_file ORDER BY d_day ASC, d_year DESC";
        $fam_sql = "SELECT DISTINCT 'FAM'  AS type, f_id AS xref, f_file AS gedcom_id, f_gedcom AS gedcom, d_type, d_day, d_month, d_year, d_fact FROM `##dates`, `##families` {$where} AND d_gid=f_id AND d_file=f_file ORDER BY d_day ASC, d_year DESC";
        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->getTag() == $row->d_fact) {
                        $fact->anniv = $row->d_year == 0 ? 0 : $anniv->y - $row->d_year;
                        $found_facts[] = $fact;
                    }
                }
            }
        }
    }
    return $found_facts;
}
Пример #2
0
     $title = WT_I18N::translate('Theme dropdown selector for theme changes');
     $text = WT_I18N::translate('Gives users the option of selecting their own theme from a menu.<br><br>Even with this option set, the theme currently in effect may not provide for such a menu.  To be effective, this option requires the <b>Allow users to select their own theme</b> option to be set as well.');
     break;
 case 'ALLOW_USER_THEMES':
     $title = WT_I18N::translate('Allow users to select their own theme');
     $text = WT_I18N::translate('Gives users the option of selecting their own theme.');
     break;
 case 'CALENDAR_FORMAT':
     $d1 = new WT_Date('22 SEP 1792');
     $d1 = $d1->Display(false, null, array());
     $d2 = new WT_Date('31 DEC 1805');
     $d2 = $d2->Display(false, null, array());
     $d3 = new WT_Date('15 OCT 1582');
     $d3 = $d3->Display(false, null, array());
     $title = WT_I18N::translate('Calendar conversion');
     $text = '<p>' . WT_I18N::translate('Different calendar systems are used in different parts of the world, and many other calendar systems have been used in the past.  Where possible, you should enter dates using the calendar in which the event was originally recorded.  You can then specify a conversion, to show these dates in a more familiar calendar.  If you regularly use two calendars, you can specify two conversions and dates will be converted to both the selected calendars.') . '<p>' . WT_I18N::translate('The following calendars are supported:') . '</p><ul>' . '<li>' . WT_Date_Gregorian::calendarName() . '</li>' . '<li>' . WT_Date_Julian::calendarName() . '</li>' . '<li>' . WT_Date_Jewish::calendarName() . '</li>' . '<li>' . WT_Date_French::calendarName() . '</li>' . '<li>' . WT_Date_Hijri::calendarName() . '</li>' . '<li>' . WT_Date_Jalali::calendarName() . '</li>' . '</ul><p>' . WT_I18N::translate('Dates are only converted if they are valid for the calendar.  For example, only dates between %1$s and %2$s will be converted to the French calendar and only dates after %3$s will be converted to the Gregorian calendar.', $d1, $d2, $d3) . '</p><p>' . WT_I18N::translate('In some calendars, days start at midnight.  In other calendars, days start at sunset.  The conversion process does not take account of the time, so for any event that occurs between sunset and midnight, the conversion between these types of calendar will be one day out.') . '</p>';
     break;
 case 'CHART_BOX_TAGS':
     $title = WT_I18N::translate('Other facts to show in charts');
     $text = WT_I18N::translate('This should be a comma or space separated list of facts, in addition to birth and death, that you want to appear in chart boxes such as the pedigree chart.  This list requires you to use fact tags as defined in the GEDCOM 5.5.1 standard.  For example, if you wanted the occupation to show up in the box, you would add “OCCU” to this field.');
     break;
 case 'CHECK_MARRIAGE_RELATIONS':
     $title = WT_I18N::translate('Check relationships by marriage');
     $text = WT_I18N::translate('When calculating relationships, this option controls whether <b>webtrees</b> will include spouses/partners as well as blood relatives.');
     break;
 case 'COMMON_NAMES_ADD':
     $title = WT_I18N::translate('Names to add to common surnames (comma separated)');
     $text = WT_I18N::translate('If the number of times that a certain surname occurs is lower than the threshold, it will not appear in the list.  It can be added here manually.  If more than one surname is entered, they must be separated by a comma.  <b>Surnames are case-sensitive.</b>');
     break;
 case 'COMMON_NAMES_REMOVE':
     $title = WT_I18N::translate('Names to remove from common surnames (comma separated)');
Пример #3
0
 public function configureBlock($block_id)
 {
     if (WT_Filter::postBool('save') && WT_Filter::checkCsrf()) {
         set_block_setting($block_id, 'days', WT_Filter::postInteger('days', 1, 30, 7));
         set_block_setting($block_id, 'infoStyle', WT_Filter::post('infoStyle', 'list|table', 'table'));
         set_block_setting($block_id, 'calendar', WT_Filter::post('calendar', 'jewish|gregorian', 'jewish'));
         set_block_setting($block_id, 'block', WT_Filter::postBool('block'));
         exit;
     }
     require_once WT_ROOT . 'includes/functions/functions_edit.php';
     $days = get_block_setting($block_id, 'days', 7);
     echo '<tr><td class="descriptionbox wrap width33">';
     echo WT_I18N::translate('Number of days to show');
     echo '</td><td class="optionbox">';
     echo '<input type="text" name="days" size="2" value="' . $days . '">';
     echo ' <em>', WT_I18N::plural('maximum %d day', 'maximum %d days', 30, 30), '</em>';
     echo '</td></tr>';
     $infoStyle = get_block_setting($block_id, 'infoStyle', 'table');
     echo '<tr><td class="descriptionbox wrap width33">';
     echo WT_I18N::translate('Presentation style');
     echo '</td><td class="optionbox">';
     echo select_edit_control('infoStyle', array('list' => WT_I18N::translate('list'), 'table' => WT_I18N::translate('table')), null, $infoStyle, '');
     echo '</td></tr>';
     $calendar = get_block_setting($block_id, 'calendar');
     echo '<tr><td class="descriptionbox wrap width33">';
     echo WT_I18N::translate('Calendar');
     echo '</td><td class="optionbox">';
     echo select_edit_control('calendar', array('jewish' => WT_Date_Jewish::calendarName(), 'gregorian' => WT_Date_Gregorian::calendarName()), null, $calendar, '');
     echo '</td></tr>';
     $block = get_block_setting($block_id, 'block', true);
     echo '<tr><td class="descriptionbox wrap width33">';
     echo WT_I18N::translate('Add a scrollbar when block contents grow');
     echo '</td><td class="optionbox">';
     echo edit_field_yes_no('block', $block);
     echo '</td></tr>';
 }
Пример #4
0
} else {
    echo "<a href=\"calendar.php?cal={$cal}&amp;day={$cal_date->d}&amp;month={$cal_month}&amp;year={$cal_date->y}&amp;filterev={$filterev}&amp;filterof={$filterof}&amp;filtersx={$filtersx}&amp;action=today\">", WT_I18N::translate('View day'), "</a>";
}
if ($action == 'calendar') {
    echo ' | <span class="error">', WT_I18N::translate('View month'), '</span>';
} else {
    echo " | <a href=\"calendar.php?cal={$cal}&amp;day={$cal_date->d}&amp;month={$cal_month}&amp;year={$cal_date->y}&amp;filterev={$filterev}&amp;filterof={$filterof}&amp;filtersx={$filtersx}&amp;action=calendar\">", WT_I18N::translate('View month'), "</a>";
}
if ($action == 'year') {
    echo ' | <span class="error">', WT_I18N::translate('View year'), '</span>';
} else {
    echo " | <a href=\"calendar.php?cal={$cal}&amp;day={$cal_date->d}&amp;month={$cal_month}&amp;year={$cal_date->y}&amp;filterev={$filterev}&amp;filterof={$filterof}&amp;filtersx={$filtersx}&amp;action=year\">", WT_I18N::translate('View year'), "</a>";
}
echo '</td><td class="topbottombar width50">';
$n = 0;
foreach (array('gregorian' => WT_Date_Gregorian::calendarName(), 'julian' => WT_Date_Julian::calendarName(), 'jewish' => WT_Date_Jewish::calendarName(), 'french' => WT_Date_French::calendarName(), 'hijri' => WT_Date_Hijri::calendarName(), 'jalali' => WT_Date_Jalali::calendarName()) as $newcal => $cal_name) {
    $tmp = $cal_date->convertToCalendar($newcal);
    if ($tmp->inValidRange()) {
        if ($n++) {
            echo ' | ';
        }
        if (get_class($tmp) == get_class($cal_date)) {
            echo "<span class=\"error\">{$cal_name}</span>";
        } else {
            $newcalesc = urlencode($tmp->format('%@'));
            $tmpmonth = $tmp->format('%O');
            echo "<a href=\"calendar.php?cal={$newcalesc}&amp;day={$tmp->d}&amp;month={$tmpmonth}&amp;year={$tmp->y}&amp;filterev={$filterev}&amp;filterof={$filterof}&amp;filtersx={$filtersx}&amp;action={$action}\">{$cal_name}</a>";
        }
    }
}
echo "</td></tr>";
Пример #5
0
if (count($CALENDAR_FORMATS) == 1) {
    $CALENDAR_FORMATS[] = 'none';
}
foreach (array('none' => WT_I18N::translate('No calendar conversion'), 'gregorian' => WT_Date_Gregorian::calendarName(), 'julian' => WT_Date_Julian::calendarName(), 'french' => WT_Date_French::calendarName(), 'jewish' => WT_Date_Jewish::calendarName(), 'hijri' => WT_Date_Hijri::calendarName(), 'jalali' => WT_Date_Jalali::calendarName()) as $cal => $name) {
    echo '<option value="', $cal, '"';
    if ($CALENDAR_FORMATS[0] == $cal) {
        echo ' selected="selected"';
    }
    echo '>', $name, '</option>';
}
?>
					</select>

					<select id="NEW_CALENDAR_FORMAT1" name="NEW_CALENDAR_FORMAT1">
						<?php 
foreach (array('none' => WT_I18N::translate('No calendar conversion'), 'gregorian' => WT_Date_Gregorian::calendarName(), 'julian' => WT_Date_Julian::calendarName(), 'french' => WT_Date_French::calendarName(), 'jewish' => WT_Date_Jewish::calendarName(), 'hijri' => WT_Date_Hijri::calendarName(), 'jalali' => WT_Date_Jalali::calendarName()) as $cal => $name) {
    echo '<option value="', $cal, '"';
    if ($CALENDAR_FORMATS[1] == $cal) {
        echo ' selected="selected"';
    }
    echo '>', $name, '</option>';
}
?>
					</select></td>
				</tr>
				<tr>
					<td>
						<?php 
echo WT_I18N::translate('Use RIN number instead of GEDCOM ID'), help_link('USE_RIN');
?>
					</td>