Apache-PageKit
view release on metacpan or search on metacpan
! The param method returns a empty list in list context if
the param was not defined. Older PageKits returned undef
( Boris Zentner )
- Fix: add missing : in binmode $fh, ":encoding(...)";
( Boris Zentner )
- Fix: typo in scripts/pkit_rename_app.pl ( Boris Zentner )
1.15
- Add: request_class parameter just for the case, that you like
another class or subclass do what Apache::Request do for you.
Defaults to Apache::Request::PageKit ( Boris Zentner )
- Fix: conversion error if the tmpl file's encoding is != utf8 and no
content_var's are used. affects only perl < 5.8.0
( Boris Zentner )
- Add: Basic testsuite ( Boris Zentner )
- Remove setup_eg.pl this file is obsolete ( Boris Zentner )
- Fix: Fresh created session cookie headers are wrongly not send
for pkit_redirect pages this is fixed now. ( Boris Zentner )
- Add: Experimental support for Template Toolkit. Enabled with
template_class = "Template" in your Config.xml
( Boris Zentner)
- Fix: with pkit_admin=on and perl 5.8.x the input data is
Makefile.PL view on Meta::CPAN
$message =~ s/<(!--)?\s*PKIT_ERRORSTR\s*(?(1)--)>/$default_error_str/gi;
@@ -290,7 +283,12 @@
}
sub fillinform {
- return shift->{pkit_pk}->{fillinform_object}->param(@_);
+ my $model = shift;
+ my @params = @_;
+ for ( @params ) {
+ Encode::_utf8_off( $_ ) unless ref $_;
+ }
+ return $model->{pkit_pk}->{fillinform_object}->param(@params);
}
sub ignore_fillinform_fields {
@@ -313,17 +311,7 @@
my ($model, %p) = @_;
my $view = $model->{pkit_pk}->{view};
my $input_charset = exists $p{input_charset} ? $p{input_charset} : $view->{default_input_charset};
- my $default_output_charset = $view->{default_output_charset};
Makefile.PL view on Meta::CPAN
}
}
}
diff -Nur a/lib/Apache/PageKit/View.pm b/lib/Apache/PageKit/View.pm
--- a/lib/Apache/PageKit/View.pm 2005-01-01 20:42:57.141131208 +0100
+++ b/lib/Apache/PageKit/View.pm 2005-01-01 19:51:50.980258512 +0100
@@ -182,11 +182,13 @@
my $fif;
if(@{$view->{fillinform_objects}}){
$view->{pkit_pk}->{browser_cache} = 'no';
+ Encode::_utf8_off($output);
$fif = HTML::FillInForm->new();
$output = $fif->fill(scalarref => \$output,
fobject => $view->{fillinform_objects},
ignore_fields => $view->{ignore_fillinform_fields}
);
+ Encode::_utf8_on($output);
}
}
if($view->{can_edit} eq 'yes'){
@@ -206,15 +208,15 @@
# is the cache entry valid or changed on disc?
if(-f "$gzipped_filename"){
- open FH, "<$gzipped_filename" or return undef;
- binmode FH;
+ open my $fh, "<$gzipped_filename" or return undef;
Makefile.PL view on Meta::CPAN
@@ -510,38 +513,9 @@
# remove PKIT_COMMENT parts.
my $pkit_comment_re = $re_helper{ $view->{relaxed_parser} eq 'yes' ? 'relaxed_parser' : 'std_parser' }->{pkit_comment_re};
$$template_ref =~ s/$pkit_comment_re//sgi;
-
- # my $template_file = $view->_find_template($pkit_view, $page_id);
- my ( $lang_tmpl, $skip_xpath_content ) = $content->process_template($page_id, $template_ref);
- # find the right converter for perl < 5.8.0
- # if we skip the xpath content, the string is in $default_input_charset.
- # otherwise it is in utf8 ( from libxml2 )
- my $converter;
- my $default_output_charset = $view->{default_output_charset};
- if ( $skip_xpath_content ) {
- my $default_input_charset = $view->{default_input_charset};
- unless ( lc $default_input_charset eq lc $default_output_charset) {
- eval {
- $converter = Text::Iconv->new( $default_input_charset, $default_output_charset );
- };
- if ($@) {
- (my $config_dir = $view->{content_dir}) =~ s!/Content$!/Config!;
- die "The conversion from ($default_input_charset => $default_output_charset) is not supported by Text::Iconv please check file ${config_dir}/Config.xml";
- }
- }
- else {
- unless ( /^utf-?8$/i =~ $default_output_charset) {
- eval {
- $converter = Text::Iconv->new( 'utf8', $default_output_charset);
- };
- if ($@) {
- (my $config_dir = $view->{content_dir}) =~ s!/Content$!/Config!;
- die "The conversion from ('utf8' => $default_output_charset) is not supported by Text::Iconv please check file ${config_dir}/Config.xml";
- }
- }
- }
- }
+ # my $template_file = $view->_find_template($pkit_view, $page_id);
+ my $lang_tmpl = $content->process_template($page_id, $template_ref);
# add used content file(s) to the mtimes hash
while( my ( $file, $mtime ) = each( %{ $content->{include_mtimes} } ) ) {
@@ -551,10 +525,6 @@
Makefile.PL view on Meta::CPAN
sub _preparse_model_tags {
- use bytes;
my ( $view, $html_code_ref ) = @_;
my $exclude_params_set = {};
@@ -817,12 +786,14 @@
my $fif;
if ( @{ $view->{fillinform_objects} } ) {
$view->{pkit_pk}->{browser_cache} = 'no';
+ Encode::_utf8_off($output);
$fif = HTML::FillInForm->new();
$output = $fif->fill(
scalarref => \$output,
fobject => $view->{fillinform_objects},
ignore_fields => $view->{ignore_fillinform_fields}
);
+ Encode::_utf8_on($output);
}
}
if ( $view->{can_edit} eq 'yes' ) {
@@ -868,36 +839,7 @@
$$template_ref =~ s/$pkit_comment_re//sgi;
# my $template_file = $view->_find_template($pkit_view, $page_id);
- my ( $lang_tmpl, $skip_xpath_content ) = $content->process_template($page_id, $template_ref);
-
- # find the right converter for perl < 5.8.0
- # if we skip the xpath content, the string is in $default_input_charset.
- # otherwise it is in utf8 ( from libxml2 )
- my $converter;
- my $default_output_charset = $view->{default_output_charset};
- if ( $skip_xpath_content ) {
- my $default_input_charset = $view->{default_input_charset};
- unless ( lc $default_input_charset eq lc $default_output_charset) {
- eval {
- $converter = Text::Iconv->new( $default_input_charset, $default_output_charset );
- };
- if ($@) {
- (my $config_dir = $view->{content_dir}) =~ s!/Content$!/Config!;
- die "The conversion from ($default_input_charset => $default_output_charset) is not supported by Text::Iconv please check file ${config_dir}/Config.xml";
- }
- }
- else {
- unless ( /^utf-?8$/i =~ $default_output_charset) {
- eval {
- $converter = Text::Iconv->new( 'utf8', $default_output_charset);
- };
- if ($@) {
- (my $config_dir = $view->{content_dir}) =~ s!/Content$!/Config!;
- die "The conversion from ('utf8' => $default_output_charset) is not supported by Text::Iconv please check file ${config_dir}/Config.xml";
- }
- }
- }
- }
+ my $lang_tmpl = $content->process_template( $page_id, $template_ref );
# add used content file(s) to the mtimes hash
while ( my ( $file, $mtime ) = each( %{ $content->{include_mtimes} } ) ) {
@@ -907,12 +849,6 @@
# go through content files (which have had content filled in)
Makefile.PL view on Meta::CPAN
my $exclude_params_set = {};
diff -Nur a/lib/Apache/PageKit.pm b/lib/Apache/PageKit.pm
--- a/lib/Apache/PageKit.pm 2005-01-01 20:42:57.175126040 +0100
+++ b/lib/Apache/PageKit.pm 2005-01-01 19:33:16.000000000 +0100
@@ -17,8 +17,8 @@
# $Id: PageKit.pm,v 1.236 2004/05/06 09:54:35 borisz Exp $
-# required for UNIVERSAL->can
-require 5.005;
+# require perl 5.8 for numerous utf8 issues ( and Encode )
+require 5.008;
use strict;
@@ -34,7 +34,7 @@
use HTML::Parser ();
use HTML::Entities ();
use HTML::Template ();
-use Text::Iconv ();
+use Encode ();
docsrc/reference.xml view on Meta::CPAN
</refentry>
<refentry id="model.api.output_convert">
<refnamediv>
<refname>output_convert</refname>
<refpurpose>
Outputs data for display, converting charset.
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<synopsis>
$model->output_convert(output => {foo => $utf8_text},
input_charset => 'UTF-8');
</synopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
This is a wrapper to the <link linkend="model.api.output">output</link>
method. It converts the output from the character set specified by
the charset argument to <link linkend="config.global.default_output_charset">default_output_charset</link>. If the character set is not specified, then
<link linkend="config.global.default_input_charset">default_input_charset</link> is used.
</para>
</refsect1>
<refsect1>
<title>Examples</title>
<informalexample>
<programlisting>
# converts from UTF-8
$model->output_convert(output => { key => $utf8_text },
charset => 'UTF-8');
# converts from default_input_charset
$model->output_convert(key => $text)
</programlisting>
</informalexample>
</refsect1>
</refentry>
<refentry id="model.api.output">
<refnamediv>
<refname>output</refname>
lib/Apache/PageKit/View.pm view on Meta::CPAN
# remove PKIT_COMMENT parts.
my $pkit_comment_re = $re_helper{ $view->{relaxed_parser} eq 'yes' ? 'relaxed_parser' : 'std_parser' }->{pkit_comment_re};
$$template_ref =~ s/$pkit_comment_re//sgi;
# my $template_file = $view->_find_template($pkit_view, $page_id);
my ( $lang_tmpl, $skip_xpath_content ) = $content->process_template($page_id, $template_ref);
# find the right converter for perl < 5.8.0
# if we skip the xpath content, the string is in $default_input_charset.
# otherwise it is in utf8 ( from libxml2 )
my $converter;
my $default_output_charset = $view->{default_output_charset};
if ( $skip_xpath_content ) {
my $default_input_charset = $view->{default_input_charset};
unless ( lc $default_input_charset eq lc $default_output_charset) {
eval {
$converter = Text::Iconv->new( $default_input_charset, $default_output_charset );
};
if ($@) {
(my $config_dir = $view->{content_dir}) =~ s!/Content$!/Config!;
die "The conversion from ($default_input_charset => $default_output_charset) is not supported by Text::Iconv please check file ${config_dir}/Config.xml";
}
}
else {
unless ( /^utf-?8$/i =~ $default_output_charset) {
eval {
$converter = Text::Iconv->new( 'utf8', $default_output_charset);
};
if ($@) {
(my $config_dir = $view->{content_dir}) =~ s!/Content$!/Config!;
die "The conversion from ('utf8' => $default_output_charset) is not supported by Text::Iconv please check file ${config_dir}/Config.xml";
}
}
}
}
# add used content file(s) to the mtimes hash
while( my ( $file, $mtime ) = each( %{ $content->{include_mtimes} } ) ) {
$view->{include_mtimes}->{$file} = $mtime;
}
lib/Apache/PageKit/View.pm view on Meta::CPAN
# remove PKIT_COMMENT parts.
my $pkit_comment_re = $re_helper{ $view->{relaxed_parser} eq 'yes' ? 'relaxed_parser' : 'std_parser' }->{pkit_comment_re};
$$template_ref =~ s/$pkit_comment_re//sgi;
# my $template_file = $view->_find_template($pkit_view, $page_id);
my ( $lang_tmpl, $skip_xpath_content ) = $content->process_template($page_id, $template_ref);
# find the right converter for perl < 5.8.0
# if we skip the xpath content, the string is in $default_input_charset.
# otherwise it is in utf8 ( from libxml2 )
my $converter;
my $default_output_charset = $view->{default_output_charset};
if ( $skip_xpath_content ) {
my $default_input_charset = $view->{default_input_charset};
unless ( lc $default_input_charset eq lc $default_output_charset) {
eval {
$converter = Text::Iconv->new( $default_input_charset, $default_output_charset );
};
if ($@) {
(my $config_dir = $view->{content_dir}) =~ s!/Content$!/Config!;
die "The conversion from ($default_input_charset => $default_output_charset) is not supported by Text::Iconv please check file ${config_dir}/Config.xml";
}
}
else {
unless ( /^utf-?8$/i =~ $default_output_charset) {
eval {
$converter = Text::Iconv->new( 'utf8', $default_output_charset);
};
if ($@) {
(my $config_dir = $view->{content_dir}) =~ s!/Content$!/Config!;
die "The conversion from ('utf8' => $default_output_charset) is not supported by Text::Iconv please check file ${config_dir}/Config.xml";
}
}
}
}
# add used content file(s) to the mtimes hash
while ( my ( $file, $mtime ) = each( %{ $content->{include_mtimes} } ) ) {
$view->{include_mtimes}->{$file} = $mtime;
}
t/03_charset.t view on Meta::CPAN
# preform the test twice, the first time to fill the cache and a
# second time to use the results.
for ( 1 .. 2 ) {
my $data = GET_BODY $url, 'Accept-Charset', 'iso-8859-1';
ok t_cmp( $data, qr~$s1~, "street ok? (iso-8859-1)" );
ok t_cmp( $data, qr~$s2~, "street from content_var ok? (iso-8859-1)" );
}
for ( 1 .. 2 ) {
my $data = GET_BODY $url, 'Accept-Charset', 'utf8';
unless ( $] < 5.008 ) {
Encode::from_to( $data, utf8 => 'iso-8859-1' );
}
else {
my $c = Text::Iconv->new( utf8 => "iso-8859-1");
$data = $c->convert( $data );
}
ok t_cmp( $data, qr~$s1~, "street ok? (utf8)" );
ok t_cmp( $data, qr~$s2~, "street from content_var ok? (utf8)" );
}
t/09_charset_tmpl.t view on Meta::CPAN
my $s1 = 'index.tmpl: straße straße ööäöüäüöüü';
# preform the test twice, the first time to fill the cache and a
# second time to use the results.
for ( 1 .. 2 ) {
my $data = GET_BODY $url, 'Accept-Charset', 'iso-8859-1';
ok t_cmp( $data, qr~$s1~, "street ok? (iso-8859-1)" );
}
for ( 1 .. 2 ) {
my $data = GET_BODY $url, 'Accept-Charset', 'utf8';
unless ( $] < 5.008 ) {
Encode::from_to( $data, utf8 => 'iso-8859-1' );
}
else {
my $c = Text::Iconv->new( utf8 => "iso-8859-1");
$data = $c->convert( $data );
}
ok t_cmp( $data, qr~$s1~, "street ok? (utf8)" );
}
( run in 1.038 second using v1.01-cache-2.11-cpan-49f99fa48dc )