getting closer to bucket output
This commit is contained in:
parent
deb6b353d6
commit
268947c1d5
8 changed files with 192 additions and 42 deletions
|
|
@ -861,6 +861,7 @@ Returns a toolbar with a set of icons that hyperlink to functions that delete, e
|
|||
|
||||
sub getToolbar {
|
||||
my $self = shift;
|
||||
return $self->{_toolbar} if (exists $self->{_toolbar});
|
||||
my $i18n = WebGUI::International->new($self->session, "Asset");
|
||||
my $toolbar = $self->session->icon->delete('func=delete',$self->get("url"),$i18n->get(43));
|
||||
my $commit;
|
||||
|
|
@ -1441,6 +1442,19 @@ sub newByUrl {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 prepareView ( )
|
||||
|
||||
Executes what is necessary to make the view() method work with content streaming. This includes things like processing template head tags.
|
||||
|
||||
=cut
|
||||
|
||||
sub prepareView {
|
||||
my $self = shift;
|
||||
$self->{_toolbar} = $self->getToolbar;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 processPropertiesFromFormPost ( )
|
||||
|
||||
Updates current Asset with data from Form.
|
||||
|
|
|
|||
|
|
@ -134,6 +134,26 @@ sub getEditForm {
|
|||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
sub prepareView {
|
||||
my $self = shift;
|
||||
$self->SUPER::prepareView;
|
||||
if ($self->session->var->isAdminOn) {
|
||||
# under normal circumstances we don't put HTML stuff in our code, but this will make it much easier
|
||||
# for end users to work with our templates
|
||||
$self->session->style->setScript($self->session->config->get("extrasURL")."/draggable.js",{ type=>"text/javascript" });
|
||||
$self->session->style->setLink($self->session->config->get("extrasURL")."/draggable.css",{ type=>"text/css", rel=>"stylesheet", media=>"all" });
|
||||
$self->session->style->setRawHeadTags('
|
||||
<style type="text/css">
|
||||
.dragging, .empty {
|
||||
background-image: url("'.$self->session->config->get("extrasURL").'/opaque.gif");
|
||||
}
|
||||
</style>
|
||||
');
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub viewOriginal {
|
||||
my $self = shift;
|
||||
|
|
@ -276,15 +296,6 @@ sub view {
|
|||
if ($vars{showAdmin}) {
|
||||
# under normal circumstances we don't put HTML stuff in our code, but this will make it much easier
|
||||
# for end users to work with our templates
|
||||
$self->session->style->setScript($self->session->config->get("extrasURL")."/draggable.js",{ type=>"text/javascript" });
|
||||
$self->session->style->setLink($self->session->config->get("extrasURL")."/draggable.css",{ type=>"text/css", rel=>"stylesheet", media=>"all" });
|
||||
$self->session->style->setRawHeadTags('
|
||||
<style type="text/css">
|
||||
.dragging, .empty {
|
||||
background-image: url("'.$self->session->config->get("extrasURL").'/opaque.gif");
|
||||
}
|
||||
</style>
|
||||
');
|
||||
$vars{"dragger.icon"} = $self->session->icon->drag();
|
||||
$vars{"dragger.init"} = '
|
||||
<iframe id="dragSubmitter" style="display: none;" src="'.$self->session->config->get("extrasURL").'/spacer.gif"></iframe>
|
||||
|
|
@ -295,12 +306,12 @@ sub view {
|
|||
}
|
||||
my @parts = split("~~~",$self->processTemplate(\%vars,$self->get("templateId")));
|
||||
foreach my $part (@parts) {
|
||||
print $part;
|
||||
$self->session->output->print($part);
|
||||
my $asset = shift @placeHolder;
|
||||
if (defined $asset) {
|
||||
my $t = [Time::HiRes::gettimeofday()] if ($showPerformance);
|
||||
print $asset->view;
|
||||
print "Asset:".Time::HiRes::tv_interval($t) if ($showPerformance);
|
||||
$self->session->output->print($asset->view);
|
||||
$self->session->output->print("Asset:".Time::HiRes::tv_interval($t)) if ($showPerformance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -317,11 +328,12 @@ sub www_setContentPositions {
|
|||
sub www_view {
|
||||
my $self = shift;
|
||||
$self->session->http->getHeader;
|
||||
$self->prepareView;
|
||||
my $style = $self->processStyle("~~~");
|
||||
my ($head, $foot) = split("~~~",$style);
|
||||
print $head;
|
||||
$self->session->output->print($head);
|
||||
$self->view;
|
||||
print $foot;
|
||||
$self->session->output->print($foot);
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -197,11 +197,11 @@ sub www_exportGenerate {
|
|||
return $self->session->privilege->insufficient() unless ($self->session->user->isInGroup(13));
|
||||
# This routine is called in an IFRAME and prints status output directly to the browser.
|
||||
$|++; # Unbuffered data output
|
||||
$self->session->request->print($self->session->http->getHeader());
|
||||
$self->session->output->print($self->session->http->getHeader());
|
||||
my $startTime =$self->session->datetime->time();
|
||||
my $error = $self->checkExportPath();
|
||||
if ($error) {
|
||||
$self->session->request->print($error);
|
||||
$self->session->output->print($error);
|
||||
return;
|
||||
}
|
||||
my $i18n = WebGUI::International->new($self->session, 'Asset');
|
||||
|
|
@ -212,9 +212,9 @@ sub www_exportGenerate {
|
|||
my $assets = $self->getLineage(["self","descendants"],{returnObjects=>1,endingLineageLength=>$self->getLineageLength+$self->session->form->process("depth")});
|
||||
foreach my $asset (@{$assets}) {
|
||||
my $url = $asset->get("url");
|
||||
$self->session->request->printf( $i18n->get('exporting page'), $url);
|
||||
$self->session->output->printf( $i18n->get('exporting page'), $url);
|
||||
unless ($asset->canView($userId)) {
|
||||
$self->session->request->print ($i18n->get('bad user privileges')."\n");
|
||||
$self->session->output->print ($i18n->get('bad user privileges')."\n");
|
||||
next;
|
||||
}
|
||||
my $path;
|
||||
|
|
@ -235,23 +235,23 @@ sub www_exportGenerate {
|
|||
$path = $self->session->config->get("exportPath") . "/" . $path;
|
||||
eval { mkpath($path) };
|
||||
if($@) {
|
||||
$self->session->request->printf($i18n->get('could not create path'), $path, $@);
|
||||
$self->session->output->printf($i18n->get('could not create path'), $path, $@);
|
||||
return;
|
||||
}
|
||||
}
|
||||
$path .= "/".$filename;
|
||||
eval { open(FILE, "> $path") or die "$!" };
|
||||
if ($@) {
|
||||
$self->session->request->printf($i18n->get('could not open path'), $path, $@);
|
||||
$self->session->output->printf($i18n->get('could not open path'), $path, $@);
|
||||
return;
|
||||
} else {
|
||||
print FILE $asset->exportAsHtml({userId=>$userId,extrasUrl=>$extrasURL,uploadsUrl=>$uploadsURL});
|
||||
close(FILE);
|
||||
}
|
||||
$self->session->request->print($i18n->get('done'));
|
||||
$self->session->output->print($i18n->get('done'));
|
||||
}
|
||||
$self->session->request->printf($i18n->get('export information'), scalar(@{$assets}), ($self->session->datetime->time()-$startTime));
|
||||
$self->session->request->print('<a target="_parent" href="'.$self->getUrl.'">'.$i18n->get(493).'</a>');
|
||||
$self->session->output->printf($i18n->get('export information'), scalar(@{$assets}), ($self->session->datetime->time()-$startTime));
|
||||
$self->session->output->print('<a target="_parent" href="'.$self->getUrl.'">'.$i18n->get(493).'</a>');
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ use WebGUI::Session::Http;
|
|||
use WebGUI::Session::Icon;
|
||||
use WebGUI::Session::Id;
|
||||
use WebGUI::Session::Os;
|
||||
use WebGUI::Session::Output;
|
||||
use WebGUI::Session::Privilege;
|
||||
use WebGUI::Session::Scratch;
|
||||
use WebGUI::Session::Setting;
|
||||
|
|
@ -63,6 +64,7 @@ B<NOTE:> It is important to distinguish the difference between a WebGUI session
|
|||
$session->form
|
||||
$session->http
|
||||
$session->os
|
||||
$session->output
|
||||
$session->request
|
||||
$session->scratch
|
||||
$session->server
|
||||
|
|
@ -364,6 +366,23 @@ sub open {
|
|||
return $self;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 output ( )
|
||||
|
||||
Returns a WebGUI::Session::Output object.
|
||||
|
||||
=cut
|
||||
|
||||
sub output {
|
||||
my $self = shift;
|
||||
unless (exists $self->{_output}) {
|
||||
$self->{_output} = WebGUI::Session::Output->new($self);
|
||||
}
|
||||
return $self->{_output};
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 os ( )
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ sub error {
|
|||
my $self = shift;
|
||||
my $message = shift;
|
||||
$self->getLogger->error($message);
|
||||
print("\n\n".$message.":\n".$self->getStackTrace());
|
||||
$self->session->output->print("\n\n".$message.":\n".$self->getStackTrace());
|
||||
$self->getLogger->debug("Stack trace for ERROR ".$message."\n".$self->getStackTrace());
|
||||
$self->session->stow->set("debug_error", $self->session->stow->get("debug_error").$message."\n");
|
||||
}
|
||||
|
|
@ -193,19 +193,19 @@ sub fatal {
|
|||
Apache2::RequestUtil->request->content_type('text/html') if ($self->session->request);
|
||||
$self->getLogger->fatal($message);
|
||||
$self->getLogger->debug("Stack trace for FATAL ".$message."\n".$self->getStackTrace());
|
||||
print $self->session->http->getHeader if ($self->session->request);
|
||||
$self->session->output->print($self->session->http->getHeader) if ($self->session->request);
|
||||
unless ($self->canShowDebug()) {
|
||||
#NOTE: You can't internationalize this because with some types of errors that would cause an infinite loop.
|
||||
print "<h1>Problem With Request</h1>
|
||||
$self->session->output->print("<h1>Problem With Request</h1>
|
||||
We have encountered a problem with your request. Please use your back button and try again.
|
||||
If this problem persists, please contact us with what you were trying to do and the time and date of the problem.";
|
||||
print '<br />'.$self->session->setting("companyName");
|
||||
print '<br />'.$self->session->setting("companyEmail");
|
||||
print '<br />'.$self->session->setting("companyURL");
|
||||
If this problem persists, please contact us with what you were trying to do and the time and date of the problem.");
|
||||
$self->session->output->print('<br />'.$self->session->setting("companyName"));
|
||||
$self->session->output->print('<br />'.$self->session->setting("companyEmail"));
|
||||
$self->session->output->print('<br />'.$self->session->setting("companyURL"));
|
||||
} else {
|
||||
print "<h1>WebGUI Fatal Error</h1><p>Something unexpected happened that caused this system to fault.</p>\n";
|
||||
print "<p>".$message."</p>\n";
|
||||
print $self->showDebug();
|
||||
$self->session->output->print("<h1>WebGUI Fatal Error</h1><p>Something unexpected happened that caused this system to fault.</p>\n");
|
||||
$self->session->output->print("<p>".$message."</p>\n");
|
||||
$self->session->output->print($self->showDebug());
|
||||
}
|
||||
$self->session->close();
|
||||
die $message;
|
||||
|
|
|
|||
106
lib/WebGUI/Session/Output.pm
Normal file
106
lib/WebGUI/Session/Output.pm
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
package WebGUI::Session::Output;
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2006 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
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use WebGUI::Macro;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Session::Output
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This class provides a handler for returning output. Through this we can apply filters (like macros), and simple page caching mechanisms.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
$session->output->print($content);
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this package:
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head DESTROY ( )
|
||||
|
||||
Deconstructor.
|
||||
|
||||
=cut
|
||||
|
||||
sub DESTROY {
|
||||
my $self = shift;
|
||||
undef $self;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 new ( session )
|
||||
|
||||
Constructor.
|
||||
|
||||
=head3 session
|
||||
|
||||
A reference to the current session.
|
||||
|
||||
=cut
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
bless {_session=>$session}, $class;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 print ( content )
|
||||
|
||||
Outputs content to either the web server or standard out, depending on which is available.
|
||||
|
||||
=head3 content
|
||||
|
||||
The content to output.
|
||||
|
||||
=cut
|
||||
|
||||
sub print {
|
||||
my $self = shift;
|
||||
my $content = shift;
|
||||
WebGUI::Macro::process($self->session, \$content);
|
||||
print $content;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 session ( )
|
||||
|
||||
Returns a reference to the current session.
|
||||
|
||||
=cut
|
||||
|
||||
sub session {
|
||||
my $self = shift;
|
||||
return $self->{_session};
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
|
@ -195,6 +195,7 @@ props["pageURL"] = "'.$self->session->url->page(undef, undef, 1).'";
|
|||
return props[propName];
|
||||
}
|
||||
</script>
|
||||
<!--morehead-->
|
||||
';
|
||||
if ($self->session->user->isInGroup(2)) {
|
||||
# This "triple incantation" panders to the delicate tastes of various browsers for reliable cache suppression.
|
||||
|
|
@ -204,7 +205,6 @@ if ($self->session->user->isInGroup(2)) {
|
|||
<meta http-equiv="Expires" content="0" />
|
||||
';
|
||||
}
|
||||
$var{'head.tags'} .= "\n<!-- macro head tags -->\n";
|
||||
my $style = WebGUI::Asset::Template->new($self->session,$templateId);
|
||||
my $output;
|
||||
if (defined $style) {
|
||||
|
|
@ -212,10 +212,9 @@ if ($self->session->user->isInGroup(2)) {
|
|||
} else {
|
||||
$output = "WebGUI was unable to instantiate your style template.".$var{'body.content'};
|
||||
}
|
||||
WebGUI::Macro::process($self->session,\$output);
|
||||
my $macroHeadTags = $self->generateAdditionalHeadTags();
|
||||
WebGUI::Macro::process($self->session,\$macroHeadTags);
|
||||
$output =~ s/\<\!-- macro head tags --\>/$macroHeadTags/;
|
||||
WebGUI::Macro::process(\$output);
|
||||
my $macroHeadTags = $self->generateAdditionalHeadTags();
|
||||
$output =~ s/\<\!--morehead--\>/$macroHeadTags/;
|
||||
if ($self->session->errorHandler->canShowDebug()) {
|
||||
$output .= $self->session->errorHandler->showDebug();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue