2012-05-11 09:44:39 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* A button that allows a user to view readonly details of a record. This is
|
2013-05-20 12:18:07 +02:00
|
|
|
* disabled by default and intended for use in readonly {@link GridField}
|
|
|
|
* instances.
|
2012-05-11 09:44:39 +02:00
|
|
|
*
|
2013-11-29 05:12:47 +01:00
|
|
|
* @package forms
|
2013-05-20 12:18:07 +02:00
|
|
|
* @subpackage fields-gridfield
|
2012-05-11 09:44:39 +02:00
|
|
|
*/
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|