mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
Add spam row highlight
This commit is contained in:
parent
0c698a813a
commit
5c71b2f141
@ -50,7 +50,7 @@ class CommentAdmin extends LeftAndMain implements PermissionProvider {
|
||||
|
||||
$newComments = Comment::get()->filter('Moderated', 0);
|
||||
|
||||
$newGrid = new GridField(
|
||||
$newGrid = new CommentsGridField(
|
||||
'NewComments',
|
||||
_t('CommentsAdmin.NewComments', 'New'),
|
||||
$newComments,
|
||||
@ -59,7 +59,7 @@ class CommentAdmin extends LeftAndMain implements PermissionProvider {
|
||||
|
||||
$approvedComments = Comment::get()->filter('Moderated', 1)->filter('IsSpam', 0);
|
||||
|
||||
$approvedGrid = new GridField(
|
||||
$approvedGrid = new CommentsGridField(
|
||||
'ApprovedComments',
|
||||
_t('CommentsAdmin.ApprovedComments', 'Approved'),
|
||||
$approvedComments,
|
||||
@ -68,7 +68,7 @@ class CommentAdmin extends LeftAndMain implements PermissionProvider {
|
||||
|
||||
$spamComments = Comment::get()->filter('Moderated', 1)->filter('IsSpam', 1);
|
||||
|
||||
$spamGrid = new GridField(
|
||||
$spamGrid = new CommentsGridField(
|
||||
'SpamComments',
|
||||
_t('CommentsAdmin.SpamComments', 'Spam'),
|
||||
$spamComments,
|
||||
|
37
code/admin/CommentsGridField.php
Normal file
37
code/admin/CommentsGridField.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?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
|
||||
);
|
||||
}
|
||||
}
|
@ -457,11 +457,13 @@ class CommentsExtension extends DataExtension {
|
||||
* @param FieldList $fields
|
||||
*/
|
||||
protected function updateModerationFields(FieldList $fields) {
|
||||
Requirements::css(COMMENTS_DIR . '/css/Comments.css');
|
||||
|
||||
$commentsConfig = CommentsGridFieldConfig::create();
|
||||
|
||||
$newComments = $this->owner->AllComments()->filter('Moderated', 0);
|
||||
|
||||
$newGrid = new GridField(
|
||||
$newGrid = new CommentsGridField(
|
||||
'NewComments',
|
||||
_t('CommentsAdmin.NewComments', 'New'),
|
||||
$newComments,
|
||||
@ -470,7 +472,7 @@ class CommentsExtension extends DataExtension {
|
||||
|
||||
$approvedComments = $this->owner->AllComments()->filter('Moderated', 1)->filter('IsSpam', 0);
|
||||
|
||||
$approvedGrid = new GridField(
|
||||
$approvedGrid = new CommentsGridField(
|
||||
'ApprovedComments',
|
||||
_t('CommentsAdmin.Comments', 'Approved'),
|
||||
$approvedComments,
|
||||
@ -479,7 +481,7 @@ class CommentsExtension extends DataExtension {
|
||||
|
||||
$spamComments = $this->owner->AllComments()->filter('Moderated', 1)->filter('IsSpam', 1);
|
||||
|
||||
$spamGrid = new GridField(
|
||||
$spamGrid = new CommentsGridField(
|
||||
'SpamComments',
|
||||
_t('CommentsAdmin.SpamComments', 'Spam'),
|
||||
$spamComments,
|
||||
|
3
css/Comments.css
Normal file
3
css/Comments.css
Normal file
@ -0,0 +1,3 @@
|
||||
.cms table.ss-gridfield-table tr.spam {
|
||||
background-color: #FFD8D8 ;
|
||||
}
|
Loading…
Reference in New Issue
Block a user