Index: openacs-4/packages/calendar-portlet/www/calendar-full-portlet.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar-portlet/www/calendar-full-portlet.tcl,v diff -u -r1.21.2.3 -r1.21.2.4 --- openacs-4/packages/calendar-portlet/www/calendar-full-portlet.tcl 6 Mar 2003 21:40:57 -0000 1.21.2.3 +++ openacs-4/packages/calendar-portlet/www/calendar-full-portlet.tcl 13 Mar 2003 14:14:02 -0000 1.21.2.4 @@ -25,16 +25,19 @@ {page_num ""} {date ""} {julian_date ""} +} -properties { + } -validate { valid_date -requires { date } { if {![string equal $date ""]} { - if {[catch {set date [clock format [clock scan $date] -format "%Y%m%d"]} err]} { - ad_complain "Your input was not valid. It has to be in the form YYYYMMDD." + if {[catch {set date [clock format [clock scan $date] -format "%Y-%m-%d"]} err]} { + ad_complain "Your input ($date) was not valid. It has to be in the form YYYYMMDD." } } } } + # get stuff out of the config array array set config $cf if {[empty_string_p $view]} { @@ -88,9 +91,33 @@ } if {$view == "day"} { + + # Check that the previous and next days are in the tcl boundaries + # so that the calendar widget doesn't bomb when it creates the next/prev links + if {[catch {set yest [clock format [clock scan "1 day ago" -base [clock scan $date]] -format "%Y-%m-%d"]}]} { + set previous_link "" + } else { + if {[catch {clock scan $yest}]} { + set previous_link "" + } else { + set previous_link "\"back" + } + } + + if {[catch {set tomor [clock format [clock scan "1 day" -base [clock scan $date]] -format "%Y-%m-%d"]}]} { + set next_link "" + } else { + if {[catch {clock scan $tomor}]} { + set next_link "" + } else { + set next_link "\"forward" + } + } + + set cal_stuff [calendar::one_day_display \ - -prev_nav_template "\"back" \ - -next_nav_template "\"forward" \ + -prev_nav_template $previous_link \ + -next_nav_template $next_link \ -item_template $item_template \ -hour_template $hour_template \ -date $current_date -start_hour 7 -end_hour 22 \ @@ -100,28 +127,75 @@ } if {$view == "week"} { + + # Check that the previous and next weeks are in the tcl boundaries + # so that the calendar widget doesn't bomb when it creates the next/prev links + if {[catch {set last_w [clock format [clock scan "1 week ago" -base [clock scan $date]] -format "%Y-%m-%d"]}]} { + set previous_link "" + } else { + if {[catch {clock scan $last_w}]} { + set previous_link "" + } else { + set previous_link "\"back" + } + } + + if {[catch {set next_w [clock format [clock scan "1 week" -base [clock scan $date]] -format "%Y-%m-%d"]}]} { + set next_link "" + } else { + if {[catch {clock scan $next_w}]} { + set next_link "" + } else { + set next_link "\"forward" + } + } + set cal_stuff [calendar::one_week_display \ -item_template $item_template \ -day_template "\"Add\$day - \$pretty_date" \ -date $current_date \ -calendar_id_list $list_of_calendar_ids \ -url_stub_callback "calendar_portlet_display::get_url_stub" \ - -prev_week_template "\"back" \ - -next_week_template "\"forward" \ + -prev_week_template $previous_link \ + -next_week_template $next_link \ -show_calendar_name_p $show_calendar_name_p ] } if {$view == "month"} { + + # Check that the previous and next months are in the tcl boundaries + # so that the calendar widget doesn't bomb when it creates the next/prev links + if {[catch {set prev_m [clock format [clock scan "1 month ago" -base [clock scan $date]] -format "%Y-%m-%d"]}]} { + set previous_link "" + } else { + if {[catch {clock scan $prev_m}]} { + set previous_link "" + } else { + set previous_link "\"back" + } + } + + if {[catch {set next_m [clock format [clock scan "1 month" -base [clock scan $date]] -format "%Y-%m-%d"]}]} { + set next_link "" + } else { + if {[catch {clock scan $next_m}]} { + set next_link "" + } else { + set next_link "\"forward" + } + } + + set cal_stuff [calendar::one_month_display \ -item_template "$item_template" \ -day_template "\$day_number" \ -date $current_date \ -item_add_template "$item_add_template" \ -calendar_id_list $list_of_calendar_ids \ -url_stub_callback "calendar_portlet_display::get_url_stub" \ - -prev_month_template "\"back" \ - -next_month_template "\"forward" \ + -prev_month_template $previous_link \ + -next_month_template $next_link \ -show_calendar_name_p $show_calendar_name_p] } Index: openacs-4/packages/calendar-portlet/www/calendar-list-portlet.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar-portlet/www/calendar-list-portlet.tcl,v diff -u -r1.2.2.3 -r1.2.2.4 --- openacs-4/packages/calendar-portlet/www/calendar-list-portlet.tcl 6 Mar 2003 21:40:57 -0000 1.2.2.3 +++ openacs-4/packages/calendar-portlet/www/calendar-list-portlet.tcl 13 Mar 2003 14:14:02 -0000 1.2.2.4 @@ -26,16 +26,19 @@ {date ""} {julian_date ""} {sort_by ""} -} -validate { +} -properties { + +} -validate { valid_date -requires { date } { if {![string equal $date ""]} { - if {[catch {set date [clock format [clock scan $date] -format "%Y%m%d"]} err]} { + if {[catch {set date [clock format [clock scan $date] -format "%Y-%m-%d"]} err]} { ad_complain "Your input was not valid. It has to be in the form YYYYMMDD." } } } } + # get stuff out of the config array array set config $cf if {[empty_string_p $view]} {