2015-04-07 05:56:00 +02:00
|
|
|
<?php
|
|
|
|
|
2017-01-16 20:57:37 +01:00
|
|
|
namespace SilverStripe\Comments\Admin;
|
|
|
|
|
2017-01-19 14:23:00 +01:00
|
|
|
use Colymba\BulkManager\BulkManager;
|
2018-02-26 00:33:08 +01:00
|
|
|
use SilverStripe\Comments\Admin\CommentsGridFieldBulkAction\ApproveHandler;
|
|
|
|
use SilverStripe\Comments\Admin\CommentsGridFieldBulkAction\SpamHandler;
|
2017-01-16 20:57:37 +01:00
|
|
|
use SilverStripe\Core\Convert;
|
2019-01-25 03:47:38 +01:00
|
|
|
use SilverStripe\Forms\GridField\GridField_ActionMenu;
|
2017-01-16 20:57:37 +01:00
|
|
|
use SilverStripe\Forms\GridField\GridFieldConfig_RecordEditor;
|
|
|
|
use SilverStripe\Forms\GridField\GridFieldDataColumns;
|
|
|
|
|
2016-02-19 01:48:25 +01:00
|
|
|
class CommentsGridFieldConfig extends GridFieldConfig_RecordEditor
|
|
|
|
{
|
|
|
|
public function __construct($itemsPerPage = 25)
|
|
|
|
{
|
|
|
|
parent::__construct($itemsPerPage);
|
|
|
|
|
|
|
|
// $this->addComponent(new GridFieldExportButton());
|
|
|
|
|
2019-01-25 03:47:38 +01:00
|
|
|
$this->addComponents([
|
|
|
|
new CommentsGridFieldSpamAction(),
|
|
|
|
new CommentsGridFieldApproveAction(),
|
|
|
|
]);
|
2016-02-19 01:48:25 +01:00
|
|
|
|
|
|
|
// Format column
|
2018-09-24 18:16:03 +02:00
|
|
|
/** @var GridFieldDataColumns $columns */
|
2017-01-16 20:57:37 +01:00
|
|
|
$columns = $this->getComponentByType(GridFieldDataColumns::class);
|
2018-09-24 18:16:03 +02:00
|
|
|
$columns->setFieldFormatting([
|
2016-02-19 01:48:25 +01:00
|
|
|
'ParentTitle' => function ($value, &$item) {
|
|
|
|
return sprintf(
|
|
|
|
'<a href="%s" class="cms-panel-link external-link action" target="_blank">%s</a>',
|
|
|
|
Convert::raw2att($item->Link()),
|
|
|
|
$item->obj('ParentTitle')->forTemplate()
|
|
|
|
);
|
|
|
|
}
|
2018-09-24 18:16:03 +02:00
|
|
|
]);
|
2016-02-19 01:48:25 +01:00
|
|
|
|
|
|
|
// Add bulk option
|
2018-09-24 18:16:03 +02:00
|
|
|
$manager = BulkManager::create(null, false);
|
2018-02-26 00:33:08 +01:00
|
|
|
|
|
|
|
$spamAction = SpamHandler::create()->setLabel(_t(__CLASS__ . '.SPAM', 'Spam'));
|
|
|
|
$approveAction = ApproveHandler::create()->setLabel(_t(__CLASS__ . '.APPROVE', 'Approve'));
|
|
|
|
|
|
|
|
$manager
|
|
|
|
->addBulkAction($spamAction)
|
|
|
|
->addBulkAction($approveAction);
|
2016-02-19 01:48:25 +01:00
|
|
|
|
|
|
|
$this->addComponent($manager);
|
|
|
|
}
|
|
|
|
}
|