Apache-App-Mercury
view release on metacpan or search on metacpan
Mercury/Controller.pm view on Meta::CPAN
sub infomsg { $_[0]->{msg} = $_[1] if $_[1]; $_[0]->{msg}; }
sub pagetitle { $_[0]->{title} = $_[1] if $_[1]; $_[0]->{title}; }
sub pagebody { $_[0]->{body} = $_[1] if $_[1]; $_[0]->{body}; }
sub write_response {
my ($self) = @_;
my $r = $self->{r};
my $q = $self->{q};
$r->content_type("text/html");
if ($r->status != REDIRECT) {
$self->{out} = '<html><head>';
if ($self->{error_title}) {
$self->{out} .= $q->title($self->{error_title});
} elsif ($self->{error}) {
$self->{out} .= $q->title("Apache::App::Mercury - Error");
} else {
$self->{out} .= $q->title($self->{title});
}
$self->{out} .= '</head><body>';
if ($self->{error}) {
$self->{out} .= $self->{error};
} else {
$self->{out} .= $self->process_msg if defined $self->{msg};
$self->{out} .= $self->{body};
}
$self->{out} .= '</body></html>';
$r->header_out("Location" => $r->uri);
$r->header_out("Content-Length" => length($self->{out}));
$r->status(DOCUMENT_FOLLOWS);
if ($self->{cgi_headers}) {
$r->send_cgi_header($self->{cgi_headers} . "\n");
} else {
$r->send_http_header;
}
$r->print($self->{out});
} else {
$r->send_http_header;
}
$self->{out} = '';
$self->{body} = '';
undef $self->{msg};
return $r->status;
}
sub process_msg {
my ($self) = @_;
my $q = $self->{q};
return
($q->div({-align => 'center'},
$q->font({-color => '#ff0000'}, $q->b($self->{msg}))) .
$q->br . $q->hr({-size => 1, -width => '80%', -align => 'center'}) .
$q->br
);
}
1;
__END__
=head1 AUTHOR
Adi Fairbank <adi@adiraj.org>
=head1 COPYRIGHT
Copyright (c) 2003 - Adi Fairbank
This software (Apache::App::Mercury and all related Perl modules under
the Apache::App::Mercury namespace) is copyright Adi Fairbank.
=head1 LAST MODIFIED
July 19, 2003
=cut
( run in 2.372 seconds using v1.01-cache-2.11-cpan-5735350b133 )