package WebGUI::Macro::Widget; #------------------------------------------------------------------- # WebGUI is Copyright 2001-2007 Plain Black Corporation. #------------------------------------------------------------------- # Please read the legal notices (docs/legal.txt) and the license # (docs/license.txt) that came with this distribution before using # this software. #------------------------------------------------------------------- # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- use strict; #------------------------------------------------------------------- sub process { # get passed parameters my $session = shift; my $url = shift; my $width = shift || 600; my $height = shift || 400; my $templateId = shift || 'none'; # Get location for CSS and JS files my $conf = $session->config; my $extras = $conf->get("extrasURL"); # add CSS and JS to the page my $style = $session->style; $style->setLink($extras."/yui/build/container/assets/container.css",{ rel=>"stylesheet", type=>"text/css", } ); # and the JS $style->setScript($extras."/wgwidget.js",{ type=>"text/javascript" } ); $style->setScript($extras."/yui/build/yahoo-dom-event/yahoo-dom-event.js",{ type=>"text/javascript" } ); $style->setScript($extras."/yui/build/container/container-min.js",{ type=>"text/javascript" } ); # construct the absolute URL and get the asset ID my $asset = WebGUI::Asset->newByUrl($session, $url); my $assetId = $asset->getId; # ... and the full URL. If there's an exportWidget scratch variable, we're # exporting, and we need to use that URL. my($fullUrl, $wgWidgetPath); my $scratch = $session->scratch; my $exportUrl = $scratch->get('exportUrl'); if($exportUrl) { my $storage = WebGUI::Storage->get($session, $assetId); $fullUrl = $exportUrl . $storage->getUrl("$assetId.html"); $wgWidgetPath = $exportUrl . $extras . '/wgwidget.js'; $scratch->delete('exportUrl'); my $content = $asset->view; WebGUI::Macro::process($session, \$content); 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 $wgWidgetJs = $extras . '/wgwidget.js'; my $wgWidgetPath = $extras . '/wgwidget.js'; my $output = < $content OUTPUT $storage->addFileFromScalar("$assetId.html", $content); } else { $fullUrl = "http://" . $conf->get("sitename")->[0] . $asset->getUrl; $wgWidgetPath = 'http://' . $conf->get('sitename')->[0] . $extras . '/wgwidget.js'; } # get the gear icon my $imgSrc = $extras . '/gear.png'; my $output = < EOHTML return $output; } 1;