Index: openacs-4/packages/calendar-portlet/www/calendar-full-portlet.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar-portlet/www/calendar-full-portlet.adp,v diff -u -r1.17 -r1.18 --- openacs-4/packages/calendar-portlet/www/calendar-full-portlet.adp 5 Sep 2003 07:14:16 -0000 1.17 +++ openacs-4/packages/calendar-portlet/www/calendar-full-portlet.adp 22 Sep 2003 10:04:39 -0000 1.18 @@ -19,60 +19,19 @@ %> - - - +
- - - +
- - -

- #calendar.Add_Item##calendar.Add_Item# -

- - -

- - - - - - - - - - - - - - - - - - + + @cal_nav;noquote@ +

+

+ @cal_stuff;noquote@ +
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.26 -r1.27 --- openacs-4/packages/calendar-portlet/www/calendar-full-portlet.tcl 5 Sep 2003 07:14:16 -0000 1.26 +++ openacs-4/packages/calendar-portlet/www/calendar-full-portlet.tcl 22 Sep 2003 10:04:39 -0000 1.27 @@ -37,17 +37,23 @@ } } + # get stuff out of the config array array set config $cf if {[empty_string_p $view]} { set view $config(default_view) } - set list_of_calendar_ids $config(calendar_id) +set scoped_p $config(scoped_p) +if {$scoped_p == "t"} { + set show_calendar_name_p 1 +} else { + set show_calendar_name_p 0 +} + if {[llength $list_of_calendar_ids] > 1} { - set force_calendar_id [calendar_have_private_p -return_id 1 -calendar_id_lis - t $list_of_calendar_ids [ad_conn user_id]] + set force_calendar_id [calendar_have_private_p -return_id 1 -calendar_id_list $list_of_calendar_ids [ad_conn user_id]] } else { set force_calendar_id [lindex $list_of_calendar_ids 0] } @@ -71,25 +77,157 @@ set return_url "[ns_conn url]?[ns_conn query]" set encoded_return_url [ns_urlencode $return_url] -set list_of_calendar_ids $config(calendar_id) +set cal_nav [dt_widget_calendar_navigation "" $view $date "page_num=$page_num"] -set base_url [calendar_portlet_display::get_url_stub $list_of_calendar_ids] +set item_template "\$item" -set scoped_p $config(scoped_p) -if {$scoped_p == "t"} { - set show_calendar_name_p 1 -} else { - set show_calendar_name_p 0 -} if {$create_p} { - set hour_template "\$localized_day_current_hour" - set item_add_template " \"Add" + set hour_template "\$hour" + set item_add_template "+" } else { set hour_template "\$hour" set item_add_template "" } -set calendar_list [calendar::calendar_list] +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 $previous_link \ + -next_nav_template $next_link \ + -item_template $item_template \ + -hour_template $hour_template \ + -date $current_date -start_hour 7 -end_hour 22 \ + -calendar_id_list $list_of_calendar_ids \ + -url_stub_callback "calendar_portlet_display::get_url_stub" \ + -show_calendar_name_p $show_calendar_name_p] +} + +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" \ + -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 $previous_link \ + -next_month_template $next_link \ + -show_calendar_name_p $show_calendar_name_p] +} + +if {$view == "list"} { + set sort_by [ns_queryget sort_by] + + set thirty_days [expr 60*60*24*30] + set start_date [ns_fmttime [expr [ns_time] - $thirty_days] "%Y-%m-%d 00:00"] + set end_date [ns_fmttime [expr [ns_time] + $thirty_days] "%Y-%m-%d 00:00"] + + set cal_stuff [calendar::list_display \ + -item_template $item_template \ + -date $current_date \ + -start_date $start_date \ + -end_date $end_date \ + -calendar_id_list $list_of_calendar_ids \ + -sort_by $sort_by \ + -url_template "?view=list&sort_by=\$order_by&page_num=$page_num" \ + -url_stub_callback "calendar_portlet_display::get_url_stub" \ + -show_calendar_name_p $show_calendar_name_p] +} + +if {$view == "year"} { + set cal_stuff "" +} + ad_return_template + + + + + + + + Index: openacs-4/packages/calendar-portlet/www/calendar-portlet.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar-portlet/www/calendar-portlet.adp,v diff -u -r1.10 -r1.11 --- openacs-4/packages/calendar-portlet/www/calendar-portlet.adp 17 Aug 2003 01:48:08 -0000 1.10 +++ openacs-4/packages/calendar-portlet/www/calendar-portlet.adp 22 Sep 2003 10:04:39 -0000 1.11 @@ -1,10 +1,26 @@ - +<% - + # + # Copyright (C) 2001, 2002 MIT + # + # This file is part of dotLRN. + # + # dotLRN is free software; you can redistribute it and/or modify it under the + # terms of the GNU General Public License as published by the Free Software + # Foundation; either version 2 of the License, or (at your option) any later + # version. + # + # dotLRN is distributed in the hope that it will be useful, but WITHOUT ANY + # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + # details. + # +%> + + +@cal_stuff;noquote@ -
Index: openacs-4/packages/calendar-portlet/www/calendar-portlet.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar-portlet/www/calendar-portlet.tcl,v diff -u -r1.22 -r1.23 --- openacs-4/packages/calendar-portlet/www/calendar-portlet.tcl 17 Aug 2003 01:48:08 -0000 1.22 +++ openacs-4/packages/calendar-portlet/www/calendar-portlet.tcl 22 Sep 2003 10:04:39 -0000 1.23 @@ -1,4 +1,3 @@ - # # Copyright (C) 2001, 2002 MIT # @@ -38,6 +37,7 @@ } } + # get stuff out of the config array array set config $cf set view $config(default_view) @@ -70,19 +70,133 @@ set current_date $date set date_format "YYYY-MM-DD HH24:MI" -set calendar_list [calendar::calendar_list] -set date [calendar::adjust_date -date $date -julian_date $julian_date] +set item_template "\$item" -if {$view == "list"} { - if {[empty_string_p $start_date]} { - set start_date $date +if {$create_p} { + set hour_template "\$hour" + set item_add_template "ADD" +} else { + set hour_template "\$hour" + set item_add_template "" +} + +# big switch on the view var +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" + } } - set ansi_list [split $start_date "- "] - set ansi_year [lindex $ansi_list 0] - set ansi_month [string trimleft [lindex $ansi_list 1] "0"] - set ansi_day [string trimleft [lindex $ansi_list 2] "0"] - set end_date [dt_julian_to_ansi [expr [dt_ansi_to_julian $ansi_year $ansi_month $ansi_day ] + $period_days]] + 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 $previous_link \ + -next_nav_template $next_link \ + -item_template $item_template \ + -hour_template $hour_template \ + -date $current_date -start_hour 7 -end_hour 22 \ + -calendar_id_list $list_of_calendar_ids \ + -url_stub_callback "calendar_portlet_display::get_url_stub" \ + -show_calendar_name_p $show_calendar_name_p] + } -ad_return_template +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 \ + -date $current_date \ + -calendar_id_list $list_of_calendar_ids \ + -url_stub_callback "calendar_portlet_display::get_url_stub" \ + -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" \ + -show_calendar_name_p $show_calendar_name_p] +} + +if {$view == "list"} { + set cal_stuff [calendar::list_display \ + -item_template $item_template \ + -date $current_date \ + -calendar_id_list $list_of_calendar_ids \ + -url_stub_callback "calendar_portlet_display::get_url_stub" \ + -prev_month_template $previous_link \ + -next_month_template $next_link \ + -show_calendar_name_p $show_calendar_name_p] +} + + +ad_return_template