array( 'name' => _t('CommentAdmin.ADMIN_PERMISSION', "Access to 'Comments' section"), 'category' => _t('Permission.CMS_ACCESS_CATEGORY', 'CMS Access') ) ); } /** * @return Form */ public function getEditForm($id = null, $fields = null) { if(!$id) $id = $this->currentPageID(); $form = parent::getEditForm($id); $record = $this->getRecord($id); if($record && !$record->canView()) { return Security::permissionFailure($this); } $commentsConfig = CommentsGridFieldConfig::create(); $newComments = Comment::get()->filter('Moderated', 0); $newGrid = new GridField( 'NewComments', _t('CommentsAdmin.NewComments', 'New'), $newComments, $commentsConfig ); $approvedComments = Comment::get()->filter('Moderated', 1)->filter('IsSpam', 0); $approvedGrid = new GridField( 'ApprovedComments', _t('CommentsAdmin.ApprovedComments', 'Approved'), $approvedComments, $commentsConfig ); $spamComments = Comment::get()->filter('Moderated', 1)->filter('IsSpam', 1); $spamGrid = new GridField( 'SpamComments', _t('CommentsAdmin.SpamComments', 'Spam'), $spamComments, $commentsConfig ); $newCount = '(' . count($newComments) . ')'; $approvedCount = '(' . count($approvedComments) . ')'; $spamCount = '(' . count($spamComments) . ')'; $fields = new FieldList( $root = new TabSet( 'Root', new Tab('NewComments', _t('CommentAdmin.NewComments', 'New') . ' ' . $newCount, $newGrid ), new Tab('ApprovedComments', _t('CommentAdmin.ApprovedComments', 'Approved') . ' ' . $approvedCount, $approvedGrid ), new Tab('SpamComments', _t('CommentAdmin.SpamComments', 'Spam') . ' ' . $spamCount, $spamGrid ) ) ); $root->setTemplate('CMSTabSet'); $actions = new FieldList(); $form = new Form( $this, 'EditForm', $fields, $actions ); $form->addExtraClass('cms-edit-form'); $form->setTemplate($this->getTemplatesWithSuffix('_EditForm')); if($form->Fields()->hasTabset()) { $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet'); $form->addExtraClass('center ss-tabset cms-tabset ' . $this->BaseCSSClasses()); } $this->extend('updateEditForm', $form); return $form; } }