calendar_basic_month {-calendar_details "" -date "" -days_of_week "Sunday Monday Tuesday Wednesday Thursday Friday Saturday" -large_calendar_p 1 -master_bgcolor "black" -header_bgcolor "black" -header_text_color "white" -header_text_size "+2" -day_number_template {<!--\$julian_date--><font size=1>\$day_number</font>} -day_header_size 2 -day_header_bgcolor "#666666" -calendar_width "100%" -day_bgcolor "#DDDDDD" -day_text_color "white" -empty_bgcolor "white" -next_month_template "" -prev_month_template "" -prev_next_links_in_title 0 -fill_all_days 0 }What it does:
Returns a calendar for a specific month, with details supplied by Julian date. Defaults to this month. To specify details for the individual days (if large_calendar_p is set) put data in an ns_set calendar_details. The key is the Julian date of the day, and the value is a string (possibly with HTML formatting) that represents the details.Defined in: /web/philip/tcl/ad-calendar-widget.tcl
Source code:
arg_parser_for_calendar_basic_month $args
set selection [calendar_get_info_from_db $date]
set_variables_after_query
if { $calendar_details == "" } {
set calendar_details [ns_set create calendar_details]
}
set day_of_week $first_day_of_month
set julian_date $first_julian_date
set month_heading [format "%s %s" $month $year]
set next_month_url ""
set prev_month_url ""
if { $prev_month_template != "" } {
set ansi_date [ns_urlencode $prev_month]
set prev_month_url [subst $prev_month_template]
}
if { $next_month_template != "" } {
set ansi_date [ns_urlencode $next_month]
set next_month_url [subst $next_month_template]
}
# We offer an option to put the links to next and previous months in the title bar
if { $prev_next_links_in_title == 0 } {
set title "<td colspan=7 align=center><font size=$header_text_size color=$header_text_color><b>$month_heading</b></font></td>"
} else {
set title "
<td colspan=7>
<table width=100% cellpadding=0 cellspacing=0 border=0>
<tr>
<td align=left>$prev_month_url</td>
<td align=center><font size=$header_text_size color=$header_text_color><b>$month_heading</b></font></td>
<td align=right>$next_month_url</td>
</tr>
</table>
</td>
"
}
# Write out the header and the days of the week
append output "<table bgcolor=$master_bgcolor cellpadding=3 cellspacing=1 border=0 width=$calendar_width>
<tr bgcolor=$header_bgcolor>
$title
</tr>
<tr bgcolor=$day_header_bgcolor>"
foreach day_of_week $days_of_week {
append output "<td width=14% align=center><font face=\"Verdana,Arial,Helvetica\" size=$day_header_size color=$day_text_color><b>$day_of_week</b></font></td>"
}
append output "</tr><tr>"
if { $fill_all_days == 0 } {
for { set n 1} { $n < $first_day_of_month } { incr n } {
append output "<td bgcolor=$empty_bgcolor align=right valign=top></td>"
}
}
set day_of_week 1
set julian_date $first_julian_date
set day_number $first_day
while {1} {
if {$julian_date < $first_julian_date_of_month} {
set before_month_p 1
set after_month_p 0
} elseif {$julian_date > $last_julian_date_in_month} {
set before_month_p 0
set after_month_p 1
} else {
set before_month_p 0
set after_month_p 0
}
if {$julian_date == $first_julian_date_of_month} {
set day_number 1
} elseif {$julian_date > $last_julian_date} {
break
} elseif {$julian_date == [expr $last_julian_date_in_month +1]} {
set day_number 1
}
if { $day_of_week == 1} {
append output "\n<tr>\n"
}
set skip_day 0
if {$before_month_p || $after_month_p} {
append output "<td bgcolor=$empty_bgcolor align=right valign=top> "
if { $fill_all_days == 0 } {
set skip_day 1
} else {
append output "[subst $day_number_template] "
}
} else {
append output "<td bgcolor=$day_bgcolor align=right valign=top>[subst $day_number_template] "
}
if { (! $skip_day) && $large_calendar_p == 1 } {
append output "<div align=left>"
set calendar_day_index [ns_set find $calendar_details $julian_date]
while { $calendar_day_index >= 0 } {
set calendar_day [ns_set value $calendar_details $calendar_day_index]
ns_set delete $calendar_details $calendar_day_index
append output "$calendar_day"
set calendar_day_index [ns_set find $calendar_details $julian_date]
}
append output "</div>"
}
append output "</td>\n"
incr day_of_week
incr julian_date
incr day_number
if { $day_of_week > 7 } {
set day_of_week 1
append output "</tr>\n"
}
}
# There are two ways to display previous and next month link - this is the default
if { $prev_next_links_in_title == 0 } {
append output "
<tr bgcolor=white>
<td align=center colspan=7>$prev_month_url$next_month_url</td>
</tr>"
}
append output "</table>"
return $output