Apache-ContentHandler

 view release on metacpan or  search on metacpan

ContentHandler.pm  view on Meta::CPAN

		  $self->footer,
		  end_html,
		 );

  if ($self->{redirect}) {
    print $self->{cgi}->redirect(-uri=>$self->{redirect});
    return REDIRECT;
  } elsif (! $self->{noprint}) {
    if ($self->{mod_perl}) {
      my $request = $self->{request};
      $request->content_type('text/html');
      $request->no_cache(1);
      $request->send_http_header;
      return OK if $request->header_only;
      print $html;
      return OK;
    } else {
      print $self->{cgi}->header;
      print $html;
    }
  } else {
    return $work;
  }
}

############################################################
# Standard CGI Functions:

=back

=head1 PROTECTED METHODS

=over 4

=item * _init

Private: called by new. Override to put your application specific
variables here.

=cut

sub _init {
  my $self = shift || die 'need $self';
  my $request = shift;

  $self->{mod_perl} = exists $ENV{"MOD_PERL"};

  if ($self->{mod_perl}) {
    $self->{request} = $request;
  }

  $self->{cgi} = new CGI; # used in various places regardless of mod_perl

  $self->{url}       = ($self->{mod_perl}
			? $request->uri
			: $self->url(-absolute=>1));

  $self->{title}     = 'Untitled Application';
  $self->{subtitle}  = '';
  $self->{action}    = $self->arg('action');
  $self->{default_action} = 'does_not_exist';
  $self->{debug}     = $self->arg('debug') || 0;
  $self->{error}     = {};
  $self->{redirect}  = '';
  $self->{noprint}   = 0;

  $self->{error_email}  = 'root';
  $self->{dbi_driver}   = '';
  $self->{dbi_user}     = '';
  $self->{dbi_password} = '';
}

=item * $val = $self->arg($key)

Returns a CGI/mod_perl parameter for the key $key.

=cut

sub arg {
  my $self = shift;
  my $key = shift;

  if ($self->{mod_perl}) {
    my %args = $self->{request}->args;
    return $args{$key};
  } else {
    return param($key);
  }
}

=item * @keys = $self->args

Returns a list of all of the mod_perl/cgi parameters.

=cut

sub args {
  my $self = shift;

  if ($self->{mod_perl}) {
    my %args = $self->{request}->args;
    return keys %args;
  } else {
    return param();
  }
}

=item * $s = $hc->header

Returns a string containing the preheader, an HTML title, and a
postheader. You probably do not want to override this unless you want
a different type of title.

=cut

sub header {
  my $self = shift || die 'need $self';

  return join(
	      '',
	      $self->preheader(),



( run in 0.757 second using v1.01-cache-2.11-cpan-39bf76dae61 )