silverstripe-framework/forms/gridfield/GridFieldViewButton.php
Will Rossiter ddcfcf7bed Update @package, @subpackage labels
Cleanup of framework's use of @package and @subpackage labels and additional of labels for classes missing packages.

Moved all GridField related components to the one name.

Countless spelling fixes, grammar for other comments.

Link ClassName references in file headers.
2013-05-21 22:24:41 +12:00

37 lines
952 B
PHP

<?php
/**
* A button that allows a user to view readonly details of a record. This is
* disabled by default and intended for use in readonly {@link GridField}
* instances.
*
* @package framework
* @subpackage fields-gridfield
*/
class GridFieldViewButton implements GridField_ColumnProvider {
public function augmentColumns($field, &$cols) {
if(!in_array('Actions', $cols)) $cols[] = 'Actions';
}
public function getColumnsHandled($field) {
return array('Actions');
}
public function getColumnContent($field, $record, $col) {
if($record->canView()) {
$data = new ArrayData(array(
'Link' => Controller::join_links($field->Link('item'), $record->ID, 'view')
));
return $data->renderWith('GridFieldViewButton');
}
}
public function getColumnAttributes($field, $record, $col) {
return array('class' => 'col-buttons');
}
public function getColumnMetadata($gridField, $col) {
return array('title' => null);
}
}