Version: current

# Class SS_Report

Base "abstract" class creating reports on your data.

# Creating reports

Creating a new report is a matter overloading a few key methods
`SS_Report::title()`: Return the title - i18n is your responsibility `SS_Report::description()`: Return the description - i18n is your responsibility `SS_Report::sourceQuery()`: Return a DataObjectSet of the search results `SS_Report::columns()`: Return information about the columns in this report. `SS_Report::parameterFields()`: 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.

`SS_Report::getReportField()`: Return a FormField in the place where your report's TableListField usually appears. `SS_Report::getCMSFields()`: 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).

  Object
  ViewableData implements IteratorAggregate
  SS_Report

### Direct known subclasses

`BigFilesReport`, `BrokenLinksReport`, `SS_ReportWrapper`, `NonUsedFilesReport`, `SideReport_BrokenFiles`, `SideReport_BrokenLinks`, `SideReport_BrokenRedirectorPages`, `SideReport_BrokenVirtualPages`, `SideReport_EmptyPages`, `SideReport_RecentlyEdited`, `SideReport_ToDo`

### Indirect known subclasses

`SideReportWrapper`, `SubsiteReportWrapper`

Package: cms\reports
Located at cms/code/Report.php

## Methods summary

`public` | # `title( )` Return the title of this report. Return the title of this report. You have two ways of specifying the description: - overriding description(), which lets you support i18n - defining the $description property
`public` | # `description( )` Return the description of this report. Return the description of this report. You have two ways of specifying the description: - overriding description(), which lets you support i18n - defining the $description property
`public` | # `parameterFields( )` Return a FieldSet specifying the search criteria for this report. Return a FieldSet specifying the search criteria for this report. Override this method to define search criteria.
`public` | # `sourceQuery( mixed $params )` Return the `SQLQuery` that provides your report data. Return the `SQLQuery` that provides your report data.
`public` | # `records( mixed $params )` Return a DataObjectSet records for this report. Return a DataObjectSet records for this report.
`public` | # `columns( )` Return an map of columns for your report. - The map keys will be the source columns for your report (in TableListField dot syntax) - The values can either be a string (the column title), or a map containing the following column parameters: - title: The column title - formatting: A formatting string passed to `TableListField::setFieldFormatting()` Return an map of columns for your report. - The map keys will be the source columns for your report (in TableListField dot syntax) - The values can either be a string (the column title), or a map containing the following column parameters: - title: The column title - formatting: A formatting string passed to `TableListField::setFieldFormatting()`
`public` | # `sortColumns( )`
`public` | # `count( )` Return the number of records in this report with no filters applied. Return the number of records in this report with no filters applied.
`public` | # `dataClass( )` Return the data class for this report Return the data class for this report
`public `FieldSet`` | # `getCMSFields( )` Returns a FieldSet with which to create the CMS editing form. You can use the extend() method of FieldSet to create customised forms for your other data objects. Returns a FieldSet with which to create the CMS editing form. You can use the extend() method of FieldSet to create customised forms for your other data objects. #### Returns ``FieldSet`` FieldSet #### Uses ``SS_Report::getReportField()`` to render a table, or similar field for the report. This method should be defined on the SS_Report subclasses.
`public` | # `getCMSActions( )`
`public `FormField`` | # `getReportField( )` Return a field, such as a `ComplexTableField` that is used to show and manipulate data relating to this report. Return a field, such as a `ComplexTableField` that is used to show and manipulate data relating to this report. Generally, you should override `SS_Report::columns()` and `SS_Report::records()` to make your report, but if they aren't sufficiently flexible, then you can override this method. #### Returns ``FormField`` subclass #### Used by ``SS_Report::getCMSFields()`` to render a table, or similar field for the report. This method should be defined on the SS_Report subclasses.
`public boolean` | # `canView( `Member` $member = null )` #### Parameters $member Member $member #### Returns `boolean` boolean
`public string` | # `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. 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. #### Returns `string` string
`public string` | # `ID( )` Return the ID of this Report class. Because it doesn't have a number, we use the class name as the ID. Return the ID of this Report class. Because it doesn't have a number, we use the class name as the ID. #### Returns `string` string
`public static` | # `register( mixed $list, mixed $reportClass, mixed $priority = 0 )` Register a report. Register a report. #### Parameters $list $list The list to add the report to: "ReportAdmin" or "SideReports" $reportClass $reportClass The class of the report to add. $priority $priority The priority. Higher numbers will appear furhter up in the reports list. The default value is zero.
`public static` | # `unregister( mixed $list, mixed $reportClass )` Unregister a report, removing it from the list Unregister a report, removing it from the list
`public static An` | # `get_reports( mixed $list )` Return the SS_Report objects making up the given list. Return the SS_Report objects making up the given list. #### Returns `An` array of SS_Report objects

### Methods inherited from ViewableData

`ATT_val()`, `BaseHref()`, `CSSClasses()`, `ColumnBreak()`, `ColumnCalc()`, `ColumnNumber()`, `ColumnPad()`, `ColumnPos()`, `CurrentMember()`, `CurrentPage()`, `Debug()`, `Even()`, `EvenOdd()`, `First()`, `FirstLast()`, `HasPerm()`, `IsAjax()`, `JS_val()`, `Last()`, `Me()`, `Middle()`, `MiddleString()`, `Modulus()`, `MultipleOf()`, `Odd()`, `Pos()`, `RAW_val()`, `SQL_val()`, `ThemeDir()`, `ThemeName()`, `Top()`, `TotalItems()`, `XML_val()`, `__get()`, `__isset()`, `__set()`, `buildCastingCache()`, `cachedCall()`, `castingClass()`, `castingHelper()`, `castingHelperPair()`, `castingObjectCreator()`, `castingObjectCreatorPair()`, `customise()`, `defineMethods()`, `escapeTypeForField()`, `getField()`, `getIterator()`, `getSecurityID()`, `getXMLValues()`, `hasField()`, `hasValue()`, `i18nLocale()`, `iteratorProperties()`, `obj()`, `renderWith()`, `setCustomisedObj()`, `setField()`

### Methods inherited from Object

`__call()`, `__construct()`, `__toString()`, `__wakeup()`, `addMethodsFrom()`, `addStaticVars()`, `addWrapperMethod()`, `add_extension()`, `add_static_var()`, `allMethodNames()`, `cacheToFile()`, `cacheToFileWithArgs()`, `clearCache()`, `combined_static()`, `create()`, `createMethod()`, `create_from_string()`, `exists()`, `extInstance()`, `extend()`, `getCustomClass()`, `getExtensionInstance()`, `getExtensionInstances()`, `get_extensions()`, `get_static()`, `hasExtension()`, `hasMethod()`, `has_extension()`, `invokeWithExtensions()`, `is_a()`, `loadCache()`, `parentClass()`, `parse_class_spec()`, `remove_extension()`, `sanitiseCachename()`, `saveCache()`, `set_stat()`, `set_static()`, `set_uninherited()`, `stat()`, `strong_create()`, `uninherited()`, `uninherited_static()`, `useCustomClass()`

### Magic methods summary

## Properties summary

`protected string` | $title | # This is the title of the report, used by the ReportAdmin templates. This is the title of the report, used by the ReportAdmin templates.
`protected string` | $description | # This is a description about what this report does. Used by the ReportAdmin templates. This is a description about what this report does. Used by the ReportAdmin templates.
`protected string` | $dataClass | # The class of object being managed by this report. Set by overriding in your subclass. The class of object being managed by this report. Set by overriding in your subclass.

### Properties inherited from ViewableData

`$casting`, `$customisedObject`, `$default_cast`, `$failover`, `$iteratorPos`, `$iteratorTotalItems`

### Properties inherited from Object

`$class`, `$extension_instances`, `$extensions`

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -