From 6e8547169af8c9a96b83a778acaa2cef3aa78baa Mon Sep 17 00:00:00 2001
From: Doug Bell
Date: Thu, 1 Feb 2007 20:24:00 +0000
Subject: [PATCH] fixed changelog and some formatting issues
---
docs/changelog/7.x.x.txt | 1 +
lib/WebGUI/AssetExportHtml.pm | 56 ++++++++++++++++++++------------
lib/WebGUI/AssetVersioning.pm | 1 +
lib/WebGUI/Session/Style.pm | 6 ++--
lib/WebGUI/i18n/English/Asset.pm | 7 ++++
5 files changed, 49 insertions(+), 22 deletions(-)
diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt
index 46c533a5c..cecb00ac7 100644
--- a/docs/changelog/7.x.x.txt
+++ b/docs/changelog/7.x.x.txt
@@ -40,6 +40,7 @@
- fix: EMS: blank lines appearing in registrants. Note - this fix requires
the use of new template variables in the EMS checkout template. See
gotchas.txt for details.
+ - fix: AssetExportHtml now handles periods in URLs more gracefully.
7.3.8
- Fixed a template variable rewriting problem with HTML::Template::Expr
diff --git a/lib/WebGUI/AssetExportHtml.pm b/lib/WebGUI/AssetExportHtml.pm
index 4c0e315a4..80d7d2bf8 100644
--- a/lib/WebGUI/AssetExportHtml.pm
+++ b/lib/WebGUI/AssetExportHtml.pm
@@ -104,7 +104,8 @@ sub _exportAsHtml {
# Get a list of the asset IDs we need, reverse sorted by URL
my $assetIds
= $newSelf->getLineage(["self","descendants"],{
- endingLineageLength => $newSelf->getLineageLength+$self->session->form->process("depth")
+ endingLineageLength => $newSelf->getLineageLength+$self->session->form->process("depth"),
+ orderByClause => 'assetData.url DESC',
});
$tempSession->var->end;
@@ -138,27 +139,41 @@ sub _exportAsHtml {
$defaultAssetPath = $fullPath;
}
+ # Make sure that the filename is not a directory in this path
+ if (-d $exportPath . "/" . $fullPath) {
+ # A previous asset created this directory
+ # so make this asset the index of this directory
+ if (!-e "$exportPath/$fullPath/$index") {
+ $path .= "/$filename";
+ $filename = $index;
+ $fullPath .= "/$index";
+ }
+ else {
+ return (0, sprintf($i18n->get('file exists when making directory index'), $fullPath, $@));
+ }
+ }
+
$self->session->db->write("UPDATE asset SET lastExportedAs = ? WHERE assetId = ?", [$fullPath, $asset->getId]);
- $path = $exportPath . (length($path)? "/$path" : "");
- eval { mkpath($path) };
- if($@) {
- return (0, sprintf($i18n->get('could not create path'), $path, $@));
- }
- $path .= "/".$filename;
+ $path = $exportPath . (length($path)? "/$path" : "");
+ eval { mkpath($path) };
+ if($@) {
+ return (0, sprintf($i18n->get('could not create path'), $path, $@));
+ }
+ $path .= "/".$filename;
- my $file = eval { FileHandle->new(">".$path) or die "$!" };
- if ($@) {
- return (0, sprintf($i18n->get('could not open path'), $path, $@));
- } else {
- $assetSession->output->setHandle($file);
- $assetSession->asset($asset);
- my $content = $asset->exportHtml_view;
- unless ($content eq "chunked") {
- $assetSession->output->print($content);
- }
- $file->close;
- }
+ my $file = eval { FileHandle->new(">".$path) or die "$!" };
+ if ($@) {
+ return (0, sprintf($i18n->get('could not open path'), $path, $@));
+ } else {
+ $assetSession->output->setHandle($file);
+ $assetSession->asset($asset);
+ my $content = $asset->exportHtml_view;
+ unless ($content eq "chunked") {
+ $assetSession->output->print($content);
+ }
+ $file->close;
+ }
$assetSession->var->end;
$assetSession->close;
@@ -384,8 +399,9 @@ Executes the export process and displays real time status. This operation is dis
sub www_exportGenerate {
my $self = shift;
return $self->session->privilege->insufficient() unless ($self->session->user->isInGroup(13));
- # This routine is called in an IFRAME and prints status output directly to the browser.
+ # This routine is called in an IFRAME and prints status output directly to the browser.
$|++; # Unbuffered data output
+ $self->session->style->useEmptyStyle(1);
$self->session->http->sendHeader;
my $i18n = WebGUI::International->new($self->session, 'Asset');
diff --git a/lib/WebGUI/AssetVersioning.pm b/lib/WebGUI/AssetVersioning.pm
index fdb5396c4..3881916b7 100644
--- a/lib/WebGUI/AssetVersioning.pm
+++ b/lib/WebGUI/AssetVersioning.pm
@@ -36,6 +36,7 @@ This is a mixin package for WebGUI::Asset that contains all versioning related f
# TODO: Add usage for all methods available from this class
+
=head1 METHODS
These methods are available from this class:
diff --git a/lib/WebGUI/Session/Style.pm b/lib/WebGUI/Session/Style.pm
index f31ab6b07..fb4ec5e89 100644
--- a/lib/WebGUI/Session/Style.pm
+++ b/lib/WebGUI/Session/Style.pm
@@ -400,11 +400,13 @@ sub setScript {
=head2 useEmptyStyle ( boolean )
-Tells the style system to use an empty style rather than outputing the normal style. This is useful when you want your code to dynamically generate a style.
+Tells the style system to use an empty style rather than outputing the normal
+style. This is useful when you want your code to dynamically generate a style.
=head3 boolean
-If set to 1 it will use an empty style, if set to 0 it will use the regular style. Defaults to 0.
+If set to 1 it will use an empty style, if set to 0 it will use the regular
+style. Defaults to 0.
=cut
diff --git a/lib/WebGUI/i18n/English/Asset.pm b/lib/WebGUI/i18n/English/Asset.pm
index 2b20e5f7d..e88121d33 100644
--- a/lib/WebGUI/i18n/English/Asset.pm
+++ b/lib/WebGUI/i18n/English/Asset.pm
@@ -854,6 +854,13 @@ config file must be enabled for this function to be available.
lastUpdated => 1129420080,
},
+ 'file exists when making directory index' => {
+ message => q{Couldn't create %-s because %-s
}
+ . q{This most likely means you have a page with this URL already. }
+ . q{Altering that page's URL to not end with your directory index will fix this.},
+ lastUpdated => 0,
+ },
+
'could not create path' => {
message => q|
Couldn't create %-s because %-s