From 0389e784b2177cad9800eb111aa1b16932dea626 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Fri, 28 May 2010 02:23:10 +0000 Subject: [PATCH] API CHANGE: Removed SideReport class, use SSReport as the base-class for them instead. API CHANGE: Use SSReport::register(SideReport) to explicitly register reports on the LHS of the content view. BUGFIX: Updated all cms side reports to use SSReport as the base class. (from r95884) (from r98176) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@105827 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- _config.php | 10 +- code/CMSMain.php | 45 +++++---- code/SideReport.php | 180 ++++++++++++++++++++---------------- code/SideReportsHandler.php | 94 ------------------- 4 files changed, 136 insertions(+), 193 deletions(-) delete mode 100644 code/SideReportsHandler.php diff --git a/_config.php b/_config.php index aa1fa5c2..2224397a 100644 --- a/_config.php +++ b/_config.php @@ -50,5 +50,13 @@ HtmlEditorConfig::get('cms')->insertButtonsAfter ('advcode', 'fullscreen', 'sepa HtmlEditorConfig::get('cms')->removeButtons('tablecontrols'); HtmlEditorConfig::get('cms')->addButtonsToLine(3, 'tablecontrols'); +// Register default side reports +SS_Report::register("SideReport", "SideReport_ToDo"); +SS_Report::register("SideReport", "SideReport_BrokenRedirectorPages"); +SS_Report::register("SideReport", "SideReport_BrokenVirtualPages"); +SS_Report::register("SideReport", "SideReport_BrokenFiles"); +SS_Report::register("SideReport", "SideReport_BrokenLinks"); +SS_Report::register("SideReport", "SideReport_RecentlyEdited"); +SS_Report::register("SideReport", "SideReport_EmptyPages"); -?> +?> \ No newline at end of file diff --git a/code/CMSMain.php b/code/CMSMain.php index c936abe9..114d4968 100755 --- a/code/CMSMain.php +++ b/code/CMSMain.php @@ -635,19 +635,25 @@ JS; } } - function sidereports() { - return new SideReportsHandler($this, 'sidereports'); + /** + * @return Array + */ + function SideReports() { + return SSReport::get_reports('SideReport'); } + /** + * @return Form + */ function SideReportsForm() { $record = $this->currentPage(); - $reports = $this->sidereports()->getReportClasses(); - $options = array(); - foreach($reports as $report) { - if($report != 'SideReport' && singleton($report)->canView()) { - $options[singleton($report)->group()][singleton($report)->sort()][$report] = singleton($report)->title(); + + foreach($this->SideReports() as $report) { + if($report->canView()) { + $options[$report->group()][$report->sort()][$report->ID()] = $report->title(); } } + $finalOptions = array(); foreach($options as $group => $weights) { ksort($weights); @@ -657,11 +663,8 @@ JS; } } } - $selectorField = new GroupedDropdownField( - "ReportClass", - false, - $finalOptions - ); + + $selectorField = new GroupedDropdownField("ReportClass", _t('CMSMain.REPORT', 'Report'),$finalOptions); $form = new Form( $this, @@ -684,11 +687,21 @@ JS; /** * @return Form */ - function doShowSideReport($data, $form) { - $form = $this->sidereports()->getForm($data['ReportClass'], $data); - return $form->forTemplate(); + function doShowSideReport() { + $reportClass = $this->urlParams['ID']; + $reports = $this->SideReports(); + if(isset($reports[$reportClass])) { + $report = $reports[$reportClass]; + if($report) { + $view = new SideReportView($this, $report); + $view->setParameters($this->request->requestVars()); + return $view->forTemplate(); + } else { + return false; + } + } } - + /** * @return Form */ diff --git a/code/SideReport.php b/code/SideReport.php index 79f681cb..b6fd62cb 100755 --- a/code/SideReport.php +++ b/code/SideReport.php @@ -1,4 +1,5 @@ controller = $controller; + $this->report = $report; + parent::__construct(); + } function group() { return 'Other'; @@ -21,47 +25,22 @@ abstract class SideReport extends Object { return 0; } - function getHTML() { - $records = $this->records(); - $fieldsToShow = $this->fieldsToShow(); + function setParameters($parameters) { + $this->parameters = $parameters; + } + + function forTemplate() { + $records = $this->report->records($this->parameters); + $columns = $this->report->columns(); - if($records && count($records)) { + if($records && $records->Count()) { $result = "