diff --git a/code/admin/CommentAdmin.php b/code/admin/CommentAdmin.php index b27d2ef..36538ed 100644 --- a/code/admin/CommentAdmin.php +++ b/code/admin/CommentAdmin.php @@ -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, diff --git a/code/admin/CommentsGridField.php b/code/admin/CommentsGridField.php new file mode 100644 index 0000000..94c307b --- /dev/null +++ b/code/admin/CommentsGridField.php @@ -0,0 +1,37 @@ +IsSpam) { + $classes[] = 'spam'; + } + + $attributes = array( + 'class' => implode(' ', $classes), + 'data-id' => $record->ID, + 'data-class' => $record->ClassName, + ); + + return FormField::create_tag( + 'tr', + $attributes, + $content + ); + } +} \ No newline at end of file diff --git a/code/extensions/CommentsExtension.php b/code/extensions/CommentsExtension.php index 21e240a..f2cec69 100644 --- a/code/extensions/CommentsExtension.php +++ b/code/extensions/CommentsExtension.php @@ -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, diff --git a/css/Comments.css b/css/Comments.css new file mode 100644 index 0000000..63f9284 --- /dev/null +++ b/css/Comments.css @@ -0,0 +1,3 @@ +.cms table.ss-gridfield-table tr.spam { + background-color: #FFD8D8 ; +}