tina_mvc/helpers/tina_mvc_pagination_helper_class.php

Show: PublicProtectedPrivateinherited
Table of Contents
Pagination Helper class file

Builds a paginated, sortable HTML table of results from data or SQL

Package
Tina-MVC  
Subpackage
Core  

\TINA_MVC\pagination

Package: Tina-MVC\Core
Pagination Helper class file

Builds a paginated, sortable HTML table of results from SQL

Parent(s)
\TINA_MVC\Paginator

Properties

>VPropertyprotected$custom_html_headings
All variables are protected.

Use setters and getters to access properties. Direct access to object properties is not supported.

Details
Type
n/a
>VPropertyprotected$custom_html_rows
All variables are protected.

Use setters and getters to access properties. Direct access to object properties is not supported.

Details
Type
n/a
>VPropertyprotected$default_sort_by
All variables are protected.

Use setters and getters to access properties. Direct access to object properties is not supported.

Details
Type
n/a
>VPropertyprotected$default_sort_ord
All variables are protected.

Use setters and getters to access properties. Direct access to object properties is not supported.

Details
Type
n/a
>VPropertyprotected$do_not_allow_sort_on_these_columns
All variables are protected.

Use setters and getters to access properties. Direct access to object properties is not supported.

Details
Type
n/a
>VPropertyprotected$pager_id
All variables are protected.

Use setters and getters to access properties. Direct access to object properties is not supported.

Details
Type
n/a
>VPropertyprotected$sort_by
All variables are protected.

Use setters and getters to access properties. Direct access to object properties is not supported.

Details
Type
n/a
>VPropertyprotected$sort_ord
All variables are protected.

Use setters and getters to access properties. Direct access to object properties is not supported.

Details
Type
n/a
>VPropertyprotected$sql_results
All variables are protected.

Use setters and getters to access properties. Direct access to object properties is not supported.

Details
Type
n/a
>VPropertyprotected$suppress_sort
All variables are protected.

Use setters and getters to access properties. Direct access to object properties is not supported.

Details
Type
n/a

Methods

methodpublic__construct(string $pagername = false) : void

Constructor

Sets up the paginator

Parameters
NameTypeDescription
$pagernamestring

unique name for the pager e.g. 'users-list'

methodprivatebuild_sql() : void

Get parameters from $_POST and $_GET, build SQL statements, including sort and order parameters, retrieve the count, retrieve the records.

methodpublicfilter_box_on_fields(array $fields = array()) : object

Set 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.

Parameters
NameTypeDescription
$fieldsarray

Fields to filter by - array ( 'Display Name' => 'mysql_field_name' )

Returns
TypeDescription
objectpagination helper
methodpublicget_base_url() : string

Getter

Returns
TypeDescription
string
methodprivateget_filter_box_html() : string

Get the html form for the filter box

Returns
TypeDescription
string
methodpublicget_html() : string

Return the complete HTML

Navigation links appear before and after the table

Returns
TypeDescription
string
methodpublicget_id() : string

Getter

Returns
TypeDescription
string
methodpublicget_name() : string

Getter

Returns
TypeDescription
string
methodprivateget_search_term() : string

Checks $_POST and $_SESSION for search terms or if user has clicked the 'clear' button

Returns
TypeDescription
string
methodprivateget_sort_params_from_url(string $u) : void

Used to get sort parameters from a url

Parameters
NameTypeDescription
$ustring
Details
See
\TINA_MVC\$this->get_html()  
methodpublicget_sql_rows() : array

Get 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.

Returns
TypeDescription
arrayAn array of objects - the results fo the SQL query
Details
See
\TINA_MVC\set_html_rows()  
methodpublicset_base_sql(string $s = '') : object

Sets 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

Parameters
NameTypeDescription
$sstring

the sql statement

Returns
TypeDescription
objectpagination helper
Details
See
\TINA_MVC\$this->set_count_from_sql()  
methodpublicset_base_url(string $u = '') : object

Set 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)

Parameters
NameTypeDescription
$ustring

The base url to this table

Returns
TypeDescription
objectpagination helper
methodpublicset_count_from_sql(string $sql = '') : object

Set 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

Parameters
NameTypeDescription
$sqlstring

a properly formatted SQL string

Returns
TypeDescription
objectpagination helper
methodpublicset_default_sort_by(string $o = FALSE) : object

Set the default sort order.

Must correspond to a database field name or alias

Parameters
NameTypeDescription
$ostring
Returns
TypeDescription
objectpagination helper
methodpublicset_default_sort_order(string $o = 'asc') : object

Set the default order by as asc or desc

Parameters
NameTypeDescription
$ostring

'asc' or 'desc'

Returns
TypeDescription
objectpagination helper
methodpublicset_html_headings(string $h = '') : object

Sets the custom HTML headings

Only used in conjunction with custom html rows

Parameters
NameTypeDescription
$hstring

htmnl to be displayed above the table

Returns
TypeDescription
objectpagination helper
methodpublicset_html_rows(mixed $rows) : void

Set 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

Parameters
NameTypeDescription
$rowsmixed

array or object

methodpublicset_id(string $id = FALSE) : object

Sets the id for the table

Parameters
NameTypeDescription
$idstring

The CSS id to be used for the table

Returns
TypeDescription
objectpagination helper
methodpublicset_items_per_page(mixed $i = 25) : object

Set the rows per page

Parameters
NameTypeDescription
$imixed

an integer or 'all'

Returns
TypeDescription
objectpagination helper
methodpublicset_mid_range(integer $m = 0) : object

Setter

Parameters
NameTypeDescription
$minteger

the number of clickable pages to display in between Previous and Next links

Returns
TypeDescription
objectpagination helper
methodpublicset_name(string $name = '') : object

Sets the name (after sanitising)

Parameters
NameTypeDescription
$namestring
Returns
TypeDescription
objectpagination helper
methodpublicsuppress_sort( $columns = TRUE) : object

Remove 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

Parameters
NameTypeDescription
$columns

mixed

Returns
TypeDescription
objectpagination helper
Documentation was generated by phpDocumentor 2.0.0a12.