From 2a919067a62b511e19cf4641f7f8a7e6d30526a9 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Fri, 15 Oct 2010 01:48:34 +0000 Subject: [PATCH] ENHANCEMENT Showing 20 comments in tabular view for CommentAdmin (and making the setting configurable via CommentAdmin::set_comments_per_page()) (from r105269) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@112464 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/CommentAdmin.php | 36 +++++++++++++++++++++++++++++------- code/CommentTableField.php | 1 - 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/code/CommentAdmin.php b/code/CommentAdmin.php index 81f14d20..77799efc 100644 --- a/code/CommentAdmin.php +++ b/code/CommentAdmin.php @@ -22,6 +22,12 @@ class CommentAdmin extends LeftAndMain { 'EditForm', '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(); @@ -89,15 +95,13 @@ class CommentAdmin extends LeftAndMain { 'Created' => 'SSDatetime->Full', '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 - ) - ) + 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; + } } ?> diff --git a/code/CommentTableField.php b/code/CommentTableField.php index f9bf395e..cf0d6c56 100644 --- a/code/CommentTableField.php +++ b/code/CommentTableField.php @@ -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;