Apache-PageKit
view release on metacpan or search on metacpan
session (Boris Zentner, Russell D. Weiss)
- Add page attribute use_sessions defaults to 'yes'
(Boris Zentner, Russell D. Weiss)
- Fix PKIT_SELFURL and handling of empty parameters
(Bill Karwin)
- Fix PKIT_MACRO expansion for nested templates.
(Boris Zentner, Russell D. Weiss)
- setup_eg.pl is now os indpendent (Boris Zentner)
- Add docs for <PKIT_ELSE>, <PKIT_IS_ERROR>, <PKIT_NOT_ERROR> and
pkit_component_params_hashref (Boris Zentner)
- Fix pkit_validate_input to work with Data::FormValidator >= 1.11
(Paul G. Weiss, Boris Zentner)
1.10
- Add a note to the docs, that some pages can not be protected
(Boris Zentner, Rob Starkey)
- Fix some links in the eg site to work in a different
location (Boris Zentner)
- Do not deliver a page direct if the client forget to add a '/'
instead redirect to the right place. This is done to get
relative links right. (Boris Zentner)
- Prepare PageKit for W32 (Boris Zentner)
<MODEL_VAR> and <MODEL_LOOP> for Model Data and
<CONTENT_VAR> and <CONTENT_LOOP> for Content Data and
<PKIT_VAR> and <PKIT_LOOP> for PageKit Data
- Renamed <PKIT_INCLUDE> to <PKIT_COMPONENT> and replaced
'include' with 'component' across the framework
- Moved and renamed nav_title option from config to
<NAV_TITLE> </NAV_TITLE> in content XML for
better foreign language support.
- Renamed Apache::PageKit::FormValidator to Apache::PageKit::Model
and redesigned class to replace form_validator
constructor option with $model->validate_input($hash_ref)
method. Eliminated error_page and error_page_run_code
options (user should use $pk->continue
in model instead). This should make the development
easier because all the logic is in the Model class instead
being scattered across the derived class and configuration.
- View templates get pre-parsed using file_cache/cache option of
HTML::Template, and the HTML can be optimized by
using HTML::Clean if html_clean_level is set to >=1
- Changed template_cache option to use yes for cache
in HTML::Template and no for file_cache.
docsrc/features.xml view on Meta::CPAN
interfering with each other.
</para>
<sect2>
<title>Model</title>
<para>
The Model is provided by Perl classes which implement the business logic that is custom to the
site. These class files should be located in the <filename>Model/</filename> directory. Each URL is translated into a class and method automatically.
</para>
<para>
It includes support for <ulink url="http://search.cpan.org/doc/MARKSTOS/Data-FormValidator-1.6/lib/Data/FormValidator.pm">Data::FormValidator</ulink>, making the tedious task of input validation easier.
To validate a form, you simply specify required fields and constraints. If there is an error, you
can return to the input form, and the invalid fields automatically get highlighted in red.
</para>
</sect2>
<sect2>
<title>View</title>
<para>
The View is defined by a set of PageKit Templates making up pages and their
components located in the <filename>View/</filename> directory. These
templates can be in HTML, WML, XML, or any text based format.
</para>
docsrc/features.xml view on Meta::CPAN
</para>
</sect1>
<sect1><?dbhtml filename="validation.html"?>
<title>Form Validation</title>
<para>
PageKit uses <ulink url="http://search.cpan.org/doc/MARKSTOS/Data-FormValidator-1.5/lib/Data/FormValidator.pm">Data::FormValidator</ulink> to provide easy form validation. Highlights
fields in red that user filled incorrectly by using the
<link linkend="pkit.errorfont">PKIT_ERRORFONT</link> tag. In addition,
error message(s) are displayed using the <link linkend="pkit.messages">PKIT_MESSAGES</link> tag.
To use, pass an input profile to the
<literal><link linkend="model.api.pkit_validate_input">pkit_validate_input</link></literal> method.
</para>
<para>
In addition, you may implement your own custom error handling by using <literal><link linkend="model.api.pkit_set_errorfont">pkit_set_errorfont</link></literal> to set the <link linkend="pkit.errorfont">PKIT_ERRORFONT</link> tags.
</para>
</sect1>
<sect1><?dbhtml filename="fillinform.html"?>
<title>Sticky HTML Forms</title>
<para>
PageKit uses <ulink url="http://kobesearch.cpan.org/search?dist=HTML-FillInForm">HTML::FillInForm</ulink> to fill in HTML Forms with the request parameters. You
can turn this feature off by setting <literal><link linkend="config.page.fill_in_form">fill_in_form</link></literal> to <emphasis>no</emphasis>.
docsrc/reference.xml view on Meta::CPAN
set to <emphasis>recent</emphasis>. Defaults to 3600 (1 hour).
</para>
</listitem>
</varlistentry>
<varlistentry id="config.global.relaxed_parser">
<term>relaxed_parser</term>
<listitem>
<para>
If set to yes, this option allows template tags to be placed inside
HTML comments. It also permits spaces and newlines within the tag itself.
This option may be useful to HTML authors who would like to validate their
templates' HTML syntax prior to processing, or who use DTD-aware editing
tools.
Defaults to <emphasis>no</emphasis>.
<informalexample>
<programlisting>
relaxed_parser = "yes"
# these tags are all allowed if relaxed_parser is enabled:
<MODEL_VAR NAME="x">
docsrc/reference.xml view on Meta::CPAN
Sets the corresponding <link linkend="pkit.errorspan">PKIT_ERRORSPAN</link> tag in the template. Useful
for implementing your own custom constraints. Since version 1.08 it is possible to select the errorstr. This
is done with the second parameter. The color must be a string thar starts with a # followed by exactly six hexdigits.
If you do not specify the errorstr, the string is taken from the
<literal><link linkend="config.global.default_errorstr">default_errorstr</link></literal>.
See also <link linkend="pkit.errorstr">PKIT_ERRORSTR</link>.
</para>
</refsect1>
</refentry>
<refentry id="model.api.pkit_validate_input">
<refnamediv>
<refname>pkit_validate_input</refname>
<refpurpose>
Validates input from an HTML form.
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<synopsis><![CDATA[
# very simple validation, just check to see if name field was filled out
my $input_profile = {required => [ qw ( name ) ]};
# validate user input
unless($model->pkit_validate_input($input_profile)){
# user must have not filled out name field,
# i.e. $apr->param('name') = $model->input('name') is
# not set, so go back to original form
# if you used a <PKIT_ERRORFONT NAME="name"> tag, then it will be set to
# red
$model->pkit_internal_redirect('orig_form');
return;
}
]]>
</synopsis>
eg/Model/MyPageKit/MyModel.pm view on Meta::CPAN
optional => [ qw( toppings ) ],
constraints => {
email => "email",
phone => "phone",
},
messages => {
email => "The E-mail address, <b>%%VALUE%%</b>, is invalid.",
phone => "The phone number, <b>%%VALUE%%</b>, is invalid.",
},
};
# validate user input
unless($model->pkit_validate_input($input_profile)){
$model->pkit_internal_redirect('form_validation');
return;
}
$model->pkit_redirect('index');
}
sub index {
my $model = shift;
my $session_id = $model->pkit_get_session_id || '[Session not set]';
eg/Model/MyPageKit/MyModel.pm view on Meta::CPAN
params => [ qw( passwd1 passwd2 ) ]
},
},
messages => {
login => "The login, <b>%%VALUE%%</b>, has already been used.",
email => "The E-mail address, <b>%%VALUE%%</b>, is invalid.",
phone => "The phone number you entered is invalid.",
passwd1 => "The passwords you entered do not match.",
},
};
# validate user input
unless($model->pkit_validate_input($input_profile)){
$model->pkit_internal_redirect('newacct1');
return;
}
my $login = $model->input('login');
my $passwd = $model->input('passwd1');
# page to return to after user is logged in
my $pkit_done = $model->input('pkit_done');
eg/contrib/locale/README view on Meta::CPAN
thats all.
with this patch pkit have locale info. This is very usefull for
languages != en for obvious reason but also for en. with this you
can have some sites with different messages four the same thing.
like: "You logged in succsesfully." on one site and
"You are welcome." on the other.
also all messages form the pkit_validate_input are translated.
use_locale = 'yes' in the global config part of the Config.xml file activates
the use of the locale info you provide. You need the module Locale::gettext
1.01. if reload = 'yes' (from the server config part) then the .mo files
are reread on every request. else only on serverstartup or first usage.
the API:
pkit_gettext($text);
translate the text $text and return the translated text.
lib/Apache/PageKit/Model.pm view on Meta::CPAN
my $end_value = $model->pkit_get_config_attr( GLOBAL => 'errorspan_end_tag' ) || q{</font>};
$model->output($begin_name => $begin_value);
$model->output($end_name => $end_value);
}
# for now both are the same this may change.
# but only pkit_set_errorspan should change.
*pkit_set_errorspan = \&pkit_set_errorfont;
sub pkit_validate_input {
my ($model, $input_profile) = @_;
my $messages = delete $input_profile->{messages};
my $validator = Data::FormValidator->new({default => $input_profile});
# put the data from input into a %fdat hash so Data::FormValidator can read it
my $input_hashref = $model->pkit_input_hashref;
# put derived Model object in pkit_model
# so form validation can access $dbh, etc
# this is used, for example, to see if a login already exists
$input_hashref->{'pkit_model'} = $model;
my ($valids, $missings, $invalids, $unknowns) = $validator->validate($input_hashref, 'default');
# put our messages back into the hash...
$input_profile->{messages} = $messages if defined $messages;
# used to change apply changes from filter to apr
while (my ($key, $value) = each %$valids){
# if multiple request param, don't set, since formvalidator doesn't deal
# with them yet
$model->input($key,$value) unless ref($input_hashref->{$key}) eq 'ARRAY';
}
lib/Apache/PageKit/Model.pm view on Meta::CPAN
=head1 NAME
Apache::PageKit::Model - Base Model Class
=head1 DESCRIPTION
This class provides a base class for the Modules implementing
the backend business logic for your web site.
This module also contains a wrapper to L<Data::FormValidator>.
It validates the form data from the L<Apache::Request> object contained
in the L<Apache::PageKit> object.
When deriving classes from Apache::PageKit::Model, keep in mind that
all methods and hash keys that begin with pkit_ are reserved for
future use.
=head1 SYNOPSIS
Method in derived class.
lib/Apache/PageKit/Session.pm view on Meta::CPAN
my $store = $self->{args}->{Store};
my $lock = $self->{args}->{Lock};
my $gen = $self->{args}->{Generate};
my $ser = $self->{args}->{Serialize};
$self->{object_store} = new $store $self if ($store) ;
$self->{lock_manager} = new $lock $self if ($lock);
$self->{generate} = \&{$gen . '::generate'} if ($gen);
$self->{validate} = \&{$gen . '::validate'} if ($gen);
$self->{serialize} = \&{$ser . '::serialize'} if ($ser);
$self->{unserialize} = \&{$ser . '::unserialize'} if ($ser) ;
return $self;
}
1 ;
( run in 0.302 second using v1.01-cache-2.11-cpan-4d50c553e7e )