silverstripe-comments/code/admin/CommentsGridFieldConfig.php

49 lines
1.2 KiB
PHP
Raw Normal View History

<?php
class CommentsGridFieldConfig extends GridFieldConfig_RecordEditor {
public function __construct($itemsPerPage = 25) {
parent::__construct($itemsPerPage);
2015-04-13 05:41:18 +02:00
// $this->addComponent(new GridFieldExportButton());
$this->addComponent(new CommentsGridFieldAction());
// Format column
$columns = $this->getComponentByType('GridFieldDataColumns');
$columns->setFieldFormatting(array(
'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()
);
}
));
// Add bulk option
$manager = new GridFieldBulkManager();
2015-04-13 05:41:18 +02:00
$manager->addBulkAction(
2015-04-16 04:40:16 +02:00
'spam', 'Spam', 'CommentsGridFieldBulkAction_Handlers',
2015-04-13 05:41:18 +02:00
array(
'isAjax' => true,
'icon' => 'cross',
'isDestructive' => false
)
);
$manager->addBulkAction(
2015-04-16 04:40:16 +02:00
'approve', 'Approve', 'CommentsGridFieldBulkAction_Handlers',
array(
'isAjax' => true,
2015-04-13 05:41:18 +02:00
'icon' => 'cross',
'isDestructive' => false
)
);
2015-04-13 05:41:18 +02:00
$manager->removeBulkAction('bulkEdit');
$manager->removeBulkAction('unLink');
$this->addComponent($manager);
}
}