Blame view

framework/forms/gridfield/GridFieldViewButton.php 948 Bytes
0084d336   Administrator   Importers CRUD
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  <?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 forms
   * @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);
  	}
  }