From 1e2737bc5ad60f216c6ab27cbe2ac30d5092cdc6 Mon Sep 17 00:00:00 2001 From: Cam Findlay Date: Sat, 15 Nov 2014 11:39:19 +1300 Subject: [PATCH] Refactored EditLink --- code/controllers/DocumentationViewer.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/code/controllers/DocumentationViewer.php b/code/controllers/DocumentationViewer.php index 0c93af8..3c9fa69 100755 --- a/code/controllers/DocumentationViewer.php +++ b/code/controllers/DocumentationViewer.php @@ -573,15 +573,20 @@ class DocumentationViewer extends Controller { * @return string */ public function getEditLink() { + $page = $this->getPage(); if($page) { + $entity = $page->getEntity(); - if($entity && isset(self::$edit_links[$entity->title])) { + + + if($entity && isset(self::$edit_links[strtolower($entity->title)])) { + // build the edit link, using the version defined - $url = self::$edit_links[$entity->title]; - $version = $this->getVersion(); + $url = self::$edit_links[strtolower($entity->title)]; + $version = $entity->getVersion(); if($version == "trunk" && (isset($url['options']['rewritetrunktomaster']))) { if($url['options']['rewritetrunktomaster']) { @@ -592,10 +597,10 @@ class DocumentationViewer extends Controller { return str_replace( array('%entity%', '%lang%', '%version%', '%path%'), array( - $entity->getBaseFolder(), + $entity->title, $this->getLanguage(), $version, - ltrim($page->getPath(), '/') + ltrim($page->getRelativePath(), '/') ), $url['url']