Apache-JAF
view release on metacpan or search on metacpan
# the page handler for each URI of sample site is 'do_index'
# you should swap left and right ||-parts for real application
my $handler = 'index' || shift @{$self->{uri}};
return $handler;
}
sub site_handler {
my ($self) = @_;
# common stuff before handler is called
$self->{m} = JAF::MyJAF->new(); # create modeller -- if needed
$self->SUPER::site_handler();
# common stuff after handler is called
return $self->{status}
}
1;
page handler -- controller's method that makes one (or more) pages
sub do_index {
my ($self) = @_;
# page handler must fill $self->{res} hash that process with template
$self->{res}{test} = __PACKAGE__ . 'test';
may set site-wide properties such as *debug_level*, *header* or
*footer*, templates and includes extensions and so on. If handler
name depends on application logic implemented in modeller then you
have to create modeller in this method and store it in *m* property
for later use. The primary *setup_handler* is shown in "SYNOPSIS".
site_handler
You can override this method to provide common tasks for each of
your page-handlers. For example you may create instance of modeller
class, provide some custom authorization/authentication or sessions
handling and so on. You must call "$self>SUPER::site_handler" and
return "$self->{status}" from it.
Apache::JAF properties
r Current "Apache::Request" object.
filter
Using "Apache::Filter" flag.
uri Reference to the array of current URI (splitted by slash). Usually
you need to modify it in "setup_handler" method to determine page's
examples/site/modules/Apache/JAF/MyJAF.pm view on Meta::CPAN
# the page handler for every uri for sample site is 'do_index'
# you should swap left and right || parts for real application
my $handler = 'index' || shift @{$self->{uri}};
return $handler;
}
sub site_handler {
my ($self) = @_;
# common stuff before handler is called
# $self->{m} = JAF::MyJAF->new(); # create modeller -- if needed
$self->SUPER::site_handler();
# common stuff after handler is called
return $self->{status}
}
1;
lib/Apache/JAF.pm view on Meta::CPAN
# Constructor
################################################################################
sub new {
my ($ref, $r) = @_;
my $self = {};
#
# use as template provider
#
if (ref($r) eq 'HASH') {
$self = $ref->SUPER::new($r);
bless ($self, $ref);
return $self;
}
#
# use as framework
#
$r = Apache::Request->instance($r);
bless ($self, $ref);
lib/Apache/JAF.pm view on Meta::CPAN
}
# Global Apache::JAF handler. If you want some stuff before (and|or) after
# running handler you must override it like that:
#
# sub site_handler {
# my $self = shift;
#
# [before stuff goes here]
#
# $self->{status} = $self->SUPER::site_handler(@_);
#
# [after stuff goes here]
#
# return $self->{status}
# }
################################################################################
sub site_handler {
my ($self) = @_;
my ($method, $last_modified, $cache, $mtime);
lib/Apache/JAF.pm view on Meta::CPAN
# the page handler for each URI of sample site is 'do_index'
# you should swap left and right ||-parts for real application
my $handler = 'index' || shift @{$self->{uri}};
return $handler;
}
sub site_handler {
my ($self) = @_;
# common stuff before handler is called
$self->{m} = JAF::MyJAF->new(); # create modeller -- if needed
$self->SUPER::site_handler();
# common stuff after handler is called
return $self->{status}
}
1;
=item page handler -- controller's method that makes one (or more) pages
sub do_index {
my ($self) = @_;
# page handler must fill $self->{res} hash that process with template
lib/Apache/JAF.pm view on Meta::CPAN
or I<footer>, templates and includes extensions and so on. If handler name depends on
application logic implemented in modeller then you have to create modeller in this method
and store it in I<m> property for later use.
The primary I<setup_handler> is shown in L<"SYNOPSIS">.
=item site_handler
You can override this method to provide common tasks for each of your page-handlers. For
example you may create instance of modeller class, provide some custom
authorization/authentication or sessions handling and so on. You must call
C<$selfE<gt>SUPER::site_handler> and return C<$self-E<gt>{status}> from it.
=back
=head2 Apache::JAF properties
=over 4
=item r
Current C<Apache::Request> object.
lib/JAF/DBI/Oracle.pm view on Meta::CPAN
package JAF::DBI::Oracle;
use strict;
use base qw( JAF::DBI );
sub _init {
my $self = shift;
$self->SUPER::_init();
$self->{scheme} = $self->{parent}{scheme};
}
sub last_insert_id {
shift->{last_insert_id}
}
sub _insert_sql {
my ($self, $options) = @_;
my $cols = $options->{cols} || $self->{cols};
return "insert into ".($options->{scheme} || $self->{scheme}).".$self->{table} (".(join ',', @$cols).") values (".(join ',', map {'?'} @$cols).")";
}
sub insert {
my ($self, $params, $options) = @_;
if($self->{key} && !ref $self->{key}) {
$params->{$self->{key}} = $self->{dbh}->selectrow_array("select ".($options->{scheme} || $self->{scheme}).".seq_$self->{table}.nextval from dual") unless($params->{$self->{key}});
$self->{last_insert_id} = $params->{$self->{key}};
}
return $self->SUPER::insert($params, $options)
}
sub _update_sql {
my ($self, $options) = @_;
my $cols = $options->{cols} || $self->{cols};
my $criteria = exists $options->{criteria} ? $options->{criteria} : $self->{key};
return "update ".($options->{scheme} || $self->{scheme}).".$self->{table} set ".(join ',', map {"$_ = ?"} @$cols).($criteria ? " where ".(ref $criteria eq 'ARRAY' ? join ' and ', map {"$_ = ?"} @$criteria : "$criteria = ?") : '');
}
sub _delete_sql {
lib/JAF/DBI/Pg.pm view on Meta::CPAN
sub datetime_format {
return sprintf "%04d-%02d-%02d %02d:%02d:%02d", (shift =~ /(\d{1,2}).(\d{1,2}).(\d{4})\s+(\d{2}).(\d{2}).?(\d{2})?/)[2,1,0,3,4,5];
}
sub insert {
my ($self, $params, $options) = @_;
if($self->{key} && !ref $self->{key}) {
$params->{$self->{key}} = $self->{dbh}->selectrow_array("select nextval('seq_$self->{table}')") unless($params->{$self->{key}});
$self->{last_insert_id} = $params->{$self->{key}};
}
return $self->SUPER::insert($params, $options)
}
sub _record_sql {
my ($self, $options) = @_;
my @cols = $options && $options->{cols} ? @{$options->{cols}} : @{$self->{cols}};
foreach my $c(!$self->{key} ? () : ref $self->{key} eq 'ARRAY' ? @{$self->{key}} : ($self->{key})) {
push @cols, $c unless(grep {$_ eq $c} @cols)
}
my $criteria = $options->{criteria};
( run in 1.351 second using v1.01-cache-2.11-cpan-49f99fa48dc )