From cb19549a97db34c3796322721af413a2aa08e92d Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Mon, 4 Jul 2011 12:05:22 +1200 Subject: [PATCH] ENHANCEMENT: if viewing site on current version, do not include version in the parsed links --- code/models/DocumentationEntity.php | 2 +- tests/DocumentationPageTest.php | 3 +++ tests/DocumentationParserTest.php | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/code/models/DocumentationEntity.php b/code/models/DocumentationEntity.php index 95cff3f..94c240c 100755 --- a/code/models/DocumentationEntity.php +++ b/code/models/DocumentationEntity.php @@ -234,8 +234,8 @@ class DocumentationEntity extends ViewableData { } function getRelativeLink($version = false, $lang = false) { - if(!$version) $version = $this->getLatestVersion(); if(!$lang) $lang = 'en'; + if($version == $this->getLatestVersion()) $version = false; return Controller::join_links( DocumentationViewer::get_link_base(), diff --git a/tests/DocumentationPageTest.php b/tests/DocumentationPageTest.php index 830f908..e656edd 100755 --- a/tests/DocumentationPageTest.php +++ b/tests/DocumentationPageTest.php @@ -33,6 +33,9 @@ class DocumentationPageTest extends SapphireTest { // test with version. $entity = DocumentationService::register("versionlinks", BASE_PATH . "/sapphiredocs/tests/docs-v2.4/", '1'); + $entity->addVersion('2', BASE_PATH . "/sapphiredocs/tests/docs-v3.0/"); + $entity->setLatestVersion('2'); + $page = new DocumentationPage(); $page->setRelativePath('test.md'); $page->setEntity($entity); diff --git a/tests/DocumentationParserTest.php b/tests/DocumentationParserTest.php index 36d59f4..31dc735 100755 --- a/tests/DocumentationParserTest.php +++ b/tests/DocumentationParserTest.php @@ -205,7 +205,7 @@ HTML; $result ); } - + function testRetrieveMetaData() { $page = new DocumentationPage(); $page->setRelativePath('MetaDataTest.md');