tina_mvc/helpers/tina_mvc_pagination_helper_class.php
Builds a paginated, sortable HTML table of results from data or SQL
- Package
- Tina-MVC
- Subpackage
- Core
\TINA_MVC\pagination
Builds a paginated, sortable HTML table of results from SQL
- Parent(s)
- \TINA_MVC\Paginator
Properties

$custom_html_headingsUse setters and getters to access properties. Direct access to object properties is not supported.
- Type
- n/a

$custom_html_rowsUse setters and getters to access properties. Direct access to object properties is not supported.
- Type
- n/a

$default_sort_byUse setters and getters to access properties. Direct access to object properties is not supported.
- Type
- n/a

$default_sort_ordUse setters and getters to access properties. Direct access to object properties is not supported.
- Type
- n/a

$do_not_allow_sort_on_these_columnsUse setters and getters to access properties. Direct access to object properties is not supported.
- Type
- n/a

$pager_idUse setters and getters to access properties. Direct access to object properties is not supported.
- Type
- n/a

$sort_byUse setters and getters to access properties. Direct access to object properties is not supported.
- Type
- n/a

$sort_ordUse setters and getters to access properties. Direct access to object properties is not supported.
- Type
- n/a

$sql_resultsUse setters and getters to access properties. Direct access to object properties is not supported.
- Type
- n/a
Methods

__construct(string $pagername = false) : voidConstructor
Sets up the paginator
| Name | Type | Description |
|---|---|---|
| $pagername | string | unique name for the pager e.g. 'users-list' |

build_sql() : voidGet parameters from $_POST and $_GET, build SQL statements, including sort and order parameters, retrieve the count, retrieve the records.

filter_box_on_fields(array $fields = array()) : objectSet a filter box at the top of the form
We don't do any validation that the fields are correct, but we do escape them. You may filter on any fields, but it may confuse your users if the fields being filtered do not appear in the display.
| Name | Type | Description |
|---|---|---|
| $fields | array | Fields to filter by - array ( 'Display Name' => 'mysql_field_name' ) |
| Type | Description |
|---|---|
| object | pagination helper |

get_html() : stringReturn the complete HTML
Navigation links appear before and after the table
| Type | Description |
|---|---|
| string |

get_search_term() : stringChecks $_POST and $_SESSION for search terms or if user has clicked the 'clear' button
| Type | Description |
|---|---|
| string |

get_sort_params_from_url(string $u) : voidUsed to get sort parameters from a url
| Name | Type | Description |
|---|---|---|
| $u | string |
- See
- \TINA_MVC\$this->get_html()

get_sql_rows() : arrayGet SQL results
Use this to get the results as an array. Generally you use this to iterate through the result set and make up your own HTML rows. You would use this to prevent the use of the tina_mvc_table_helper to format results.
| Type | Description |
|---|---|
| array | An array of objects - the results fo the SQL query |
- See
- \TINA_MVC\set_html_rows()

set_base_sql(string $s = '') : objectSets the base SQL to product the table of results you want
You can name columns by using 'SELECT fieldname AS Field Name...' in your
SQL. This SQL must agree with the SQL used to get theh total number of rows
set in $this->set_count_from_sql().
The SQL statement should not include 'LIMIT' or 'ORDER BY' clauses
NB: You must pass a valid SQL statement, we do no escaping for you here
| Name | Type | Description |
|---|---|---|
| $s | string | the sql statement |
| Type | Description |
|---|---|
| object | pagination helper |
- See
- \TINA_MVC\$this->set_count_from_sql()

set_base_url(string $u = '') : objectSet the base url to this table
This should be the url that gets you to the default table view
This class will append strings to this url to support paging and order by functions. You need to manually set this value as Wordpress may not be set up to use the default permalinks (i.e. example.com/?p=123)
| Name | Type | Description |
|---|---|---|
| $u | string | The base url to this table |
| Type | Description |
|---|---|
| object | pagination helper |

set_count_from_sql(string $sql = '') : objectSet a SQL statement that will give the total number of rows of data
NB: Make sure you escape your own SQL before passing it to this function
| Name | Type | Description |
|---|---|---|
| $sql | string | a properly formatted SQL string |
| Type | Description |
|---|---|
| object | pagination helper |

set_default_sort_by(string $o = FALSE) : objectSet the default sort order.
Must correspond to a database field name or alias
| Name | Type | Description |
|---|---|---|
| $o | string |
| Type | Description |
|---|---|
| object | pagination helper |

set_default_sort_order(string $o = 'asc') : objectSet the default order by as asc or desc
| Name | Type | Description |
|---|---|---|
| $o | string | 'asc' or 'desc' |
| Type | Description |
|---|---|
| object | pagination helper |

set_html_headings(string $h = '') : objectSets the custom HTML headings
Only used in conjunction with custom html rows
| Name | Type | Description |
|---|---|---|
| $h | string | htmnl to be displayed above the table |
| Type | Description |
|---|---|
| object | pagination helper |

set_html_rows(mixed $rows) : voidSet the HTML rows to be displayed
Accepts: 1) array or object of rows. In this case the complete HTML to display a row should be passed. This overrides the use of tina_mvc_table_helper for formatting results. 2) array (or object) of array (or object) of values. In this case the tina_mvc_table_helper is used for formatting results.
Use $this->get_sql_rows() to retrieve results
| Name | Type | Description |
|---|---|---|
| $rows | mixed | array or object |

set_id(string $id = FALSE) : objectSets the id for the table
| Name | Type | Description |
|---|---|---|
| $id | string | The CSS id to be used for the table |
| Type | Description |
|---|---|
| object | pagination helper |

set_items_per_page(mixed $i = 25) : objectSet the rows per page
| Name | Type | Description |
|---|---|---|
| $i | mixed | an integer or 'all' |
| Type | Description |
|---|---|
| object | pagination helper |

set_mid_range(integer $m = 0) : objectSetter
| Name | Type | Description |
|---|---|---|
| $m | integer | the number of clickable pages to display in between Previous and Next links |
| Type | Description |
|---|---|
| object | pagination helper |

set_name(string $name = '') : objectSets the name (after sanitising)
| Name | Type | Description |
|---|---|---|
| $name | string |
| Type | Description |
|---|---|
| object | pagination helper |

suppress_sort( $columns = TRUE) : objectRemove sortable column headings from the final output
This is useful if you post process your rows of results after retrieval from the database. If you change column headings, or make up new fields and use $this->set_html_rows() to pass them back to the pagination helper, then you will break the relationship between your final rows and the rows as found in the database. In that case the clickable (sortable) headings will not work
| Name | Type | Description |
|---|---|---|
| $columns | mixed |
| Type | Description |
|---|---|
| object | pagination helper |