mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
37 lines
632 B
PHP
37 lines
632 B
PHP
<?php
|
|
|
|
class CommentsGridField extends GridField
|
|
{
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
protected function newRow($gridfield, $total, $index, $record, $attributes, $content) {
|
|
$classes = array('ss-gridfield-item');
|
|
|
|
if($index == 0) {
|
|
$classes[] = 'first';
|
|
}
|
|
|
|
if($index == $total - 1) {
|
|
$classes[] = 'last';
|
|
}
|
|
|
|
$classes[] = ($index % 2) ? 'even' : 'odd';
|
|
|
|
if ($record->IsSpam) {
|
|
$classes[] = 'spam';
|
|
}
|
|
|
|
$attributes = array(
|
|
'class' => implode(' ', $classes),
|
|
'data-id' => $record->ID,
|
|
'data-class' => $record->ClassName,
|
|
);
|
|
|
|
return FormField::create_tag(
|
|
'tr',
|
|
$attributes,
|
|
$content
|
|
);
|
|
}
|
|
} |