• Publicity: Public Only All

paginator-procs.tcl

Query paginator for the ArsDigita Templating System

Location:
packages/acs-templating/tcl/paginator-procs.tcl
Author:
Karl Goldstein <karlg@arsdigita.com>
CVS Identification:
$Id: paginator-procs.tcl,v 1.36 2024/09/11 06:15:48 gustafn Exp $

Procedures in this file

Detailed information

template::paginator (public)

 template::paginator command [ args... ]

pagination object. Please see the individual command for their arguments.

Parameters:
command (required)
See Also:

Partial Call Graph (max 5 caller/called nodes):
%3 template::list::get_rowcount template::list::get_rowcount (public) template::paginator template::paginator template::list::get_rowcount->template::paginator template::list::page_get_ids template::list::page_get_ids (public) template::list::page_get_ids->template::paginator template::list::page_get_rowcount template::list::page_get_rowcount (public) template::list::page_get_rowcount->template::paginator template::list::prepare template::list::prepare (public) template::list::prepare->template::paginator template::list::render template::list::render (public) template::list::render->template::paginator

Testcases:
No testcase defined.

template::paginator::create (public)

 template::paginator::create statement_name name 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.

Parameters:
statement_name (required)
A query name. This is overwritten by the contents of the "query" parameter if it is not the empty string.
name (required)
A unique name corresponding to the query being paginated, including specific values in the where clause and sorting specified in the order by clause.
query (required)
The actual query that returns the IDs of all rows in the results. Bind variables may be used.
Options:
-timeout
The lifetime of a query result in seconds, after which the query must be refreshed (if not reset).
-pagesize
The number of rows to display on a single page.
-groupsize
The number of pages in a group, for UI purposes. This is useful for result sets which span several pages. For example, if you have 1000 results at 10 results per page, that will leave you with 100 pages and you may not want to display 1-100 in the UI. In this case, setting a groupsize of 10 will allow you to display pages 1-10, then 11-20, and so on. The default groupsize is 10.
-contextual
Boolean indicating whether the pagination interface presented to the user will provide some other contextual clue in addition or instead of page number, such as the first few letters of a title or date. By default, the second column in the result set returned by query will be used as the context.
-page_offset
The first page in a set of page groups to be created by this paginator. This can be used to slice very large sets of page groups into paginators, cached separately (be sure to name each page group's paginator uniquely if you're caching pagination query results). Very useful since filling the cache for an entire set of page groups can be very costly, and since often only the first few pages of items (for instance, forum threads) are visited through the pagination interface. The list builder provides an example of how to do this.

Partial Call Graph (max 5 caller/called nodes):
%3 ad_return_top_of_page ad_return_top_of_page (public) ad_script_abort ad_script_abort (public) security::csp::nonce security::csp::nonce (public) template::adp_level template::adp_level (public) template::cache template::cache (public) template::paginator::create template::paginator::create template::paginator::create->ad_return_top_of_page template::paginator::create->ad_script_abort template::paginator::create->security::csp::nonce template::paginator::create->template::adp_level template::paginator::create->template::cache

Testcases:
No testcase defined.

template::paginator::get_all_row_ids (public)

 template::paginator::get_all_row_ids name

Gets a list of IDs in the master ID list generated by the initial query submitted for pagination. IDs are typically primary key values.

Parameters:
name (required)
The reference to the paginator object.
Returns:
A Tcl list of row identifiers.

Partial Call Graph (max 5 caller/called nodes):
%3 template::paginator::get_reference template::paginator::get_reference (private) template::paginator::get_all_row_ids template::paginator::get_all_row_ids template::paginator::get_all_row_ids->template::paginator::get_reference

Testcases:
No testcase defined.

template::paginator::get_context (public)

 template::paginator::get_context name datasource pages

Gets the context cues for a set of pages in the form of a multirow data source with 3 columns: rownum (starting with 1); page (number of the page); and context (a short string such as the first few letters of a name or title). The context cues may be used in the paging interface along with or instead of page numbers. This command is only valid if the contextual option is specified when creating the paginator.

Parameters:
name (required)
The reference to the paginator object.
datasource (required)
The name of the multirow datasource to create
pages (required)
A Tcl list of page numbers.

Partial Call Graph (max 5 caller/called nodes):
%3 template::paginator::get_reference template::paginator::get_reference (private) template::paginator::get_context template::paginator::get_context template::paginator::get_context->template::paginator::get_reference

Testcases:
No testcase defined.

template::paginator::get_data (public)

 template::paginator::get_data statement_name name datasource query \
    id_column page

Sets a multirow data source with data for the rows on the current page. The pseudocolumn "all_rownum" is added to each row, indicating the index of the row relative to all rows across all pages.

Parameters:
statement_name (required)
name (required)
The reference to the paginator object.
datasource (required)
The name of the datasource to create.
query (required)
The query to execute, containing IN (CURRENT_PAGE_SET).
id_column (required)
The name of the ID column in the display query (required to order rows properly).
page (required)

Partial Call Graph (max 5 caller/called nodes):
%3 ns_dbquotelist ns_dbquotelist template::paginator::get_row template::paginator::get_row (public) template::paginator::get_row_ids template::paginator::get_row_ids (public) template::util::list_to_lookup template::util::list_to_lookup (public) template::paginator::get_data template::paginator::get_data template::paginator::get_data->ns_dbquotelist template::paginator::get_data->template::paginator::get_row template::paginator::get_data->template::paginator::get_row_ids template::paginator::get_data->template::util::list_to_lookup

Testcases:
No testcase defined.

template::paginator::get_display_info (public)

 template::paginator::get_display_info name datasource page

Make paginator display properties available as a onerow data source:

next_page: following page or empty string if at end
previous_page: preceding page or empty string if at beginning
next_group: page that begins the next page group or empty string if at end
previous_group: page that begins the last page group or empty string if at endl.
page_count: the number of pages

Parameters:
name (required)
The reference to the paginator object.
datasource (required)
The name of the onerow datasource to create
page (required)
A page number representing the reference point from which the display properties are calculated.

Partial Call Graph (max 5 caller/called nodes):
%3 template::paginator::get_group template::paginator::get_group (public) template::paginator::get_reference template::paginator::get_reference (private) template::paginator::get_display_info template::paginator::get_display_info template::paginator::get_display_info->template::paginator::get_group template::paginator::get_display_info->template::paginator::get_reference

Testcases:
No testcase defined.

template::paginator::get_full_row_count (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.

Parameters:
name (required)
The reference to the paginator object.
Returns:
A number representing the full row count.

Partial Call Graph (max 5 caller/called nodes):
%3 template::paginator::get_reference template::paginator::get_reference (private) template::paginator::get_full_row_count template::paginator::get_full_row_count template::paginator::get_full_row_count->template::paginator::get_reference

Testcases:
No testcase defined.

template::paginator::get_group (public)

 template::paginator::get_group name pagenum

Calculates the page group in which the specified page is located.

Parameters:
name (required)
The reference to the paginator object.
pagenum (required)
A number ranging from one to the number of pages in the query result.
Returns:
A number ranging from one to the number of groups in the query result, as determined by both the page size and the group size. This number represents the page group number that the specified page lies in.

Partial Call Graph (max 5 caller/called nodes):
%3 template::paginator::create template::paginator::create (public) template::paginator::get_group template::paginator::get_group template::paginator::create->template::paginator::get_group template::paginator::get_display_info template::paginator::get_display_info (public) template::paginator::get_display_info->template::paginator::get_group template::paginator::get_reference template::paginator::get_reference (private) template::paginator::get_group->template::paginator::get_reference

Testcases:
No testcase defined.

template::paginator::get_group_count (public)

 template::paginator::get_group_count name

Gets the total number of groups in the paginated query

Parameters:
name (required)
The reference to the paginator object.
Returns:
A number representing the group count.

Partial Call Graph (max 5 caller/called nodes):
%3 template::paginator::get_reference template::paginator::get_reference (private) template::paginator::get_group_count template::paginator::get_group_count template::paginator::get_group_count->template::paginator::get_reference

Testcases:
No testcase defined.

template::paginator::get_groups (public)

 template::paginator::get_groups name group count

Determines the set of groups to which a group belongs, and calculates the starting page of each group in that set.

Parameters:
name (required)
The reference to the paginator object.
group (required)
A number ranging from one to the number of page groups in the query result.
count (required)
The desired size of the group set.
Returns:
A Tcl list of page numbers.

Partial Call Graph (max 5 caller/called nodes):
%3 template::paginator::get_reference template::paginator::get_reference (private) template::paginator::get_groups template::paginator::get_groups template::paginator::get_groups->template::paginator::get_reference

Testcases:
No testcase defined.

template::paginator::get_page (public)

 template::paginator::get_page name rownum

Calculates the page on which the specified row is located.

Parameters:
name (required)
The reference to the paginator object.
rownum (required)
A number ranging from one to the number of rows in the query result, representing the number of a row therein.
Returns:
A number ranging from one to the number of pages in the query result, representing the number of the page the specified row is located in.

Partial Call Graph (max 5 caller/called nodes):
%3 template::paginator::create template::paginator::create (public) template::paginator::get_page template::paginator::get_page template::paginator::create->template::paginator::get_page template::paginator::get_reference template::paginator::get_reference (private) template::paginator::get_page->template::paginator::get_reference

Testcases:
No testcase defined.

template::paginator::get_page_count (public)

 template::paginator::get_page_count name

Gets the total number of pages in the paginated query

Parameters:
name (required)
The reference to the paginator object.
Returns:
A number representing the page count.

Partial Call Graph (max 5 caller/called nodes):
%3 template::paginator::get_reference template::paginator::get_reference (private) template::paginator::get_page_count template::paginator::get_page_count template::paginator::get_page_count->template::paginator::get_reference

Testcases:
No testcase defined.

template::paginator::get_pages (public)

 template::paginator::get_pages name group

Gets a list of pages in a group, truncating if appropriate at the end.

Parameters:
name (required)
The reference to the paginator object.
group (required)
A number ranging from one to the number of page groups in the query result.
Returns:
A Tcl list of page numbers.

Partial Call Graph (max 5 caller/called nodes):
%3 template::paginator::get_reference template::paginator::get_reference (private) template::paginator::get_pages template::paginator::get_pages template::paginator::get_pages->template::paginator::get_reference

Testcases:
No testcase defined.

template::paginator::get_pages_info (public)

 template::paginator::get_pages_info name datasource pages

Gets the page information for a set of pages in the form of a multirow data source with 2 columns: rownum (starting with 1); and page (number of the page). This is a counterpart for get_context when using page objects that are non-contextual. Using this makes it easier to switch from contextual to non-contextual so that less modification is needed on adp template pages. Think in terms of taking out the display of one element in a multirow datasource as compared to converting an adp to handle a list datasource instead of a multirow datasource.

Parameters:
name (required)
The reference to the paginator object.
datasource (required)
The name of the multirow datasource to create
pages (required)
A Tcl list of page numbers.

Partial Call Graph (max 5 caller/called nodes):
%3 template::paginator::get_reference template::paginator::get_reference (private) template::paginator::get_pages_info template::paginator::get_pages_info template::paginator::get_pages_info->template::paginator::get_reference

Testcases:
No testcase defined.

template::paginator::get_query (public)

 template::paginator::get_query name id_column page

Returns a query with the data for the rows on the current page.

Parameters:
name (required)
The reference to the paginator object.
id_column (required)
The name of the ID column in the display query (required to order rows properly).
page (required)

Partial Call Graph (max 5 caller/called nodes):
%3 ns_dbquotelist ns_dbquotelist template::paginator::get_row template::paginator::get_row (public) template::paginator::get_row_ids template::paginator::get_row_ids (public) template::util::list_to_lookup template::util::list_to_lookup (public) template::paginator::get_query template::paginator::get_query template::paginator::get_query->ns_dbquotelist template::paginator::get_query->template::paginator::get_row template::paginator::get_query->template::paginator::get_row_ids template::paginator::get_query->template::util::list_to_lookup

Testcases:
No testcase defined.

template::paginator::get_row (public)

 template::paginator::get_row name pagenum

Calculates the first row displayed on a page.

Parameters:
name (required)
The reference to the paginator object.
pagenum (required)
A number ranging from one to the number of pages in the query result, representing the number of a page therein.
Returns:
A number ranging from one to the number of rows in the query result, representing the number of the first row on the specified page.

Partial Call Graph (max 5 caller/called nodes):
%3 template::paginator::get_data template::paginator::get_data (public) template::paginator::get_row template::paginator::get_row template::paginator::get_data->template::paginator::get_row template::paginator::get_query template::paginator::get_query (public) template::paginator::get_query->template::paginator::get_row template::paginator::get_reference template::paginator::get_reference (private) template::paginator::get_row->template::paginator::get_reference

Testcases:
No testcase defined.

template::paginator::get_row_count (public)

 template::paginator::get_row_count name

Gets the total number of records in the paginated query

Parameters:
name (required)
The reference to the paginator object.
Returns:
A number representing the row count.

Partial Call Graph (max 5 caller/called nodes):
%3 template::paginator::get_reference template::paginator::get_reference (private) template::paginator::get_row_count template::paginator::get_row_count template::paginator::get_row_count->template::paginator::get_reference

Testcases:
No testcase defined.

template::paginator::get_row_ids (public)

 template::paginator::get_row_ids name pagenum

Gets a list of IDs in a page, selected from the master ID list generated by the initial query submitted for pagination. IDs are typically primary key values.

Parameters:
name (required)
The reference to the paginator object.
pagenum (required)
A number ranging from one to the number of pages in the query result.
Returns:
A Tcl list of row identifiers.

Partial Call Graph (max 5 caller/called nodes):
%3 template::paginator::get_data template::paginator::get_data (public) template::paginator::get_row_ids template::paginator::get_row_ids template::paginator::get_data->template::paginator::get_row_ids template::paginator::get_query template::paginator::get_query (public) template::paginator::get_query->template::paginator::get_row_ids template::paginator::get_reference template::paginator::get_reference (private) template::paginator::get_row_ids->template::paginator::get_reference

Testcases:
No testcase defined.

template::paginator::get_row_last (public)

 template::paginator::get_row_last name pagenum

Calculates the last row displayed on a page.

Parameters:
name (required)
The reference to the paginator object.
pagenum (required)
A number ranging from one to the number of pages in the query result, representing the number of a page therein.
Returns:
A number ranging from one to the number of rows in the query result, representing the number of the last row on the specified page.

Partial Call Graph (max 5 caller/called nodes):
%3 template::paginator::get_reference template::paginator::get_reference (private) template::paginator::get_row_last template::paginator::get_row_last template::paginator::get_row_last->template::paginator::get_reference

Testcases:
No testcase defined.

template::paginator::reset (public)

 template::paginator::reset name query

Resets the cache for a query.

Parameters:
name (required)
query (required)

Partial Call Graph (max 5 caller/called nodes):
%3 template::cache template::cache (public) template::paginator::reset template::paginator::reset template::paginator::reset->template::cache

Testcases:
No testcase defined.
[ show source ]