From aa6e1c3341a5aa0ac598e2fbd8bf56de0ca724c2 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Mon, 4 Oct 2010 05:35:19 +0000 Subject: [PATCH] BUGFIX: Correct StaticPublisher filenames, now works with nested URLS (from r99465) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@111612 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/staticpublisher/FilesystemPublisher.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/code/staticpublisher/FilesystemPublisher.php b/code/staticpublisher/FilesystemPublisher.php index a7d62ea2..a02a788d 100644 --- a/code/staticpublisher/FilesystemPublisher.php +++ b/code/staticpublisher/FilesystemPublisher.php @@ -49,7 +49,13 @@ class FilesystemPublisher extends StaticPublisher { foreach($urls as $url) { $urlParts = @parse_url($url); $urlParts['path'] = isset($urlParts['path']) ? $urlParts['path'] : ''; - $urlSegment = preg_replace('/[^a-zA-Z0-9]/si', '_', trim($urlParts['path'], '/')); + // perform similar transformations to SiteTree::generateURLSegment() + $urlSegment = $urlParts['path']; + $urlSegment = str_replace('&','-and-',$urlSegment); + $urlSegment = str_replace('&','-and-',$urlSegment); + $urlSegment = ereg_replace('[^A-Za-z0-9\/-]+','-',$urlSegment); + $urlSegment = ereg_replace('-+','-',$urlSegment); + $urlSegment = trim($urlSegment, '/'); $filename = $urlSegment ? "$urlSegment.$this->fileExtension" : "index.$this->fileExtension"; @@ -113,7 +119,7 @@ class FilesystemPublisher extends StaticPublisher { echo " * Publishing page $i/$totalURLs: $url\n"; flush(); } - + Requirements::clear(); $response = Director::test(str_replace('+', ' ', $url)); Requirements::clear();