PHP Class GridHandler, pkp-lib

Inheritance: extends PKPHandler
Afficher le fichier Open project: pkp/pkp-lib Class Usage Examples

Méthodes publiques

Свойство Type Description
$_actions Grid actions. The first key represents the position of the action in the grid, the second key represents the action id.
$_columns The GridColumns of this grid.
$_data The grid's data source.
$_dataProvider GridDataProvider
$_emptyRowText empty row locale key
$_features The grid features.
$_footNote Grid foot note locale key
$_itemIterator The item iterator to be used for paging.
$_template The grid template.
$_title grid title locale key
$_urls The urls that will be used in JS handler.

Méthodes publiques

Méthode Description
__construct ( $dataProvider = null ) Constructor.
addAction ( $action, $position = GRID_ACTION_POSITION_ABOVE ) Add an action.
addColumn ( $column ) Add a column.
authorize ( $request, &$args, $roleAssignments, $enforceRestrictedSite = true )
fetchCell ( &$args, $request ) : JSONMessage Render a cell and send it to the client
fetchGrid ( $args, $request ) : JSONMessage Render the entire grid controller and send it to the client.
fetchRow ( &$args, $request ) : JSONMessage Render a row and send it to the client. If the row no longer exists then inform the client.
fetchRows ( $args, $request ) : JSONMessage Fetch all grid rows from loaded data.
getActions ( $position = GRID_ACTION_POSITION_ABOVE ) : array Get all actions for a given position within the grid.
getColumn ( $columnId ) : GridColumn Retrieve a single column by id.
getColumns ( ) : array Get all columns.
getColumnsByFlag ( $flag ) : array Get columns by flag.
getColumnsCount ( $flag = null ) : integer Get columns number. If a flag is passed, the columns using it will not be counted.
getDataElementSequence ( &$gridDataElement ) : integer Override to return the data element sequence value.
getDataProvider ( ) : FilesGridDataProvider Get the data provider.
getEmptyRowText ( ) Get the no items locale key
getFeatures ( ) : array Get all grid attached features.
getFootNote ( ) : string Get the grid foot note.
getGridDataElements ( $request ) : array Get the grid data.
getGridRangeInfo ( $request, $rangeName, $contextData = null ) : DBResultRange Get grid range info.
getIsSubcomponent ( ) : boolean Override this method to return true if you want to use the grid within another component (e.g. to remove the title or change the layout accordingly).
getItemIterator ( ) : ItemIterator Get the item iterator that represents this grid data.
getJSHandler ( ) : string Get the js handler for this component.
getPublishChangeEvents ( ) : array Get "publish data changed" event list.
getRequestArg ( $key ) : mixed Get a single grid request parameter.
getRequestArgs ( ) : array Get the grid request parameters. These are the parameters that uniquely identify the data within a grid.
getRequestedRow ( $request, $args ) : GridRow Tries to identify the data element in the grids data source that corresponds to the requested row id.
getSelectName ( ) : string Get the select parameter name to store the selected files.
getTemplate ( ) : string Get the grid template.
getTitle ( ) : string Get the grid title.
getUrls ( ) : array Return all grid urls that will be used in JS handler.
hasColumn ( $columnId ) : boolean Checks whether a column exists.
hasGridDataElements ( $request ) : boolean Check whether the grid has rows.
initialize ( $request, $args = null )
isDataElementSelected ( $gridDataElement ) : boolean Returns the current selection state of the grid data element.
renderRow ( $request, $row ) : string Render the passed row and return its markup.
saveSequence ( $args, $request ) : JSONMessage Hook oportunity for grid features to request a save items sequence operation. If no grid feature that implements the saveSequence hook is attached to this grid, this operation will only return the data changed event json message.
setDataElementSequence ( $request, $rowId, &$gridDataElement, $newSequence ) Override to set the data element new sequence.
setEmptyRowText ( $emptyRowText ) Set the no items locale key
setFootNote ( $footNote ) Set the grid foot note.
setGridDataElements ( $data ) Set the grid data.
setTemplate ( $template ) Set the grid template.
setTitle ( $title ) Set the grid title.
setUrls ( $request, $extraUrls = [] ) Define the urls that will be used in JS handler.

Méthodes protégées

Méthode Description
callFeaturesHook ( $hookName, $args ) Call the passed hook in all attached features.
doSpecificFetchGridActions ( $args, $request, $templateMgr ) Override this method if your subclass needs to perform different actions than the ones implemented here.
getDataElementFromRequest ( $request, &$elementId ) : object Create a data element from a request. This is used to format new rows prior to their insertion or existing rows that have been edited but not saved.
getFilterForm ( ) : Form | string Returns a Form object or the path name of a filter template.
getFilterSelectionData ( $request ) : array Method that extracts the user's filter selection from the request either by instantiating the filter's Form object or by reading the request directly (if using a simple filter template only).
getRowDataElement ( $request, &$rowId ) : mixed Retrieve a single data element from the grid's data source corresponding to the given row id. If none is found then return null.
getRowInstance ( ) : GridRow Get a new instance of a grid row. May be overridden by subclasses if they want to provide a custom row definition.
getRowsSequence ( $request ) : array Return the sequence map of the current loaded grid items.
initFeatures ( $request, &$args ) : array Override to init grid features.
isFilterFormCollapsible ( ) : boolean Determine whether a filter form should be collapsible.
loadData ( $request, $filter ) : grid Implement this method to load data into the grid.
noAutocompleteResults ( ) : JSONMessage Returns a common 'no matches' result when subclasses find no results for AJAX autocomplete requests.
renderFilter ( $request, $filterData = [] ) : string Render the filter (a template or a Form).
renderGridBodyPartsInternally ( Request $request ) : array Method that renders tbodys to go in the grid main body.
renderRowInternally ( $request, $row ) : string Method that renders a single row.
renderRowsInternally ( $request, &$elements ) : array Cycle through the data and get generate the row HTML.
setFirstDataColumn ( ) Define the first column that will contain grid data.

Private Methods

Méthode Description
_addFeatures ( $features ) Add grid features.
_fixColumnWidths ( ) Method that grabs all the existing columns and makes sure the column widths add to exactly 100 N.B. We do some extra column fetching because PHP makes copies of arrays with foreach.
_getInitializedRowInstance ( $request, $elementId, &$element, $isModified = false ) : GridRow Instantiate a new row.
_renderCellInternally ( $request, $row, $column ) : string Method that renders a cell.

Method Details

__construct() public méthode

Constructor.
public __construct ( $dataProvider = null )
$dataProvider GridDataProvider An optional data provider for the grid. If no data provider is given then the grid assumes that child classes will override default method implementations.

addAction() public méthode

Add an action.
public addAction ( $action, $position = GRID_ACTION_POSITION_ABOVE )
$action Mixed a single action.
$position string The position of the action.

addColumn() public méthode

Add a column.
public addColumn ( $column )
$column mixed A single GridColumn instance.

authorize() public méthode

public authorize ( $request, &$args, $roleAssignments, $enforceRestrictedSite = true )

callFeaturesHook() protected méthode

Call the passed hook in all attached features.
protected callFeaturesHook ( $hookName, $args )
$hookName string
$args array Arguments provided by this handler.

doSpecificFetchGridActions() protected méthode

This method is called by GridHandler::fetchGrid()
protected doSpecificFetchGridActions ( $args, $request, $templateMgr )
$args array
$request Request

fetchCell() public méthode

Render a cell and send it to the client
public fetchCell ( &$args, $request ) : JSONMessage
$args array
$request Request
Résultat JSONMessage JSON object

fetchGrid() public méthode

Render the entire grid controller and send it to the client.
public fetchGrid ( $args, $request ) : JSONMessage
$args array
$request Request
Résultat JSONMessage JSON object

fetchRow() public méthode

Render a row and send it to the client. If the row no longer exists then inform the client.
public fetchRow ( &$args, $request ) : JSONMessage
$args array
$request Request
Résultat JSONMessage JSON object.

fetchRows() public méthode

Fetch all grid rows from loaded data.
public fetchRows ( $args, $request ) : JSONMessage
$args Array
$request Request
Résultat JSONMessage JSON object.

getActions() public méthode

Get all actions for a given position within the grid.
public getActions ( $position = GRID_ACTION_POSITION_ABOVE ) : array
$position string The position of the actions.
Résultat array The LinkActions for the given position.

getColumn() public méthode

Retrieve a single column by id.
public getColumn ( $columnId ) : GridColumn
$columnId
Résultat GridColumn

getColumns() public méthode

Get all columns.
public getColumns ( ) : array
Résultat array An array of GridColumn instances.

getColumnsByFlag() public méthode

Get columns by flag.
public getColumnsByFlag ( $flag ) : array
$flag string
Résultat array

getColumnsCount() public méthode

Get columns number. If a flag is passed, the columns using it will not be counted.
public getColumnsCount ( $flag = null ) : integer
$flag optional string
Résultat integer

getDataElementFromRequest() protected méthode

Create a data element from a request. This is used to format new rows prior to their insertion or existing rows that have been edited but not saved.
protected getDataElementFromRequest ( $request, &$elementId ) : object
$request PKPRequest
$elementId int Reference to be filled with element ID (if one is to be used)
Résultat object

getDataElementSequence() public méthode

Override to return the data element sequence value.
public getDataElementSequence ( &$gridDataElement ) : integer
$gridDataElement mixed
Résultat integer

getDataProvider() public méthode

Get the data provider.
public getDataProvider ( ) : FilesGridDataProvider
Résultat FilesGridDataProvider

getEmptyRowText() public méthode

Get the no items locale key
public getEmptyRowText ( )

getFeatures() public méthode

Get all grid attached features.
public getFeatures ( ) : array
Résultat array

getFilterForm() protected méthode

Returns a Form object or the path name of a filter template.
protected getFilterForm ( ) : Form | string
Résultat Form | string

getFilterSelectionData() protected méthode

Method that extracts the user's filter selection from the request either by instantiating the filter's Form object or by reading the request directly (if using a simple filter template only).
protected getFilterSelectionData ( $request ) : array
$request PKPRequest
Résultat array

getFootNote() public méthode

Get the grid foot note.
public getFootNote ( ) : string
Résultat string locale key

getGridDataElements() public méthode

Get the grid data.
public getGridDataElements ( $request ) : array
$request PKPRequest
Résultat array

getGridRangeInfo() public méthode

Get grid range info.
public getGridRangeInfo ( $request, $rangeName, $contextData = null ) : DBResultRange
$request PKPRequest
$rangeName string The grid id.
$contextData mixed
Résultat DBResultRange

getIsSubcomponent() public méthode

Override this method to return true if you want to use the grid within another component (e.g. to remove the title or change the layout accordingly).
public getIsSubcomponent ( ) : boolean
Résultat boolean

getItemIterator() public méthode

Should only be used for retriving paging data. See #6498.
public getItemIterator ( ) : ItemIterator
Résultat ItemIterator

getJSHandler() public méthode

Get the js handler for this component.
public getJSHandler ( ) : string
Résultat string

getPublishChangeEvents() public méthode

Get "publish data changed" event list.
public getPublishChangeEvents ( ) : array
Résultat array

getRequestArg() public méthode

Get a single grid request parameter.
See also: getRequestArgs()
public getRequestArg ( $key ) : mixed
$key string The name of the parameter to retrieve.
Résultat mixed

getRequestArgs() public méthode

NB: You should make sure to authorize and/or validate parameters before you publish them through this interface. Callers will assume that data accessed through this method will not have to be sanitized. The default implementation tries to retrieve request parameters from a data provider if there is one.
public getRequestArgs ( ) : array
Résultat array

getRequestedRow() public méthode

Raises a fatal error if such an element cannot be found.
public getRequestedRow ( $request, $args ) : GridRow
$request PKPRequest
$args array
Résultat GridRow the requested grid row, already configured with id and data or null if the row could not been found.

getRowDataElement() protected méthode

Retrieve a single data element from the grid's data source corresponding to the given row id. If none is found then return null.
protected getRowDataElement ( $request, &$rowId ) : mixed
$rowId string The row ID; reference permits modification.
Résultat mixed

getRowInstance() protected méthode

Get a new instance of a grid row. May be overridden by subclasses if they want to provide a custom row definition.
protected getRowInstance ( ) : GridRow
Résultat GridRow

getRowsSequence() protected méthode

This is not the sequence value of the data represented by the row, it's just the mapping of the rows sequence, in the order that they are loaded. To handle grid items ordering, see OrderItemsFeature class.
protected getRowsSequence ( $request ) : array
$request PKPRequest
Résultat array

getSelectName() public méthode

Get the select parameter name to store the selected files.
public getSelectName ( ) : string
Résultat string

getTemplate() public méthode

Get the grid template.
public getTemplate ( ) : string
Résultat string

getTitle() public méthode

Get the grid title.
public getTitle ( ) : string
Résultat string locale key

getUrls() public méthode

Return all grid urls that will be used in JS handler.
public getUrls ( ) : array
Résultat array

hasColumn() public méthode

Checks whether a column exists.
public hasColumn ( $columnId ) : boolean
$columnId
Résultat boolean

hasGridDataElements() public méthode

Check whether the grid has rows.
public hasGridDataElements ( $request ) : boolean
Résultat boolean

initFeatures() protected méthode

This method is called by GridHandler::initialize() method that use the returned array with the initialized features to add them to grid.
protected initFeatures ( $request, &$args ) : array
$request Request
$args array
Résultat array Array with initialized grid features objects.

initialize() public méthode

See also: PKPHandler::initialize()
public initialize ( $request, $args = null )
$request PKPRequest
$args array optional

isDataElementSelected() public méthode

Returns the current selection state of the grid data element.
public isDataElementSelected ( $gridDataElement ) : boolean
$gridDataElement mixed
Résultat boolean

isFilterFormCollapsible() protected méthode

Determine whether a filter form should be collapsible.
protected isFilterFormCollapsible ( ) : boolean
Résultat boolean

loadData() protected méthode

Implement this method to load data into the grid.
protected loadData ( $request, $filter ) : grid
$request Request
$filter array An associative array with filter data as returned by getFilterSelectionData(). If no filter has been selected by the user then the array will be empty.
Résultat grid data

noAutocompleteResults() protected méthode

Returns a common 'no matches' result when subclasses find no results for AJAX autocomplete requests.
protected noAutocompleteResults ( ) : JSONMessage
Résultat JSONMessage JSON object

renderFilter() protected méthode

Render the filter (a template or a Form).
protected renderFilter ( $request, $filterData = [] ) : string
$request PKPRequest
$filterData Array Data to be used by the filter template.
Résultat string

renderGridBodyPartsInternally() protected méthode

Method that renders tbodys to go in the grid main body.
protected renderGridBodyPartsInternally ( Request $request ) : array
$request Request
Résultat array

renderRow() public méthode

Render the passed row and return its markup.
public renderRow ( $request, $row ) : string
$request PKPRequest
$row GridRow
Résultat string

renderRowInternally() protected méthode

NB: You must have initialized the row before you call this method.
protected renderRowInternally ( $request, $row ) : string
$request PKPRequest
$row GridRow
Résultat string the row HTML

renderRowsInternally() protected méthode

Cycle through the data and get generate the row HTML.
protected renderRowsInternally ( $request, &$elements ) : array
$request PKPRequest
$elements array The grid data elements to be rendered.
Résultat array of HTML Strings for Grid Rows.

saveSequence() public méthode

Hook oportunity for grid features to request a save items sequence operation. If no grid feature that implements the saveSequence hook is attached to this grid, this operation will only return the data changed event json message.
public saveSequence ( $args, $request ) : JSONMessage
$args array
$request Request
Résultat JSONMessage JSON object

setDataElementSequence() public méthode

Override to set the data element new sequence.
public setDataElementSequence ( $request, $rowId, &$gridDataElement, $newSequence )
$request PKPRequest
$rowId int
$gridDataElement mixed
$newSequence int

setEmptyRowText() public méthode

Set the no items locale key
public setEmptyRowText ( $emptyRowText )

setFirstDataColumn() protected méthode

Override this method to define a different column than the first one.
protected setFirstDataColumn ( )

setFootNote() public méthode

Set the grid foot note.
public setFootNote ( $footNote )
$footNote string locale key

setGridDataElements() public méthode

Set the grid data.
public setGridDataElements ( $data )
$data mixed an array or ItemIterator with element data

setTemplate() public méthode

Set the grid template.
public setTemplate ( $template )
$template string

setTitle() public méthode

Set the grid title.
public setTitle ( $title )
$title string locale key

setUrls() public méthode

Define the urls that will be used in JS handler.
public setUrls ( $request, $extraUrls = [] )
$request Request
$extraUrls array Optional extra urls.

Property Details

$_actions public_oe property

Grid actions. The first key represents the position of the action in the grid, the second key represents the action id.
public $_actions

$_columns public_oe property

The GridColumns of this grid.
public $_columns

$_data public_oe property

The grid's data source.
public $_data

$_dataProvider public_oe property

public GridDataProvider $_dataProvider
Résultat GridDataProvider

$_emptyRowText public_oe property

empty row locale key
public $_emptyRowText

$_features public_oe property

The grid features.
public $_features

$_footNote public_oe property

Grid foot note locale key
public $_footNote

$_itemIterator public_oe property

The item iterator to be used for paging.
public $_itemIterator

$_template public_oe property

The grid template.
public $_template

$_title public_oe property

grid title locale key
public $_title

$_urls public_oe property

The urls that will be used in JS handler.
public $_urls