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.57.8.9 -r1.57.8.10 --- openacs-4/packages/acs-templating/tcl/list-procs.tcl 25 Aug 2014 09:40:06 -0000 1.57.8.9 +++ openacs-4/packages/acs-templating/tcl/list-procs.tcl 27 Apr 2015 07:02:08 -0000 1.57.8.10 @@ -555,6 +555,9 @@ set last_row [expr {$first_row + ($groupsize + 1) * $page_size - 1}] set page_offset [expr {($page_group - 1) * $groupsize}] + # Obtain query which retrieves records count + set list_properties(count_query) [db_map count_query] + # Now wrap the provided query with the limit information set list_properties(page_query_substed) [db_map pagination_query] @@ -587,6 +590,7 @@ --dummy--query--name-- \ $list_properties(paginator_name) \ $list_properties(page_query_substed) \ + $list_properties(count_query) \ -pagesize $list_properties(page_size) \ -groupsize $list_properties(page_groupsize) \ -page_offset $page_offset \ @@ -986,8 +990,30 @@ return [template::paginator get_row_count $list_properties(paginator_name)] } +ad_proc -public template::list::get_rowcount { + -name:required +} { + Gets the full number of rows retrieved from this template::list. This number can + exceed number_of_pages * rows_per_page. If list is not paginated, size of the + multirow will be returned. Multirow must exist for count to succeed on a not + paginated list. + @param name Name of the list builder list for which you want the full number of rows. +} { + # Get an upvar'd reference to list_properties + get_reference -name $name + + if { $list_properties(page_size) eq "" || $list_properties(page_size) == 0 } { + if {![template::multirow exists {*}$list_properties(multirow)]} { + return {} + } + return [template::multirow size {*}$list_properties(multirow)] + } + + return [template::paginator get_full_row_count $list_properties(paginator_name)] +} + ad_proc -public template::list::orderby_clause { -name:required -orderby:boolean Fisheye: Tag 1.1 refers to a dead (removed) revision in file `openacs-4/packages/acs-templating/tcl/list-procs.xql'. Fisheye: No comparison available. Pass `N' to diff? Index: openacs-4/packages/acs-templating/tcl/paginator-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/paginator-procs.tcl,v diff -u -r1.19.2.7 -r1.19.2.8 --- openacs-4/packages/acs-templating/tcl/paginator-procs.tcl 10 Sep 2014 14:06:24 -0000 1.19.2.7 +++ openacs-4/packages/acs-templating/tcl/paginator-procs.tcl 27 Apr 2015 07:02:09 -0000 1.19.2.8 @@ -38,7 +38,7 @@ paginator::$command {*}$args } -ad_proc -public template::paginator::create { statement_name name query args } { +ad_proc -public template::paginator::create { statement_name name query count_query args } { Creates a paginator object. Performs an initial query to get the complete list of rows in the query result and caches the result for subsequent queries. @@ -53,6 +53,10 @@ @param query The actual query that returns the IDs of all rows in the results. Bind variables may be used. + @param count_query Query returning the total number of records retrieved by + the original paginator query. This is the full number of + records, possibly exceeding number_of_pages * rows_per_page. + @option timeout The lifetime of a query result in seconds, after which the query must be refreshed (if not reset). @@ -97,6 +101,9 @@ set cache_key $name:$query set row_ids [cache get $cache_key:row_ids] + + # full number of rows returned by original paginator query + set full_row_count [cache get $cache_key:full_row_count] # # GN: In the following line, we had instead of [::cache exists @@ -140,7 +147,7 @@ ns_write [ns_adp_parse -file $header_file] } ns_write [lindex $opts(printing_prefs) 6] - init $statement_name $name $query 1 + init $statement_name $name $query $count_query 1 ns_write [lindex $opts(printing_prefs) 7] set footer_file [lindex $opts(printing_prefs) 4] if { $footer_file ne "" } { @@ -164,10 +171,11 @@ } ad_script_abort } else { - init $statement_name $name $query + init $statement_name $name $query $count_query } } else { set opts(row_ids) $row_ids + set opts(full_row_count) $full_row_count set opts(context_ids) [cache get $cache_key:context_ids] } @@ -176,7 +184,7 @@ set opts(group_count) [get_group $name $opts(page_count)] } -ad_proc -private template::paginator::init { statement_name name query {print_p 0} } { +ad_proc -private template::paginator::init { statement_name name query count_query {print_p 0} } { Initialize a paginated query. Only called by create. } { get_reference @@ -282,6 +290,11 @@ set properties(row_ids) $ids cache set $name:$query:row_ids $ids $properties(timeout) } + + # Get full number of rows retrieved by original paginator query + set full_row_count [uplevel 3 [list db_string query $count_query]] + set properties(full_row_count) $full_row_count + cache set $name:$query:full_row_count $full_row_count $properties(timeout) } ad_proc -public template::paginator::get_page { name rownum } { @@ -559,6 +572,20 @@ return $properties(row_count) } +ad_proc -public template::paginator::get_full_row_count { name } { + Gets the total number of records returned by the original + paginator query. This is the 'true' row_count, which won't + be limited to number_of_pages * rows_per_page. + + @param name The reference to the paginator object. + + @return A number representing the full row count. +} { + get_reference + + return $properties(full_row_count) +} + ad_proc -public template::paginator::get_page_count { name } { Gets the total number of pages in the paginated query