ENHANCEMENT Showing 20 comments in tabular view for CommentAdmin (and making the setting configurable via CommentAdmin::set_comments_per_page())

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@105269 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-05-20 07:28:12 +00:00 committed by Sam Minnee
parent 5d5cc70a69
commit 4182cd4709
2 changed files with 29 additions and 8 deletions

View File

@ -23,6 +23,12 @@ class CommentAdmin extends LeftAndMain {
'unmoderated'
);
/**
* the number of comments per page for the {@see CommentTable} in this admin
* defaulted 20.
*/
static $comments_per_page = '20';
public function init() {
parent::init();
@ -90,14 +96,12 @@ class CommentAdmin extends LeftAndMain {
'Comment' => array('HTMLText->LimitCharacters', 150)
));
$table->setPageSize(self::get_comments_per_page());
$fields = new FieldSet(
new TabSet( 'Root',
new Tab(_t('CommentAdmin.COMMENTS', 'Comments'),
new LiteralField("Title", $title),
$idField,
$table
)
)
);
$actions = new FieldSet();
@ -295,6 +299,24 @@ JS;
function NumSpam() {
return DB::query("SELECT COUNT(*) FROM \"PageComment\" WHERE \"IsSpam\"=1")->value();
}
/**
* Set CommentAdmin::comments_per_page
* @param $num int
*/
function set_comments_per_page($num){
self::$comments_per_page = $num;
}
/**
* Get CommentAdmin::comments_per_page
* @return int
*/
function get_comments_per_page(){
return self::$comments_per_page;
}
}
?>

View File

@ -16,7 +16,6 @@ class CommentTableField extends ComplexTableField {
parent::__construct($controller, $name, $sourceClass, $fieldList, $detailFormFields, $sourceFilter, $sourceSort, $sourceJoin);
$this->Markable = true;
$this->setPageSize(15);
// search
$search = isset($_REQUEST['CommentSearch']) ? Convert::raw2sql($_REQUEST['CommentSearch']) : null;