Apache2-PageKit
view release on metacpan or search on metacpan
lib/Apache2/PageKit.pm view on Meta::CPAN
-name => $pkit_session_id,
-value => $session_id,
-path => "/");
$cookie->domain($cookie_domain) if $cookie_domain;
$cookie->expires($expires) if $expires;
$apr->err_headers_out->add('Set-Cookie' => $cookie->as_string );
}
# save for logging purposes (warning, undocumented and might go away)
$apr->notes->set(pkit_session_id => $session_id);
}
}
# check to see if page has either template or perl code associated with it
sub page_exists{
my ($pk, $page_id) = @_;
# check to see if template file exists
my $pkit_view = $pk->{apr}->param('pkit_view') || 'Default';
return 1 if $pk->{view}->template_file_exists($page_id, $pkit_view);
# check to see if perl subroutine for page exists
return 1 if $pk->page_sub;
# check to see if content file exists
my $pkit_root = $pk->{apr}->dir_config('PKIT_ROOT');
return 1 if (-f "$pkit_root/Content/$page_id.xml");
}
sub is_directory {
my ($pk, $page_id) = @_;
# check to see if the page/url is a directory
my $apr = $pk->{apr};
foreach ($apr->param('pkit_view'), 'Default') {
if (defined ($_)) {
my $filename = $apr->dir_config('PKIT_ROOT') . '/View/' . $_ . '/' . $page_id;
return $filename if (-d "$filename");
}
}
return undef;
}
sub static_page_exists{
my ($pk, $page_id) = @_;
my $apr = $pk->{apr};
foreach ($apr->param('pkit_view'), 'Default') {
if (defined ($_)){
my $filename = $apr->dir_config('PKIT_ROOT') . '/View/' . $_ . '/' . $page_id;
return $filename if (-f "$filename");
}
}
return undef;
}
1;
__END__
=head1 NAME
Apache2::PageKit - MVCC web framework using mod_perl, XML and HTML::Template
=head1 SYNOPSIS
In httpd.conf
SetHandler perl-script
PerlSetVar PKIT_ROOT /path/to/pagekit/files
PerlSetVar PKIT_SERVER staging
PerlHandler +Apache2::PageKit
<Perl>
Apache2::PageKit->startup('/path/to/pagekit/files', 'staging');
</Perl>
In MyPageKit/Common.pm
package MyPageKit::Common;
use base 'Apache2::PageKit::Model';
sub pkit_dbi_connect {
return DBI->connect("DBI:mysql:db","user","passwd");
}
sub pkit_session_setup {
my $model = shift;
my $dbh = $model->dbh;
return {
session_lock_class => 'MySQL',
session_store_class => 'MySQL',
session_args => {
Handle => $dbh,
LockHandle => $dbh,
},
};
}
sub pkit_auth_credential {
my ($model) = @_;
# in this example, login and passwd are the names of the credential fields
my $login = $model->input('login');
my $passwd = $model->input('passwd');
# create a session key
# your code here.........
return $ses_key;
}
sub pkit_auth_session_key {
my ($model, $ses_key) = @_;
# check whether $ses_key is valid, if so return user id in $user_id
# your code here.........
return $ok ? $user_id : undef;
}
=head1 DESCRIPTION
PageKit is an mod_perl based application framework that uses HTML::Template and
XML to separate code, design, and content. Includes session management,
authentication, form validation, co-branding, and a content management system.
Its goal is to solve all the common problems of web programming, and to make
the creation and maintenance of dynamic web sites fast, easy and enjoyable.
You have to write a module named MyPageKit::Common
that inherits from Apache2::PageKit::Model and
provides methods common across the site.
For example, if you wish to support authentication, it must
include the two methods C<pkit_auth_credential> and C<pkit_auth_session_key>.
For more information, visit http://www.pagekit.org/
Most of the docs have been moved out of POD to DocBook. The sources can
be found in the docsrc directory of the distribution, and the HTML output
can be found at http://www.pagekit.org/guide
=head1 METHODS
The following method is available to the user as Apache2::PageKit API.
=over 4
This function should be called at server startup from your httpd.conf file:
If you use PageKit >= 1.09 and mod_perl < 1.26, the follow the instructions
for PageKit < 1.09.
PerlSetVar PKIT_ROOT /path/to/pagekit/files
PerlSetVar PKIT_SERVER staging
PerlHandler +Apache2::PageKit
<Perl>
Apache2::PageKit->startup;
</Perl>
PageKit < 1.09 should be started this way:
PerlSetVar PKIT_ROOT /path/to/pagekit/files
PerlSetVar PKIT_SERVER staging
PerlHandler +Apache2::PageKit
<Perl>
Apache2::PageKit->startup("/path/to/pagekit/files","staging");
</Perl>
Where the first argument is the root directory of the
PageKit application. The second (optional) argument is the server id.
It loads /path/to/pagekit/files/Model into the perl search
path so that PageKit can make calls into MyPageKit::Common and
other Model classes. It also loads
the Config and Content XML files and pre-parses the View template files.
=back
=head1 FREQUENTLY ASKED QUESTIONS
See http://www.pagekit.org/faq.html
L<Apache2::PageKit::FAQ>
=head1 SEE ALSO
L<Apache2::Request>, L<HTML::FillInForm>, L<HTML::Template>,
L<Data::FormValidator>
=head1 VERSION
This document describes Apache2::PageKit module version 1.18
=head1 NOTES
Requires mod_perl2, Apache::SessionX, Compress::Zlib, Data::FormValidator,
HTML::Clean, HTML::FillInForm and HTML::Template, Text::Iconv and
XML::LibXML
I wrote these modules because I needed an application framework that was based
on mod_perl and seperated HTML from Perl. HTML::Embperl, Apache::ASP
and HTML::Mason are frameworks that work with mod_perl, but embed Perl code
in HTML. The development was inspired in part by Webmacro, which
is an open-source Java servlet framework that seperates Code from HTML.
The goal is of these modules is to develop a framework that provides most of the
functionality that is common across dynamic web sites, including session management,
authorization, form validation, component design, error handling, and content management.
=head1 BUGS
Please submit any bug reports, comments, or suggestions to the Apache2::PageKit
mailing list at http://lists.sourceforge.net/mailman/listinfo/pagekit-users
=head1 TODO
Support Template-Toolkit templates as well as HTML::Template templates.
Support for multiple transformations with stylesheets, and for filters.
Add more tests to the test suite.
=head1 AUTHORS
T.J. Mather (tjmather@tjmather.com)
Boris Zentner (bzm@2bz.de) has contributed numerous patches and is currently
maintaining the package.
=head1 CREDITS
Fixes, Bug Reports, Docs have been generously provided by:
Ben Ausden
Stu Pae
Yann Kerhervé
Chris Burbridge
Leonardo de Carvalho
Rob Falcon
Sheffield Nolan
David Raimbault
Rob Starkey
Anton Berezin
Chris Hamilton
David Christian
Anton Permyakov
Glenn Morgan
Gabriel Burca
John Robinson
Paul G. Weiss
Russell D. Weiss
Paul Flinders
Bill Karwin
Daniel Gardner
Andy Massey
Michael Cook
Michael Pheasant
John Moose
Sheldon Hearn
Vladimir Sekissov
Tomasz Konefal
Michael Wojcikiewicz
Vladimir Bogdanov
Eugene Rachinsky
Erik Günther
Bruno Czekay
( run in 1.400 second using v1.01-cache-2.11-cpan-e1769b4cff6 )