Index: openacs-4/packages/acs-templating/tcl/list-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/list-procs.tcl,v diff -u -r1.27 -r1.28 --- openacs-4/packages/acs-templating/tcl/list-procs.tcl 9 Aug 2005 23:20:05 -0000 1.27 +++ openacs-4/packages/acs-templating/tcl/list-procs.tcl 4 Jun 2006 00:45:48 -0000 1.28 @@ -33,7 +33,7 @@ {-has_checkboxes:boolean} {-checkbox_name "checkbox"} {-orderby_name "orderby"} - {-row_pretty_plural "data"} + {-row_pretty_plural "#acs-templating.data#"} {-no_data ""} {-main_class "list"} {-sub_class ""} @@ -285,6 +285,7 @@ } # Set default for no_data + set row_pretty_plural [lang::util::localize $row_pretty_plural] set no_data [ad_decode $no_data "" [_ acs-templating.No_row_pretty_plural] $no_data] # Set ulevel to the level of the page, so we can access it later set list_properties(ulevel) "\#[expr [info level] - $ulevel]" @@ -336,8 +337,8 @@ -list_name $name \ -element_name $checkbox_name \ -spec { - label {} - display_template {} + label {} + display_template {} sub_class {narrow} html { align center } } @@ -428,20 +429,20 @@ template::list::filter::create \ -list_name $name \ -filter_name "page_size" \ - -spec [list label "Page Size" default_value 20 hide_p t] + -spec [list label "[_ acs-templating.Page_Size]" default_value 20 hide_p t] } if { (![empty_string_p $list_properties(page_size)] && $list_properties(page_size) != 0) || $list_properties(page_size_variable_p) == 1 } { # Check that we have either page_query or page_query_name if { [empty_string_p $list_properties(page_query)] && [empty_string_p $list_properties(page_query_name)] } { - error "When specifying a non-zero page_size, you must also provide either page_query or page_query_name" + error "[_ acs-templating.lt_When_specifying_a_non]" } # We create the selected page as a filter, so we get the filter,page thing out template::list::filter::create \ -list_name $name \ -filter_name "page" \ - -spec [list label "Page" default_value 1 hide_p t] + -spec [list label "[_ acs-templating.Page]" default_value 1 hide_p t] } # Done, prepare the list. This has to be done while we still have access to the caller's scope @@ -556,8 +557,9 @@ } # We need this uplevel so that the bind variables in the query will get bound at the caller's level + # The query has already been looked up so we need to pass a dummy query name uplevel $ulevel [list template::paginator create \ - $list_properties(page_query_name) \ + $list_properties(page_query_name) \ $list_properties(paginator_name) \ $list_properties(page_query_substed) \ -pagesize $list_properties(page_size) \ @@ -732,7 +734,7 @@ append __output "\"[join $__cols "\",\""]\"\n" } - ns_return 200 text/plain $__output + ns_return 200 text/csv $__output } @@ -1094,9 +1096,13 @@ # Thus, we need to do the dynamic columns above before this step set __adp_output [template -name $name -style $style] - # compile the template (this is the second compilation, if we're using a dynamic template -- I think) - set __list_code [template::adp_compile -string $__adp_output] + # set __adp_stub so includes work. Only fully qualified includes will work with this + set __list_code { + set __adp_stub "" + } + append __list_code [template::adp_compile -string $__adp_output] + # Paginator if { $list_properties(page_size_variable_p) == 1 } { template::util::list_to_multirow page_sizes {{name 10 value 10} {name 20 value 20} {name 50 value 50} {name 100 value 100}} @@ -1319,7 +1325,6 @@ if { [empty_string_p [string trim $label]] } { set label $filter_properties(null_label) } - switch $filter_properties(type) { singleval { set selected_p [exists_and_equal current_filter_value $value] @@ -1328,12 +1333,22 @@ if { ![exists_and_not_null current_filter_value] } { set selected_p 0 } else { - set selected_p [util_sets_equal_p $current_filter_value $value] + # Since here we have multiple values + # we set as selected_p the value that match any + # of the values present in the list + set selected_p 0 + foreach val $current_filter_value { + if { [util_sets_equal_p $val $value] } { + set selected_p 1 + break + } + } } } multivar { # Value is a list of { key value } lists # We only check the value whose key matches the filter name + set selected_p 0 foreach elm $value { foreach { elm_key elm_value } [lrange $elm 0 1] {} if { [string equal $elm_key $filter_properties(name)] } { @@ -1413,7 +1428,8 @@ url_html_title \ count \ add_url \ - selected_p + selected_p \ + type foreach filter_ref $list_properties(filter_refs) { @@ -1424,6 +1440,7 @@ # Loop over 'values' and 'url' simultaneously foreach elm $filter_properties(values) url $filter_properties(urls) selected_p $filter_properties(selected_p) add_url $filter_properties(add_urls) { + # 'label' is the first element, 'value' the second # We do an lrange here, otherwise values would be set wrong # in case someone accidentally supplies a list with too many elements, @@ -1434,17 +1451,25 @@ set label $filter_properties(null_label) } - template::multirow -local append filters \ - $filter_properties(name) \ - $filter_properties(label) \ - $filter_properties(clear_url) \ - [string_truncate -len 25 -- $label] \ - $value \ - $url \ - $label \ - $count \ - $add_url \ - $selected_p + if { [string equal $filter_properties(type) "multival"] } { + # We need to ns_urlencode the name to work + set filter_properties_name [ns_urlencode $filter_properties(name)] + } else { + set filter_properties_name $filter_properties(name) + } + + template::multirow -local append filters \ + $filter_properties_name \ + $filter_properties(label) \ + $filter_properties(clear_url) \ + [string_truncate -len 25 -- $label] \ + $value \ + $url \ + $label \ + $count \ + $add_url \ + $selected_p \ + $filter_properties(type) } } }