API CHANGE Removed CMSMain->SideReportsForm() and related functionality, now handled by dedicated ReportAdmin interface

This commit is contained in:
Ingo Schommer 2012-03-09 23:07:31 +01:00
parent 059137290f
commit 055b3b9799

View File

@ -38,8 +38,6 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
'publishall', 'publishall',
'publishitems', 'publishitems',
'PublishItemsForm', 'PublishItemsForm',
'sidereport',
'SideReportsForm',
'submit', 'submit',
'EditForm', 'EditForm',
'AddForm', 'AddForm',
@ -843,99 +841,6 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
$this->redirectBack(); $this->redirectBack();
} }
} }
/**
* @return Array
*/
function SideReports() {
return SS_Report::get_reports('SideReport');
}
/**
* @return Form
*/
function SideReportsForm() {
$record = $this->currentPage();
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);
foreach($weights as $weight => $reports) {
foreach($reports as $class => $report) {
$finalOptions[$group][$class] = $report;
}
}
}
$selectorField = new GroupedDropdownField("ReportClass", _t('CMSMain.REPORT', 'Report'),$finalOptions);
$form = new Form(
$this,
'SideReportsForm',
new FieldList(
$selectorField,
new HiddenField('ID', false, ($record) ? $record->ID : null),
new HiddenField('Locale', false, $this->Locale)
),
new FieldList(
FormAction::create('doShowSideReport', _t('CMSMain_left.ss.GO','Go'))->setUseButtonTag(true)
)
);
$form->unsetValidator();
$this->extend('updateSideReportsForm', $form);
return $form;
}
/**
* Generate the parameter HTML for SideReports that have params
*
* @return LiteralField
*/
function ReportFormParameters() {
$forms = array();
foreach($this->SideReports() as $report) {
if ($report->canView()) {
if ($fieldset = $report->parameterFields()) {
$formHtml = '';
foreach($fieldset as $field) {
$formHtml .= $field->FieldHolder();
}
$forms[$report->ID()] = $formHtml;
}
}
}
$pageHtml = '';
foreach($forms as $class => $html) {
$pageHtml .= "<div id=\"SideReportForm_$class\" style=\"display:none\">$html</div>\n\n";
}
return new LiteralField("ReportFormParameters", '<div id="SideReportForms" style="display:none">'.$pageHtml.'</div>');
}
/**
* @return Form
*/
function doShowSideReport($data, $form) {
$reportClass = (isset($data['ReportClass'])) ? $data['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;
}
}
}
function publish($data, $form) { function publish($data, $form) {
$data['publish'] = '1'; $data['publish'] = '1';