package Apache::MVC::Base;

use strict;
use warnings;

sub parse_location {
    my $self = shift;
    $self->{path} = $self->{ar}->uri;
    my $loc = $self->{ar}->location;
    no warnings 'uninitialized';
    $self->{path} =~ s/^($loc)?\///;
    $self->parse_path;
    $self->parse_args;
}

sub send_output {
    my $r = shift;
    $r->{ar}->content_type( $r->{content_type} );
    $r->{ar}->headers_out->set( "Content-Length" => length $r->{output} );
    $r->{ar}->send_http_header;
    $r->{ar}->print( $r->{output} );
}

sub get_template_root {
    my $r = shift;
    $r->{ar}->document_root . "/" . $r->{ar}->location;
}

1;

=head1 NAME

Apache::MVC::Base - Apache front-end base class

=head1 SYNOPSIS

    use base 'Apache::Maypole::Base';

=head1 DESCRIPTION

The base class for the Apache and Apache2 front-ends.

=head1 AUTHOR

Simon Cozens, C<simon@cpan.org>
Screwed up by Sebastian Riedel, C<sri@oook.de>

=head1 LICENSE

You may distribute this code under the same terms as Perl itself.
