Index: openacs-4/packages/calendar/www/mini-calendar.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/mini-calendar.tcl,v diff -u -r1.20.2.4 -r1.20.2.5 --- openacs-4/packages/calendar/www/mini-calendar.tcl 9 Sep 2013 16:44:26 -0000 1.20.2.4 +++ openacs-4/packages/calendar/www/mini-calendar.tcl 3 Oct 2013 07:39:46 -0000 1.20.2.5 @@ -1,8 +1,8 @@ -if {![exists_and_not_null base_url]} { +if {(![info exists base_url] || $base_url eq "")} { set base_url [ad_conn url] } -if {![exists_and_not_null date]} { +if {(![info exists date] || $date eq "")} { set date [dt_sysdate] } @@ -20,7 +20,7 @@ } -on_submit {} -if {[exists_and_not_null page_num]} { +if {([info exists page_num] && $page_num ne "")} { set page_num_formvar [export_vars -form {page_num}] set page_num "&page_num=$page_num" } else { @@ -29,8 +29,10 @@ } # Determine whether we need to pass on the period_days variable from the list view -if {[string equal $view list]} { - if {![exists_and_not_null period_days] || [string equal $period_days [parameter::get -parameter ListView_DefaultPeriodDays -default 31]]} { +if {$view eq "list"} { + if {(![info exists period_days] || $period_days eq "") + || $period_days eq [parameter::get -parameter ListView_DefaultPeriodDays -default 31] + } { set url_stub_period_days "" } else { set url_stub_period_days "&period_days=${period_days}" @@ -49,12 +51,12 @@ # Create row with existing views multirow create views name text active_p url foreach viewname {list day week month} { - if { [string equal $viewname $view] } { + if {$viewname eq $view} { set active_p t } else { set active_p f } - if {[string equal $viewname list]} { + if {$viewname eq "list"} { multirow append views [lang::util::localize $message_key_array($viewname)] $viewname $active_p \ "[export_vars -base $base_url {date {view $viewname}}]${page_num}${url_stub_period_days}" } else { @@ -88,7 +90,7 @@ set today [lc_time_fmt [dt_sysdate] "%q"] -if [string equal $view month] { +if {$view eq "month"} { set prev_year [clock format [clock scan "1 year ago" -base $now] -format "%Y-%m-%d"] set next_year [clock format [clock scan "1 year" -base $now] -format "%Y-%m-%d"] set prev_year_url "$base_url?view=$view&date=[ad_urlencode $prev_year]${page_num}${url_stub_period_days}" @@ -104,8 +106,8 @@ # show 3 months in a row - set new_row_p [expr $i / 3] -# if {($i != 0) && ([expr $i % 3] == 0)} { + set new_row_p [expr {$i / 3}] +# if {($i != 0) && ($i % 3 == 0)} { # set new_row_p t # } else { # set new_row_p f @@ -117,7 +119,7 @@ set current_month_p f } set target_date [clock format \ - [clock scan "[expr $i-$curr_month_idx] month" -base $now] -format "%Y-%m-%d"] + [clock scan "[expr {$i-$curr_month_idx}] month" -base $now] -format "%Y-%m-%d"] multirow append months $month $current_month_p $new_row_p \ "[export_vars -base $base_url {{date $target_date} view}]${page_num}${url_stub_period_days}" @@ -134,7 +136,7 @@ multirow create days_of_week day_short day_num for {set i 0} {$i < 7} {incr i} { multirow append days_of_week \ - [lindex $week_days [expr [expr $i + $first_day_of_week] % 7]] \ + [lindex $week_days [expr {[expr {$i + $first_day_of_week}] % 7}]] \ $i } @@ -143,14 +145,14 @@ set day_of_week 1 # Calculate number of active days - set active_days_before_month [expr [expr [dt_first_day_of_month $year $month]] -1 ] - set active_days_before_month [expr [expr $active_days_before_month + 7 - $first_day_of_week] % 7] + set active_days_before_month [expr {[dt_first_day_of_month $year $month] - 1} ] + set active_days_before_month [expr {($active_days_before_month + 7 - $first_day_of_week) % 7}] - set calendar_starts_with_julian_date [expr $first_julian_date_of_month - $active_days_before_month] - set day_number [expr $days_in_last_month - $active_days_before_month + 1] + set calendar_starts_with_julian_date [expr {$first_julian_date_of_month - $active_days_before_month}] + set day_number [expr {$days_in_last_month - $active_days_before_month + 1}] - for {set julian_date $calendar_starts_with_julian_date} {$julian_date <= [expr $last_julian_date + 7]} {incr julian_date} { - if {$julian_date > $last_julian_date_in_month && [string equal $end_of_week_p t] } { + for {set julian_date $calendar_starts_with_julian_date} {$julian_date <= $last_julian_date + 7} {incr julian_date} { + if {$julian_date > $last_julian_date_in_month && $end_of_week_p eq "t" } { break } set today_p f @@ -166,7 +168,7 @@ if {$julian_date == $first_julian_date_of_month} { set day_number 1 - } elseif {$julian_date == [expr $last_julian_date_in_month +1]} { + } elseif {$julian_date == $last_julian_date_in_month + 1} { set day_number 1 } @@ -203,7 +205,7 @@ set today_url "$base_url?view=day&date=[ad_urlencode [dt_sysdate]]${page_num}${url_stub_period_days}" -if { $view == "day" && [dt_sysdate] == $date } { +if { $view eq "day" && [dt_sysdate] == $date } { set today_p t } else { set today_p f