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.14 -r1.15
--- openacs-4/packages/calendar/www/view-month-display.tcl 21 Jan 2004 11:41:11 -0000 1.14
+++ openacs-4/packages/calendar/www/view-month-display.tcl 15 Feb 2004 12:16:25 -0000 1.15
@@ -28,9 +28,11 @@
}
if {[exists_and_not_null calendar_id_list]} {
- set calendars_clause "and on_which_calendar in ([join $calendar_id_list ","]) and (cals.private_p='f' or (cals.private_p='t' and cals.owner_id= :user_id))"
+ set calendars_clause "and on_which_calendar in ([join $calendar_id_list ","]) \
+ and (cals.private_p='f' or (cals.private_p='t' and cals.owner_id= :user_id))"
} else {
- set calendars_clause "and ((cals.package_id= :package_id and cals.private_p='f') or (cals.private_p='t' and cals.owner_id= :user_id))"
+ set calendars_clause "and ((cals.package_id= :package_id and cals.private_p='f') \
+ or (cals.private_p='t' and cals.owner_id= :user_id))"
}
dt_get_info $date
@@ -48,21 +50,24 @@
if { [info exists prev_month_template] } {
set prev_month_url "[subst $prev_month_template]"
} else {
- set prev_month_url ""
+ set prev_month_url ""
}
if { [info exists next_month_template] } {
set next_month_url "[subst $next_month_template]"
} else {
- set next_month_url ""
+ set next_month_url ""
}
set first_day_of_week [lc_get firstdayofweek]
set last_day_of_week [expr [expr $first_day_of_week + 7] % 7]
-
set week_days [lc_get abday]
multirow create weekday_names weekday_short
for {set i 0} {$i < 7} {incr i} {
@@ -76,20 +81,19 @@
set last_date_in_month [dt_julian_to_ansi $last_julian_date_in_month]
set last_date_in_month_system [lc_time_conn_to_system "$last_date_in_month 23:59:59"]
-set number_day_cells 0
-
set day_number $first_day
set today_ansi_list [dt_ansi_to_list $today_date]
set today_julian_date [dt_ansi_to_julian [lindex $today_ansi_list 0] [lindex $today_ansi_list 1] [lindex $today_ansi_list 2]]
-multirow create days_of_a_month calendar_item item_id ansi_start_date ansi_start_time day_number calendar_name beginning_of_week_p end_of_week_p today_p outside_month_p full_item time_p
+# Create the multirow that holds the calendar information
+multirow create days_of_a_month calendar_item item_url ansi_start_date \
+ ansi_start_time day_number calendar_name beginning_of_week_p end_of_week_p \
+ today_p outside_month_p time_p url
-
-# Calculate number of greyed days
+# 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 ]
-# Adjust for i18n
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} {
@@ -98,27 +102,25 @@
} else {
set beginning_of_week_p f
}
- multirow append days_of_a_month "" "" [dt_julian_to_ansi [expr $first_julian_date_of_month + $current_day -1]] "" "" "" $beginning_of_week_p f "" t ""
+ multirow append days_of_a_month "" "" \
+ [dt_julian_to_ansi [expr $first_julian_date_of_month + $current_day -1]] \
+ "" "" "" $beginning_of_week_p f "" t "" ""
}
set current_day $first_julian_date_of_month
-# Set the necessary variables for the unified calendar query in views.xql.
-if {[string match [db_type] "postgresql"]} {
- set interval_limitation_clause " to_timestamp(:first_date_of_month_system,'YYYY-MM-DD HH24:MI:SS') and to_timestamp(:last_date_in_month_system, 'YYYY-MM-DD HH24:MI:SS')"
-} else {
- set interval_limitation_clause " to_date(:first_date_of_month_system,'YYYY-MM-DD HH24:MI:SS') and to_date(:last_date_in_month_system, 'YYYY-MM-DD HH24:MI:SS')"
-}
set order_by_clause " order by ansi_start_date, ansi_end_date"
set additional_limitations_clause ""
set additional_select_clause ""
+set interval_limitation_clause [db_map dbqd.calendar.www.views.month_interval_limitation]
db_foreach dbqd.calendar.www.views.select_items {} {
# Convert from system timezone to user timezone
set ansi_start_date [lc_time_system_to_conn $ansi_start_date]
set ansi_end_date [lc_time_system_to_conn $ansi_end_date]
- if { [string equal $ansi_start_date $ansi_end_date] && [string equal [lc_time_fmt $ansi_start_date "%T"] "00:00:00"] } {
+ 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
@@ -131,8 +133,17 @@
if {$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]
- multirow append days_of_a_month "" "" [dt_julian_to_ansi $current_day] "" $display_information(day_number) "" $display_information(beginning_of_week_p) $display_information(end_of_week_p) $display_information(today_p) f "" 0
+ 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 days_of_a_month "" "" [dt_julian_to_ansi $current_day] \
+ "" $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"
}
}
@@ -156,21 +167,40 @@
set item "$name"
set full_item "[subst $item_template]"
- 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 days_of_a_month $name $item_id [dt_julian_to_ansi $current_day] $ansi_start_time $display_information(day_number) $calendar_name $display_information(beginning_of_week_p) $display_information(end_of_week_p) $display_information(today_p) f $full_item $time_p
+ 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 days_of_a_month $full_item \
+ "cal-item-view?cal_item_id=$item_id" [dt_julian_to_ansi $current_day] \
+ $ansi_start_time $display_information(day_number) $calendar_name \
+ $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"
}
-
+# 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 days_of_a_month "" "" [dt_julian_to_ansi $current_day] "" $display_information(day_number) "" $display_information(beginning_of_week_p) $display_information(end_of_week_p) $display_information(today_p) f "" 0
- incr number_day_cells
+ 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 days_of_a_month "" "" [dt_julian_to_ansi $current_day] ""\
+ $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"
}
+# 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 days_of_a_month "" "" "" "" "" "" f f "" t "" 0
+ multirow append days_of_a_month "" "" "" "" "" "" f f "" t 0
}
}