Skip to content
This repository
Browse code

FIX Corrected page edit links in reports

  • Loading branch information...
commit 8055fc2e7be9c4e6dd137702f2baf7993f340c92 1 parent 57c615d
Ingo Schommer authored July 12, 2012
13  code/reports/BrokenLinksReport.php
@@ -80,11 +80,12 @@ function columns() {
80 80
 			$dateTitle = _t('BrokenLinksReport.ColumnDateLastPublished', 'Date last published');
81 81
 		}
82 82
 		
  83
+		$linkBase = singleton('CMSPageEditController')->Link('show') . '/';
83 84
 		$fields = array(
84 85
 			"Title" => array(
85 86
 				"title" => _t('BrokenLinksReport.PageName', 'Page name'),
86 87
 				'formatting' => sprintf(
87  
-					'<a href=\"admin/show/$ID\" title=\"%s\">$value</a>',
  88
+					'<a href=\"' . $linkBase . '$ID\" title=\"%s\">$value</a>',
88 89
 					_t('BrokenLinksReport.HoverTitleEditPage', 'Edit page')
89 90
 				)
90 91
 			),
@@ -97,7 +98,15 @@ function columns() {
97 98
 			),
98 99
 			'AbsoluteLink' => array(
99 100
 				'title' => _t('BrokenLinksReport.ColumnURL', 'URL'),
100  
-				'formatting' => '$value " . ($AbsoluteLiveLink ? "<a target=\"_blank\" href=\"$AbsoluteLiveLink\">(live)</a>" : "") . " <a target=\"_blank\" href=\"$value?stage=Stage\">(draft)</a>'
  101
+				'formatting' => function($value, $item) {
  102
+					$liveLink = $item->AbsoluteLiveLink;
  103
+					$stageLink = $item->AbsoluteLink();
  104
+					return sprintf('%s <a href="%s">%s</a>',
  105
+						$stageLink,
  106
+						$liveLink ? $liveLink : $stageLink . '?stage=Stage',
  107
+						$liveLink ? '(live)' : '(draft)'
  108
+					);
  109
+				}
101 110
 			)
102 111
 		);
103 112
 		
2  code/reports/Report.php
@@ -238,7 +238,7 @@ function getCMSFields() {
238 238
 		}
239 239
 			
240 240
 		// Add search fields is available
241  
-		if($fields = $this->parameterFields()) {
  241
+		if($this->hasMethod('parameterFields') && $fields = $this->parameterFields()) {
242 242
 			foreach($fields as $field) {
243 243
 				// Namespace fields for easier handling in form submissions
244 244
 				$field->setName(sprintf('filters[%s]', $field->getName()));
3  code/reports/SideReport.php
@@ -92,7 +92,8 @@ protected function formatValue($record, $source, $info) {
92 92
 		}
93 93
 		
94 94
 		if(isset($info['link']) && $info['link']) {
95  
-			$link = ($info['link'] === true) ? "admin/show/$record->ID" : $info['link'];
  95
+			$linkBase = singleton('CMSPageEditController')->Link('show') . '/';
  96
+			$link = ($info['link'] === true) ? $linkBase . $record->ID : $info['link'];
96 97
 			return $prefix . "<a $classClause href=\"$link\">$val</a>";
97 98
 		} else {
98 99
 			return $prefix . "<span $classClause>$val</span>";

0 notes on commit 8055fc2

Please sign in to comment.
Something went wrong with that request. Please try again.