Class WPDP_Project_Page_List extends WPDP_Child_List_Table
This class implements the lookup functionality. A lookup is the opposite of a one to many relationship. (1) A lookup provides the user with a listbox of possible values (2) A lookup offers the user comfort to search in lookup strings (e.g. titles or descriptions)
see | \WPDataProjects\Parent_Child\WPDP_Child_List_Table |
---|---|
author | Peter Schulz |
since | 2.0.0 |
package | WPDataProjects\Project |
inherited_from | \WPDataProjects\Parent_Child\WPDP_Child_List_Table |
__construct(array $args = array()
)
Add specific column headers to list table
inherited_from | \WPDataProjects\Parent_Child\WPDP_Child_List_Table::__construct() |
---|
array
__construct(array $args = array()
)
A table name must be provided in the constructor call. The table must be a valid MySQL database table to which acces (to the back-end) is granted. If no table name is provided, the table does not exist or access to the back-end for the given table is not granted, processing is stopped. It makes no sense to continue without a valid table. A check for table existence is performed to prevent SQL injection.
There are two types of tables to build a list table on:
To build a list of tables in the WordPress database schema, we query table 'information_schema.tables' (which is in fact a view). This is the only query allowed outside the WordPress database schema. The table/view name is stored in constant WPDA_List_Table::LIST_BASE_TABLE for validation purposes.
A list of rows for a specific table is based on WordPress class WP_List_Table.
WPDA_List_Table can be used to build list tables for views as well. View based list tables however, do not support insert, update, delete, import and export actions.
A table name is not the only thing we need to build a list table. We also need to have access to the table columns. If no table columns are provided execution is stopped as well.
since | 1.0.0 |
---|
array
[
'table_name' => (string) Database table name
'wpda_list_columns' => (object) Reference to a WPDA_List_Columns object
'singular' => (string) Singular object label
'plural' => (string) lural object label
'ajax' => (string) TRUE = list table support Ajax
'column_headers' => (array|string) Column headers
'title' => (string) Page title
'subtitle' => (string) Page subtitle
'bulk_export_enabled' => (boolean)
'search_box_enabled' => (boolean)
'bulk_actions_enabled' => (boolean)
'show_view_link' => (string) on|off
'allow_insert' => (string) on|off
'allow_update' => (string) on|off
'allow_delete' => (string) on|off
'allow_import' => (string) on|off
'hide_navigation' => (boolean)
'default_where' => (string)
]
column_cb(array $item) : string
since | 1.0.0 |
---|
array
Column list.
string
Content for checkbox column.column_default(array $item, string $column_name) : mixed | string
array
string
mixed
string
column_default(array $item, string $column_name) : mixed
Three links are provided for every list table row:
Links to view, edit and delete records are only available if a primary key for the table is found. Without a primary key unique identification of records is not possible.
Links to action are offered through hidden forms to prevent long URL's and problem when refreshing pages manually. More information about how and why is provided in source code at place where I thoug the information could be helpful.
since | 1.0.0 |
---|
array
Column info.
string
Column name.
mixed
Value display in list table columncolumn_headers_labels()
delete_row(string $where) : mixed
The table must have a primary key and the values for all primary key colummns must be provided in the request. The where clause must be a named array in format: ['column_name'] = 'value'
since | 1.0.0 |
---|
string
Where clause.
mixed
get_bulk_actions() : array
since | 1.0.0 |
---|
array
get_columns() : array
since | 1.0.0 |
---|
array
get_rows()
Where clause must be prepared in advance and written to $this->where (\WPDataAccess\List_Table\WPDA_List_Table::construct_where_clause()).
No return value. Result is directly written to $this->items (base class member).
since | 1.0.0 |
---|
get_sortable_columns() : array
since | 1.0.0 |
---|
array
get_where_clause()
no_items()
since | 1.0.0 |
---|
prepare_items()
Overwrites WP_List_Table::prepare_items()
since | 1.0.0 |
---|
print_column_headers(boolean $with_id = true
)
Overriding original method print_column_headers to support post instead of get. Changes are marked!
since | 1.0.0 |
---|---|
staticvar | $cb_counter int |
boolean
Whether to set the id attribute or not.
process_bulk_action()
Delete and bulk-delete actions use the primary key list as a reference. Before performing the actual delete statement(s) we'll check the provided column names against the data dictionary. This will protect us against SQL injection attacks.
For export actions table names will not be checked here. They are handed over WPDA_Export where the validity and access rights are checked anyway (to be safe).
All actions can be processed only with a valid wpnonce value.
To perform actions the user must have the appropriate rights.
since | 1.0.0 |
---|
record_count() : null | string
Returns the number of records in the database table. Where clause must be prepared in advance and written to $this->where (\WPDataAccess\List_Table\WPDA_List_Table::construct_where_clause())
since | 1.0.0 |
---|
null
string
Number of rows in the current tablesearch_box(string $text, string $input_id)
since | 1.0.0 |
---|
string
The 'submit' button label.
string
ID attribute value for the search input field.
set_bulk_actions_enabled(boolean $bulk_actions_enabled)
since | 1.0.0 |
---|
boolean
TRUE = allowed, FALSE = not allowed.
set_bulk_export_enabled(boolean $bulk_export_enabled)
since | 1.0.0 |
---|
boolean
TRUE = allowed, FALSE = not allowed.
set_columns_queried(mixed $columns_queried)
Set columns to be queried and shown in the list table. By default all columns in the table will be displayed.
since | 1.0.0 |
---|
mixed
Column list.
set_search_box_enabled(boolean $search_box_enabled)
since | 1.0.0 |
---|
boolean
TRUE = show search box, FALSE = do not show search bow.
set_subtitle(string $subtitle)
since | 1.0.0 |
---|
string
Page subtitle.
set_title(string $title)
since | 1.0.0 |
---|
string
Page title.
show()
Inside the list table page, the list table is shown. The necessary functionality to show the list table specifically is found in method \WPDataAccess\List_Table\WPDA_List_Table::display().
since | 1.0.0 |
---|---|
see | \WPDataAccess\List_Table\WPDA_List_Table::display() |
add_parent_args()
add_parent_args_as_string(array $item) : string
Overwrite this function if you want to use the list table as a child list table related to some parent form. You can add parent arguments to calls to make sure you get back to the right parent.
since | 1.5.0 |
---|
array
Column info.
string
String contains parent arguments.column_default_add_action(array $item, string $column_name, array $actions)
Adds parent arguments
inherited_from | \WPDataProjects\Parent_Child\WPDP_Child_List_Table::column_default_add_action() |
---|
array
string
array
column_default_add_action(array $item, string $column_name, array $actions)
array
Item information.
string
Column name.
array
Array of actions to be added to row.
column_lookup(string $target_column_name, string $target_table_name, string $source_column_name, mixed $value, string $data_type, string $and, string $target_schema_name) : mixed
string
Lookup key column
string
Lookup tabel name
string
Source column name
mixed
Lookup key value
string
Lookup key data type
string
Extension of where clause
string
Database schema name
mixed
Lookup valueconstruct_where_clause()
Arguments might come from the URL so we need to check for SQL injection and use prepare. The resulting where clause is written directly to member $this->where.
since | 1.0.0 |
---|
display_tablenav(string $which) : void
Generates the table navigation above or bellow the table and removes the _wp_http_referrer and _wpnonce because it generates a error about URL too large.
since | 1.0.0 |
---|
string
CSS Class name.
get_key_input_fields(array $item) : string
array
Column info.
string
String containg key items and values.get_search_value() : string
since | 1.5.0 |
---|
string
handle_row_actions(object $item, string $column_name, string $primary) : string
object
string
string
string
pagination(string $which)
Overriding original method pagination to support post instead of get. Changes are marked!
since | 1.0.0 |
---|
string
CSS Class name.
render_column_content(string $column_content, string $column_name) : string
Strip content if too long and replace & character.
string
Unprepared column content
string
Database column name
string
Rendered column content$is_child : boolean
true
Parent and stand-alone list tables do not have this property.
$allow_delete : string
null
$allow_insert : string
null
$allow_update : string
null
$bulk_actions_enabled : boolean
\WPDataAccess\List_Table\WPDA_List_Table::DEFAULT_BULK_ACTIONS_ENABLED
$bulk_export_enabled : boolean
\WPDataAccess\List_Table\WPDA_List_Table::DEFAULT_BULK_EXPORT_ENABLED
$child : array
$child_tab : null
''
$column_headers : array
$columns_indexed : array
array()
$columns_queried : array
$current_page : integer
1
$first_display_column : string
''
Default is the first column displayed
$help_url : null | string
null
$items_per_page : integer
$list_number : integer
0
$mode : string
$page : string
$page_number_item : null
''
$page_number_item_name : string
'page_number'
The name can be changed for pages on multiple levels. This is needed to get back to the right page in parent-child page.
$page_number_link : null
''
$parent : array
$schema_name : string
''
$search_box_enabled : boolean
\WPDataAccess\List_Table\WPDA_List_Table::DEFAULT_SEARCH_BOX_ENABLED
$search_item_name : string
SELF::SEARCH_ITEM_NAME_DEFAULT
$search_value : null | string
null
$search_value_old : null | string
null
$setname : string
'default'
$show_page_title
true
$show_view_link : string
null
$subtitle : string
''
$table_name : string
''
$title : string
$where : string
''
$where_in : string
'in'
$wpda_data_dictionary : \WPDataAccess\Data_Dictionary\WPDA_Dictionary_Exist
$wpda_import : \WPDataAccess\Utilities\WPDA_Import
null
$wpda_list_columns : \WPDataAccess\Data_Dictionary\WPDA_List_Columns
$wpda_table_settings : null | object
null
DEFAULT_BULK_ACTIONS_ENABLED = true
DEFAULT_BULK_EXPORT_ENABLED = true
DEFAULT_SEARCH_BOX_ENABLED = true
LIST_BASE_TABLE = 'information_schema.tables'
SEARCH_ITEM_NAME_DEFAULT = 'wpda_s'