2013-02-24 01:09:14 +01:00
|
|
|
<?php
|
2016-09-09 09:00:05 +02:00
|
|
|
|
2016-11-29 18:20:15 +01:00
|
|
|
namespace SilverStripe\Forms\GridField;
|
|
|
|
|
2016-09-09 09:00:05 +02:00
|
|
|
use SilverStripe\Forms\GridField\GridField_HTMLProvider;
|
|
|
|
use SilverStripe\ORM\ArrayList;
|
|
|
|
use SilverStripe\View\ArrayData;
|
|
|
|
|
2013-02-24 01:09:14 +01:00
|
|
|
/**
|
|
|
|
* A simple header which displays column titles.
|
|
|
|
*/
|
|
|
|
class GridFieldTitleHeader implements GridField_HTMLProvider {
|
|
|
|
|
|
|
|
public function getHTMLFragments($grid) {
|
|
|
|
$cols = new ArrayList();
|
|
|
|
|
|
|
|
foreach ($grid->getColumns() as $name) {
|
|
|
|
$meta = $grid->getColumnMetadata($name);
|
|
|
|
|
|
|
|
$cols->push(new ArrayData(array(
|
|
|
|
'Name' => $name,
|
|
|
|
'Title' => $meta['title']
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
|
|
|
|
return array(
|
|
|
|
'header' => $cols->renderWith('GridFieldTitleHeader'),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|