From c7369060168c6214cf88403fef6c316446f6a5d9 Mon Sep 17 00:00:00 2001 From: Nicolaas Date: Thu, 21 Feb 2013 09:01:26 +1300 Subject: [PATCH 1/2] adding getCount method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit the getCount method works out the number of "entries" for each report. E.g. if the report is "missing pages" and the method returns 3 then there are three "missing pages".  --- code/Report.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/code/Report.php b/code/Report.php index 82c786d8..b673e36d 100644 --- a/code/Report.php +++ b/code/Report.php @@ -127,6 +127,7 @@ class SS_Report extends ViewableData { return $this->dataClass; } + public function getLink($action = null) { return Controller::join_links( 'admin/reports/', @@ -136,6 +137,21 @@ class SS_Report extends ViewableData { ); } + + /** + * counts the number of objects returned + * @param Array $params - any parameters for the sourceRecords + * @return Int + */ + public function getCount($params = array()){ + $sourceRecords = $this->sourceRecords($params, null, null); + if(!$sourceRecords instanceOf SS_List){ + user_error($this->class."::sourceRecords does not return an SS_List", E_USER_NOTICE); + return "-1"; + } + return $sourceRecords->count(); + } + /** * Exclude certain reports classes from the list of Reports in the CMS * @param $reportClass Can be either a string with the report classname or an array of reports classnames @@ -420,4 +436,4 @@ abstract class SS_ReportWrapper extends SS_Report { public function canView($member = null) { return $this->baseReport->canView($member); } -} \ No newline at end of file +} From 78cebe8723bf8f5e87eb456ba6ed0f935a192aaf Mon Sep 17 00:00:00 2001 From: Nicolaas Date: Thu, 21 Feb 2013 09:04:21 +1300 Subject: [PATCH 2/2] adding count to reports adds a count for each report. --- code/ReportAdmin.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/code/ReportAdmin.php b/code/ReportAdmin.php index 04305084..8a222ca6 100644 --- a/code/ReportAdmin.php +++ b/code/ReportAdmin.php @@ -165,9 +165,9 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider { 'title' => _t('ReportAdmin.ReportTitle', 'Title'), )); - $columns->setFieldFormatting(array( - 'title' => '$value' - )); + $columns->setFieldFormatting(array( + 'title' => '$value ($Count)' + )); $gridField->addExtraClass('all-reports-gridfield'); $fields->push($gridField); } @@ -181,4 +181,4 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider { return $form; } -} \ No newline at end of file +}