Class WPDP_Parent_List_View extends WPDA_List_View

Adds parent-child functionality to WPDA_List_View

see \WPDataAccess\List_Table\WPDA_List_View
author Peter Schulz
since 2.0.0
package WPDataProjects\Parent_Child
inherited_from \WPDataProjects\List_Table\WPDP_List_View

 Methods

WPDP_Parent_List_View constructor

__construct(array $args = array()

Adds parent-child functionality

inherited_from \WPDataProjects\List_Table\WPDP_List_View::__construct()

Parameters

$args

array

WPDA_List_View constructor

__construct(array $args = array()
Inherited

Page hook suffix

We first check if we have a page hook suffix. This is the reference to the sub menu to which we want to add the list view. If no page hook suffix is provided, the list table might be displayed as expected, the screen options in the top right corner however will not be shown.

Database table usage

  • The constructor can be called with or without a table name. If a table name is provided, a list table is generated for that database table.
  • If no table name is provided, we need to checked if a table name argument was given in the request. If a table name was provided with the request, a list table is generated for that table.
  • If no table name is provided (neither as an argument nor with the request) a list of all tables available in the WordPress database schema is generated.

Table names are always checked! We need to check:

  • if a table exists in our database schema and
  • if we have access to that table.

These checks are performed to prevent SQL injection and misuse of our WordPress database. These checks however are not performed in this class. They are performed in class \WPDataAccess\List_Table\WPDA_List_Table as we do not perform any queries in this class. We do perform queries on the given tables in \WPDataAccess\List_Table\WPDA_List_Table.

see \WPDataAccess\List_Table\WPDA_List_Table
since 1.0.0

Parameters

$args

array

[

'page_hook_suffix' => (string|boolean) Page hook suffix of false (default = false)

'schema_name' => (string) Database schema name (default = '')

'table_name' => (string) Database table name (default = '')

'bulk_actions_enabled' => (boolean) Allow bulk actions? (default = TRUE)

'search_box_enabled' => (boolean) Show search box? (default = TRUE)

'bulk_export_enabled' => (boolean) Allow bulk exports? (default = TRUE)

'list_table_class' => (string) Class providing list table functionality

'edit_form_class' => (string) Class providing data entry functionality

'column_headers' => (array|string) Column headers (default = '' : headers taken from data dictionary)

'title' => (string) Page title (default = null)

'subtitle' => (string) Page subtitle (default = null)

'show_view_link' => (string) default = 'on'

'allow_insert' => (string) default = 'off'

'allow_update' => (string) default = 'off'

'allow_delete' => (string) default = 'off'

'allow_import' => (string) default = 'off'

'default_where' => (string)

]

Get column headers

get_column_headers() : array
Inherited
since 1.0.0

Returns

array

Set page screen options

page_screen_options() 
Inherited

Provided are column selection (enable/disable) and rows per page. The table name is included in the meta_key to save screen options per table.

since 1.0.0

Enable or disable bulk actions

set_bulk_actions_enabled(boolean $bulk_actions_enabled) 
Inherited

If enabled user can perform actions on multiple rows at once.

since 1.0.0

Parameters

$bulk_actions_enabled

boolean

TRUE = allow bulk actions, FALSE = no bulk actions.

Set columns to be queried

set_columns_queried(mixed $columns_queried) 
Inherited

If not set all column (*) will be selected/set/queried.

since 1.0.0

Parameters

$columns_queried

mixed

Column array, '' or '*'.

Callback for set-screen-option filter

set_screen_option(string $status, string $option, mixed $value) : mixed
Inherited
since 1.0.0

Parameters

$status

string

Not used.

$option

string

string Not used.

$value

mixed

Option value.

Returns

mixed

Enable search box

set_search_box_enabled(boolean $search_box_enabled) 
Inherited

Shows a search box if enabled. In WP Data Access only columns with data type varchar or enum are searched.

since 1.0.0

Parameters

$search_box_enabled

boolean

TRUE = show search box, FALSE = no search box.

Overwrites method show to add parent-child functionality

show() 

Page types to be displayed:

  • List table
  • View form
  • Data entry form (add new)
  • Data entry form (update)

The type of table displayed depend on the value of the action argument provided in the request. The value of argument action is stored in $this->action in the constructor.

inherited_from \WPDataProjects\List_Table\WPDP_List_View::show()

Display page

show() 
Inherited

Page types to be displayed:

  • List table
  • View form
  • Data entry form (add new)
  • Data entry form (update)

The type of table displayed depend on the value of the action argument provided in the request. The value of argument action is stored in $this->action in the constructor.

since 1.0.0

show_screen_options()

show_screen_options($status, $args) 
Inherited

Parameters

$status

$args

Adds Data Designer menu-item to plugin menu

display_design_menu() 
Inherited

Overwrites method display_edit_form to add parent-child functionality

display_edit_form() 

Called when action is:

  • 'new' to add a new record to the table
  • 'edit' to update a record
  • 'view" to show a record (readonly)

Class WPDA_Simple_Form is the default class used to generate data entry forms. This class provides dynamic generation of data entry forms for any table, as long as the table has a primary key. The primary key is necessary to perform updates (unique identification of records).

For more specific data entry forms WPDA_Simple_Form can be extended. These classes need to implement some methods to work properly. Check out \WPDataAccess\Simple_Form\WPDA_Simple_Form for more information.

inherited_from \WPDataProjects\List_Table\WPDP_List_View::display_edit_form()

Display data entry form

display_edit_form() 
Inherited

Called when action is:

  • 'new' to add a new record to the table
  • 'edit' to update a record
  • 'view" to show a record (readonly)

Class WPDA_Simple_Form is the default class used to generate data entry forms. This class provides dynamic generation of data entry forms for any table, as long as the table has a primary key. The primary key is necessary to perform updates (unique identification of records).

For more specific data entry forms WPDA_Simple_Form can be extended. These classes need to implement some methods to work properly. Check out \WPDataAccess\Simple_Form\WPDA_Simple_Form for more information.

since 1.0.0
see \WPDataAccess\Simple_Form\WPDA_Simple_Form

Overwrites method display_list_table to add parent-child functionality

display_list_table() 

There are two type of list tables here:

  • List of tables in the WordPress database schema
  • List of rows in a specific table

A list of tables in the WordPress database schema is in fact a list of rows as well. The MySQL base table (which is in fact a view) used to show this information is 'information_schema.tables'. The list of tables contains a link to a list table for every table.

The list of rows is provided by class \WPDataAccess\List_Table\WPDA_List_Table. WPDA_List_Table extends Wordprees class WP_List_Table.

The list of tables is provided by class \WPDataAccess\List_Table\WPDA_List_Table_Menu. WPDA_List_Table_Menu extends class WPDA_List_Table.

inherited_from \WPDataProjects\List_Table\WPDP_List_View::display_list_table()

Display list table

display_list_table() 
Inherited

There are two type of list tables here:

  • List of tables in the WordPress database schema
  • List of rows in a specific table

A list of tables in the WordPress database schema is in fact a list of rows as well. The MySQL base table (which is in fact a view) used to show this information is 'information_schema.tables'. The list of tables contains a link to a list table for every table.

The list of rows is provided by class \WPDataAccess\List_Table\WPDA_List_Table. WPDA_List_Table extends Wordprees class WP_List_Table.

The list of tables is provided by class \WPDataAccess\List_Table\WPDA_List_Table_Menu. WPDA_List_Table_Menu extends class WPDA_List_Table.

since 1.0.0
see \WPDataAccess\List_Table\WPDA_List_Table
see \WPDataAccess\List_Table\WPDA_List_Table_Menu

 Properties

 

Action (taken from $_REQUEST)

$action : string

Default

''
 

Allow delete? (on|off)

$allow_delete : string

Default

null
 

Allow import? (on|off)

$allow_import : string

Default

null
 

Allow insert? (on|off)

$allow_insert : string

Default

null
 

Allow update? (on|off)

$allow_update : string

Default

null
 

Indicates if bulk actions are allow

$bulk_actions_enabled : boolean

Default

 

Indicates if bulk exports are allowed

$bulk_export_enabled : boolean

Default

 

Possible values: TRUE and null

$child_request : mixed

Default

TRUE = request is a child request All other values (including null) = request is a parent request

 

Contains child table name if child request, otherwise false

$child_request : boolean | string

Default

false

I don't like this kind of programming! This should be in child class of course! The load action to add screen options however cannot be delayed and therefor must be in the parent call.

 

Child relationships

$children : array

Default

 

Column headers (labels)

$column_headers : string

Default

 

Default WHERE clause

$default_where : string

Default

''
 

Classname of data entry form

$edit_form_class : string

Default

 

Possible values for label type are: listtable and tableform

$label_type : string

Default

'listtable'
 

Classname of list table

$list_table_class : string

Default

 

Possible values: edit and view

$mode : string

Default

null
inherited_from \WPDataProjects\List_Table\WPDP_List_View::$mode
 

Possible values for mode are: view and edit

$mode : 

Default

 

Page hook suffix

$page_hook_suffix : object | boolean

Default

 

Page ID

$page_id : string

Default

null
inherited_from \WPDataProjects\List_Table\WPDP_List_View::$page_id
 

Page ID

$page_id : null

Default

null
 

Parent info

$parent : array

Default

 

Class to be instantiated for data entry form

$parent_edit_form_class : string | null

Default

null
 

Instance of class WPDP_Project for $this->project_id

$project : \WPDataProjects\Project\WPDP_Project

Default

inherited_from \WPDataProjects\List_Table\WPDP_List_View::$project
 

Project info

$project : \WPDataProjects\Project\WPDP_Project

Default

null
 

Project ID

$project_id : string

Default

null
inherited_from \WPDataProjects\List_Table\WPDP_List_View::$project_id
 

Project ID

$project_id : null | string

Default

null
 

Database schema name

$schema_name : string

Default

 

$screen_settings_saved

$screen_settings_saved 

Default

false
Static
 

Indicates if a search box is shown

$search_box_enabled : boolean

Default

 

Options set name

$setname : string

Default

'default'
   

Page sub title

$subtitle : string

Default

inherited_from \WPDataProjects\List_Table\WPDP_List_View::$subtitle
 

Page subtitle

$subtitle : string

Default

 

Database table name

$table_name : string

Default

 

Page title

$title : string

Default

inherited_from \WPDataProjects\List_Table\WPDP_List_View::$title
 

Page title

$title : string

Default

 

SQL where clause

$where_clause : null

Default

null
inherited_from \WPDataProjects\List_Table\WPDP_List_View::$where_clause
 

SQL where clause

$where_clause : null

Default

null
 

Reference to list columns

$wpda_list_columns : \WPDataAccess\Data_Dictionary\WPDA_List_Columns

Default

null
 

Reference to list table

$wpda_list_table : \WPDataAccess\List_Table\WPDA_List_Table | \WPDataAccess\List_Table\WPDA_List_Table_Menu

Default

 Constants

 

HIDDENCOLUMNS_PREFIX

HIDDENCOLUMNS_PREFIX = 'wpda_manage_columnshidden_'