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 = "