Macro Widgets now take a style, defaulting to the users.

This commit is contained in:
Kaleb Murphy 2009-01-23 19:50:49 +00:00
parent 0c91491ed0
commit d8127aec73
3 changed files with 29 additions and 13 deletions

View file

@ -1857,7 +1857,7 @@ sub newPending {
#-------------------------------------------------------------------
=head2 outputWidgetMarkup ( width, height, templateId )
=head2 outputWidgetMarkup ( width, height, templateId, [styleTemplateId] )
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:
@ -1909,12 +1909,20 @@ widget-in-widget function properly.
=cut
=head3 styleTemplateId
The style templateId for this widgetized asset to use. Not 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;
my $self = shift;
my $width = shift;
my $height = shift;
my $templateId = shift;
my $styleTemplateId = shift;
# construct / retrieve the values we'll use later.
my $assetId = $self->getId;
@ -1938,6 +1946,11 @@ sub outputWidgetMarkup {
# we'll be serializing the content of the asset which is being widgetized.
my $storage = WebGUI::Storage->get($session, $assetId);
my $content = $self->view;
if($styleTemplateId eq '' or $styleTemplateId eq 'none'){
$content = $self->session->style->userStyle($content);
}else{
$content = $self->session->style->process($content,$styleTemplateId);
}
WebGUI::Macro::process($session, \$content);
my $jsonContent = to_json( { "asset$assetId" => { content => $content } } );
$storage->addFileFromScalar("$assetId.js", "data = $jsonContent");
@ -2721,9 +2734,10 @@ sub www_widgetView {
return $session->privilege->noAccess() unless $self->canView;
my $templateId = $session->form->process('templateId');
my $width = $session->form->process('width');
my $height = $session->form->process('height');
my $templateId = $session->form->process('templateId');
my $width = $session->form->process('width');
my $height = $session->form->process('height');
my $styleTemplateId = $session->form->process('styleTemplateId');
if($templateId eq 'none') {
$self->prepareView;
@ -2731,7 +2745,7 @@ sub www_widgetView {
else {
$self->prepareWidgetView($templateId);
}
return $self->outputWidgetMarkup($width, $height, $templateId);
return $self->outputWidgetMarkup($width, $height, $templateId, $styleTemplateId);
}
1;

View file

@ -21,6 +21,7 @@ sub process {
my $width = shift || 600;
my $height = shift || 400;
my $templateId = shift || 'none';
my $styleTemplateId = shift || 'none';
# Get location for CSS and JS files
my $conf = $session->config;
@ -85,7 +86,7 @@ sub process {
<script type='text/javascript'>
function setupPage() {
WebGUI.widgetBox.retargetLinksAndForms();
WebGUI.widgetBox.initButton( { 'wgWidgetPath' : '$wgWidgetPath', 'fullUrl' : '$fullUrl', 'assetId' : '$assetId', 'width' : $width, 'height' : $height, 'templateId' : '$templateId' } );
WebGUI.widgetBox.initButton( { 'wgWidgetPath' : '$wgWidgetPath', 'fullUrl' : '$fullUrl', 'assetId' : '$assetId', 'width' : $width, 'height' : $height, 'templateId' : '$templateId', 'styleTemplateId' : $styleTemplateId } );
}
YAHOO.util.Event.addListener(window, 'load', setupPage);
</script>
@ -108,7 +109,7 @@ OUTPUT
my $output = <<EOHTML;
<a href="#$assetId" id="show$assetId" name="show$assetId"><img src="$imgSrc" /></a>
<script type="text/javascript">
YAHOO.util.Event.addListener(window, 'load', WebGUI.widgetBox.initButton, { 'wgWidgetPath' : '$wgWidgetPath', 'fullUrl' : '$fullUrl', 'assetId' : '$assetId', 'width' : $width, 'height' : $height, 'templateId' : '$templateId' } );
YAHOO.util.Event.addListener(window, 'load', WebGUI.widgetBox.initButton, { 'wgWidgetPath' : '$wgWidgetPath', 'fullUrl' : '$fullUrl', 'assetId' : '$assetId', 'width' : $width, 'height' : $height, 'templateId' : '$templateId', 'styleTemplateId' : '$styleTemplateId' } );
</script>
EOHTML

View file

@ -30,7 +30,7 @@ WebGUI.widgetBox = {
return widgetFrame;
},
widget : function( url, parentId, width, height, templateId ) {
widget : function( url, parentId, width, height, templateId, styleTemplateId ) {
if(url == "") {
return "<iframe scrolling='no'><body>No content available from "+url+"</body></iframe>";
}
@ -49,6 +49,7 @@ WebGUI.widgetBox = {
this.url = url + "?func=widgetView&templateId=" + templateId;
this.url += ";width=" + width;
this.url += ";height=" + height;
this.url += ";styleTemplateId=" + styleTemplateId;
}
this.parentNodeId = parentId;
@ -111,7 +112,7 @@ WebGUI.widgetBox = {
var jsCode = "";
jsCode += "&lt;script type='text/javascript' src='" + params.wgWidgetPath + "'&gt; &lt;/script&gt;";
jsCode += "&lt;script type='text/javascript'&gt;";
jsCode += "document.write(WebGUI.widgetBox.widget('" + params.fullUrl + "', '" + params.assetId + "', " + params.width + ", " + params.height + ", '" + params.templateId + "')); &lt;/script&gt;";
jsCode += "document.write(WebGUI.widgetBox.widget('" + params.fullUrl + "', '" + params.assetId + "', " + params.width + ", " + params.height + ", '" + params.templateId + "', '" + params.styleTemplateId + "')); &lt;/script&gt;";
// Instantiate the Dialog
codeGeneratorButton = new YAHOO.widget.SimpleDialog("codeGeneratorButton", {