2011-12-06 01:56:24 +01:00
|
|
|
<?php
|
|
|
|
|
2016-06-15 06:03:16 +02:00
|
|
|
use SilverStripe\ORM\SS_List;
|
|
|
|
use SilverStripe\ORM\DataObjectInterface;
|
|
|
|
|
2011-12-06 01:56:24 +01:00
|
|
|
/**
|
2013-05-20 12:18:07 +02:00
|
|
|
* Base interface for all components that can be added to GridField.
|
|
|
|
*
|
2013-11-29 05:12:47 +01:00
|
|
|
* @package forms
|
2013-05-20 12:18:07 +02:00
|
|
|
* @subpackage fields-gridfield
|
2011-12-06 01:56:24 +01:00
|
|
|
*/
|
2014-08-15 08:53:05 +02:00
|
|
|
interface GridFieldComponent {
|
2011-12-06 01:56:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-05-20 12:18:07 +02:00
|
|
|
* A GridField manipulator that provides HTML for the header/footer rows, or f
|
|
|
|
* or before/after the template.
|
|
|
|
*
|
2013-11-29 05:12:47 +01:00
|
|
|
* @package forms
|
2013-05-20 12:18:07 +02:00
|
|
|
* @subpackage fields-gridfield
|
2011-12-06 01:56:24 +01:00
|
|
|
*/
|
|
|
|
interface GridField_HTMLProvider extends GridFieldComponent {
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2011-12-06 01:56:24 +01:00
|
|
|
/**
|
2014-08-15 08:53:05 +02:00
|
|
|
* Returns a map where the keys are fragment names and the values are
|
2013-05-20 12:18:07 +02:00
|
|
|
* pieces of HTML to add to these fragments.
|
2012-03-08 07:04:07 +01:00
|
|
|
*
|
2014-08-15 08:53:05 +02:00
|
|
|
* Here are 4 built-in fragments: 'header', 'footer', 'before', and
|
2013-05-20 12:18:07 +02:00
|
|
|
* 'after', but components may also specify fragments of their own.
|
2014-08-15 08:53:05 +02:00
|
|
|
*
|
|
|
|
* To specify a new fragment, specify a new fragment by including the
|
|
|
|
* text "$DefineFragment(fragmentname)" in the HTML that you return.
|
2012-03-08 07:04:07 +01:00
|
|
|
*
|
2013-05-20 12:18:07 +02:00
|
|
|
* Fragment names should only contain alphanumerics, -, and _.
|
2012-03-08 07:04:07 +01:00
|
|
|
*
|
2014-08-15 08:53:05 +02:00
|
|
|
* If you attempt to return HTML for a fragment that doesn't exist, an
|
2013-05-20 12:18:07 +02:00
|
|
|
* exception will be thrown when the {@link GridField} is rendered.
|
|
|
|
*
|
|
|
|
* @return array
|
2011-12-06 01:56:24 +01:00
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function getHTMLFragments($gridField);
|
2011-12-06 01:56:24 +01:00
|
|
|
}
|
2012-03-06 12:39:13 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a new column to the table display body, or modify existing columns.
|
2013-05-20 12:18:07 +02:00
|
|
|
*
|
2012-03-06 12:39:13 +01:00
|
|
|
* Used once per record/row.
|
2013-05-20 12:18:07 +02:00
|
|
|
*
|
2013-11-29 05:12:47 +01:00
|
|
|
* @package forms
|
2013-05-20 12:18:07 +02:00
|
|
|
* @subpackage fields-gridfield
|
2012-03-06 12:39:13 +01:00
|
|
|
*/
|
2011-12-06 01:56:24 +01:00
|
|
|
interface GridField_ColumnProvider extends GridFieldComponent {
|
2012-03-06 12:39:13 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Modify the list of columns displayed in the table.
|
2013-05-20 12:18:07 +02:00
|
|
|
*
|
|
|
|
* @see {@link GridFieldDataColumns->getDisplayFields()}
|
|
|
|
* @see {@link GridFieldDataColumns}.
|
2014-08-15 08:53:05 +02:00
|
|
|
*
|
2012-05-09 00:31:39 +02:00
|
|
|
* @param GridField $gridField
|
2013-06-21 00:32:08 +02:00
|
|
|
* @param arary $columns List of columns
|
2012-05-09 00:31:39 +02:00
|
|
|
* @param array - List reference of all column names.
|
2012-03-06 12:39:13 +01:00
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function augmentColumns($gridField, &$columns);
|
2012-03-06 12:39:13 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Names of all columns which are affected by this component.
|
2014-08-15 08:53:05 +02:00
|
|
|
*
|
2012-05-09 00:31:39 +02:00
|
|
|
* @param GridField $gridField
|
2014-08-15 08:53:05 +02:00
|
|
|
* @return array
|
2012-03-06 12:39:13 +01:00
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function getColumnsHandled($gridField);
|
2012-03-06 12:39:13 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* HTML for the column, content of the <td> element.
|
2014-08-15 08:53:05 +02:00
|
|
|
*
|
2012-05-09 00:31:39 +02:00
|
|
|
* @param GridField $gridField
|
|
|
|
* @param DataObject $record - Record displayed in this row
|
|
|
|
* @param string $columnName
|
|
|
|
* @return string - HTML for the column. Return NULL to skip.
|
2012-03-06 12:39:13 +01:00
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function getColumnContent($gridField, $record, $columnName);
|
2012-03-06 12:39:13 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Attributes for the element containing the content returned by {@link getColumnContent()}.
|
2014-08-15 08:53:05 +02:00
|
|
|
*
|
2012-05-09 00:31:39 +02:00
|
|
|
* @param GridField $gridField
|
|
|
|
* @param DataObject $record displayed in this row
|
|
|
|
* @param string $columnName
|
|
|
|
* @return array
|
2012-03-06 12:39:13 +01:00
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function getColumnAttributes($gridField, $record, $columnName);
|
2012-03-06 12:39:13 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Additional metadata about the column which can be used by other components,
|
|
|
|
* e.g. to set a title for a search column header.
|
2014-08-15 08:53:05 +02:00
|
|
|
*
|
2012-05-09 00:31:39 +02:00
|
|
|
* @param GridField $gridField
|
|
|
|
* @param string $columnName
|
|
|
|
* @return array - Map of arbitrary metadata identifiers to their values.
|
2012-03-06 12:39:13 +01:00
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function getColumnMetadata($gridField, $columnName);
|
2011-12-06 01:56:24 +01:00
|
|
|
}
|
2012-03-06 12:39:13 +01:00
|
|
|
|
|
|
|
/**
|
2014-08-15 08:53:05 +02:00
|
|
|
* An action is defined by two things: an action name, and zero or more named
|
|
|
|
* arguments.
|
2013-05-20 12:18:07 +02:00
|
|
|
*
|
2014-08-15 08:53:05 +02:00
|
|
|
* There is no built-in notion of a record-specific or column-specific action,
|
|
|
|
* but you may choose to define an argument such as ColumnName or RecordID in
|
2013-05-20 12:18:07 +02:00
|
|
|
* order to implement these.
|
|
|
|
*
|
|
|
|
* Does not provide interface elements to call those actions.
|
|
|
|
*
|
|
|
|
* @see {@link GridField_FormAction}.
|
|
|
|
*
|
2013-11-29 05:12:47 +01:00
|
|
|
* @package forms
|
2013-05-20 12:18:07 +02:00
|
|
|
* @subpackage fields-gridfield
|
2012-03-06 12:39:13 +01:00
|
|
|
*/
|
2011-12-06 01:56:24 +01:00
|
|
|
interface GridField_ActionProvider extends GridFieldComponent {
|
|
|
|
/**
|
2012-03-06 12:39:13 +01:00
|
|
|
* Return a list of the actions handled by this action provider.
|
2013-05-20 12:18:07 +02:00
|
|
|
*
|
2014-08-15 08:53:05 +02:00
|
|
|
* Used to identify the action later on through the $actionName parameter
|
2013-05-20 12:18:07 +02:00
|
|
|
* in {@link handleAction}.
|
|
|
|
*
|
2014-08-15 08:53:05 +02:00
|
|
|
* There is no namespacing on these actions, so you need to ensure that
|
2013-05-20 12:18:07 +02:00
|
|
|
* they don't conflict with other components.
|
2014-08-15 08:53:05 +02:00
|
|
|
*
|
2012-03-06 12:39:13 +01:00
|
|
|
* @param GridField
|
2014-08-15 08:53:05 +02:00
|
|
|
* @return Array with action identifier strings.
|
2011-12-06 01:56:24 +01:00
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function getActions($gridField);
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2011-12-06 01:56:24 +01:00
|
|
|
/**
|
2013-05-20 12:18:07 +02:00
|
|
|
* Handle an action on the given {@link GridField}.
|
|
|
|
*
|
2014-08-15 08:53:05 +02:00
|
|
|
* Calls ALL components for every action handled, so the component needs
|
2013-05-20 12:18:07 +02:00
|
|
|
* to ensure it only accepts actions it is actually supposed to handle.
|
2014-08-15 08:53:05 +02:00
|
|
|
*
|
2012-03-06 12:39:13 +01:00
|
|
|
* @param GridField
|
|
|
|
* @param String Action identifier, see {@link getActions()}.
|
2014-08-15 08:53:05 +02:00
|
|
|
* @param Array Arguments relevant for this
|
2012-03-06 12:39:13 +01:00
|
|
|
* @param Array All form data
|
2011-12-06 01:56:24 +01:00
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function handleAction(GridField $gridField, $actionName, $arguments, $data);
|
2011-12-06 01:56:24 +01:00
|
|
|
}
|
2012-03-06 12:39:13 +01:00
|
|
|
|
|
|
|
/**
|
2014-08-15 08:53:05 +02:00
|
|
|
* Can modify the data list.
|
2013-05-20 12:18:07 +02:00
|
|
|
*
|
2014-08-15 08:53:05 +02:00
|
|
|
* For example, a paginating component can apply a limit, or a sorting
|
|
|
|
* component can apply a sort.
|
2013-05-20 12:18:07 +02:00
|
|
|
*
|
2014-08-15 08:53:05 +02:00
|
|
|
* Generally, the data manipulator will make use of to {@link GridState}
|
2013-05-20 12:18:07 +02:00
|
|
|
* variables to decide how to modify the {@link DataList}.
|
|
|
|
*
|
2013-11-29 05:12:47 +01:00
|
|
|
* @package forms
|
2013-05-20 12:18:07 +02:00
|
|
|
* @subpackage fields-gridfield
|
2012-03-06 12:39:13 +01:00
|
|
|
*/
|
2011-12-06 01:56:24 +01:00
|
|
|
interface GridField_DataManipulator extends GridFieldComponent {
|
2013-05-20 12:18:07 +02:00
|
|
|
|
2011-12-06 01:56:24 +01:00
|
|
|
/**
|
2013-05-20 12:18:07 +02:00
|
|
|
* Manipulate the {@link DataList} as needed by this grid modifier.
|
2014-08-15 08:53:05 +02:00
|
|
|
*
|
2012-03-06 12:39:13 +01:00
|
|
|
* @param GridField
|
|
|
|
* @param SS_List
|
|
|
|
* @return DataList
|
2011-12-06 01:56:24 +01:00
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function getManipulatedData(GridField $gridField, SS_List $dataList);
|
2012-01-09 06:47:31 +01:00
|
|
|
}
|
|
|
|
|
2012-03-06 12:39:13 +01:00
|
|
|
/**
|
2014-08-15 08:53:05 +02:00
|
|
|
* Sometimes an action isn't enough: you need to provide additional support
|
2013-05-20 12:18:07 +02:00
|
|
|
* URLs for the {@link GridField}.
|
|
|
|
*
|
2014-08-15 08:53:05 +02:00
|
|
|
* These URLs may return user-visible content, for example a pop-up form for
|
|
|
|
* editing a record's details, or they may be support URLs for front-end
|
|
|
|
* functionality.
|
2013-05-20 12:18:07 +02:00
|
|
|
*
|
2014-08-15 08:53:05 +02:00
|
|
|
* For example a URL that will return JSON-formatted data for a javascript
|
2013-05-20 12:18:07 +02:00
|
|
|
* grid control.
|
|
|
|
*
|
2013-11-29 05:12:47 +01:00
|
|
|
* @package forms
|
2013-05-20 12:18:07 +02:00
|
|
|
* @subpackage fields-gridfield
|
2012-03-06 12:39:13 +01:00
|
|
|
*/
|
2012-01-09 06:47:31 +01:00
|
|
|
interface GridField_URLHandler extends GridFieldComponent {
|
2013-05-20 12:18:07 +02:00
|
|
|
|
2012-01-09 06:47:31 +01:00
|
|
|
/**
|
2014-08-15 08:53:05 +02:00
|
|
|
* Return URLs to be handled by this grid field, in an array the same form
|
2013-05-20 12:18:07 +02:00
|
|
|
* as $url_handlers.
|
|
|
|
*
|
2014-08-15 08:53:05 +02:00
|
|
|
* Handler methods will be called on the component, rather than the
|
2013-05-20 12:18:07 +02:00
|
|
|
* {@link GridField}.
|
2012-01-09 06:47:31 +01:00
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function getURLHandlers($gridField);
|
2012-03-24 04:04:52 +01:00
|
|
|
}
|
2013-01-15 12:41:25 +01:00
|
|
|
|
|
|
|
/**
|
2014-08-15 08:53:05 +02:00
|
|
|
* A component which is used to handle when a {@link GridField} is saved into
|
2013-05-20 12:18:07 +02:00
|
|
|
* a record.
|
|
|
|
*
|
2013-11-29 05:12:47 +01:00
|
|
|
* @package forms
|
2013-05-20 12:18:07 +02:00
|
|
|
* @subpackage fields-gridfield
|
2013-01-15 12:41:25 +01:00
|
|
|
*/
|
|
|
|
interface GridField_SaveHandler extends GridFieldComponent {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when a grid field is saved - i.e. the form is submitted.
|
|
|
|
*
|
|
|
|
* @param GridField $field
|
|
|
|
* @param DataObjectInterface $record
|
|
|
|
*/
|
|
|
|
public function handleSave(GridField $grid, DataObjectInterface $record);
|
|
|
|
|
|
|
|
}
|