silverstripe-cms/code/Report.php
Sam Minnee f71804e465 API CHANGE: Renamed conflicting classes to have an "SS_" namespace, and renamed existing "SS" namespace to "SS_". The affected classes are: HTTPRequest, HTTPResponse, Query, Database, SSBacktrace, SSCli, SSDatetime, SSDatetimeTest, SSLog, SSLogTest, SSLogEmailWriter, SSLogErrorEmailFormatter, SSLogErrorFileFormatter, SSLogFileWriter and SSZendLog.
MINOR: Replaced usage of renamed classes with the new namespaced name.

From: Sam Minnee <sam@silverstripe.com>


git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@90076 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-10-26 03:06:42 +00:00

122 lines
2.9 KiB
PHP

<?php
/**
* Base "abstract" class for all Report classes
* viewable in the Reports top menu section of CMS.
*
* To include your own report into the ReportAdmin
* of the CMS, your subclass of SS_Report should
* overload these:
*
* @link SS_Report::$title
* @link SS_Report::$description
* @link SS_Report->getReportField()
*
* getReportField() should return a FormField instance,
* such as a ComplexTableField, or TableListField. This
* is the "meat" of the report, as it's designed to
* show the actual data for the function of the report.
* For example, if this was a report that should show
* all orders that aren't printed, then it would show
* a TableListField listing orders that have the property
* "Unprinted = 1".
*
* @see ReportAdmin for where SS_Report instances are
* used in the CMS.
*
* @package cms
* @subpackage reports
*/
class SS_Report extends ViewableData {
/**
* This is the title of the report,
* used by the ReportAdmin templates.
*
* @var string
*/
protected $title = '';
/**
* This is a description about what this
* report does. Used by the ReportAdmin
* templates.
*
* @var string
*/
protected $description = '';
/**
* 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.
*
* @uses getReportField() to render a table, or similar field for the report. This
* method should be defined on the SS_Report subclasses.
*
* @return FieldSet
*/
function getCMSFields() {
$fields = new FieldSet(
new TabSet('Root',
new Tab('Report',
new LiteralField('ReportTitle', "<h3>{$this->title}</h3>"),
new LiteralField('ReportDescription', "<p>{$this->description}</p>"),
$this->getReportField()
)
)
);
return $fields;
}
/**
* @param Member $member
* @return boolean
*/
function canView($member = null) {
if(!$member && $member !== FALSE) {
$member = Member::currentUser();
}
return true;
}
/**
* Return a field, such as a {@link ComplexTableField} that is
* used to show and manipulate data relating to this report.
*
* For example, if this were an "Unprinted Orders" report, this
* field would return a table that shows all Orders with "Unprinted = 1".
*
* @return FormField subclass
*/
function getReportField() {
user_error('Please implement getReportField() on ' . $this->class, E_USER_ERROR);
}
/**
* 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 string
*/
function TreeTitle() {
return $this->title;
}
/**
* Return the ID of this Report class.
* Because it doesn't have a number, we
* use the class name as the ID.
*
* @return string
*/
function ID() {
return $this->class;
}
}
?>