Skip to content

Commit

Permalink
FIX Corrected page edit links in reports
Browse files Browse the repository at this point in the history
  • Loading branch information
chillu committed Jul 12, 2012
1 parent 57c615d commit 8055fc2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
13 changes: 11 additions & 2 deletions code/reports/BrokenLinksReport.php
Expand Up @@ -80,11 +80,12 @@ function columns() {
$dateTitle = _t('BrokenLinksReport.ColumnDateLastPublished', 'Date last published');
}

$linkBase = singleton('CMSPageEditController')->Link('show') . '/';
$fields = array(
"Title" => array(
"title" => _t('BrokenLinksReport.PageName', 'Page name'),
'formatting' => sprintf(
'<a href=\"admin/show/$ID\" title=\"%s\">$value</a>',
'<a href=\"' . $linkBase . '$ID\" title=\"%s\">$value</a>',
_t('BrokenLinksReport.HoverTitleEditPage', 'Edit page')
)
),
Expand All @@ -97,7 +98,15 @@ function columns() {
),
'AbsoluteLink' => array(
'title' => _t('BrokenLinksReport.ColumnURL', 'URL'),
'formatting' => '$value " . ($AbsoluteLiveLink ? "<a target=\"_blank\" href=\"$AbsoluteLiveLink\">(live)</a>" : "") . " <a target=\"_blank\" href=\"$value?stage=Stage\">(draft)</a>'
'formatting' => function($value, $item) {
$liveLink = $item->AbsoluteLiveLink;
$stageLink = $item->AbsoluteLink();
return sprintf('%s <a href="%s">%s</a>',
$stageLink,
$liveLink ? $liveLink : $stageLink . '?stage=Stage',
$liveLink ? '(live)' : '(draft)'
);
}
)
);

Expand Down
2 changes: 1 addition & 1 deletion code/reports/Report.php
Expand Up @@ -238,7 +238,7 @@ function getCMSFields() {
}

// Add search fields is available
if($fields = $this->parameterFields()) {
if($this->hasMethod('parameterFields') && $fields = $this->parameterFields()) {
foreach($fields as $field) {
// Namespace fields for easier handling in form submissions
$field->setName(sprintf('filters[%s]', $field->getName()));
Expand Down
3 changes: 2 additions & 1 deletion code/reports/SideReport.php
Expand Up @@ -92,7 +92,8 @@ protected function formatValue($record, $source, $info) {
}

if(isset($info['link']) && $info['link']) {
$link = ($info['link'] === true) ? "admin/show/$record->ID" : $info['link'];
$linkBase = singleton('CMSPageEditController')->Link('show') . '/';
$link = ($info['link'] === true) ? $linkBase . $record->ID : $info['link'];
return $prefix . "<a $classClause href=\"$link\">$val</a>";
} else {
return $prefix . "<span $classClause>$val</span>";
Expand Down

0 comments on commit 8055fc2

Please sign in to comment.