Index: openacs-4/packages/calendar/tcl/calendar-display-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/tcl/Attic/calendar-display-procs.tcl,v diff -u -r1.35 -r1.36 --- openacs-4/packages/calendar/tcl/calendar-display-procs.tcl 26 May 2003 09:59:54 -0000 1.35 +++ openacs-4/packages/calendar/tcl/calendar-display-procs.tcl 30 May 2003 12:07:57 -0000 1.36 @@ -1,21 +1,124 @@ ad_library { - Utility functions for Displaying Calendar Things - NOTE: this needs some serious refactoring. This code is already refactored from Tcl scripts. - I'm working as fast as I can to fix this, but there is a LOT to fix (ben). + Utility functions for Displaying Calendar Things. Originally by Ben Adida, + now maintained by Dirk Gomez. + The procs in this file are only kept for backward compatibility. The calendar + package doesn't make use of these procs anymore and they will disappear in + release 5.1. - @author Ben Adida (ben@openforce.net) + @author Dirk Gomez (openacs@dirkgomez.de) @creation-date Jan 21, 2002 @cvs-id $Id$ } namespace eval calendar { - ad_proc -public one_week_display { + ad_proc -public -deprecated -warn one_month_display { {-calendar_id_list ""} + {-day_template "\$day_number"} + {-item_template "\$item"} + {-item_add_template ""} + {-date ""} + {-url_stub_callback ""} + {-show_calendar_name_p 1} + {-prev_month_template ""} + {-next_month_template ""} + } { + This proc is deprecated and the calendar package doesn't use it anymore. + It is kept for backward compatibility and will disappear in release 5.1. + (Dirk Gomez 30-May-2003) + + Creates a month widget with events for that month + + The url_stub_callback parameter allows a parameterizable URL stub + for each calendar_id. If the parameter is non-null, it is considered a proc + that can be called on a calendar_id to generate a URL stub. + } { + if {[empty_string_p $date]} { + set date [dt_systime] + } + + # If we were given no calendars, we assume we display the + # private calendar. It makes no sense for this to be called with + # no data whatsoever. + if {[empty_string_p $calendar_id_list]} { + set calendar_id_list [list [calendar_have_private_p -return_id 1 [ad_get_user_id]]] + } + + set items [ns_set create] + + + db_foreach select_monthly_items {} { + # Calendar name now set in query + # set calendar_name [calendar_get_name $calendar_id] + + # reset url stub + set url_stub "" + + # In case we need to dispatch to a different URL (ben) + if {![empty_string_p $url_stub_callback]} { + # Cache the stuff + if {![info exists url_stubs($calendar_id)]} { + set url_stubs($calendar_id) [$url_stub_callback $calendar_id] + } + + set url_stub $url_stubs($calendar_id) + } + + set item "$name" + set item "[subst $item_template]" + + if {![dt_no_time_p -start_time $start_time -end_time $end_time]} { + set item "$start_time $item" + } + + if {$show_calendar_name_p} { + append item " ($calendar_name)" + } + + # DRB: This ugly hack was added for dotlrn-events, to give us a way to + # flag event status in red in accordance with the spec. When calendar + # is rewritten we should come up with a way for objects derived from + # acs-events to render their own name summary and full descriptions. + + if { [string length $status_summary] > 0 } { + append item " $status_summary " + } + + append item "
" + + ns_set put $items $start_date $item + } + + + # Display stuff + if {[empty_string_p $item_add_template]} { + set day_number_template "$day_template" + } else { + set day_number_template "$day_template     $item_add_template" + } + + return [dt_widget_month -calendar_details $items -date $date \ + -master_bgcolor black \ + -header_bgcolor lavender \ + -header_text_color black \ + -header_text_size "+1" \ + -day_header_bgcolor lavender \ + -day_bgcolor white \ + -today_bgcolor #FFF8DC \ + -empty_bgcolor lightgrey \ + -day_text_color black \ + -prev_next_links_in_title 1 \ + -prev_month_template $prev_month_template \ + -next_month_template $next_month_template \ + -day_number_template $day_number_template] + } + + ad_proc -public -deprecated -warn one_week_display { + {-calendar_id_list ""} {-day_template "\$day   -   \$pretty_date"} {-item_template "\$item"} {-item_add_template ""} @@ -25,6 +128,10 @@ {-next_week_template ""} {-show_calendar_name_p 1} } { + This proc is deprecated and the calendar package doesn't use it anymore. + It is kept for backward compatibility and will disappear in release 5.1. + (Dirk Gomez 30-May-2003) + Creates a week widget The url_stub_callback parameter allows a parameterizable URL stub @@ -74,7 +181,7 @@ if {[dt_no_time_p -start_time $start_date -end_time $end_date]} { set time_details "" } else { - set time_details "$ansi_start_date - $ansi_end_date:" + set time_details "$pretty_start_date - $pretty_end_date:" } set item "$time_details $item_details" @@ -102,7 +209,7 @@ } - ad_proc -public one_day_display { + ad_proc -public -deprecated -warn one_day_display { {-date ""} {-calendar_id_list ""} {-hour_template {$hour}} @@ -114,6 +221,10 @@ {-url_stub_callback ""} {-show_calendar_name_p 1} } { + This proc is deprecated and the calendar package doesn't use it anymore. + It is kept for backward compatibility and will disappear in release 5.1. + (Dirk Gomez 30-May-2003) + Creates a day widget The url_stub_callback parameter allows a parameterizable URL stub @@ -172,7 +283,7 @@ set item $name set item_subst [subst $item_template] - if {[dt_no_time_p -start_time $ansi_start_date -end_time $ansi_end_date]} { + if {[dt_no_time_p -start_time $pretty_start_date -end_time $pretty_end_date]} { # Hack for no-time items set item "$item_subst" if {![empty_string_p $item_details]} { @@ -181,7 +292,7 @@ set ns_set_pos "X" } else { - set item "$ansi_start_date - $ansi_end_date: $item_subst" + set item "$pretty_start_date - $pretty_end_date: $item_subst" if {![empty_string_p $item_details]} { append item " ($item_details)" } @@ -209,4 +320,151 @@ -calendar_details $items -date $date -overlap_p 1] } + + ad_proc -public -deprecated -warn list_display { + {-date ""} + {-start_date ""} + {-end_date ""} + {-calendar_id_list ""} + {-item_template {$item}} + {-url_template {?sort_by=$order_by}} + {-url_stub_callback ""} + {-show_calendar_name_p 1} + {-sort_by "item_type"} + } { + This proc is deprecated and the calendar package doesn't use it anymore. + It is kept for backward compatibility and will disappear in release 5.1. + (Dirk Gomez 30-May-2003) + + create a list display of items + } { + # If we were given no calendars, we assume we display the + # private calendar. It makes no sense for this to be called with + # no data whatsoever. + if {[empty_string_p $calendar_id_list]} { + set calendar_id_list [list [calendar_have_private_p -return_id 1 [ad_get_user_id]]] + } + + # sort by cannot be empty + if {[empty_string_p $sort_by]} { + set sort_by "item_type" + } + + set date_format "YYYY-MM-DD HH24:MI" + set current_date $date + set items [ns_set create] + + # Loop through the calendars + foreach calendar_id $calendar_id_list { + set calendar_name [calendar_get_name $calendar_id] + + # In case we need to dispatch to a different URL (ben) + if {![empty_string_p $url_stub_callback]} { + set url_stub [$url_stub_callback $calendar_id] + } + + db_foreach select_list_items {} { + ns_log Notice "BMA-CHECK: test $name" + set item "$name" + set item [subst $item_template] + + if {$show_calendar_name_p} { + append item " ($calendar_name)" + } + + ns_set put $items $start_hour [list $pretty_date $pretty_start_date $pretty_end_date $pretty_weekday $item_type $item] + } + + } + + # Now we have the items in a big ns_set + # We call the widget maker + return [dt_widget_list -order_by $sort_by \ + -item_template $item_template \ + -calendar_details $items \ + -start_date $start_date \ + -end_date $end_date \ + -url_template $url_template] + + } + +# ad_proc -public list_display { +# {-date ""} +# {-calendar_id_list ""} +# {-item_template {$item}} +# {-url_stub_callback ""} +# {-show_calendar_name_p 1} +# } { +# Creates a list widget +# } { +# if {[empty_string_p $date]} { +# set date [dt_sysdate] +# } + +# set date_format "YYYY-MM-DD HH24:MI" +# set current_date $date + +# # If we were given no calendars, we assume we display the +# # private calendar. It makes no sense for this to be called with +# # no data whatsoever. +# if {[empty_string_p $calendar_id_list]} { +# set calendar_id_list [list [calendar_have_private_p -return_id 1 [ad_get_user_id]]] +# } + +# set items [ns_set create] + +# # Loop through the calendars +# foreach calendar_id $calendar_id_list { +# set calendar_name [calendar_get_name $calendar_id] + +# # In case we need to dispatch to a different URL (ben) +# if {![empty_string_p $url_stub_callback]} { +# set url_stub [$url_stub_callback $calendar_id] +# } + +# db_foreach select_day_items {} { +# # ns_log Notice "bma: one item" +# set item "$pretty_start_date - $pretty_end_date: $name" + +# if {$show_calendar_name_p} { +# append item " ($calendar_name)" +# } + +# set item [subst $item_template] + +# ns_set put $items $start_hour $item +# } + +# } + +# set return_html "Items for [util_AnsiDatetoPrettyDate $date]:

" + +# return $return_html +# } + + + }