mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
BUG Fix incorrect url manipulation
Fixes https://github.com/silverstripe/silverstripe-cms/issues/1183
This commit is contained in:
parent
b985ce0eba
commit
87477a1e01
@ -293,8 +293,20 @@ class SS_Report extends ViewableData {
|
|||||||
if(isset($info['casting'])) $fieldCasting[$source] = $info['casting'];
|
if(isset($info['casting'])) $fieldCasting[$source] = $info['casting'];
|
||||||
|
|
||||||
if(isset($info['link']) && $info['link']) {
|
if(isset($info['link']) && $info['link']) {
|
||||||
$link = singleton('CMSPageEditController')->Link('show');
|
$fieldFormatting[$source] = function($value, $item) {
|
||||||
$fieldFormatting[$source] = '<a href=\"' . $link . '/$ID\">$value</a>';
|
$title = Convert::raw2xml($value);
|
||||||
|
|
||||||
|
// If this item is previewable, decorate with link
|
||||||
|
if ($item instanceof CMSPreviewable) {
|
||||||
|
return sprintf(
|
||||||
|
'<a href="%s" title="%s">%s</a>',
|
||||||
|
$item->CMSEditLink(), $title, $title
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fall back to basic title
|
||||||
|
return $title;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
$displayFields[$source] = isset($info['title']) ? $info['title'] : $source;
|
$displayFields[$source] = isset($info['title']) ? $info['title'] : $source;
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
*/
|
*/
|
||||||
class ReportTest extends SapphireTest {
|
class ReportTest extends SapphireTest {
|
||||||
|
|
||||||
|
protected $usesDatabase = true;
|
||||||
|
|
||||||
public function testGetReports() {
|
public function testGetReports() {
|
||||||
$reports = SS_Report::get_reports();
|
$reports = SS_Report::get_reports();
|
||||||
$this->assertNotNull($reports, "Reports returned");
|
$this->assertNotNull($reports, "Reports returned");
|
||||||
@ -76,6 +78,42 @@ class ReportTest extends SapphireTest {
|
|||||||
$this->logInWithPermission('ADMIN');
|
$this->logInWithPermission('ADMIN');
|
||||||
$this->assertTrue($report->canView());
|
$this->assertTrue($report->canView());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testColumnLink() {
|
||||||
|
$report = new ReportTest_FakeTest();
|
||||||
|
/** @var GridField $gridField */
|
||||||
|
$gridField = $report->getReportField();
|
||||||
|
/** @var GridFieldDataColumns $columns */
|
||||||
|
$columns = $gridField->getConfig()->getComponentByType('GridFieldDataColumns');
|
||||||
|
|
||||||
|
$page = new ReportTest_FakeObject();
|
||||||
|
$page->Title = 'My Object';
|
||||||
|
$page->ID = 959547;
|
||||||
|
|
||||||
|
$titleContent = $columns->getColumnContent($gridField, $page, 'Title');
|
||||||
|
$this->assertEquals('<a href="dummy-edit-link/959547" title="My Object">My Object</a>', $titleContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ReportTest_FakeObject extends DataObject implements CMSPreviewable, TestOnly {
|
||||||
|
|
||||||
|
private static $db = array(
|
||||||
|
'Title' => 'Varchar'
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return String Absolute URL to the end-user view for this record.
|
||||||
|
* Example: http://mysite.com/my-record
|
||||||
|
*/
|
||||||
|
public function Link()
|
||||||
|
{
|
||||||
|
return Controller::join_links('dummy-link', $this->ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function CMSEditLink()
|
||||||
|
{
|
||||||
|
return Controller::join_links('dummy-edit-link', $this->ID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -89,7 +127,8 @@ class ReportTest_FakeTest extends SS_Report implements TestOnly {
|
|||||||
public function columns() {
|
public function columns() {
|
||||||
return array(
|
return array(
|
||||||
"Title" => array(
|
"Title" => array(
|
||||||
"title" => "Page Title"
|
"title" => "Page Title",
|
||||||
|
"link" => true,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user