3 September 2005 * * $Id: calendar.php 6891 2010-01-31 18:15:51Z wooc $ * @package PhpGedView * @subpackage Calendar */ define('PGV_SCRIPT_NAME', 'calendar.php'); require './config.php'; require PGV_ROOT.'includes/functions/functions_print_lists.php'; if (isset($_REQUEST['cal'])) $cal = $_REQUEST['cal']; if (isset($_REQUEST['day'])) $day = $_REQUEST['day']; if (isset($_REQUEST['month'])) $month = $_REQUEST['month']; if (isset($_REQUEST['year'])) $year = $_REQUEST['year']; if (isset($_REQUEST['action'])) $action = $_REQUEST['action']; if (isset($_REQUEST['filterev'])) $filterev = $_REQUEST['filterev']; if (isset($_REQUEST['filterof'])) $filterof = $_REQUEST['filterof']; if (isset($_REQUEST['filtersx'])) $filtersx = $_REQUEST['filtersx']; // Set undefined parameters to defaults if (empty($cal )) $cal =''; if (empty($day )) $day =''; if (empty($month )) $month =''; if (empty($year )) $year =''; if (empty($action )) $action ='today'; if (empty($filterev)) $filterev='bdm'; if (empty($filterof)) $filterof='all'; if (empty($filtersx)) $filtersx=''; // Create a CalendarDate from the parameters $cal=urldecode($cal); // advance-year "year range" if (preg_match('/^(\d+)-(\d+)$/', $year, $match)) { if (strlen($match[1]) > strlen($match[2])) $match[2]=substr($match[1], 0, strlen($match[1])-strlen($match[2])).$match[2]; $ged_date=new GedcomDate("FROM {$cal} {$match[1]} TO {$cal} {$match[2]}"); $action='year'; } else // advanced-year "decade/century wildcard" if (preg_match('/^(\d+)(\?+)$/', $year, $match)) { $y1=$match[1].str_replace('?', '0', $match[2]); $y2=$match[1].str_replace('?', '9', $match[2]); $ged_date=new GedcomDate("FROM {$cal} {$y1} TO {$cal} {$y2}"); $action='year'; } else { if ($year<0) $year=(-$year)."B.C."; // need BC to parse date $ged_date=new GedcomDate("{$cal} {$day} {$month} {$year}"); $year=$ged_date->date1->y; // need negative year for year entry field. } $cal_date=&$ged_date->date1; $cal=urlencode($cal); // Invalid month? Pick a sensible one. if ($cal_date->CALENDAR_ESCAPE()=='@#DHEBREW@' && $cal_date->m==7 && $cal_date->y!=0 && !$cal_date->IsLeapYear()) $cal_date->m=6; // Fill in any missing bits with todays date $today=$cal_date->Today(); if ($cal_date->d==0) $cal_date->d=$today->d; if ($cal_date->m==0) $cal_date->m=$today->m; if ($cal_date->y==0) $cal_date->y=$today->y; $cal_date->SetJDfromYMD(); if ($year==0) $year=$cal_date->y; // Extract values from date $days_in_month=$cal_date->DaysInMonth(); $days_in_week=$cal_date->DaysInWeek(); $cal_month=$cal_date->Format('O'); $today_month=$today->Format('O'); // Invalid dates? Go to monthly view, where they'll be found. if ($cal_date->d>$days_in_month && $action=='today') $action='calendar'; // Print the header stuff print_header($pgv_lang['anniversary_calendar']); echo '
{$pgv_lang['individuals']} | "; echo "{$pgv_lang['families']} | "; echo "
";
// Avoid an empty unordered list
ob_start();
echo calendar_list_text($indis, "
| ';
echo "";
// Avoid an empty unordered list
ob_start();
echo calendar_list_text($fams, "
| ';
echo "
{$pgv_lang['total_indis']} ";
echo count($indis);
echo " "; echo Person::sexImage('M', 'small', 'vertical-align: middle', $pgv_lang['stat_males']), " {$males} "; echo Person::sexImage('F', 'small', 'vertical-align: middle', $pgv_lang['stat_females']), " {$females} "; if (count($indis)!=$males+$females) echo Person::sexImage('U', 'small', 'vertical-align: middle', $pgv_lang['all_people']), ' ', count($indis)-$males-$females; echo " | ";
echo "{$pgv_lang['total_fams']} ".count($fams)." | "; echo "
{$day_name} | "; } echo "
";
if ($d<1 || $d>$days_in_month)
if (count($cal_facts[0])>0) {
echo "{$pgv_lang['day_not_set']} "; echo " ";
echo calendar_list_text($cal_facts[0], "", "", false);
echo " ";
$cal_facts[0]=array();
} else
echo ' ';
else {
// Format the day number using the calendar
$tmp=new GedcomDate($cal_date->Format("@ {$d} O E")); $d_fmt=$tmp->date1->Format('j');
if ($d==$today->d && $cal_date->m==$today->m)
echo "{$d_fmt}";
else
echo "{$d_fmt}";
// Show a converted date
foreach (explode('_and_', $CALENDAR_FORMAT) as $convcal) {
$alt_date=$cal_date->convert_to_cal($convcal);
if ($alt_date->CALENDAR_ESCAPE()!=$cal_date->CALENDAR_ESCAPE()) {
list($alt_date->y, $alt_date->m, $alt_date->d)=$alt_date->JDtoYMD($cal_date->minJD+$d-1);
$alt_date->SetJDfromYMD();
echo "".$alt_date->Format("j M")."";
break;
}
}
echo "";
echo calendar_list_text($cal_facts[$d], "", "", false);
echo " ";
}
echo " | ";
if (($d+$cal_date->minJD-$week_start) % $days_in_week==0) {
echo '