mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +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) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@98191 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
5e8fc6c920
commit
63580a4b13
@ -60,6 +60,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']);
|
||||
@ -71,17 +77,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