X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=lib%2FApache%2FMVC%2FModel%2FCDBI.pm;h=854118e1559f2007fda5983a31a41b2708a604ae;hb=5cccc5a89004f9c514e9d611b5e2a02e9aa28ece;hp=d842d5f16730788f52efb256d88bbbf83057fa63;hpb=727e28be9837a49a27e024e5ee68c33da59039e0;p=maypole.git diff --git a/lib/Apache/MVC/Model/CDBI.pm b/lib/Apache/MVC/Model/CDBI.pm index d842d5f..854118e 100644 --- a/lib/Apache/MVC/Model/CDBI.pm +++ b/lib/Apache/MVC/Model/CDBI.pm @@ -4,9 +4,23 @@ use Lingua::EN::Inflect::Number qw(to_PL); use Class::DBI::AsForm; use Class::DBI::FromCGI; use Class::DBI::AbstractSearch; +use Class::DBI::Pager; use CGI::Untaint; use strict; +=head1 NAME + +Apache::MVC::Model::CDBI - Model class based on Class::DBI + +=head1 DESCRIPTION + +This is a master model class which uses C to do all the hard +work of fetching rows and representing them as objects. It is a good +model to copy if you're replacing it with other database abstraction +modules. + +=cut + sub related { my ($self, $r) = @_; # Has-many methods; XXX this is a hack @@ -67,15 +81,13 @@ sub search :Exported { $r->{template_args}{search} = 1; } +sub list :Exported { + my ($self, $r) = @_; + if ( my $rows = $r->config->{rows_per_page}) { + $self = $self->pager($rows, $r->query->{page}); + $r->{template_args}{pager} = $self; + } + $r->objects([ $self->retrieve_all ]); +} 1; -=head1 NAME - -Apache::MVC::Model::CDBI - Model class based on Class::DBI - -=head1 DESCRIPTION - -This is a master model class which uses C to do all the hard -work of fetching rows and representing them as objects; instead, it -concentrates on the actions that can be performed in the URL: -C, C and C.