PHP Класс GridHandler, pkp-lib

Наследование: extends PKPHandler
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$_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.

Открытые методы

Метод Описание
__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.

Защищенные методы

Метод Описание
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.

Приватные методы

Метод Описание
_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.

Описание методов

__construct() публичный Метод

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() публичный Метод

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

addColumn() публичный Метод

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

authorize() публичный Метод

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

callFeaturesHook() защищенный Метод

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

doSpecificFetchGridActions() защищенный Метод

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

fetchCell() публичный Метод

Render a cell and send it to the client
public fetchCell ( &$args, $request ) : JSONMessage
$args array
$request Request
Результат JSONMessage JSON object

fetchGrid() публичный Метод

Render the entire grid controller and send it to the client.
public fetchGrid ( $args, $request ) : JSONMessage
$args array
$request Request
Результат JSONMessage JSON object

fetchRow() публичный Метод

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
Результат JSONMessage JSON object.

fetchRows() публичный Метод

Fetch all grid rows from loaded data.
public fetchRows ( $args, $request ) : JSONMessage
$args Array
$request Request
Результат JSONMessage JSON object.

getActions() публичный Метод

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.
Результат array The LinkActions for the given position.

getColumn() публичный Метод

Retrieve a single column by id.
public getColumn ( $columnId ) : GridColumn
$columnId
Результат GridColumn

getColumns() публичный Метод

Get all columns.
public getColumns ( ) : array
Результат array An array of GridColumn instances.

getColumnsByFlag() публичный Метод

Get columns by flag.
public getColumnsByFlag ( $flag ) : array
$flag string
Результат array

getColumnsCount() публичный Метод

Get columns number. If a flag is passed, the columns using it will not be counted.
public getColumnsCount ( $flag = null ) : integer
$flag optional string
Результат integer

getDataElementFromRequest() защищенный Метод

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)
Результат object

getDataElementSequence() публичный Метод

Override to return the data element sequence value.
public getDataElementSequence ( &$gridDataElement ) : integer
$gridDataElement mixed
Результат integer

getDataProvider() публичный Метод

Get the data provider.
public getDataProvider ( ) : FilesGridDataProvider
Результат FilesGridDataProvider

getEmptyRowText() публичный Метод

Get the no items locale key
public getEmptyRowText ( )

getFeatures() публичный Метод

Get all grid attached features.
public getFeatures ( ) : array
Результат array

getFilterForm() защищенный Метод

Returns a Form object or the path name of a filter template.
protected getFilterForm ( ) : Form | string
Результат Form | string

getFilterSelectionData() защищенный Метод

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
Результат array

getFootNote() публичный Метод

Get the grid foot note.
public getFootNote ( ) : string
Результат string locale key

getGridDataElements() публичный Метод

Get the grid data.
public getGridDataElements ( $request ) : array
$request PKPRequest
Результат array

getGridRangeInfo() публичный Метод

Get grid range info.
public getGridRangeInfo ( $request, $rangeName, $contextData = null ) : DBResultRange
$request PKPRequest
$rangeName string The grid id.
$contextData mixed
Результат DBResultRange

getIsSubcomponent() публичный Метод

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
Результат boolean

getItemIterator() публичный Метод

Should only be used for retriving paging data. See #6498.
public getItemIterator ( ) : ItemIterator
Результат ItemIterator

getJSHandler() публичный Метод

Get the js handler for this component.
public getJSHandler ( ) : string
Результат string

getPublishChangeEvents() публичный Метод

Get "publish data changed" event list.
public getPublishChangeEvents ( ) : array
Результат array

getRequestArg() публичный Метод

Get a single grid request parameter.
См. также: getRequestArgs()
public getRequestArg ( $key ) : mixed
$key string The name of the parameter to retrieve.
Результат mixed

getRequestArgs() публичный Метод

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
Результат array

getRequestedRow() публичный Метод

Raises a fatal error if such an element cannot be found.
public getRequestedRow ( $request, $args ) : GridRow
$request PKPRequest
$args array
Результат GridRow the requested grid row, already configured with id and data or null if the row could not been found.

getRowDataElement() защищенный Метод

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.
Результат mixed

getRowInstance() защищенный Метод

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
Результат GridRow

getRowsSequence() защищенный Метод

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
Результат array

getSelectName() публичный Метод

Get the select parameter name to store the selected files.
public getSelectName ( ) : string
Результат string

getTemplate() публичный Метод

Get the grid template.
public getTemplate ( ) : string
Результат string

getTitle() публичный Метод

Get the grid title.
public getTitle ( ) : string
Результат string locale key

getUrls() публичный Метод

Return all grid urls that will be used in JS handler.
public getUrls ( ) : array
Результат array

hasColumn() публичный Метод

Checks whether a column exists.
public hasColumn ( $columnId ) : boolean
$columnId
Результат boolean

hasGridDataElements() публичный Метод

Check whether the grid has rows.
public hasGridDataElements ( $request ) : boolean
Результат boolean

initFeatures() защищенный Метод

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
Результат array Array with initialized grid features objects.

initialize() публичный Метод

См. также: PKPHandler::initialize()
public initialize ( $request, $args = null )
$request PKPRequest
$args array optional

isDataElementSelected() публичный Метод

Returns the current selection state of the grid data element.
public isDataElementSelected ( $gridDataElement ) : boolean
$gridDataElement mixed
Результат boolean

isFilterFormCollapsible() защищенный Метод

Determine whether a filter form should be collapsible.
protected isFilterFormCollapsible ( ) : boolean
Результат boolean

loadData() защищенный Метод

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.
Результат grid data

noAutocompleteResults() защищенный Метод

Returns a common 'no matches' result when subclasses find no results for AJAX autocomplete requests.
protected noAutocompleteResults ( ) : JSONMessage
Результат JSONMessage JSON object

renderFilter() защищенный Метод

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.
Результат string

renderGridBodyPartsInternally() защищенный Метод

Method that renders tbodys to go in the grid main body.
protected renderGridBodyPartsInternally ( Request $request ) : array
$request Request
Результат array

renderRow() публичный Метод

Render the passed row and return its markup.
public renderRow ( $request, $row ) : string
$request PKPRequest
$row GridRow
Результат string

renderRowInternally() защищенный Метод

NB: You must have initialized the row before you call this method.
protected renderRowInternally ( $request, $row ) : string
$request PKPRequest
$row GridRow
Результат string the row HTML

renderRowsInternally() защищенный Метод

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.
Результат array of HTML Strings for Grid Rows.

saveSequence() публичный Метод

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
Результат JSONMessage JSON object

setDataElementSequence() публичный Метод

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

setEmptyRowText() публичный Метод

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

setFirstDataColumn() защищенный Метод

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

setFootNote() публичный Метод

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

setGridDataElements() публичный Метод

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

setTemplate() публичный Метод

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

setTitle() публичный Метод

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

setUrls() публичный Метод

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

Описание свойств

$_actions публичное свойство

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

$_columns публичное свойство

The GridColumns of this grid.
public $_columns

$_data публичное свойство

The grid's data source.
public $_data

$_dataProvider публичное свойство

public GridDataProvider $_dataProvider
Результат GridDataProvider

$_emptyRowText публичное свойство

empty row locale key
public $_emptyRowText

$_features публичное свойство

The grid features.
public $_features

$_footNote публичное свойство

Grid foot note locale key
public $_footNote

$_itemIterator публичное свойство

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

$_template публичное свойство

The grid template.
public $_template

$_title публичное свойство

grid title locale key
public $_title

$_urls публичное свойство

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