From 6f90867d2636f5b3208fcb04b73339c0d1b74d6b Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Fri, 18 Jul 2008 21:09:11 +0000 Subject: [PATCH] fixed: issue with asset export HTML and putting head tags ABOVE and tags. Now creates a new session for each asset that it exports. fixed: Widget gear now does not move user to a different part of the page added a nice error message when the Widget macro can't find a URL. --- docs/changelog/7.x.x.txt | 4 ++++ lib/WebGUI/AssetExportHtml.pm | 21 ++++++++++----------- lib/WebGUI/Macro/Widget.pm | 3 +++ www/extras/wgwidget.js | 3 ++- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 1f7fe5b9b..c3c09d05d 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -1,5 +1,9 @@ 7.5.18 - fixed: Product no longer shows "Continue Shopping" view when a different user adds the Product to their Cart. The issue was the Product cached itself when an item was added to the cart. Now it checks for if a cart asset exists for this session. + - fixed: HTML Export now creates a new session for each asset it exports to + stop problems from certain flags that get set once per session. + - fixed: Clicking on Widget gear causes user to jump to another part of the page. + 7.5.17 - fixed: Payment Methods Hover Help Incomplete - fixed: Payment Method Titles Don't Match Buttons diff --git a/lib/WebGUI/AssetExportHtml.pm b/lib/WebGUI/AssetExportHtml.pm index ca1742840..0c66c1de5 100644 --- a/lib/WebGUI/AssetExportHtml.pm +++ b/lib/WebGUI/AssetExportHtml.pm @@ -270,24 +270,24 @@ sub exportAsHtml { my $assetIds = $self->exportGetDescendants($user, $depth); - # now, create a new session as the user doing the exports. this is so that - # the exported assets are taken from that user's perspective. - my $exportSession = WebGUI::Session->open($self->session->config->getWebguiRoot, $self->session->config->getFilename); - $exportSession->user( { userId => $userId } ); - # make sure this user can view the top level asset we're exporting. if not, # don't do anything. unless ( $self->canView($userId) ) { $returnCode = 0; $message = "can't view asset at URL " . $self->getUrl; - $exportSession->var->end; - $exportSession->close; return ($returnCode, $message); } my $exportedCount = 0; foreach my $assetId ( @{$assetIds} ) { + # now, create a new session as the user doing the exports. this is so that + # the exported assets are taken from that user's perspective. + # Must be created once for each asset, since session is supposed to only handle + # one main asset + my $exportSession = WebGUI::Session->open($self->session->config->getWebguiRoot, $self->session->config->getFilename); + $exportSession->user( { userId => $userId } ); + # set a scratch variable for widgets to know we're exporting $exportSession->scratch->set('exportUrl', $exportUrl); @@ -347,6 +347,9 @@ sub exportAsHtml { unless( $quiet ) { $session->output->print($i18n->get('done')); } + + $exportSession->var->end; + $exportSession->close; } # handle symlinking @@ -368,10 +371,6 @@ sub exportAsHtml { } } - # we don't need the session any more, so close it. - $exportSession->var->end; - $exportSession->close; - # we're done. give the user a status report. $returnCode = 1; my $timeRequired = $session->datetime->time - $startTime; diff --git a/lib/WebGUI/Macro/Widget.pm b/lib/WebGUI/Macro/Widget.pm index 5f23c857b..209c3e0aa 100755 --- a/lib/WebGUI/Macro/Widget.pm +++ b/lib/WebGUI/Macro/Widget.pm @@ -50,6 +50,9 @@ sub process { # construct the absolute URL and get the asset ID my $asset = WebGUI::Asset->newByUrl($session, $url); + if ( !$asset ) { + return "Widget: Could not find asset with URL '$url'"; + } my $assetId = $asset->getId; # ... and the full URL. If there's an exportWidget scratch variable, we're diff --git a/www/extras/wgwidget.js b/www/extras/wgwidget.js index 6bd95d3b9..b3504d16f 100755 --- a/www/extras/wgwidget.js +++ b/www/extras/wgwidget.js @@ -136,7 +136,8 @@ WebGUI.widgetBox = { YAHOO.util.Event.addListener("show" + params.assetId, "click", WebGUI.widgetBox.handleButtonShow, codeGeneratorButton, true); }, - handleButtonShow : function() { + handleButtonShow : function(e) { + e.preventDefault(); codeGeneratorButton.show(); var tag = document.getElementById('jsWidgetCode'); tag.focus();