mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
Merge pull request #114 from assertchris/add-spam-row-highlight
Add spam row highlight
This commit is contained in:
commit
75be840dce
@ -50,7 +50,7 @@ class CommentAdmin extends LeftAndMain implements PermissionProvider {
|
|||||||
|
|
||||||
$newComments = Comment::get()->filter('Moderated', 0);
|
$newComments = Comment::get()->filter('Moderated', 0);
|
||||||
|
|
||||||
$newGrid = new GridField(
|
$newGrid = new CommentsGridField(
|
||||||
'NewComments',
|
'NewComments',
|
||||||
_t('CommentsAdmin.NewComments', 'New'),
|
_t('CommentsAdmin.NewComments', 'New'),
|
||||||
$newComments,
|
$newComments,
|
||||||
@ -59,7 +59,7 @@ class CommentAdmin extends LeftAndMain implements PermissionProvider {
|
|||||||
|
|
||||||
$approvedComments = Comment::get()->filter('Moderated', 1)->filter('IsSpam', 0);
|
$approvedComments = Comment::get()->filter('Moderated', 1)->filter('IsSpam', 0);
|
||||||
|
|
||||||
$approvedGrid = new GridField(
|
$approvedGrid = new CommentsGridField(
|
||||||
'ApprovedComments',
|
'ApprovedComments',
|
||||||
_t('CommentsAdmin.ApprovedComments', 'Approved'),
|
_t('CommentsAdmin.ApprovedComments', 'Approved'),
|
||||||
$approvedComments,
|
$approvedComments,
|
||||||
@ -68,7 +68,7 @@ class CommentAdmin extends LeftAndMain implements PermissionProvider {
|
|||||||
|
|
||||||
$spamComments = Comment::get()->filter('Moderated', 1)->filter('IsSpam', 1);
|
$spamComments = Comment::get()->filter('Moderated', 1)->filter('IsSpam', 1);
|
||||||
|
|
||||||
$spamGrid = new GridField(
|
$spamGrid = new CommentsGridField(
|
||||||
'SpamComments',
|
'SpamComments',
|
||||||
_t('CommentsAdmin.SpamComments', 'Spam'),
|
_t('CommentsAdmin.SpamComments', 'Spam'),
|
||||||
$spamComments,
|
$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
|
* @param FieldList $fields
|
||||||
*/
|
*/
|
||||||
protected function updateModerationFields(FieldList $fields) {
|
protected function updateModerationFields(FieldList $fields) {
|
||||||
|
Requirements::css(COMMENTS_DIR . '/css/Comments.css');
|
||||||
|
|
||||||
$commentsConfig = CommentsGridFieldConfig::create();
|
$commentsConfig = CommentsGridFieldConfig::create();
|
||||||
|
|
||||||
$newComments = $this->owner->AllComments()->filter('Moderated', 0);
|
$newComments = $this->owner->AllComments()->filter('Moderated', 0);
|
||||||
|
|
||||||
$newGrid = new GridField(
|
$newGrid = new CommentsGridField(
|
||||||
'NewComments',
|
'NewComments',
|
||||||
_t('CommentsAdmin.NewComments', 'New'),
|
_t('CommentsAdmin.NewComments', 'New'),
|
||||||
$newComments,
|
$newComments,
|
||||||
@ -470,7 +472,7 @@ class CommentsExtension extends DataExtension {
|
|||||||
|
|
||||||
$approvedComments = $this->owner->AllComments()->filter('Moderated', 1)->filter('IsSpam', 0);
|
$approvedComments = $this->owner->AllComments()->filter('Moderated', 1)->filter('IsSpam', 0);
|
||||||
|
|
||||||
$approvedGrid = new GridField(
|
$approvedGrid = new CommentsGridField(
|
||||||
'ApprovedComments',
|
'ApprovedComments',
|
||||||
_t('CommentsAdmin.Comments', 'Approved'),
|
_t('CommentsAdmin.Comments', 'Approved'),
|
||||||
$approvedComments,
|
$approvedComments,
|
||||||
@ -479,7 +481,7 @@ class CommentsExtension extends DataExtension {
|
|||||||
|
|
||||||
$spamComments = $this->owner->AllComments()->filter('Moderated', 1)->filter('IsSpam', 1);
|
$spamComments = $this->owner->AllComments()->filter('Moderated', 1)->filter('IsSpam', 1);
|
||||||
|
|
||||||
$spamGrid = new GridField(
|
$spamGrid = new CommentsGridField(
|
||||||
'SpamComments',
|
'SpamComments',
|
||||||
_t('CommentsAdmin.SpamComments', 'Spam'),
|
_t('CommentsAdmin.SpamComments', 'Spam'),
|
||||||
$spamComments,
|
$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