Copy to clipboard
*** tiki-calendar.php.orig 2004-01-05 10:30:06.000000000 -0600
--- tiki-calendar.php 2004-01-05 16:21:52.000000000 -0600
***************
*** 408,413 ****
--- 408,414 ----
$focus_prevmonth = mktime(0,0,0,$focus_month-1,$focus_day,$focus_year);
$focus_nextmonth = mktime(0,0,0,$focus_month+1,$focus_day,$focus_year);
+ // these smarty values are all Unix timestamps....
$smarty->assign('daybefore',$focus_prevday);
$smarty->assign('weekbefore',$focus_prevweek);
$smarty->assign('monthbefore',$focus_prevmonth);
***************
*** 421,456 ****
$weekdays = range(0,6);
$d = 60*60*24;
! $currentweek = date("W",$focusdate + $d) - 1;
$wd = date('w',$focusdate);
! #if ($wd == 0) $w = 7;
! #$wd--;
// calculate timespan for sql query
if ($_SESSION['CalendarViewMode'] == 'month') {
! $firstweek = date("W",mktime(0,0,0,$focus_month,2,$focus_year)) - 1;
! $lastweek = date("W",mktime(0,0,0,$focus_month+1,1,$focus_year)) - 1;
! if ($lastweek < $firstweek) {
! $lastweek += 52;
! $currentweek += 52;
! }
! $viewstart = mktime(0,0,0,1,(7*$firstweek) - 2,$focus_year);
! $viewend = mktime(0,0,-1,1,(7*$lastweek + 1) + 6,$focus_year);
! $numberofweeks = $lastweek - $firstweek;
} elseif ($_SESSION['CalendarViewMode'] == 'week') {
! $firstweek = $currentweek;
! $lastweek = $currentweek;
! $viewstart = $focusdate - ($wd * $d);
! $viewend = $viewstart + ((7 * $d) - 1);
! $numberofweeks = 0;
} else { // I assume that this means it's a day. It's scary what this does to $weekdays...
! $firstweek = $currentweek;
! $lastweek = $currentweek;
! $viewstart = $focusdate;
! $viewend = $focusdate + ($d - 1);
! $weekdays = array(date('w',$focusdate));
! $numberofweeks = 0;
}
$smarty->assign('viewstart',$viewstart);
$smarty->assign('viewend',$viewend);
$smarty->assign('numberofweeks',$numberofweeks);
--- 422,487 ----
$weekdays = range(0,6);
$d = 60*60*24;
! // this is the ISO standard week number.
! $currentweek = date("W",$focusdate);
! // the date is zero-based with 0 being Sunday.
$wd = date('w',$focusdate);
!
// calculate timespan for sql query
if ($_SESSION['CalendarViewMode'] == 'month') {
! $viewstart = mktime(0,0,0,$focus_month, 1, $focus_year);
! $TmpWeekday = date("w",$viewstart);
! // move viewstart back to Sunday....
! $viewstart -= $TmpWeekday * $d;
! // this is the last day of $focus_month
! $viewend = mktime(0,0,0,$focus_month + 1, 0, $focus_year);
! $TmpWeekday = date("w", $viewend);
! $viewend += (6 - $TmpWeekday) * $d;
! $viewend -= 1;
! // ISO weeks --- kinda mangled because ours begin on Sunday...
! $firstweek = date("W", $viewstart + $d);
! $lastweek = date("W", $viewend);
! $numberofweeks = $lastweek - $firstweek;
} elseif ($_SESSION['CalendarViewMode'] == 'week') {
! $firstweek = $currentweek;
! $lastweek = $currentweek;
! // start by putting $viewstart at midnight starting focusdate
! $viewstart = mktime(0,0,0,$focus_month, $focus_day, $focus_year);
! // then back up to the preceding Sunday;
! $viewstart -= $wd * $d;
! // then go to the end of the week for $viewend
! $viewend = $viewstart + ((7 * $d) - 1);
! $numberofweeks = 0;
} else { // I assume that this means it's a day. It's scary what this does to $weekdays...
! $firstweek = $currentweek;
! $lastweek = $currentweek;
! $viewstart = mktime(0,0,0,$focus_month, $focus_day, $focus_year);
! $viewend = $viewstart + ($d - 1);
! $weekdays = array(date('w',$focusdate));
! $numberofweeks = 0;
! }
!
! // untested (by me, anyway!) function grabbed from the php.net site:
! // [2004/01/05:rpg]
! function m_weeks($y, $m){
! // monthday array
! $monthdays = array(1=>31, 3=>31, 4=>30, 5=>31, 6=>30,7=>31,
! 8=>31, 9=>30, 10=>31, 11=>30, 12=>31);
! // weekdays remaining in a week starting on 7 - Sunday...(could be changed)
! $weekdays = array(7=>7, 1=>6, 2=>5, 3=>4, 4=>3, 5=>2, 6=>1);
! $date = mktime( 0, 0, 0, $m, 1, $y);
! $leap = date("L", $date);
! // if it is a leap year set February to 29 days, otherwise 28
! $monthdays[2] = ($leap ? 29 : 28);
! // get the weekday of the first day of the month
! $wn = strftime("%u",$date);
! $days = $monthdays[$m] - $weekdays[$wn];
! return (ceil($days/7) + 1);
}
+
+
+ // view start and viewend are unix timestamps
$smarty->assign('viewstart',$viewstart);
$smarty->assign('viewend',$viewend);
$smarty->assign('numberofweeks',$numberofweeks);
***************
*** 470,527 ****
$listtikievents = array();
}
for ($i=0;$i<=$numberofweeks;$i++) {
! $wee = $firstweek + $i;
! $weeks[] = $wee;
! foreach ($weekdays as $w) {
! $leday = array();
! // hrum. -2 and -1 are black magic. please exorcize if you can
! $dday = mktime(0,0,0,1,(7*($wee))+$w-2,$focus_year);
! $ddayend = mktime(0,0,0,1,(7*($wee))+$w-1,$focus_year);
! $cell[$i][$w]['day'] = $dday;
! if (isset($listevents["$dday"])) {
! $e = 0;
! foreach ($listevents["$dday"] as $le) {
! $leday["{$le['time']}$e"] = $le;
! $smarty->assign_by_ref('cellextra',$le["extra"]);
! $smarty->assign_by_ref('cellhead',$le["head"]);
! $smarty->assign_by_ref('cellprio',$le["prio"]);
! $smarty->assign_by_ref('cellcalname',$le["calname"]);
! $smarty->assign_by_ref('cellname',$le["name"]);
! $smarty->assign_by_ref('celldescription',$le["description"]);
! $leday["{$le['time']}$e"]["over"] = $smarty->fetch("tiki-calendar_box.tpl");
! $e++;
! }
! }
! if (isset($listtikievents["$dday"])) {
! $e = 0;
! foreach ($listtikievents["$dday"] as $lte) {
! $leday["{$lte['time']}$e"] = $lte;
! $smarty->assign('cellextra',"");
! $smarty->assign_by_ref('cellhead',$lte["head"]);
! $smarty->assign_by_ref('cellprio',$lte["prio"]);
! $smarty->assign_by_ref('cellcalname',$lte["calname"]);
! $smarty->assign_by_ref('cellname',$lte["name"]);
! $smarty->assign_by_ref('celldescription',$lte["description"]);
! $leday["{$lte['time']}$e"]["over"] = $smarty->fetch("tiki-calendar_box.tpl");
! $e++;
! }
! }
! if (is_array($leday)) {
! ksort($leday);
! $cell[$i][$w]['items'] = array_values($leday);
! }
! }
}
! $smarty->assign('currentweek',$currentweek);
! $smarty->assign('firstweek',$firstweek);
! $smarty->assign('lastweek',$lastweek);
$smarty->assign('weekdays',$weekdays);
$smarty->assign('weeks',$weeks);
$smarty->assign('daysnames',$daysnames);
$smarty->assign('cell',$cell);
$smarty->assign('var','');
--- 501,570 ----
$listtikievents = array();
}
+ define("weekInSeconds", 604800);
+ // note that number of weeks starts at ZERO (i.e., zero = 1 week to display).
for ($i=0;$i<=$numberofweeks;$i++) {
! // $wee is a week number....
! $wee = $firstweek + $i;
!
! $weeks[] = $wee;
! // $startOfWeek is a unix timestamp
! $startOfWeek = $viewstart + $i * weekInSeconds;
! foreach ($weekdays as $w) {
! $leday = array();
! $dday = $startOfWeek + $d * $w;
! $cell[$i][$w]['day'] = $dday;
! if (isset($listevents["$dday"])) {
! $e = 0;
! foreach ($listevents["$dday"] as $le) {
! $leday["{$le['time']}$e"] = $le;
! $smarty->assign_by_ref('cellextra',$le["extra"]);
! $smarty->assign_by_ref('cellhead',$le["head"]);
! $smarty->assign_by_ref('cellprio',$le["prio"]);
! $smarty->assign_by_ref('cellcalname',$le["calname"]);
! $smarty->assign_by_ref('cellname',$le["name"]);
! $smarty->assign_by_ref('celldescription',$le["description"]);
! $leday["{$le['time']}$e"]["over"] = $smarty->fetch("tiki-calendar_box.tpl");
! $e++;
! }
! }
! if (isset($listtikievents["$dday"])) {
! $e = 0;
! foreach ($listtikievents["$dday"] as $lte) {
! $leday["{$lte['time']}$e"] = $lte;
! $smarty->assign('cellextra',"");
! $smarty->assign_by_ref('cellhead',$lte["head"]);
! $smarty->assign_by_ref('cellprio',$lte["prio"]);
! $smarty->assign_by_ref('cellcalname',$lte["calname"]);
! $smarty->assign_by_ref('cellname',$lte["name"]);
! $smarty->assign_by_ref('celldescription',$lte["description"]);
! $leday["{$lte['time']}$e"]["over"] = $smarty->fetch("tiki-calendar_box.tpl");
! $e++;
! }
! }
! if (is_array($leday)) {
! ksort($leday);
! $cell[$i][$w]['items'] = array_values($leday);
! }
! }
}
! // firstweek, currentweek, and lastweek are all, I think,
! // ISO-8601 week indices. However, I find no indication that these
! // Smarty variables are ever read. [2004/01/05:rpg]
! // $smarty->assign('currentweek',$currentweek);
! // $smarty->assign('firstweek',$firstweek);
! // $smarty->assign('lastweek',$lastweek);
! // array of indices of days covered in the chart. 0-6 unless this is
! // a single day display.
$smarty->assign('weekdays',$weekdays);
+ // array of week cell items...
$smarty->assign('weeks',$weeks);
+ // array of week day names
$smarty->assign('daysnames',$daysnames);
+ // display information (not dead sure what this array type is).
$smarty->assign('cell',$cell);
$smarty->assign('var','');
***************
*** 530,532 ****
--- 573,587 ----
?>
+
+
+
+
+
+
+
+
+
+
+
+