mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
API CHANGE: Added SideReportWrapper to help you tailor report columns for the side reports.
API CHANGE: Allow use of 'casting' option on side report columns. API CHANGE: Make 'title' optional on side report columns. (from r96272) (from r98191) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@105836 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
0a003df83e
commit
e1242f0a26
@ -64,6 +64,12 @@ class SideReportView extends ViewableData {
|
||||
// $val = $record->val($source[0], $source[1]);
|
||||
//}
|
||||
|
||||
// Casting, a la TableListField. We're deep-calling a helper method on TableListField that
|
||||
// should probably be pushed elsewhere...
|
||||
if(!empty($info['casting'])) {
|
||||
$val = TableListField::getCastedValue($val, $info['casting']);
|
||||
}
|
||||
|
||||
// Formatting, a la TableListField
|
||||
if(!empty($info['formatting'])) {
|
||||
$format = str_replace('$value', "__VAL__", $info['formatting']);
|
||||
@ -75,17 +81,37 @@ class SideReportView extends ViewableData {
|
||||
$prefix = empty($info['newline']) ? "" : "<br>";
|
||||
|
||||
|
||||
$cssClass = ereg_replace('[^A-Za-z0-9]+','',$info['title']);
|
||||
$classClause = "";
|
||||
if(isset($info['title'])) {
|
||||
$cssClass = ereg_replace('[^A-Za-z0-9]+','',$info['title']);
|
||||
$classClause = "class=\"$cssClass\"";
|
||||
}
|
||||
|
||||
if(isset($info['link']) && $info['link']) {
|
||||
$link = ($info['link'] === true) ? "admin/show/$record->ID" : $info['link'];
|
||||
return $prefix . "<a class=\"$cssClass\" href=\"$link\">$val</a>";
|
||||
return $prefix . "<a $classClause href=\"$link\">$val</a>";
|
||||
} else {
|
||||
return $prefix . "<span class=\"$cssClass\">$val</span>";
|
||||
return $prefix . "<span $classClause>$val</span>";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A report wrapper that makes it easier to define slightly different behaviour for side-reports.
|
||||
*
|
||||
* This report wrapper will use sideReportColumns() for the report columns, instead of columns().
|
||||
*/
|
||||
class SideReportWrapper extends SSReportWrapper {
|
||||
function columns() {
|
||||
if($this->baseReport->hasMethod('sideReportColumns')) {
|
||||
return $this->baseReport->sideReportColumns();
|
||||
} else {
|
||||
return parent::columns();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user