Index: openacs-4/packages/calendar/www/view-list-display.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/view-list-display.tcl,v diff -u -r1.37 -r1.38 --- openacs-4/packages/calendar/www/view-list-display.tcl 14 Nov 2017 14:49:45 -0000 1.37 +++ openacs-4/packages/calendar/www/view-list-display.tcl 20 Mar 2018 08:42:19 -0000 1.38 @@ -1,42 +1,45 @@ -if { ![info exists period_days] } { - ad_page_contract { - Some documentation. - @author Sven Schmitt (s.lrn@gmx.net) - @cvs-id $Id$ - } { - {period_days:integer,notnull {[parameter::get -parameter ListView_DefaultPeriodDays -default 31]}} - } -validate { - valid_period_days -requires { period_days } { - # Tcl allows in for relative times just 6 digits, including the "+" - if {$period_days > 99999} { - ad_complain "Invalid time period." - } +ad_include_contract { + Display list calendar view + + Expects: + date: ignored, looks like passed ni for symmetry + start_date: startinig date for the list + period_days:integer + show_calendar_name_p (optional): 0 or 1 + calendar_id_list: optional list of calendar_ids + export: may be "print" +} { + {period_days:integer,notnull {[parameter::get -parameter ListView_DefaultPeriodDays -default 31]}} + {show_calendar_name_p:boolean 1} + {sort_by "start_date"} + {start_date {[clock format [clock seconds] -format "%Y-%m-%d 00:00"]}} + {cal_system_type ""} + {date:optional} + {calendar_id_list ""} + {export ""} + {return_url:optional} +} -validate { + valid_period_days -requires { period_days } { + # Tcl allows in for relative times just 6 digits, including the "+" + if {$period_days > 99999} { + ad_complain "Invalid time period" } } + valid_start_date -requires { start_date } { + if {[catch {clock scan $start_date} errorMsg]} { + ad_complain "invalid start date" + } + } } -if { ![info exists show_calendar_name_p] || $show_calendar_name_p eq "" } { - set show_calendar_name_p 1 -} -if { ![info exists sort_by] || $sort_by eq ""} { +# +# sort_by is passed down, maybe as empty +# +if {$sort_by eq ""} { set sort_by "start_date" } -if { ![info exists start_date] || $start_date eq "" } { - set start_date [clock format [clock seconds] -format "%Y-%m-%d 00:00"] -} elseif {[catch {clock scan $start_date} errorMsg]} { - ad_page_contract_handle_datasource_error "invalid start date" - ad_script_abort -} - -if { ![info exists end_date] || $end_date eq "" } { - set end_date [clock format [clock scan "+30 days" -base [clock scan $start_date]] -format "%Y-%m-%d 00:00"] -} elseif {[catch {clock scan $end_date} errorMsg]} { - ad_page_contract_handle_datasource_error "invalid end date" - ad_script_abort -} - -if { [info exists calendar_id_list] && $calendar_id_list ne "" } { +if { $calendar_id_list ne "" } { set calendars_clause [db_map dbqd.calendar.www.views.openacs_in_portal_calendar] } else { set calendars_clause [db_map dbqd.calendar.www.views.openacs_calendar] @@ -91,7 +94,7 @@ set interval_limitation_clause [db_map dbqd.calendar.www.views.list_interval_limitation] set order_by_clause " order by $sort_by" set additional_limitations_clause "" -if { [info exists cal_system_type] && $cal_system_type ne "" } { +if { $cal_system_type ne "" } { append additional_limitations_clause " and system_type = :cal_system_type " } @@ -141,7 +144,9 @@ set today "" } - set event_url [export_vars -base [site_node::get_url_from_object_id -object_id $cal_package_id]cal-item-view {return_url {cal_item_id $item_id}}] + set event_url [export_vars -base [site_node::get_url_from_object_id -object_id $cal_package_id]cal-item-view { + return_url {cal_item_id $item_id} + }] if { !$show_calendar_name_p } { set calendar_name "" @@ -207,8 +212,9 @@ set period_url_$i "[export_vars -base $self_url -url -entire_form {{period_days $i}}]\#calendar" } -if { [info exists export] && $export eq "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]] +if { $export eq "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 } 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.27 -r1.28 --- openacs-4/packages/calendar/www/view-month-display.tcl 7 Aug 2017 23:48:05 -0000 1.27 +++ openacs-4/packages/calendar/www/view-month-display.tcl 20 Mar 2018 08:42:19 -0000 1.28 @@ -1,13 +1,28 @@ +ad_include_contract { + Display one week calendar view + Expects: + date (empty string okay): YYYY-MM-DD + show_calendar_name_p (optional): 0 or 1 + calendar_id_list: optional list of calendar_ids + export: may be "print" +} { + {date ""} + {show_calendar_name_p:boolean 1} + {calendar_id_list ""} + {export ""} + {return_url:optional} +} + set system_type "" -if {![info exists date] || $date eq ""} { +if {$date eq ""} { # Default to today's 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 [lc_time_fmt $user_now_time "%x"] } -if { [info exists export] && $export ne "" } { +if { $export ne "" } { set exporting_p 1 } else { set exporting_p 0 @@ -19,11 +34,8 @@ set return_url [ad_urlencode "../"] } -if { ![info exists show_calendar_name_p] } { - set show_calendar_name_p 1 -} -if {[info exists calendar_id_list] && $calendar_id_list ne ""} { +if {$calendar_id_list ne ""} { set calendars_clause [db_map dbqd.calendar.www.views.openacs_in_portal_calendar] } else { set calendars_clause [db_map dbqd.calendar.www.views.openacs_calendar] @@ -167,7 +179,9 @@ -first_julian_date_of_month $first_julian_date_of_month] set current_day_ansi [dt_julian_to_ansi $current_day] - set add_url [export_vars -base ${calendar_url}cal-item-new {{date $current_day_ansi} {start_time ""} {end_time ""}}] + set add_url [export_vars -base ${calendar_url}cal-item-new { + {date $current_day_ansi} {start_time ""} {end_time ""} + }] multirow append items \ "" \ "" \ @@ -212,10 +226,14 @@ -first_julian_date_of_month $first_julian_date_of_month] set current_day_ansi [dt_julian_to_ansi $current_day] - set add_url [export_vars -base ${calendar_url}cal-item-new {{date $current_day_ansi} {start_time ""} {end_time ""}}] + set add_url [export_vars -base ${calendar_url}cal-item-new { + {date $current_day_ansi} {start_time ""} {end_time ""} + }] multirow append items \ $name \ - [export_vars -base [site_node::get_url_from_object_id -object_id $cal_package_id]cal-item-view {return_url {cal_item_id $item_id}}] \ + [export_vars -base [site_node::get_url_from_object_id -object_id $cal_package_id]cal-item-view { + return_url {cal_item_id $item_id} + }] \ $description \ $calendar_name \ [lc_time_fmt $current_day_ansi %Q] \ @@ -262,7 +280,9 @@ -first_julian_date_of_month $first_julian_date_of_month] set current_day_ansi [dt_julian_to_ansi $current_day] - set add_url [export_vars -base ${calendar_url}cal-item-new {{date $current_day_ansi} {start_time ""} {end_time ""}}] + set add_url [export_vars -base ${calendar_url}cal-item-new { + {date $current_day_ansi} {start_time ""} {end_time ""} + }] multirow append items \ "" \ @@ -333,7 +353,7 @@ } } -if { [info exists export] && $export eq "print" } { +if { $export eq "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 Index: openacs-4/packages/calendar/www/view-one-day-display.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/view-one-day-display.tcl,v diff -u -r1.43 -r1.44 --- openacs-4/packages/calendar/www/view-one-day-display.tcl 7 Feb 2018 17:39:54 -0000 1.43 +++ openacs-4/packages/calendar/www/view-one-day-display.tcl 20 Mar 2018 08:42:19 -0000 1.44 @@ -1,14 +1,30 @@ +ad_include_contract { + Display one day calendar view + + Expects: + date (required but empty string okay): YYYY-MM-DD + show_calendar_name_p (optional): 0 or 1 + start_display_hour (optional): 0-23 + end_display_hour (optional): 0-23 + calendar_id_list: optional list of calendar_ids + export: may be "print" +} { + {date} + {show_calendar_name_p:boolean 1} + {start_display_hour:integer 0} + {end_display_hour:integer 23} + {calendar_id_list ""} + {cal_system_type ""} + {export ""} + {return_url:optional} +} + # FIXME from sloanspace calendar, they have added a system_type attribute to # cal_items table, which can be null, class, community, or personal # this is used to figure out which CSS class to use, for now we set to # empty string to use generic cal-Item css class DAVEB 20070121 set system_type "" -#Expects: -# date (required but empty string okay): YYYY-MM-DD -# show_calendar_name_p (optional): 0 or 1 -# start_display_hour (optional): 0-23 -# end_display_hour (optional): 0-23 #Display constants, should match up with default styles in calendar.css. set hour_height_inside 43 @@ -18,22 +34,8 @@ set bump_right_delta 155 set bump_right_units px -set current_date $date -set pretty_date [lc_time_fmt $current_date %Q] -if { ![info exists show_calendar_name_p] } { - set show_calendar_name_p 1 -} - -if { ![info exists start_display_hour]} { - set start_display_hour 0 -} - -if { ![info exists end_display_hour]} { - set end_display_hour 23 -} - -if {[info exists calendar_id_list] && $calendar_id_list ne ""} { +if {$calendar_id_list ne ""} { set calendars_clause [db_map dbqd.calendar.www.views.openacs_in_portal_calendar] } else { set calendars_clause [db_map dbqd.calendar.www.views.openacs_calendar] @@ -45,11 +47,12 @@ set user_now_time [lc_time_system_to_conn $server_now_time] set date [lc_time_fmt $user_now_time "%F"] } +set current_date $date +set pretty_date [lc_time_fmt $current_date %Q] set package_id [ad_conn package_id] set user_id [ad_conn user_id] - multirow create items \ all_day_p \ style_class \ @@ -72,7 +75,7 @@ # Loop through the items without time set additional_limitations_clause " and to_char(start_date, 'HH24:MI') = to_char(end_date, 'HH24:MI')" -if { ([info exists cal_system_type] && $cal_system_type ne "") } { +if { $cal_system_type ne "" } { append additional_limitations_clause " and system_type = :cal_system_type " } set additional_select_clause "" @@ -84,15 +87,16 @@ #query but slows this one. db_foreach dbqd.calendar.www.views.select_all_day_items {} { - # 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"] - set event_url [export_vars -base [site_node::get_url_from_object_id -object_id $cal_package_id]cal-item-view {return_url {cal_item_id $item_id}}] + set event_url [export_vars -base [site_node::get_url_from_object_id -object_id $cal_package_id]cal-item-view { + return_url {cal_item_id $item_id} + }] #height will be overwritten once we know how the vertical hour span. multirow append items 1 "calendar-${system_type}Item" \ @@ -114,7 +118,7 @@ } set additional_limitations_clause " and to_char(start_date, 'HH24:MI') <> to_char(end_date, 'HH24:MI')" -if { [info exists cal_system_type] && $cal_system_type ne "" } { +if { $cal_system_type ne "" } { append additional_limitations_clause " and system_type = :cal_system_type " } set order_by_clause " order by to_char(start_date,'HH24:MI')" @@ -154,7 +158,7 @@ } set top [expr {($start_hour * ($hour_height_inside+$hour_height_sep)) - + ($start_minutes*$hour_height_inside/60)}] + + ($start_minutes*$hour_height_inside/60)}] set bottom [expr {($end_hour * ($hour_height_inside+$hour_height_sep)) + ($end_minutes*$hour_height_inside/60)}] set height [expr {$bottom - $top - 2}] @@ -164,7 +168,7 @@ if { ($start_seconds >= $previous_start && $start_seconds < $previous_end) || ($previous_start >= $start_seconds && $previous_start < $end_seconds) } { - incr bump_right $bump_right_delta + incr bump_right $bump_right_delta } } @@ -208,7 +212,6 @@ db_1row dbqd.calendar.www.views.select_day_info {} - set dates [lc_time_fmt $date "%q"] set curr_day_name [lc_time_fmt $date "%A"] set curr_month [lc_time_fmt $date "%B"] @@ -220,8 +223,10 @@ set grid_start $adjusted_start_display_hour set grid_first_hour [lc_time_fmt "$current_date $grid_start:00:00" "%X"] set grid_hour $grid_start -set grid_first_add_url [export_vars -base ${calendar_url}cal-item-new \ - {{date $current_date} {start_time $grid_hour} return_url}] +set grid_first_add_url [export_vars -base ${calendar_url}cal-item-new { + {date $current_date} {start_time $grid_hour} return_url +}] + incr grid_start multirow create grid hour add_url Index: openacs-4/packages/calendar/www/view-week-display.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/view-week-display.tcl,v diff -u -r1.28 -r1.29 --- openacs-4/packages/calendar/www/view-week-display.tcl 7 Aug 2017 23:48:05 -0000 1.28 +++ openacs-4/packages/calendar/www/view-week-display.tcl 20 Mar 2018 08:42:19 -0000 1.29 @@ -1,7 +1,20 @@ -#Expects: -# date (required but empty string okay): YYYY-MM-DD -# show_calendar_name_p (optional): 0 or 1 +ad_include_contract { + Display one week calendar view + Expects: + date (required but empty string okay): YYYY-MM-DD + show_calendar_name_p (optional): 0 or 1 + calendar_id_list: optional list of calendar_ids + export: may be "print" +} { + {date} + {show_calendar_name_p:boolean 1} + {calendar_id_list ""} + {cal_system_type ""} + {export ""} + {return_url:optional} +} + #Display constants, should match up with default styles in calendar.css. set day_width 70 set width_units px @@ -23,13 +36,7 @@ set day_width_$i $day_width } -set current_date $date - -if { ![info exists show_calendar_name_p] } { - set show_calendar_name_p 1 -} - -if {([info exists calendar_id_list] && $calendar_id_list ne "")} { +if {$calendar_id_list ne ""} { set calendars_clause [db_map dbqd.calendar.www.views.openacs_in_portal_calendar] } else { set calendars_clause [db_map dbqd.calendar.www.views.openacs_calendar] @@ -41,6 +48,7 @@ set user_now_time [lc_time_system_to_conn $server_now_time] set date [lc_time_fmt $user_now_time "%x"] } +set current_date $date set package_id [ad_conn package_id] set user_id [ad_conn user_id] @@ -89,7 +97,7 @@ set interval_limitation_clause [db_map dbqd.calendar.www.views.week_interval_limitation] set additional_limitations_clause "" set additional_select_clause [db_map dow] -if { ([info exists cal_system_type] && $cal_system_type ne "") } { +if { $cal_system_type ne "" } { append additional_limitations_clause " and system_type = :cal_system_type " } @@ -296,7 +304,7 @@ incr week_width [set day_width_$i] } -if { [info exists export] && $export eq "print" } { +if { $export eq "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