diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt
index 1e5df3dd8..4d3b02862 100644
--- a/docs/changelog/7.x.x.txt
+++ b/docs/changelog/7.x.x.txt
@@ -1,4 +1,8 @@
7.5.11
+ - fix: widget dialogues weren't opening correctly inside a widgetized
+ view of a widget
+ - fix: snippets were exporting as index.html or such. pass them through
+ unchanged.
- add: United Knowledge Player added. This player allows you to display a photo collection as a slideshow. A demo can be found in /extras/ukplayer/slideshow. html. (Arjan Widlak, United Knowledge)
- add: Assets can now inherit their parent's URL, prepended. Check the
meta tab.
diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm
index 2b61f1df2..d5a181278 100644
--- a/lib/WebGUI/Asset.pm
+++ b/lib/WebGUI/Asset.pm
@@ -2437,7 +2437,6 @@ true.
sub isValidRssItem { 1 }
#-------------------------------------------------------------------
-
=head2 www_widgetView ( )
Returns the view() method of the asset object suitable for widgetizing.
@@ -2451,7 +2450,9 @@ sub www_widgetView {
return $session->privilege->noAccess() unless $self->canView;
- my $templateId = $session->form->process('templateId');
+ my $templateId = $session->form->process('templateId');
+ my $width = $session->form->process('width');
+ my $height = $session->form->process('height');
if($templateId eq 'none') {
$self->prepareView;
@@ -2459,8 +2460,7 @@ sub www_widgetView {
else {
$self->prepareWidgetView($templateId);
}
- $self->_outputWidgetJs;
- return $self->view;
+ return $self->outputWidgetMarkup($width, $height, $templateId);
}
#-------------------------------------------------------------------
@@ -2479,22 +2479,117 @@ sub prepareWidgetView {
my $template = WebGUI::Asset::Template->new($self->session, $templateId);
my $session = $self->session;
my $extras = $session->config->get('extrasURL');
- my $yahooDomJs = $extras . '/yui/build/yahoo-dom-event/yahoo-dom-event.js';
- my $widgetJs = $extras . '/widgetLinkTargets.js';
$template->prepare;
$self->{_viewTemplate} = $template;
}
-sub _outputWidgetJs {
+
+#-------------------------------------------------------------------
+
+=head2 outputWidgetMarkup ( width, height, templateId )
+
+Output the markup required for the widget view. Includes markup to handle the
+widget macro in the iframe holding the widgetized asset. This does the following:
+
+=item retrieves the content for this asset using its L method
+
+=item processes macros in that content
+
+=item serializes the processed content in JSON
+
+=item writes the JSON to a storage location
+
+=item refers the user to download this JSON
+
+=item references the appropriate JS files for the templating engine and the widget macro
+
+=item invokes the templating engine on this JSON
+
+=head3 width
+
+The width of the iframe. Required for making widget-in-widget function properly.
+
+=head3 height
+
+The height of the iframe. Required for making widget-in-widget function properly.
+
+=head3 templateId
+
+The templateId for this widgetized asset to use. Required for making
+widget-in-widget function properly.
+
+=cut
+
+sub outputWidgetMarkup {
+ # get our parameters.
my $self = shift;
+ my $width = shift;
+ my $height = shift;
+ my $templateId = shift;
+
+ # construct / retrieve the values we'll use later.
+ my $assetId = $self->getId;
my $session = $self->session;
- my $extras = $session->config->get('extrasURL');
+ my $conf = $session->config;
+ my $extras = $conf->get('extrasURL');
+
+ # the widgetized version of content that has the widget macro in it is
+ # executing in an iframe. this iframe doesn't have a style object.
+ # therefore, the macro won't be able to output the stylesheet and JS
+ # information it needs to do its work. because of this, we need to output
+ # that content manually. construct the filesystem paths for those files.
+ my $containerCss = $extras . '/yui/build/container/assets/container.css';
+ my $containerJs = $extras . '/yui/build/container/container-min.js';
my $yahooDomJs = $extras . '/yui/build/yahoo-dom-event/yahoo-dom-event.js';
- my $widgetJs = $extras . '/widgetLinkTargets.js';
- $session->output->print("");
- $session->output->print("");
+ my $wgWidgetJs = $extras . '/wgwidget.js';
+ my $ttJs = $extras . '/tt.js';
+
+ # the templating engine requires its source data to be in json format.
+ # write this out to disk and then serve the URL to the user. in this case,
+ # we'll be serializing the content of the asset which is being widgetized.
+ my $storage = WebGUI::Storage->get($session, $assetId);
+ my $content = $self->view;
+ WebGUI::Macro::process($session, \$content);
+ my $jsonContent = objToJson( { "asset$assetId" => { content => $content } } );
+ $storage->addFileFromScalar("$assetId.js", "data = $jsonContent");
+ my $jsonUrl = $storage->getUrl("$assetId.js");
+
+ # WebGUI.widgetBox.initButton() needs the full URL of the asset being
+ # widgetized, and also the full URL of the JS file that does most of the
+ # work.
+ my $fullUrl = "http://" . $conf->get("sitename")->[0] . $self->getUrl;
+ my $wgWidgetPath = 'http://' . $conf->get('sitename')->[0] . $extras . '/wgwidget.js';
+
+ # finally, given all of the above, construct our output. WebGUI outputs
+ # fully valid XHTML 1.0 Strict, and there's no reason this should be any
+ # different.
+ my $output = <