X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=lib%2FApache%2FMVC.pm;h=5005effb96f244fa0eaeae8526fc64d146160b80;hb=9de2e5c0ad43b2983e4aa02215685b69fd15d357;hp=0f917752bf419cc0942a1cf91f65f7a27100ad56;hpb=81b617ffe75c0d5924595fc5b832733c7bfbcc28;p=maypole.git diff --git a/lib/Apache/MVC.pm b/lib/Apache/MVC.pm index 0f91775..5005eff 100644 --- a/lib/Apache/MVC.pm +++ b/lib/Apache/MVC.pm @@ -1,43 +1,24 @@ package Apache::MVC; -use base 'Maypole'; + +use base qw(Apache::MVC::Base Maypole); use Apache; use Apache::Request; use strict; use warnings; + our $VERSION = "0.3"; sub get_request { - shift->{ar} = Apache::Request->new(Apache->request); + shift->{ar} = Apache::Request->new( Apache->request ); } -sub parse_location { +sub parse_args { my $self = shift; - $self->{path} = $self->{ar}->uri; - my $loc = $self->{ar}->location; - no warnings 'uninitialized'; - $self->{path} =~ s/^($loc)?\///; - $self->{path} ||= "frontpage"; - my @pi = split /\//, $self->{path}; - shift @pi while @pi and !$pi[0]; - $self->{table} = shift @pi; - $self->{action} = shift @pi; - $self->{args} = \@pi; - $self->{params} = { $self->{ar}->content }; - $self->{query} = { $self->{ar}->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; + while ( my ( $key, $value ) = each %{ $self->{params} } ) { + $self->{params}{$key} = '' unless defined $value; + } + $self->{query} = { $self->{ar}->args }; } 1; @@ -132,6 +113,7 @@ see L. =head1 AUTHOR Simon Cozens, C +Screwed up by Sebastian Riedel, C =head1 LICENSE