From a5753ad5efd83613a42a703d9af066639b415b78 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Thu, 4 Feb 2010 04:50:38 +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) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@98176 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- _config.php | 10 ++- code/CMSMain.php | 38 ++++---- code/SideReport.php | 206 ++++++++++++++++++++++++++------------------ 3 files changed, 152 insertions(+), 102 deletions(-) diff --git a/_config.php b/_config.php index aa1fa5c2..9246eebb 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 +SSReport::register("SideReport", "SideReport_ToDo"); +SSReport::register("SideReport", "SideReport_BrokenRedirectorPages"); +SSReport::register("SideReport", "SideReport_BrokenVirtualPages"); +SSReport::register("SideReport", "SideReport_BrokenFiles"); +SSReport::register("SideReport", "SideReport_BrokenLinks"); +SSReport::register("SideReport", "SideReport_RecentlyEdited"); +SSReport::register("SideReport", "SideReport_EmptyPages"); -?> +?> \ No newline at end of file diff --git a/code/CMSMain.php b/code/CMSMain.php index 9adc4ef2..0b5ed4e0 100755 --- a/code/CMSMain.php +++ b/code/CMSMain.php @@ -660,18 +660,18 @@ JS; Director::redirectBack(); } } + + function SideReports() { + return SSReport::get_reports('SideReport'); + } /* * Return a dropdown for selecting reports */ function ReportSelector() { - $reports = ClassInfo::subclassesFor("SideReport"); - // $options[""] = _t('CMSMain.CHOOSEREPORT',"(Choose a report)"); - 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->ID()] = $report->title(); } $finalOptions = array(); @@ -687,17 +687,15 @@ JS; return new GroupedDropdownField("ReportSelector", _t('CMSMain.REPORT', 'Report'),$finalOptions); } function ReportFormParameters() { - $reports = ClassInfo::subclassesFor("SideReport"); - $forms = array(); - foreach($reports as $report) { - if ($report != 'SideReport' && singleton($report)->canView()) { - if ($fieldset = singleton($report)->getParameterFields()) { + foreach($this->SideReports() as $report) { + if ($report->canView()) { + if ($fieldset = $report->parameterFields()) { $formHtml = ''; foreach($fieldset as $field) { $formHtml .= $field->FieldHolder(); } - $forms[$report] = $formHtml; + $forms[$report->ID()] = $formHtml; } } } @@ -713,10 +711,20 @@ JS; */ function sidereport() { $reportClass = $this->urlParams['ID']; - $report = ClassInfo::exists($reportClass) ? new $reportClass() : false; - $report->setParams($this->request->requestVars()); - return $report ? $report->getHTML() : false; + $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; + } + } } + + /** * Get the versions of the current page */ diff --git a/code/SideReport.php b/code/SideReport.php index 33b865b1..1b635480 100755 --- a/code/SideReport.php +++ b/code/SideReport.php @@ -1,16 +1,17 @@ controller = $controller; + $this->report = $report; + parent::__construct(); + } function group() { return 'Other'; @@ -20,47 +21,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 = "