Index: openacs-4/packages/calendar/www/view-month-display.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/view-month-display.tcl,v diff -u -r1.20 -r1.21 --- openacs-4/packages/calendar/www/view-month-display.tcl 26 Aug 2006 00:50:19 -0000 1.20 +++ openacs-4/packages/calendar/www/view-month-display.tcl 15 May 2007 20:14:21 -0000 1.21 @@ -1,16 +1,18 @@ -if {![info exists add_p] || [string equal "" $add_p]} { - set add_p t -} -if {![info exists link_day_p] || [string equal "" $link_day_p]} { - set link_day_p t -} + +set system_type "" if {![info exists date] || [empty_string_p $date]} { # Default to todays date in the users (the connection) timezone set server_now_time [dt_systime] set user_now_time [lc_time_system_to_conn $server_now_time] - set date $user_now_time + set date [lc_time_fmt $user_now_time "%x"] } +if { [exists_and_not_null export] } { + set exporting_p 1 +} else { + set exporting_p 0 +} + dt_get_info $date if {[info exists url_stub_callback]} { @@ -20,55 +22,39 @@ set portlet_mode_p 1 } -set url_stub_callback "" -set page_num_urlvar "" - -if { [info exists calendar_id_list] } { - if {[llength $calendar_id_list] > 1} { - set force_calendar_id [calendar::have_private_p -return_id 1 -calendar_id_list $calendar_id_list -party_id [ad_conn user_id]] - } else { - set force_calendar_id [lindex $calendar_id_list 0] - } - - calendar::get -calendar_id $force_calendar_id -array force_calendar - set base_url [apm_package_url_from_id $force_calendar(package_id)] -} else { - set base_url "" -} - -if {![info exists return_url]} { - set return_url [ad_urlencode "../"] -} - if {[info exists portlet_mode_p] && $portlet_mode_p} { set page_num_urlvar "&page_num=$page_num" - if {![info exists return_url]} { - set return_url [ad_urlencode "../"] - } - set item_template "\${url_stub}cal-item-view?show_cal_nav=0&return_url=${return_url}&action=edit&cal_item_id=\$item_id" + set item_template "\${url_stub}cal-item-view?show_cal_nav=0&return_url=[ad_urlencode "../"]&action=edit&cal_item_id=\$item_id" set prev_month_template "?view=month&date=\[ad_urlencode \$prev_month\]&page_num=$page_num" set next_month_template "?view=month&date=\[ad_urlencode \$next_month\]&page_num=$page_num" set url_stub_callback "calendar_portlet_display::get_url_stub" -} elseif {![info exists item_template] || [string equal "" $item_template]} { - # allow item_template to be passed in as a parameter +} else { set item_template "cal-item-view?cal_item_id=\$item_id" -} -# allow prev_month_template and next_month_template to be passed in -if {![info exists prev_month_template] || [string equal "" $prev_month_template]} { - set prev_month_template "view?view=month&date=\[ad_urlencode \$prev_month\]" + set prev_month_template "view?view=month&\date=[ad_urlencode $prev_month]" + set next_month_template "view?view=month&\date=[ad_urlencode $next_month]" + set url_stub_callback "" + set page_num_urlvar "" + set base_url "" } -if {![info exists next_month_template] || [string equal "" $next_month_template]} { - set next_month_template "view?view=month&date=\[ad_urlencode \$next_month\]" -} if { ![info exists show_calendar_name_p] } { set show_calendar_name_p 1 } -if { ![info exists show_calendar_name_p] } { - set show_calendar_name_p 1 +if { [info exists calendar_id_list] } { + if {[llength $calendar_id_list] > 1} { + set force_calendar_id [calendar::have_private_p -return_id 1 -calendar_id_list $calendar_id_list -party_id [ad_conn user_id]] + } else { + set force_calendar_id [lindex $calendar_id_list 0] + } + + calendar::get -calendar_id $force_calendar_id -array force_calendar + set base_url [apm_package_url_from_id $force_calendar(package_id)] +} else { + set base_url "" } + if {[exists_and_not_null calendar_id_list]} { set calendars_clause [db_map dbqd.calendar.www.views.openacs_in_portal_calendar] } else { @@ -90,9 +76,9 @@ set next_month_url "[subst $next_month_template]" set first_day_of_week [lc_get firstdayofweek] -set last_day_of_week [expr [expr $first_day_of_week + 7] % 7] +set last_day_of_week [expr [expr $first_day_of_week + 6] % 7] -set week_days [lc_get abday] +set week_days [lc_get day] multirow create weekday_names weekday_short for {set i 0} {$i < 7} {incr i} { multirow append weekday_names [lindex $week_days [expr [expr $i + $first_day_of_week] % 7]] @@ -112,46 +98,61 @@ # Create the multirow that holds the calendar information -# NOTE: added show_calendarname_p to determine if we want to show the calendar name in [ ] multirow create items \ event_name \ event_url \ + description \ calendar_name \ + weekday \ + start_date \ + end_date \ + start_time \ + end_time \ status_summary \ - ansi_start_time \ day_number \ beginning_of_week_p \ end_of_week_p \ today_p \ outside_month_p \ time_p \ add_url \ - day_url + day_url \ + style_class # Calculate number of greyed days and then add them to the calendar mulitrow set greyed_days_before_month [expr [expr [dt_first_day_of_month $this_year $this_month]] -1 ] set greyed_days_before_month [expr [expr $greyed_days_before_month + 7 - $first_day_of_week] % 7] -for {set current_day 0} {$current_day < $greyed_days_before_month} {incr current_day} { - if {$current_day == 0} { - set beginning_of_week_p t - } else { - set beginning_of_week_p f +if { !$exporting_p } { + + # These "items" are for used for display purposes only. + for {set current_day 0} {$current_day < $greyed_days_before_month} {incr current_day} { + if {$current_day == 0} { + set beginning_of_week_p t + } else { + set beginning_of_week_p f + } + multirow append items \ + "" \ + "" \ + "" \ + "" \ + "" \ + "" \ + "" \ + "" \ + "" \ + "" \ + "" \ + $beginning_of_week_p \ + f \ + "" \ + t \ + "" \ + "" \ + "" \ + "" } - multirow append items \ - "" \ - "" \ - "" \ - "" \ - "" \ - "" \ - $beginning_of_week_p \ - f \ - "" \ - t \ - "" \ - "" \ - "" } set current_day $first_julian_date_of_month @@ -166,52 +167,52 @@ set ansi_start_date [lc_time_system_to_conn $ansi_start_date] set ansi_end_date [lc_time_system_to_conn $ansi_end_date] + # Localize + set pretty_weekday [lc_time_fmt $ansi_start_date "%A"] + set pretty_start_date [lc_time_fmt $ansi_start_date "%x"] + set pretty_end_date [lc_time_fmt $ansi_end_date "%x"] + set pretty_start_time [lc_time_fmt $ansi_start_date "%X"] + set pretty_end_time [lc_time_fmt $ansi_end_date "%X"] + if { [string equal $ansi_start_date $ansi_end_date] && \ [string equal [lc_time_fmt $ansi_start_date "%T"] "00:00:00"] } { set time_p 0 } else { set time_p 1 } - set ansi_start_time [lc_time_fmt $ansi_start_date "%X"] - set ansi_end_time [lc_time_fmt $ansi_end_date "%X"] - set julian_start_date [dt_ansi_to_julian_single_arg $ansi_start_date] - if {$current_day < $julian_start_date} { + if {!$exporting_p && $current_day < $julian_start_date} { for {} {$current_day < $julian_start_date} {incr current_day} { array set display_information \ [calendar::get_month_multirow_information \ -current_day $current_day \ -today_julian_date $today_julian_date \ -first_julian_date_of_month $first_julian_date_of_month] - if {$link_day_p} { - set day_link "?view=day&date=[dt_julian_to_ansi $current_day]&$page_num_urlvar" - } else { - set day_link "" - } multirow append items \ - "" \ - "" \ - "" \ - "" \ "" \ - $display_information(day_number) \ + "" \ + "" \ + "" \ + "" \ + "" \ + "" \ + "" \ + "" \ + "" \ + $display_information(day_number) \ $display_information(beginning_of_week_p) \ $display_information(end_of_week_p) \ $display_information(today_p) \ - f \ - 0 \ - "${base_url}cal-item-new?date=[dt_julian_to_ansi $current_day]&start_time=&end_time&return_url=$return_url" \ - $day_link - + f \ + 0 \ + "${base_url}cal-item-new?date=[dt_julian_to_ansi $current_day]&start_time=&end_time" \ + "?view=day&date=[dt_julian_to_ansi $current_day]&$page_num_urlvar" \ + "calendar-${system_type}Item" } } - if {[string equal $ansi_start_time "00:00"] && [string equal $ansi_end_time "00:00"]} { - set ansi_start_time "--" - } - # reset url stub set url_stub "" @@ -224,84 +225,101 @@ set url_stub $url_stubs($calendar_id) } - - array set display_information \ - [calendar::get_month_multirow_information \ - -current_day $current_day \ - -today_julian_date $today_julian_date \ - -first_julian_date_of_month $first_julian_date_of_month] - if {$link_day_p} { - set day_link "?view=day&date=[dt_julian_to_ansi $current_day]&$page_num_urlvar" - } else { - set day_link "" - } - multirow append items \ - $name \ - [subst $item_template] \ - $calendar_name \ - "" \ - $ansi_start_time \ - $display_information(day_number) \ - $display_information(beginning_of_week_p) \ - $display_information(end_of_week_p) \ - $display_information(today_p) \ - f \ - $time_p \ - "${base_url}cal-item-new?date=[dt_julian_to_ansi $current_day]&start_time=&end_time&return_url=$return_url" \ - $day_link -} - -# Add cells for remaining days inside the month -for {} {$current_day <= $last_julian_date_in_month} {incr current_day} { array set display_information \ [calendar::get_month_multirow_information \ -current_day $current_day \ -today_julian_date $today_julian_date \ -first_julian_date_of_month $first_julian_date_of_month] - if {$link_day_p} { - set day_link "?view=day&date=[dt_julian_to_ansi $current_day]&$page_num_urlvar" - } else { - set day_link "" - } - multirow append items \ - "" \ - "" \ - "" \ - "" \ - "" \ + $name \ + [subst $item_template] \ + $description \ + $calendar_name \ + $pretty_weekday \ + $pretty_start_date \ + $pretty_end_date \ + $pretty_start_time \ + $pretty_end_time \ + "" \ $display_information(day_number) \ - $display_information(beginning_of_week_p) \ + $display_information(beginning_of_week_p) \ $display_information(end_of_week_p) \ - $display_information(today_p) \ - f \ - 0 \ - "${base_url}cal-item-new?date=[dt_julian_to_ansi $current_day]&start_time=&end_time&return_url=$return_url" \ - $day_link - + $display_information(today_p) \ + f \ + $time_p \ + "${base_url}cal-item-new?date=[dt_julian_to_ansi $current_day]&start_time=&end_time" \ + "?view=day&date=[dt_julian_to_ansi $current_day]&$page_num_urlvar" \ + "calendar-${system_type}Item" } -# Add cells for remaining days outside the month -set remaining_days [expr [expr $first_day_of_week + 6 - $current_day % 7] % 7] +if { !$exporting_p } { -if {$remaining_days > 0} { - for {} {$current_day <= [expr $last_julian_date_in_month + $remaining_days]} {incr current_day} { + # These "items" are for used for display purposes only. + + # Add cells for remaining days inside the month + for {} {$current_day <= $last_julian_date_in_month} {incr current_day} { + array set display_information \ + [calendar::get_month_multirow_information \ + -current_day $current_day \ + -today_julian_date $today_julian_date \ + -first_julian_date_of_month $first_julian_date_of_month] + multirow append items \ - "" \ - "" \ - "" \ - "" \ - "" \ - "" \ - f \ - f \ - "" \ - t \ - 0 \ - "" \ - "" + "" \ + "" \ + "" \ + "" \ + "" \ + "" \ + "" \ + "" \ + "" \ + "" \ + $display_information(day_number) \ + $display_information(beginning_of_week_p) \ + $display_information(end_of_week_p) \ + $display_information(today_p) \ + f \ + 0 \ + "${base_url}cal-item-new?date=[dt_julian_to_ansi $current_day]&start_time=&end_time" \ + "?view=day&date=[dt_julian_to_ansi $current_day]&$page_num_urlvar" \ + "" + } + # Add cells for remaining days outside the month + set remaining_days [expr [expr $first_day_of_week + 6 - $current_day % 7] % 7] + + if {$remaining_days > 0} { + for {} {$current_day <= [expr $last_julian_date_in_month + $remaining_days]} {incr current_day} { + multirow append items \ + "" \ + "" \ + "" \ + "" \ + "" \ + "" \ + "" \ + "" \ + "" \ + "" \ + "" \ + f \ + f \ + "" \ + t \ + "" \ + "" \ + "" \ + "" + } } } + +if { [info exists export] && [string equal $export print] } { + set print_html [template::adp_parse [acs_root_dir]/packages/calendar/www/view-print-display [list &items items show_calendar_name_p $show_calendar_name_p]] + ns_return 200 text/html $print_html + ad_script_abort +} +