Apache-PageKit
view release on metacpan or search on metacpan
lib/Apache/PageKit.pm view on Meta::CPAN
return $pk->{status_code} if ( defined $pk->{status_code} );
# add pkit_message from previous page, if that pagekit did a pkit_redirect
if(my @pkit_messages = $apr->param('pkit_messages')){
for my $message (@pkit_messages){
$model->pkit_message($message);
}
}
if(my @pkit_error_messages = $apr->param('pkit_error_messages')){
for my $message (@pkit_error_messages){
$model->pkit_message($message, is_error => 1);
}
}
# deal with different views
if(my $pkit_view = $apr->param('pkit_view')){
$output_param_object->param('pkit_view:' . $pkit_view => 1);
}
return OK;
}
sub _send_static_file {
my ( $pk, $filename ) = @_;
my $apr = $pk->{apr};
my $file_mtime = (stat($filename))[9];
my $ims = $apr->header_in('If-Modified-Since');
if ( $ims ) {
my $t = Apache::Util::parsedate($ims);
if ( $t && $file_mtime <= $t ) {
return HTTP_NOT_MODIFIED;
}
}
$apr->header_out( 'Last-Modified' => Apache::Util::ht_time($file_mtime) );
require MIME::Types;
my ($media_type) = MIME::Types::by_suffix($filename);
if (defined $media_type) {
$apr->content_type($media_type);
if($media_type eq "text/html" && $pk->{use_gzip} ne 'none') {
my $gzipped = $pk->{view}->get_static_gzip($filename);
if ($gzipped){
$apr->content_encoding("gzip");
$apr->send_http_header;
$apr->print($gzipped) unless $apr->header_only;
return DONE;
}
}
}
return $pk->{model}->pkit_send($filename, $media_type);
# set path_info to '', otherwise Apache tacks it on at the end
## $apr->path_info('');
## $apr->filename($filename);
## return DECLINED;
}
sub _check_gzip {
my $pk = shift;
# check Accent-Encoding or if the user_agent field for Unix/Mac Netscape
# to see if should gzip output
my $gzip_output = $pk->{config}->get_global_attr("gzip_output") || 'none';
$pk->{use_gzip} = 'none';
my $apr = $pk->{apr};
if ($gzip_output =~ m!^(all|static)$!){
if(($apr->header_in("Accept-Encoding") || '') =~ /gzip/){
$pk->{use_gzip} = $gzip_output;
} else {
my $user_agent = $apr->header_in("User-Agent");
# this regular expression borrowed from Apache::AxKit::ConfigReader::DoZip
if ($user_agent && $user_agent =~ m{
^Mozilla/
\d+
\.
\d+
[\s\[\]\w\-]+
(
\(X11 |
Macint.+PPC,\sNav
)
}x
) {
$pk->{use_gzip} = $gzip_output;
}
}
}
}
sub open_view {
my ($pk) = @_;
my $pkit_view = $pk->{apr}->param('pkit_view') || 'Default';
# open template file
$pk->{view}->open_view($pk->{page_id}, $pkit_view, $pk->{lang});
}
sub prepare_and_print_view {
my ($pk) = @_;
my $apr = $pk->{apr};
my $view = $pk->{view};
my $config = $pk->{config};
my $model = $pk->{model};
my $page_id = $pk->{page_id};
# set view fillinform_objects and associated_objects, if approriate
my $fill_in_form = $config->get_page_attr($page_id,'fill_in_form') || 'yes';
# $apr comes first, so that fillinform overrides request parameters
my @fillinform_objects_array = ( $apr, $pk->{fillinform_object} );
if ( $fill_in_form eq 'no' ) {
# we want only the $pk->{fillinform_object} object
shift @fillinform_objects_array;
}
$view->{fillinform_objects} = [ grep {$_->param} @fillinform_objects_array ];
$view->{ignore_fillinform_fields} = $pk->{ignore_fillinform_fields};
my $request_param_in_tmpl = $config->get_page_attr($page_id,'request_param_in_tmpl')
( run in 2.426 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )