Results Results(
string
$sql, [string
$param_prefix = ''], [string
$default_order = ''], [integer
$limit = 20], [boolean
$count_sql = NULL], [NULL|string
$init_page = true]
)
|
|
Constructor
Parameters:
|
string |
$sql: |
SQL query |
|
string |
$param_prefix: |
prefix to differentiate page/order params when multiple Results appear one same page |
|
string |
$default_order: |
default ordering of columns (special syntax) if not specified in the URL params example: -A-- will sort in ascending order on 2nd column example: ---D will sort in descending order on 4th column |
|
integer |
$limit: |
number of lines displayed on one page (NULL to disable paging) |
|
boolean |
$count_sql: |
|
|
NULL|string |
$init_page: |
SQL query used to count the total # of rows (if NULL, we'll try to COUNT(*) by ourselves) |
Information Tags:
| Todo: | we might not want to count total rows when not needed... |
| Todo: | fplanque: I am seriously considering putting $count_sqlinto 2nd or 3rd position. Any prefs? |
void count_total_rows(
[
$sql_count = NULL]
)
|
|
Count the total number of rows of the SQL result (all pages)
This is done by dynamically modifying the SQL query and forging a COUNT() into it.
Parameters:
Information Tags:
| Todo: | allow overriding? |
| Todo: | handle problem of empty groups! |
Redefined in descendants as:
int display(
[array|NULL
$display_params = NULL], [array
$fadeout = array()]
)
|
|
Display paged list/table based on object parameters
This is the meat of this class!
Parameters:
|
array|NULL |
$display_params: |
|
|
array |
$fadeout: |
Fadeout settings (column key => crit (array)) |
API Tags:
| Return: | # of rows displayed |
void display_body(
[array
$fadeout = array()]
)
|
|
Display list/table body.
This includes groups and data rows.
Parameters:
|
array |
$fadeout: |
fadeout list |
API Tags:
void display_colselect(
)
|
|
Display the column selection
Display the filtering form
returns the link to the first page, if necessary
void display_functions(
)
|
|
Display the functions
Redefined in descendants as:
Display list/table head.
This includes list head/title and column headers. This is optional and will only produce output if column headers are defined. EXPERIMENTAL: also dispays <tfoot>
API Tags:
true display_if_empty(
[string
$message = '']
)
|
|
Template function: display message if list is empty
Parameters:
|
string |
$message: |
String to display if list is empty |
API Tags:
Redefined in descendants as:
void display_init(
[
$display_params = NULL]
)
|
|
Initialize things in order to be ready for displaying.
This is useful when manually displaying, i-e: not by using Results::display()
Parameters:
returns the link to the last page, if necessary
void display_list_end(
[boolean
$detect_no_results = true]
)
|
|
Display list/table end.
Typically outputs </ul> or </table>
Parameters:
|
boolean |
$detect_no_results: |
do we want special treatment when there are no results |
Redefined in descendants as:
void display_list_start(
[boolean
$detect_no_results = true]
)
|
|
Display list/table start.
Typically outputs UL or TABLE tags.
Parameters:
|
boolean |
$detect_no_results: |
do we want special treatment when there are no results |
Redefined in descendants as:
void display_nav(
string
$template
)
|
|
Display navigation text, based on template.
Parameters:
|
string |
$template: |
template: 'header' or 'footer' |
API Tags:
returns a link to next pages, if necessary
void display_option_area(
string
$option_name, string
$area_name, string
$option_title, string
$submit_title, [string
$default_folde_state = 'expanded']
)
|
|
Display options area
Parameters:
|
string |
$option_name: |
name of the option ( ma_colselect, tsk_filter....) |
|
string |
$area_name: |
area name ( colselect_area, filter_area ) |
|
string |
$option_title: |
option title |
|
string |
$submit_title: |
submit button title |
|
string |
$default_folde_state: |
default folde state when is empty in the session |
returns a link to previous pages, if necessary
Display totals line if set.
Returns the first page number to be displayed in the list
array get_col_sort_values(
integer
$col_idx
)
|
|
Returns values needed to make sort links for a given column
Returns an array containing the following values:
- current_order : 'ASC', 'DESC' or ''
- order_asc : url to order in ascending order
- order_desc
- order_toggle : url to toggle sort order
Parameters:
|
integer |
$col_idx: |
column to sort |
Redefined in descendants as:
Get number of rows available for display
string get_order_field_list(
)
|
|
Returns order field list add to SQL query:
API Tags:
void get_page_ID_array(
)
|
|
Get an array of IDs for current page
API Tags:
Get a list of IDs for current page
API Tags:
Note: this function might actually not be very useful.
If you define ->Cache before display, all rows will be instantiated on the fly. No need to restart et go through the rows a second time here.
Parameters:
returns the last page number to be displayed in the list
Information Tags:
| Todo: | Support Results::order_callbacks |
Increment and update all necessary counters before processing a new line in result set
integer order_callback_wrapper_objects(
$row_a,
$row_b
)
|
|
Wrapper method to http://www.php.net/usort, which instantiates objects and passed them on to the order callback.
Parameters:
integer order_callback_wrapper_rows(
$row_a,
$row_b
)
|
|
Wrapper method to http://www.php.net/usort, which passes the rows to the order callback.
Parameters:
void page_list(
$min,
$max
)
|
|
Returns the page link list under the table
Parameters:
void parse_col_content(
$content
)
|
|
Handle variable subtitutions for column contents.
This is one of the key functions to look at when you want to use the Results class.
- $var$
- £var£
- #var#
- {row}
- {global_idx}
- {global_is_first}
- {global_is_last}
- %func()%
- ¤func()¤
Parameters:
void query(
[
$create_default_cols_if_needed = true], [
$append_limit = true], [
$append_order_by = true]
)
|
|
Run the query now!
Will only run if it has not executed before.
Parameters:
|
|
$create_default_cols_if_needed: |
|
|
|
$append_limit: |
|
|
|
$append_order_by: |
|
Redefined in descendants as:
string replace_callback(
$matches
)
|
|
Widget callback for template vars.
This allows to replace template vars, see Widget::replace_callback().
Parameters:
Redefinition of:
- Widget::replace_callback()
- Callback function used to replace only necessary values in template.
Rewind resultset
Redefined in descendants as: