BUGFIX: Correct StaticPublisher filenames, now works with nested URLS

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@99465 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Luke Hudson 2010-02-19 00:32:16 +00:00 committed by Sam Minnee
parent 12761de90b
commit 1091dafdf0

View File

@ -49,7 +49,13 @@ class FilesystemPublisher extends StaticPublisher {
foreach($urls as $url) { foreach($urls as $url) {
$urlParts = @parse_url($url); $urlParts = @parse_url($url);
$urlParts['path'] = isset($urlParts['path']) ? $urlParts['path'] : ''; $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"; $filename = $urlSegment ? "$urlSegment.$this->fileExtension" : "index.$this->fileExtension";
@ -113,7 +119,7 @@ class FilesystemPublisher extends StaticPublisher {
echo " * Publishing page $i/$totalURLs: $url\n"; echo " * Publishing page $i/$totalURLs: $url\n";
flush(); flush();
} }
Requirements::clear(); Requirements::clear();
$response = Director::test(str_replace('+', ' ', $url)); $response = Director::test(str_replace('+', ' ', $url));
Requirements::clear(); Requirements::clear();