From c7ebf76757dd8172ef6bc7104d126b6e46d52afe Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Tue, 7 May 2013 16:04:24 +1200 Subject: [PATCH] Page history panel: show appropriate message when viewing latest version --- code/controllers/CMSPageHistoryController.php | 17 ++++++++++------- .../controller/CMSPageHistoryControllerTest.php | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/code/controllers/CMSPageHistoryController.php b/code/controllers/CMSPageHistoryController.php index d1402aca..9444f141 100644 --- a/code/controllers/CMSPageHistoryController.php +++ b/code/controllers/CMSPageHistoryController.php @@ -142,13 +142,16 @@ class CMSPageHistoryController extends CMSMain { ); $revert->setReadonly(true); - } - else { - $message = _t( - 'CMSPageHistoryController.VIEWINGVERSION', - "Currently viewing version {version}.", - array('version' => $versionID) - ); + } else { + if($record->isLatestVersion()) { + $message = _t('CMSPageHistoryController.VIEWINGLATEST', 'Currently viewing the latest version.'); + } else { + $message = _t( + 'CMSPageHistoryController.VIEWINGVERSION', + "Currently viewing version {version}.", + array('version' => $versionID) + ); + } } $fields->addFieldToTab('Root.Main', diff --git a/tests/controller/CMSPageHistoryControllerTest.php b/tests/controller/CMSPageHistoryControllerTest.php index 18f0d6d5..a79a6f71 100755 --- a/tests/controller/CMSPageHistoryControllerTest.php +++ b/tests/controller/CMSPageHistoryControllerTest.php @@ -52,7 +52,7 @@ class CMSPageHistoryControllerTest extends FunctionalTest { $this->assertEquals($this->versionPublishCheck2, $form->Fields()->dataFieldByName('Version')->Value()); $this->assertContains( - sprintf("Currently viewing version %s.", $this->versionPublishCheck2), + 'Currently viewing the latest version', $form->Fields()->fieldByName('Root.Main.CurrentlyViewingMessage')->getContent() );