Index: openacs-4/packages/acs-tcl/tcl/widgets-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/widgets-procs.tcl,v diff -u -r1.17 -r1.18 --- openacs-4/packages/acs-tcl/tcl/widgets-procs.tcl 20 May 2011 08:26:58 -0000 1.17 +++ openacs-4/packages/acs-tcl/tcl/widgets-procs.tcl 27 Oct 2014 16:40:09 -0000 1.18 @@ -4,8 +4,13 @@ @cvs-id $Id$ } -ad_proc state_widget { {default ""} {select_name "usps_abbrev"}} "Returns a state selection box" { - +ad_proc us_state_widget { + {default ""} + {select_name "usps_abbrev"} +} { + Returns a state selection box. + This widget depends on the ref-us-states package. +} { set widget_value "\n" if { $default eq "" } { - if { [parameter::get -parameter SomeAmericanReadersP] } { + if { [parameter::get -parameter SomeAmericanReadersP -package_id [ad_conn subsite_id] -default 0] } { append widget_value " \n" } else { @@ -51,7 +62,14 @@ # teadams - It is usually more approprate to use html_select_options or # html_select_value_options. -ad_proc ad_generic_optionlist {items values {default ""}} "Use this to build select form fragments. Given a list of items and a list of values, will return the option tags with default highlighted as appropriate." { +ad_proc ad_generic_optionlist { + items + values + {default ""} +} { + Use this to build select form fragments. Given a list of items and a list of values, + will return the option tags with default highlighted as appropriate. +} { # items is a list of the items you would like the user to select from # values is a list of corresponding option values @@ -74,11 +92,15 @@ return {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31} } -ad_proc month_list {} "Returns list of month abbreviations" { +ad_proc month_list {} { + Returns list of month abbreviations +} { return {Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec} } -ad_proc long_month_list {} "Returns list of months" { +ad_proc long_month_list {} { + Returns list of months +} { return {January February March April May June July August September October November December} } @@ -87,7 +109,11 @@ return {1 2 3 4 5 6 7 8 9 10 11 12} } -ad_proc future_years_list {{num_year 10}} "Returns a list containing the next num_year years in the future." { +ad_proc future_years_list { + {num_year 10} +} { + Returns a list containing the next num_year years in the future. +} { set year [ns_fmttime [ns_time] %Y] set counter 0 while {$counter < $num_year } { @@ -103,7 +129,16 @@ # if pad_to_two_p is 1, the option values will be # padded to 2 digites with a leading 0 -ad_proc ad_integer_optionlist {start_value end_value {default ""} { pad_to_two_p 0} } "Produces an optionlist for a range of integers from start_value to end_value. If default matches one of the options, it is selection. If pad_to_two_p is 1, the option values will be padded to 2 digites with a leading 0." { +ad_proc ad_integer_optionlist { + start_value + end_value + {default ""} + { pad_to_two_p 0} +} { + Produces an optionlist for a range of integers from start_value to end_value. + If default matches one of the options, it is selection. If pad_to_two_p is 1, + the option values will be padded to 2 digites with a leading 0. +} { # items is a list of the items you would like the user to select from # values is a list of corresponding option values # default is the value of the item to be selected @@ -145,46 +180,45 @@ set value [lindex [split [ns_localsqltimestamp] " "] 0] } - set date_parts [split $value "-"] if { $value eq "" } { set month "" set day "" set year "" } else { - set date_parts [split $value "-"] - set month [lindex $date_parts 1] - set year [lindex $date_parts 0] - set day [lindex $date_parts 2] + lassign [split $value "-"] year month day + # trim the day, in case we get as well a time stamp + regexp {^([0-9]+) } $day _ day } set output " " + append output [subst {  + }] return $output } ad_proc ad_db_select_widget { - { - -size 0 - -multiple 0 - -default {} - -option_list {} - -blank_if_no_db 0 - -hidden_if_one_db 0 - -bind {} - } - statement_name sql_qry name + {-size 0} + {-multiple 0} + {-default {}} + {-option_list {}} + {-blank_if_no_db 0} + {-hidden_if_one_db 0} + {-bind {}} + statement_name + sql_qry + name } { given a sql query this generates a select group. If there is only one value it returns the text and a hidden variable setting that value. @@ -210,10 +244,10 @@ if {$option_list ne ""} { foreach opt $option_list { incr count - set item [lindex $opt 1] - set value [lindex $opt 0] + lassign $opt value item if { (!$multiple && $value eq $default ) - || ($multiple && [lsearch -exact $default $value] > -1)} { + || ($multiple && $value in $default) + } { append retval "\n" } else { append retval "\n" @@ -234,22 +268,23 @@ set item [ns_set value $selection 0] set value [ns_set value $selection 1] if { (!$multiple && $value eq $default ) - || ($multiple && [lsearch -exact $default $value] > -1)} { + || ($multiple && $value in $default) + } { append retval "\n" } else { append retval "\n" } } if_no_rows { if {$default ne ""} { - return "\n" + return "\n" } else { return {} } } } if { $count == 1 || ($dbcount == 1 && $hidden_if_one_db) } { - return "$item\n" + return "$item\n" } elseif {!$count && !$dbcount && $blank_if_no_db} { return {} } else { @@ -264,34 +299,6 @@ } } -ad_proc currency_widget {{default ""} {select_name "currency_code"} {size_subtag "size=\"4\""}} "Returns a currency selection box" { - - set widget_value "\n" - return $widget_value -} - ad_proc ad_html_colors {} "Returns an array of HTML colors and names." { return { { Black 0 0 0 } @@ -373,7 +380,13 @@ } } -ad_proc ad_color_widget { name default { use_js 0 } } "Returns a color selection widget, optionally using JavaScript. Default is a string of the form '0,192,255'." { +ad_proc ad_color_widget { + name + default + { use_js 0 } +} { + Returns a color selection widget, optionally using JavaScript. Default is a string of the form '0,192,255'. +} { set out "