Index: openacs-4/packages/calendar/www/view.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/view.tcl,v
diff -u -r1.9 -r1.10
--- openacs-4/packages/calendar/www/view.tcl 20 Nov 2002 17:22:11 -0000 1.9
+++ openacs-4/packages/calendar/www/view.tcl 17 May 2003 10:21:14 -0000 1.10
@@ -12,6 +12,14 @@
{julian_date ""}
{calendar_list:multiple ""}
{sort_by ""}
+} -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."
+ }
+ }
+ }
}
set package_id [ad_conn package_id]
@@ -25,13 +33,37 @@
# Set up some template
set item_template "\$item"
set hour_template "\$hour"
-set item_add_template "+"
+set item_add_template ""
+
# Depending on the view, make a different widget
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 "<"
+ }
+ }
+
+ 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 ">"
+ }
+ }
+
set cal_stuff [calendar::one_day_display \
- -prev_nav_template "<" \
- -next_nav_template ">" \
+ -prev_nav_template $previous_link \
+ -next_nav_template $next_link \
-item_template $item_template \
-hour_template $hour_template \
-date $date -start_hour 7 -end_hour 22 \
@@ -40,25 +72,71 @@
}
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 prev_w [clock format [clock scan "1 week ago" -base [clock scan $date]] -format "%Y-%m-%d"]}]} {
+ set previous_link ""
+ } else {
+ if {[catch {clock scan $prev_w}]} {
+ set previous_link ""
+ } else {
+ set previous_link "<"
+ }
+ }
+
+ 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 ">"
+ }
+ }
+
set cal_stuff [calendar::one_week_display \
-item_template $item_template \
-day_template "\$day - \$pretty_date ([_ calendar.Add_Item])" \
-date $date \
-calendar_id_list $calendar_list \
- -prev_week_template "<" \
- -next_week_template ">"
- ]
+ -prev_week_template $previous_link \
+ -next_week_template $next_link]
+
}
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 "<"
+ }
+ }
+
+ 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 ">"
+ }
+ }
+
set cal_stuff [calendar::one_month_display \
-item_template "$item_template" \
-day_template "\$day_number" \
-date $date \
-item_add_template "$item_add_template" \
-calendar_id_list $calendar_list \
- -prev_month_template "<" \
- -next_month_template ">"]
+ -prev_month_template $previous_link \
+ -next_month_template $next_link]
}
if {$view == "list"} {