From 69896840cb6fa9efe33bc7a1b59f0e019d14454e Mon Sep 17 00:00:00 2001 From: madmatt Date: Mon, 3 Aug 2015 19:30:55 +1200 Subject: [PATCH] BUGFIX: Links to CMS edit page fails when the link includes ?locale=en_NZ or similar --- code/reports/PagesDueForReviewReport.php | 17 +++++++++++++---- .../PagesWithoutReviewScheduleReport.php | 17 +++++++++++++---- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/code/reports/PagesDueForReviewReport.php b/code/reports/PagesDueForReviewReport.php index 2c132b9..c4241ff 100644 --- a/code/reports/PagesDueForReviewReport.php +++ b/code/reports/PagesDueForReviewReport.php @@ -43,12 +43,15 @@ class PagesDueForReviewReport extends SS_Report { */ public function columns() { - $linkBase = singleton('CMSPageEditController')->Link('show') . '/'; + $linkBase = singleton('CMSPageEditController')->Link('show'); + $linkPath = parse_url($linkBase, PHP_URL_PATH); + $linkQuery = parse_url($linkBase, PHP_URL_QUERY); + $fields = array( 'Title' => array( 'title' => 'Page name', - 'formatting' => '$value' + 'formatting' => sprintf('$value', $linkPath, $linkQuery) ), 'NextReviewDate' => array( 'title' => 'Review Date', @@ -85,13 +88,19 @@ class PagesDueForReviewReport extends SS_Report { ), 'ContentReviewType' => array( 'title' => 'Settings are', - 'formatting' => function($value, $item) use($linkBase) { + 'formatting' => function($value, $item) use($linkPath, $linkQuery) { if($item->ContentReviewType == 'Inherit') { $options = $item->getOptions(); if($options && $options instanceof SiteConfig) { return 'Inherited from Settings'; } elseif($options) { - return 'Inherited from '.$options->Title.''; + return sprintf( + 'Inherited from %s', + $linkPath, + $options->ID, + $linkQuery, + $options->Title + ); } } return $value; diff --git a/code/reports/PagesWithoutReviewScheduleReport.php b/code/reports/PagesWithoutReviewScheduleReport.php index c9381ca..88c101f 100644 --- a/code/reports/PagesWithoutReviewScheduleReport.php +++ b/code/reports/PagesWithoutReviewScheduleReport.php @@ -31,11 +31,14 @@ class PagesWithoutReviewScheduleReport extends SS_Report { * @return array */ public function columns() { - $linkBase = singleton('CMSPageEditController')->Link('show') . '/'; + $linkBase = singleton('CMSPageEditController')->Link('show'); + $linkPath = parse_url($linkBase, PHP_URL_PATH); + $linkQuery = parse_url($linkBase, PHP_URL_QUERY); + $fields = array( 'Title' => array( 'title' => 'Page name', - 'formatting' => '$value' + 'formatting' => sprintf('$value', $linkPath, $linkQuery) ), 'NextReviewDate' => array( 'title' => 'Review Date', @@ -59,13 +62,19 @@ class PagesWithoutReviewScheduleReport extends SS_Report { ), 'ContentReviewType' => array( 'title' => 'Settings are', - 'formatting' => function($value, $item) use($linkBase) { + 'formatting' => function($value, $item) use($linkPath, $linkQuery) { if($item->ContentReviewType == 'Inherit') { $options = $item->getOptions(); if($options && $options instanceof SiteConfig) { return 'Inherited from Settings'; } elseif($options) { - return 'Inherited from '.$options->Title.''; + return sprintf( + 'Inherited from %s', + $linkPath, + $options->ID, + $linkQuery, + $options->Title + ); } } return $value;