\SS_Report
Base "abstract" class creating reports on your data.
Creating reports
================
Creating a new report is a matter overloading a few key methods
: Return the title - i18n is your responsibility
: Return the description - i18n is your responsibility
: Return a DataObjectSet of the search results
: Return information about the columns in this report.
: Return a FieldSet of the fields that can be used to filter this
report.
If you can't express your report as a query, you can implement the this method instead:
// Return an array of fields that can be used to sort the data
public function sourceRecords($params, $sort, $limit) { ... }
The $sort value will be set to the corresponding key of the columns() array. If you wish to
make only a subset of the columns sortable, then you can override `sortColumns()` to return a
subset of the array keys.
Note that this implementation is less efficient and should only be used when necessary.
If you wish to modify the report in more extreme ways, you could overload these methods instead.
: Return a FormField in the place where your report's TableListField
usually appears.
: Return the FieldSet representing the complete right-hand area of the
report, including the title, description, parameter fields, and results.
Showing reports to the user
===========================
Right now, all subclasses of SS_Report will be shown in the ReportAdmin. However, we are planning
on adding an explicit registration mechanism, so that you can decide which reports go in the
report admin, and which go elsewhere (such as the side panel in the CMS).
Synopsis
- // members
- private static array $registered_reports = ;
- protected string $title = '';
- protected string $description = '';
- protected string $dataClass = 'SiteTree';
- // methods
- public void title()
- public void description()
- public void parameterFields()
- public void sourceQuery()
- public void records()
- public void columns()
- public void sortColumns()
- public void count()
- public void dataClass()
- public FieldSet getCMSFields()
- public void getCMSActions()
- public FormField getReportField()
- public boolean canView()
- public string TreeTitle()
- public string ID()
- public static void register()
- public static void unregister()
- public static An get_reports()
Hierarchy
Extends
- ViewableData
Members
private
-
$registered_reports
Report registry populated by {@link SS_Report::register()}
protected
-
$dataClass
The class of object being managed by this report. - $description
—
string
This is a description about what this report does. Used by the ReportAdmin templates. - $title
—
string
This is the title of the report, used by the ReportAdmin templates.
Methods
public
- ID() — Return the ID of this Report class.
- TreeTitle() — Return the name of this report, which is used by the templates to render the name of the report in the report tree, the left hand pane inside ReportAdmin.
- canView()
- columns() — Return an map of columns for your report.
- count() — Return the number of records in this report with no filters applied.
- dataClass() — Return the data class for this report
- description() — Return the description of this report.
- getCMSActions()
- getCMSFields() — Returns a FieldSet with which to create the CMS editing form.
- getReportField() — Return a field, such as a {@link ComplexTableField} that is used to show and manipulate data relating to this report.
- get_reports() — Return the SS_Report objects making up the given list.
- parameterFields() — Return a FieldSet specifying the search criteria for this report.
- records() — Return a DataObjectSet records for this report.
- register() — Register a report.
- sortColumns()
- sourceQuery() — Return the {@link SQLQuery} that provides your report data.
- title() — Return the title of this report.
- unregister() — Unregister a report, removing it from the list