Permalink
Browse files

FIX Corrected page edit links in reports

  • Loading branch information...
1 parent 57c615d commit 8055fc2e7be9c4e6dd137702f2baf7993f340c92 @chillu chillu committed Jul 12, 2012
Showing with 14 additions and 4 deletions.
  1. +11 −2 code/reports/BrokenLinksReport.php
  2. +1 −1 code/reports/Report.php
  3. +2 −1 code/reports/SideReport.php
@@ -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')
)
),
@@ -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)'
+ );
+ }
)
);
@@ -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()));
@@ -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>";

0 comments on commit 8055fc2

Please sign in to comment.