mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
FIX Duplicated tabset, invalid Pjax request, update translations and Spam/Approve buttons
This commit is contained in:
parent
118de6b595
commit
216ad8eb54
@ -44,13 +44,13 @@ en:
|
|||||||
DELETEALLCOMMENTS: 'Delete all comments on this page'
|
DELETEALLCOMMENTS: 'Delete all comments on this page'
|
||||||
SilverStripe\Comments\Admin\CommentAdmin:
|
SilverStripe\Comments\Admin\CommentAdmin:
|
||||||
ADMIN_PERMISSION: 'Access to ''Comments'' section'
|
ADMIN_PERMISSION: 'Access to ''Comments'' section'
|
||||||
ApprovedComments: Approved
|
ApprovedComments: Approved ({count})
|
||||||
Comments: Approved
|
Comments: Approved
|
||||||
MENUTITLE: Comments
|
MENUTITLE: Comments
|
||||||
Moderated: Moderated
|
Moderated: Moderated
|
||||||
NeedsModeration: 'Needs Moderation'
|
NeedsModeration: 'Needs Moderation'
|
||||||
NewComments: New
|
NewComments: New ({count})
|
||||||
SpamComments: Spam
|
SpamComments: Spam ({count})
|
||||||
SilverStripe\Comments\Admin\CommentsGridFieldAction:
|
SilverStripe\Comments\Admin\CommentsGridFieldAction:
|
||||||
APPROVE: Approve
|
APPROVE: Approve
|
||||||
COMMENTAPPROVED: 'Comment approved.'
|
COMMENTAPPROVED: 'Comment approved.'
|
||||||
|
@ -45,7 +45,7 @@ class CommentAdmin extends LeftAndMain implements PermissionProvider
|
|||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
"CMS_ACCESS_CommentAdmin" => array(
|
"CMS_ACCESS_CommentAdmin" => array(
|
||||||
'name' => _t('SilverStripe\\Comments\\Admin\\CommentAdmin.ADMIN_PERMISSION', "Access to 'Comments' section"),
|
'name' => _t(__CLASS__ . '.ADMIN_PERMISSION', "Access to 'Comments' section"),
|
||||||
'category' => _t('SilverStripe\\Security\\Permission.CMS_ACCESS_CATEGORY', 'CMS Access')
|
'category' => _t('SilverStripe\\Security\\Permission.CMS_ACCESS_CATEGORY', 'CMS Access')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -94,34 +94,42 @@ class CommentAdmin extends LeftAndMain implements PermissionProvider
|
|||||||
CommentsGridFieldConfig::create()
|
CommentsGridFieldConfig::create()
|
||||||
);
|
);
|
||||||
|
|
||||||
$newCount = '(' . count($newComments) . ')';
|
$fields = FieldList::create(
|
||||||
$approvedCount = '(' . count($approvedComments) . ')';
|
$root = TabSet::create(
|
||||||
$spamCount = '(' . count($spamComments) . ')';
|
'Root',
|
||||||
|
Tab::create(
|
||||||
$fields = new FieldList(
|
|
||||||
$root = new TabSet(
|
|
||||||
'Comments',
|
|
||||||
new Tab(
|
|
||||||
'NewComments',
|
'NewComments',
|
||||||
_t(__CLASS__.'.NewComments', 'New') . ' ' . $newCount,
|
_t(
|
||||||
|
__CLASS__.'.NewComments',
|
||||||
|
'New ({count})',
|
||||||
|
['count' => count($newComments)]
|
||||||
|
),
|
||||||
$newGrid
|
$newGrid
|
||||||
),
|
),
|
||||||
new Tab(
|
Tab::create(
|
||||||
'ApprovedComments',
|
'ApprovedComments',
|
||||||
_t(__CLASS__.'.ApprovedComments', 'Approved') . ' ' . $approvedCount,
|
_t(
|
||||||
|
__CLASS__.'.ApprovedComments',
|
||||||
|
'Approved ({count})',
|
||||||
|
['count' => count($approvedComments)]
|
||||||
|
),
|
||||||
$approvedGrid
|
$approvedGrid
|
||||||
),
|
),
|
||||||
new Tab(
|
Tab::create(
|
||||||
'SpamComments',
|
'SpamComments',
|
||||||
_t(__CLASS__.'.SpamComments', 'Spam') . ' ' . $spamCount,
|
_t(
|
||||||
|
__CLASS__.'.SpamComments',
|
||||||
|
'Spam ({count})',
|
||||||
|
['count' => count($spamComments)]
|
||||||
|
),
|
||||||
$spamGrid
|
$spamGrid
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$actions = new FieldList();
|
$actions = FieldList::create();
|
||||||
|
|
||||||
$form = new Form(
|
$form = Form::create(
|
||||||
$this,
|
$this,
|
||||||
'EditForm',
|
'EditForm',
|
||||||
$fields,
|
$fields,
|
||||||
@ -132,7 +140,7 @@ class CommentAdmin extends LeftAndMain implements PermissionProvider
|
|||||||
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
|
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
|
||||||
|
|
||||||
if ($form->Fields()->hasTabset()) {
|
if ($form->Fields()->hasTabset()) {
|
||||||
// $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
|
$form->Fields()->findOrMakeTab('Root')->setTemplate('SilverStripe\\Forms\\CMSTabSet');
|
||||||
$form->addExtraClass('center ss-tabset cms-tabset ' . $this->BaseCSSClasses());
|
$form->addExtraClass('center ss-tabset cms-tabset ' . $this->BaseCSSClasses());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,20 +62,24 @@ class CommentsGridFieldAction implements GridField_ColumnProvider, GridField_Act
|
|||||||
$field .= GridField_FormAction::create(
|
$field .= GridField_FormAction::create(
|
||||||
$gridField,
|
$gridField,
|
||||||
'CustomAction' . $record->ID . 'Spam',
|
'CustomAction' . $record->ID . 'Spam',
|
||||||
_t('SilverStripe\\Comments\\Admin\\CommentsGridFieldAction.SPAM', 'Spam'),
|
_t(__CLASS__ . '.SPAM', 'Spam'),
|
||||||
'spam',
|
'spam',
|
||||||
array('RecordID' => $record->ID)
|
array('RecordID' => $record->ID)
|
||||||
)->Field();
|
)
|
||||||
|
->addExtraClass('btn btn-secondary grid-field__icon-action')
|
||||||
|
->Field();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($record->IsSpam || !$record->Moderated) {
|
if ($record->IsSpam || !$record->Moderated) {
|
||||||
$field .= GridField_FormAction::create(
|
$field .= GridField_FormAction::create(
|
||||||
$gridField,
|
$gridField,
|
||||||
'CustomAction' . $record->ID . 'Approve',
|
'CustomAction' . $record->ID . 'Approve',
|
||||||
_t('SilverStripe\\Comments\\Admin\\CommentsGridFieldAction.APPROVE', 'Approve'),
|
_t(__CLASS__ . '.APPROVE', 'Approve'),
|
||||||
'approve',
|
'approve',
|
||||||
array('RecordID' => $record->ID)
|
array('RecordID' => $record->ID)
|
||||||
)->Field();
|
)
|
||||||
|
->addExtraClass('btn btn-secondary grid-field__icon-action')
|
||||||
|
->Field();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $field;
|
return $field;
|
||||||
@ -101,7 +105,7 @@ class CommentsGridFieldAction implements GridField_ColumnProvider, GridField_Act
|
|||||||
// output a success message to the user
|
// output a success message to the user
|
||||||
Controller::curr()->getResponse()->setStatusCode(
|
Controller::curr()->getResponse()->setStatusCode(
|
||||||
200,
|
200,
|
||||||
_t('SilverStripe\\Comments\\Admin\\CommentsGridFieldAction.COMMENTMARKEDSPAM', 'Comment marked as spam.')
|
_t(__CLASS__ . '.COMMENTMARKEDSPAM', 'Comment marked as spam.')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +116,7 @@ class CommentsGridFieldAction implements GridField_ColumnProvider, GridField_Act
|
|||||||
// output a success message to the user
|
// output a success message to the user
|
||||||
Controller::curr()->getResponse()->setStatusCode(
|
Controller::curr()->getResponse()->setStatusCode(
|
||||||
200,
|
200,
|
||||||
_t('SilverStripe\\Comments\\Admin\\CommentsGridFieldAction.COMMENTAPPROVED', 'Comment approved.')
|
_t(__CLASS__ . '.COMMENTAPPROVED', 'Comment approved.')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user