2013-02-24 01:09:14 +01:00
|
|
|
<?php
|
2016-09-09 09:00:05 +02:00
|
|
|
|
2017-06-16 06:07:09 +02:00
|
|
|
namespace Symbiote\GridFieldExtensions;
|
2016-11-29 18:20:15 +01:00
|
|
|
|
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.
|
|
|
|
*/
|
2016-12-21 03:34:58 +01:00
|
|
|
class GridFieldTitleHeader implements GridField_HTMLProvider
|
|
|
|
{
|
|
|
|
|
|
|
|
public function getHTMLFragments($grid)
|
|
|
|
{
|
2022-02-18 04:44:54 +01:00
|
|
|
$cols = ArrayList::create();
|
2016-12-21 03:34:58 +01:00
|
|
|
|
|
|
|
foreach ($grid->getColumns() as $name) {
|
|
|
|
$meta = $grid->getColumnMetadata($name);
|
|
|
|
|
2022-02-18 04:44:54 +01:00
|
|
|
$cols->push(ArrayData::create(array(
|
2016-12-21 03:34:58 +01:00
|
|
|
'Name' => $name,
|
|
|
|
'Title' => $meta['title']
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
|
|
|
|
return array(
|
|
|
|
'header' => $cols->renderWith(__CLASS__)
|
|
|
|
);
|
|
|
|
}
|
2013-02-24 01:09:14 +01:00
|
|
|
}
|