#!/usr/bin/perl #------------------------------------------------------------------- # WebGUI is Copyright 2001-2005 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 #------------------------------------------------------------------- our $webguiRoot; BEGIN { $webguiRoot = ".."; unshift (@INC, $webguiRoot."/lib"); } use DBI; use Getopt::Long; use strict qw(subs vars); use WebGUI; use WebGUI::Session; $|=1; my ($configFile, $pageId, $userId, $styleId, $toFile, $stripHTML, $help, $relativeUrls); $userId = 1; GetOptions( 'configFile:s'=>\$configFile, 'pageId:s'=>\$pageId, 'userId:s'=>\$userId, 'toFile:s'=>\$toFile, 'stripHTML'=>\$stripHTML, 'help'=>\$help, 'relativeUrls'=>\$relativeUrls, ); if ($help || $configFile eq '' ) { print < --configFile WebGUI config file (with no path info). Options: --assetId Set the page to be generated. --help Displays this message. --userId Set the user that should view the page. Defaults to "1" (Visitor). --styleId Set an alternate style for the page. Defaults to asset's default style. --toFile Set the path and filename to write the content to instead of standard out. --stripHTML A flag indicating that WebGUI should strip all the HTML from the document and output only text. NOTE: The resulting text may have formatting problems as a result. STOP exit; } # Open WebGUI session WebGUI::Session::open($webguiRoot,$configFile); WebGUI::Session::refreshUserInfo($userId,$session{dbh}); my $asset = WebGUI::Asset->new($pageId); $asset->{_properties}{styleTemplateId} = $styleId if ($styleId); my $content = $asset->www_view; $content = WebGUI::HTML::filter($content,"all") if ($stripHTML); my $content = $e->generate; if ($toFile) { open (TOFILE, ">$toFile") or die "Can't open file $toFile for writing. $!"; print TOFILE $content; close (TOFILE); } else { print $content; } # Clean-up WebGUI Session WebGUI::Session::end($session{var}{sessionId}); WebGUI::Session::close(); exit;