From ff78276f9310d8a510b6915b54645a9f0d499634 Mon Sep 17 00:00:00 2001 From: UndefinedOffset Date: Wed, 24 Feb 2016 17:30:34 -0400 Subject: [PATCH] BUGFIX: Fixed issue generating image paths introduced in 1556c77d2713732cce34dc1941b627116c7c707c --- code/DocumentationHelper.php | 14 ++++++++++++++ code/DocumentationParser.php | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/code/DocumentationHelper.php b/code/DocumentationHelper.php index c061670..768ea00 100644 --- a/code/DocumentationHelper.php +++ b/code/DocumentationHelper.php @@ -108,4 +108,18 @@ class DocumentationHelper return $path; } + + /** + * Helper function to make normalized paths relative + * + * @param string + * + * @return string + */ + public static function relativePath($path) + { + $base = self::normalizePath(Director::baseFolder()); + + return substr($path, strlen($base)); + } } diff --git a/code/DocumentationParser.php b/code/DocumentationParser.php index 085cc16..c46dde3 100755 --- a/code/DocumentationParser.php +++ b/code/DocumentationParser.php @@ -238,7 +238,7 @@ class DocumentationParser } // Rewrite URL (relative or absolute) - $baselink = Director::makeRelative( + $baselink = DocumentationHelper::relativePath( dirname($page->getPath()) ); @@ -457,7 +457,7 @@ class DocumentationParser } // file base link - $fileBaseLink = DocumentationHelper::normalizePath(Director::makeRelative(dirname($page->getPath()))); + $fileBaseLink = DocumentationHelper::relativePath(DocumentationHelper::normalizePath(dirname($page->getPath()))); if ($matches) { foreach ($matches[0] as $i => $match) {