src/Extensions/CommentsExtension.php
protected function updateModerationFields(FieldList $fields)
    {
        Requirements::css('silverstripe/comments:css/cms.css');

        $newComments = $this->owner->AllComments()->filter('Moderated', 0);

        $newGrid = CommentsGridField::create(
            'NewComments',
            _t('CommentsAdmin.NewComments', 'New'),
            $newComments,
            CommentsGridFieldConfig::create()
        );

        $approvedComments = $this->owner->AllComments()->filter('Moderated', 1)->filter('IsSpam', 0);

        $approvedGrid = new CommentsGridField(
            'ApprovedComments',
            _t('CommentsAdmin.Comments', 'Approved'),
            $approvedComments,
            CommentsGridFieldConfig::create()
        );

        $spamComments = $this->owner->AllComments()->filter('Moderated', 1)->filter('IsSpam', 1);

        $spamGrid = CommentsGridField::create(
            'SpamComments',
            _t('CommentsAdmin.SpamComments', 'Spam'),
            $spamComments,
            CommentsGridFieldConfig::create()
        );

        $newCount = '(' . count($newComments) . ')';
        $approvedCount = '(' . count($approvedComments) . ')';
        $spamCount = '(' . count($spamComments) . ')';

        if ($fields->hasTabSet()) {
            $tabs = TabSet::create(
                'Comments',
                Tab::create(
                    'CommentsNewCommentsTab',
                    _t('SilverStripe\\Comments\\Admin\\CommentAdmin.NewComments', 'New') . ' ' . $newCount,
                    $newGrid
                ),
                Tab::create(
                    'CommentsCommentsTab',
                    _t('SilverStripe\\Comments\\Admin\\CommentAdmin.Comments', 'Approved') . ' ' . $approvedCount,
                    $approvedGrid
                ),
                Tab::create(
                    'CommentsSpamCommentsTab',
                    _t('SilverStripe\\Comments\\Admin\\CommentAdmin.SpamComments', 'Spam') . ' ' . $spamCount,
                    $spamGrid
                )
            );
            $tabs->setTitle(_t(__CLASS__ . '.COMMENTSTABSET', 'Comments'));

            $fields->addFieldToTab('Root', $tabs);
        } else {
            $fields->push($newGrid);
            $fields->push($approvedGrid);
            $fields->push($spamGrid);
        }
    }
protected function updateModerationFields(FieldList $fields)
    {
        Requirements::css('silverstripe/comments:css/cms.css');

        $newComments = $this->owner->AllComments()->filter('Moderated', 0);

        $newGrid = CommentsGridField::create(
            'NewComments',
            _t('CommentsAdmin.NewComments', 'New'),
            $newComments,
            CommentsGridFieldConfig::create()
        );

        $approvedComments = $this->owner->AllComments()->filter('Moderated', 1)->filter('IsSpam', 0);

        $approvedGrid = new CommentsGridField(
            'ApprovedComments',
            _t('CommentsAdmin.Comments', 'Approved'),
            $approvedComments,
            CommentsGridFieldConfig::create()
        );

        $spamComments = $this->owner->AllComments()->filter('Moderated', 1)->filter('IsSpam', 1);

        $spamGrid = CommentsGridField::create(
            'SpamComments',
            _t('CommentsAdmin.SpamComments', 'Spam'),
            $spamComments,
            CommentsGridFieldConfig::create()
        );

        $newCount = '(' . count($newComments) . ')';
        $approvedCount = '(' . count($approvedComments) . ')';
        $spamCount = '(' . count($spamComments) . ')';

        if ($fields->hasTabSet()) {
            $tabs = TabSet::create(
                'Comments',
                Tab::create(
                    'CommentsNewCommentsTab',
                    _t('SilverStripe\\Comments\\Admin\\CommentAdmin.NewComments', 'New') . ' ' . $newCount,
                    $newGrid
                ),
                Tab::create(
                    'CommentsCommentsTab',
                    _t('SilverStripe\\Comments\\Admin\\CommentAdmin.Comments', 'Approved') . ' ' . $approvedCount,
                    $approvedGrid
                ),
                Tab::create(
                    'CommentsSpamCommentsTab',
                    _t('SilverStripe\\Comments\\Admin\\CommentAdmin.SpamComments', 'Spam') . ' ' . $spamCount,
                    $spamGrid
                )
            );
            $tabs->setTitle(_t(__CLASS__ . '.COMMENTSTABSET', 'Comments'));

            $fields->addFieldToTab('Root', $tabs);
        } else {
            $fields->push($newGrid);
            $fields->push($approvedGrid);
            $fields->push($spamGrid);
        }
    }
protected function updateModerationFields ( FieldList $ fields ) { Requirements :: css ( 'silverstripe/comments:css/cms.css' ) ; $ newComments = $ this -> owner -> AllComments ( ) -> filter ( 'Moderated' , 0 ) ; $ newGrid = CommentsGridField :: create ( 'NewComments' , _t ( 'CommentsAdmin.NewComments' , 'New' ) , $ newComments , CommentsGridFieldConfig :: create ( ) ) ; $ approvedComments = $ this -> owner -> AllComments ( ) -> filter ( 'Moderated' , 1 ) -> filter ( 'IsSpam' , 0 ) ; $ approvedGrid = new CommentsGridField ( 'ApprovedComments' , _t ( 'CommentsAdmin.Comments' , 'Approved' ) , $ approvedComments , CommentsGridFieldConfig :: create ( ) ) ; $ spamComments = $ this -> owner -> AllComments ( ) -> filter ( 'Moderated' , 1 ) -> filter ( 'IsSpam' , 1 ) ; $ spamGrid = CommentsGridField :: create ( 'SpamComments' , _t ( 'CommentsAdmin.SpamComments' , 'Spam' ) , $ spamComments , CommentsGridFieldConfig :: create ( ) ) ; $ newCount = '(' . count ( $ newComments ) . ')' ; $ approvedCount = '(' . count ( $ approvedComments ) . ')' ; $ spamCount = '(' . count ( $ spamComments ) . ')' ; if ( $ fields -> hasTabSet ( ) ) { $ tabs = TabSet :: create ( 'Comments' , Tab :: create ( 'CommentsNewCommentsTab' , _t ( 'SilverStripe\\Comments\\Admin\\CommentAdmin.NewComments' , 'New' ) . ' ' . $ newCount , $ newGrid ) , Tab :: create ( 'CommentsCommentsTab' , _t ( 'SilverStripe\\Comments\\Admin\\CommentAdmin.Comments' , 'Approved' ) . ' ' . $ approvedCount , $ approvedGrid ) , Tab :: create ( 'CommentsSpamCommentsTab' , _t ( 'SilverStripe\\Comments\\Admin\\CommentAdmin.SpamComments' , 'Spam' ) . ' ' . $ spamCount , $ spamGrid ) ) ; $ tabs -> setTitle ( _t ( __CLASS__ . '.COMMENTSTABSET' , 'Comments' ) ) ; $ fields -> addFieldToTab ( 'Root' , $ tabs ) ; } else { $ fields -> push ( $ newGrid ) ; $ fields -> push ( $ approvedGrid ) ; $ fields -> push ( $ spamGrid ) ; } }
Add moderation functions to the current fieldlist

@param FieldList $fields
Add moderation functions to the current fieldlist